pattern.h 2.9 KB

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