pattern.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. /* $Id$ */
  6. /*
  7. * pattern contains the optimization patterns in an apparently
  8. * unordered fashion. All patterns follow each other unaligned.
  9. * Each pattern looks as follows:
  10. * Byte 0: high byte of hash value associated with this pattern.
  11. * Byte 1-2: index of next pattern with same low byte of hash value.
  12. * Byte 3- : pattern and replacement.
  13. * First comes the pattern length
  14. * then the pattern opcodes,
  15. * then a boolean expression,
  16. * then the one-byte replacement length
  17. * then the intermixed pattern opcodes and operands or
  18. * 0 followed by the one-byte special optimization expression.
  19. * If the DIAGOPT option is set, the optimization is followed
  20. * by the line number in the tables.
  21. */
  22. #undef ALLOWSPECIAL /* Special optimizations allowed */
  23. #define PO_HASH 0
  24. #define PO_NEXT 1
  25. #define PO_MATCH 3
  26. struct exprnode {
  27. short ex_operator;
  28. short ex_lnode;
  29. short ex_rnode;
  30. };
  31. typedef struct exprnode expr_t;
  32. typedef struct exprnode *expr_p;
  33. /*
  34. * contents of .ex_operator
  35. */
  36. #define EX_CON 0
  37. #define EX_ARG 1
  38. #define EX_CMPEQ 2
  39. #define EX_CMPNE 3
  40. #define EX_CMPGT 4
  41. #define EX_CMPGE 5
  42. #define EX_CMPLT 6
  43. #define EX_CMPLE 7
  44. #define EX_OR2 8
  45. #define EX_AND2 9
  46. #define EX_OR1 10
  47. #define EX_XOR1 11
  48. #define EX_AND1 12
  49. #define EX_PLUS 13
  50. #define EX_MINUS 14
  51. #define EX_TIMES 15
  52. #define EX_DIVIDE 16
  53. #define EX_MOD 17
  54. #define EX_LSHIFT 18
  55. #define EX_RSHIFT 19
  56. #define EX_UMINUS 20
  57. #define EX_NOT 21
  58. #define EX_COMP 22
  59. #define EX_ROM 23
  60. #define EX_NOTREG 24
  61. #define EX_POINTERSIZE 25
  62. #define EX_WORDSIZE 26
  63. #define EX_DEFINED 27
  64. #define EX_SAMESIGN 28
  65. #define EX_SFIT 29
  66. #define EX_UFIT 30
  67. #define EX_ROTATE 31
  68. #define N_EX_OPS 32 /* must be one higher then previous */
  69. /*
  70. * Definition of special opcodes used in patterns
  71. */
  72. #define op_pfirst op_LLP
  73. #define op_LLP (op_last+1)
  74. #define op_LEP (op_last+2)
  75. #define op_SLP (op_last+3)
  76. #define op_SEP (op_last+4)
  77. #define op_plast op_SEP
  78. /*
  79. * Definition of the structure in which instruction operands
  80. * are kept during pattern matching.
  81. */
  82. typedef struct eval eval_t;
  83. typedef struct eval *eval_p;
  84. struct eval {
  85. short e_typ;
  86. union {
  87. offset e_con;
  88. num_p e_np;
  89. } e_v;
  90. };
  91. /*
  92. * contents of .e_typ
  93. */
  94. #define EV_UNDEF 0
  95. #define EV_CONST 1
  96. #define EV_NUMLAB 2
  97. #define EV_FRAG 3 /* and all higher numbers */
  98. typedef struct iarg iarg_t;
  99. typedef struct iarg *iarg_p;
  100. struct iarg {
  101. eval_t ia_ev;
  102. sym_p ia_sp;
  103. };
  104. /*
  105. * The next extern declarations refer to data generated by mktab
  106. */
  107. extern byte pattern[];
  108. extern short lastind;
  109. extern iarg_t iargs[];
  110. extern byte nparam[];
  111. extern bool nonumlab[];
  112. extern bool onlyconst[];
  113. extern expr_t enodes[];