Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

240 lines
5.7 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. opinfo.hxx
  5. Abstract:
  6. This file defines the classes used to store optimisation / usage specific
  7. information.
  8. Notes:
  9. The analysis phase is a middle phase executed prior to code generation.
  10. This phase walks thru the type sub-graph which will take part in an
  11. rpc operation in an interface. Analysis consists of:
  12. - structural analysis
  13. Peculiarities of a type eg its alignment properties, layout
  14. properties etc.
  15. - usage analysis etc.
  16. Usage count properties, directional properties, memory allocation
  17. properties etc.
  18. Author:
  19. VibhasC Jul-25-1993 Created
  20. Notes:
  21. ----------------------------------------------------------------------------*/
  22. #ifndef __OPINFO_HXX__
  23. #define __OPINFO_HXX__
  24. #if 0
  25. Notes
  26. -----
  27. The optim info and its derived classes store analysed optimization
  28. info after the analysis pass has finished. Therefore it contains the
  29. prepared information for the code generator to use.
  30. #endif // 0
  31. /****************************************************************************
  32. * include files
  33. ***************************************************************************/
  34. #include "nulldefs.h"
  35. extern "C"
  36. {
  37. #include <stdio.h>
  38. }
  39. #include "common.hxx"
  40. #include "nodeskl.hxx"
  41. #include "optprop.hxx"
  42. /****************************************************************************
  43. * local definitions
  44. ***************************************************************************/
  45. /////////////////////////////////////////////////////////////////////////////
  46. // flag to indicate if the information block is valid.
  47. /////////////////////////////////////////////////////////////////////////////
  48. typedef unsigned long INFO_VALID_FLAG;
  49. ////////////////////////////////////////////////////////////////////////////
  50. // optimisation data base class.
  51. ////////////////////////////////////////////////////////////////////////////
  52. class OPTIM_INFO
  53. {
  54. private:
  55. //
  56. // This field specifies if the optimisation / code-gen information present
  57. // here is valid. This flag will be set by the code generator / analyser
  58. // when it has actually done the analysis. The presence of this object
  59. // in the types information block in the symbol table is not necessarily
  60. // an indication that the information in it is valid. The front-end may
  61. // actually do parts of the analysis like usage counts, but that is not
  62. // the complete information anyway. This flag must only be set by the
  63. // code generator.
  64. //
  65. INFO_VALID_FLAG fInfoValid : 1;
  66. public:
  67. OPTIM_INFO()
  68. {
  69. SetInfoValid();
  70. }
  71. //
  72. // Get and set functions.
  73. //
  74. INFO_VALID_FLAG SetInfoValid()
  75. {
  76. return ( fInfoValid = 1 );
  77. }
  78. INFO_VALID_FLAG InvalidateInfo()
  79. {
  80. return ( fInfoValid = 0 );
  81. }
  82. BOOL IsInfoValid()
  83. {
  84. return (BOOL)( fInfoValid == 1 );
  85. }
  86. };
  87. ////////////////////////////////////////////////////////////////////////////
  88. // optimisation / code generation information class for structure / union.
  89. ////////////////////////////////////////////////////////////////////////////
  90. //
  91. // This class determines the properties of a composite type node, viz a
  92. // structure or a union node. We define this class with an eye towards
  93. // offlining the auxillary routines if needed. The union and structure nodes
  94. // have some properties in common, but not all. Hence this class serves as
  95. // the base class for other specific structure / union related properties.
  96. //
  97. class SU_OPTIM_INFO : public OPTIM_INFO
  98. {
  99. private:
  100. //
  101. // These 2 field describes the usage property. The usage count is tracked
  102. // upto a certain threshold of use. After that it is assumed that the
  103. // structure is used too many times.
  104. //
  105. USE_COUNT InUsageCount : 4;
  106. USE_COUNT OutUsageCount : 4;
  107. //
  108. // This field describes the Zp vs Ndr property. It is useful in figuring
  109. // out if the structure needs to be marshalled field by field or a memcopy
  110. // is sufficient.
  111. //
  112. ZP_VS_NDR ZpVsNdr : 2;
  113. public:
  114. //
  115. // the constructor.
  116. //
  117. SU_OPTIM_INFO()
  118. {
  119. InUsageCount = 0;
  120. OutUsageCount= 0;
  121. ZpVsNdr = ZP_VS_NDR_UNKNOWN;
  122. }
  123. //
  124. // increment the usage count
  125. //
  126. USE_COUNT IncrInUsage();
  127. USE_COUNT IncrOutUsage();
  128. ZP_VS_NDR SetZpVsNdr( ZP_VS_NDR Z )
  129. {
  130. return( ZpVsNdr = Z );
  131. }
  132. };
  133. ////////////////////////////////////////////////////////////////////////////
  134. // optimisation / code generation information class for structures.
  135. ////////////////////////////////////////////////////////////////////////////
  136. class STRUCT_OPTIM_INFO : public SU_OPTIM_INFO
  137. {
  138. private:
  139. //
  140. // Store the memory size and ndr (wire) size, so we dont need to calculate
  141. // the size again.
  142. //
  143. unsigned long MemSize;
  144. unsigned long NdrSize;
  145. //
  146. // This flag indicates that the no of pointers in this structure exceeds
  147. // a threshold. This flag (along with other things) helps the code
  148. // generator decide whether to generate aux routines or in-line the
  149. // code for this structure.
  150. //
  151. unsigned short fTooManyPointers : 1;
  152. //
  153. // This structure is recommended to be marshalled out of line.
  154. //
  155. OOL_PROPERTY OOLProperty : 2;
  156. //
  157. // store the pointer characteristics of the structure.
  158. //
  159. PTR_CHASE PtrChase : 4;
  160. //
  161. // The conformance property of the structure.
  162. //
  163. CONFORMANCE_PROPERTY Conformance : 8;
  164. //
  165. // The variance property of the structure.
  166. //
  167. VARIANCE_PROPERTY Variance : 8;
  168. public:
  169. //
  170. // The constructor.
  171. //
  172. STRUCT_OPTIM_INFO(
  173. unsigned long MSize,
  174. unsigned long NSize )
  175. {
  176. MemSize = MSize;
  177. NdrSize = NSize;
  178. }
  179. };
  180. #endif // __OPINFO_HXX__