cs.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. typedef short valnum;
  7. typedef struct entity *entity_p;
  8. typedef struct avail *avail_p;
  9. typedef struct token *token_p;
  10. typedef struct occur *occur_p;
  11. struct token {
  12. valnum tk_vn;
  13. offset tk_size;
  14. line_p tk_lfirst; /* Textually first instruction, involved
  15. * in pushing this token.
  16. */
  17. };
  18. /* We distinguish these entities. */
  19. #define ENCONST 0
  20. #define ENLOCAL 1
  21. #define ENEXTERNAL 2
  22. #define ENINDIR 3
  23. #define ENOFFSETTED 4
  24. #define ENALOCAL 5
  25. #define ENAEXTERNAL 6
  26. #define ENAOFFSETTED 7
  27. #define ENALOCBASE 8
  28. #define ENAARGBASE 9
  29. #define ENPROC 10
  30. #define ENFZER 11
  31. #define ENARRELEM 12
  32. #define ENLOCBASE 13
  33. #define ENHEAPPTR 14
  34. #define ENIGNMASK 15
  35. struct entity {
  36. valnum en_vn;
  37. bool en_static;
  38. byte en_kind; /* ENLOCAL, ENEXTERNAL, etc. */
  39. offset en_size;
  40. union {
  41. offset en__val; /* ENCONST. */
  42. offset en__loc; /* ENLOCAL, ENALOCAL. */
  43. obj_p en__ext; /* ENEXTERNAL, ENAEXTERNAL. */
  44. valnum en__ind; /* ENINDIR. */
  45. struct {
  46. valnum en__base;
  47. offset en__off;
  48. } en_offs; /* ENOFFSETTED, ENAOFFSETTED. */
  49. offset en__levels; /* ENALOCBASE, ENAARGBASE. */
  50. proc_p en__pro; /* ENPROC. */
  51. struct {
  52. valnum en__arbase;
  53. valnum en__index;
  54. valnum en__adesc;
  55. } en_arr; /* ENARRELEM. */
  56. } en_inf;
  57. };
  58. /* Macros to increase ease of use. */
  59. #define en_val en_inf.en__val
  60. #define en_loc en_inf.en__loc
  61. #define en_ext en_inf.en__ext
  62. #define en_ind en_inf.en__ind
  63. #define en_base en_inf.en_offs.en__base
  64. #define en_off en_inf.en_offs.en__off
  65. #define en_levels en_inf.en__levels
  66. #define en_pro en_inf.en__pro
  67. #define en_arbase en_inf.en_arr.en__arbase
  68. #define en_index en_inf.en_arr.en__index
  69. #define en_adesc en_inf.en_arr.en__adesc
  70. struct occur {
  71. line_p oc_lfirst; /* First instruction of expression. */
  72. line_p oc_llast; /* Last one. */
  73. bblock_p oc_belongs; /* Basic block it belongs to. */
  74. };
  75. /* We distinguish these groups of instructions. */
  76. #define SIMPLE_LOAD 0
  77. #define EXPENSIVE_LOAD 1
  78. #define LOAD_ARRAY 2
  79. #define STORE_DIRECT 3
  80. #define STORE_INDIR 4
  81. #define STORE_ARRAY 5
  82. #define UNAIR_OP 6
  83. #define BINAIR_OP 7
  84. #define TERNAIR_OP 8
  85. #define KILL_ENTITY 9
  86. #define SIDE_EFFECTS 10
  87. #define FIDDLE_STACK 11
  88. #define IGNORE 12
  89. #define HOPELESS 13
  90. #define BBLOCK_END 14
  91. struct avail {
  92. avail_p av_before; /* Ptr to earlier discovered expressions. */
  93. byte av_instr; /* Operator instruction. */
  94. offset av_size;
  95. line_p av_found; /* Line where expression is first found. */
  96. lset av_occurs; /* Set of recurrences of expression. */
  97. entity_p av_saveloc; /* Local where result is put in. */
  98. valnum av_result;
  99. union {
  100. valnum av__operand; /* EXPENSIVE_LOAD, UNAIR_OP. */
  101. struct {
  102. valnum av__oleft;
  103. valnum av__oright;
  104. } av_2; /* BINAIR_OP. */
  105. struct {
  106. valnum av__ofirst;
  107. valnum av__osecond;
  108. valnum av__othird;
  109. } av_3; /* TERNAIR_OP. */
  110. } av_o;
  111. };
  112. /* Macros to increase ease of use. */
  113. #define av_operand av_o.av__operand
  114. #define av_oleft av_o.av_2.av__oleft
  115. #define av_oright av_o.av_2.av__oright
  116. #define av_ofirst av_o.av_3.av__ofirst
  117. #define av_osecond av_o.av_3.av__osecond
  118. #define av_othird av_o.av_3.av__othird
  119. extern int Scs; /* Number of optimizations found. */