cgg_cg.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Header$ */
  6. /* offsets of interesting fields in EM-pattern */
  7. #define PO_HASH 0
  8. #define PO_NEXT 1
  9. #define PO_MATCH 3
  10. #define ILLHASH 0177777
  11. /* Commands for codegenerator, in low order 5 bits of byte */
  12. #define DO_NEXTEM 0
  13. #define DO_MATCH 1
  14. #define DO_XMATCH 2
  15. #define DO_XXMATCH 3
  16. #define DO_REMOVE 4
  17. #define DO_DEALLOCATE 5
  18. #define DO_REALLOCATE 6
  19. #define DO_ALLOCATE 7
  20. #define DO_MOVE 10
  21. #define DO_ERASE 11
  22. #define DO_TOKREPLACE 12
  23. #define DO_EMREPLACE 13
  24. #define DO_COST 14
  25. #define DO_RETURN 15
  26. #define DO_COERC 16
  27. #define DO_PRETURN 17
  28. #define DO_RREMOVE 18
  29. #define DO_INSTR 19
  30. #define DO_TEST 20
  31. #define DO_DLINE 21
  32. #define DO_SETCC 22
  33. #ifndef MAXATT
  34. #define MAXATT TOKENSIZE
  35. #endif
  36. typedef struct instance {
  37. short in_which;
  38. # define IN_COPY 1
  39. # define IN_MEMB 2
  40. # define IN_RIDENT 3
  41. # define IN_ALLOC 4
  42. # define IN_DESCR 5
  43. # define IN_S_DESCR 6
  44. # define IN_D_DESCR 7
  45. short in_info[MAXATT+1];
  46. } inst_t,*inst_p;
  47. typedef struct set {
  48. short set_size;
  49. short set_val[SETSIZE];
  50. } set_t,*set_p;
  51. typedef struct {
  52. short m_set1; /* number of tokenexpr in move: from */
  53. short m_expr1; /* optional expression */
  54. short m_set2; /* number of tokenexpr in move: to */
  55. short m_expr2; /* optional expression */
  56. short m_cindex; /* code index to really do it */
  57. } move_t, *move_p;
  58. typedef struct {
  59. short t_set; /* number of tokenexpr in test */
  60. short t_expr; /* optional expression */
  61. short t_cindex; /* code index to really do it */
  62. } test_t, *test_p;
  63. struct exprnode {
  64. short ex_operator;
  65. short ex_lnode;
  66. short ex_rnode;
  67. };
  68. typedef struct exprnode node_t;
  69. typedef struct exprnode *node_p;
  70. /*
  71. * contents of .ex_operator
  72. */
  73. #define EX_TOKFIELD 0
  74. #define EX_ARG 1
  75. #define EX_CON 2
  76. #define EX_ALLREG 3
  77. #define EX_SAMESIGN 4
  78. #define EX_SFIT 5
  79. #define EX_UFIT 6
  80. #define EX_ROM 7
  81. #define EX_NCPEQ 8
  82. #define EX_SCPEQ 9
  83. #define EX_RCPEQ 10
  84. #define EX_NCPNE 11
  85. #define EX_SCPNE 12
  86. #define EX_RCPNE 13
  87. #define EX_NCPGT 14
  88. #define EX_NCPGE 15
  89. #define EX_NCPLT 16
  90. #define EX_NCPLE 17
  91. #define EX_OR2 18
  92. #define EX_AND2 19
  93. #define EX_PLUS 20
  94. #define EX_CAT 21
  95. #define EX_MINUS 22
  96. #define EX_TIMES 23
  97. #define EX_DIVIDE 24
  98. #define EX_MOD 25
  99. #define EX_LSHIFT 26
  100. #define EX_RSHIFT 27
  101. #define EX_NOT 28
  102. #define EX_COMP 29
  103. #define EX_STRING 31
  104. #define EX_DEFINED 32
  105. #define EX_SUBREG 33
  106. #define EX_TOSTRING 34
  107. #define EX_UMINUS 35
  108. #define EX_REG 36
  109. #define EX_LOWW 37
  110. #define EX_HIGHW 38
  111. #define EX_INREG 39
  112. #define EX_REGVAR 40
  113. #define EX_OR 41
  114. #define EX_XOR 42
  115. #define EX_AND 43
  116. typedef struct { /* to stack coercions */
  117. short c1_texpno; /* token expression number */
  118. short c1_expr; /* boolean expression */
  119. short c1_prop; /* property of register needed */
  120. short c1_codep; /* code index */
  121. } c1_t,*c1_p;
  122. #ifdef MAXSPLIT
  123. typedef struct { /* splitting coercions */
  124. short c2_texpno; /* token expression number */
  125. short c2_expr; /* optional boolean expression */
  126. short c2_nsplit; /* split factor */
  127. short c2_repl[MAXSPLIT];/* replacement instances */
  128. short c2_codep; /* code index */
  129. } c2_t,*c2_p;
  130. #endif MAXSPLIT
  131. typedef struct { /* one to one coercions */
  132. short c3_texpno; /* token expression number */
  133. short c3_expr; /* boolean expression */
  134. short c3_prop; /* property of register needed */
  135. short c3_repl; /* replacement instance */
  136. short c3_codep; /* code index */
  137. } c3_t,*c3_p;
  138. #define getint(a,b) \
  139. if ((a=((*(b)++)&BMASK)) >= 128) {\
  140. a = ((a-128)<<BSHIFT) | (*(b)++&BMASK); \
  141. }