gensupport.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /* Declarations for rtx-reader support for gen* routines.
  2. Copyright (C) 2000-2018 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef GCC_GENSUPPORT_H
  16. #define GCC_GENSUPPORT_H
  17. #include "read-md.h"
  18. struct obstack;
  19. extern struct obstack *rtl_obstack;
  20. /* Information about an .md define_* rtx. */
  21. struct md_rtx_info {
  22. /* The rtx itself. */
  23. rtx def;
  24. /* The location of the first line of the rtx. */
  25. file_location loc;
  26. /* The unique number attached to the rtx. Currently all define_insns,
  27. define_expands, define_splits, define_peepholes and define_peephole2s
  28. share the same insn_code index space. */
  29. int index;
  30. };
  31. #define OPTAB_CL(name, pat, c, b, l) name,
  32. #define OPTAB_CX(name, pat)
  33. #define OPTAB_CD(name, pat) name,
  34. #define OPTAB_NL(name, pat, c, b, s, l) name,
  35. #define OPTAB_NC(name, pat, c) name,
  36. #define OPTAB_NX(name, pat)
  37. #define OPTAB_VL(name, pat, c, b, s, l) name,
  38. #define OPTAB_VC(name, pat, c) name,
  39. #define OPTAB_VX(name, pat)
  40. #define OPTAB_DC(name, pat, c) name,
  41. #define OPTAB_D(name, pat) name,
  42. /* Enumerates all optabs. */
  43. typedef enum optab_tag {
  44. unknown_optab,
  45. #include "optabs.def"
  46. NUM_OPTABS
  47. } optab;
  48. #undef OPTAB_CL
  49. #undef OPTAB_CX
  50. #undef OPTAB_CD
  51. #undef OPTAB_NL
  52. #undef OPTAB_NC
  53. #undef OPTAB_NX
  54. #undef OPTAB_VL
  55. #undef OPTAB_VC
  56. #undef OPTAB_VX
  57. #undef OPTAB_DC
  58. #undef OPTAB_D
  59. /* Describes one entry in optabs.def. */
  60. struct optab_def
  61. {
  62. /* The name of the optab (e.g. "add_optab"). */
  63. const char *name;
  64. /* The pattern that matching define_expands and define_insns have.
  65. See the comment at the head of optabs.def for details. */
  66. const char *pattern;
  67. /* The initializers (in the form of C code) for the libcall_basename,
  68. libcall_suffix and libcall_gen fields of (convert_)optab_libcall_d. */
  69. const char *base;
  70. const char *suffix;
  71. const char *libcall;
  72. /* The optab's enum value. */
  73. unsigned int op;
  74. /* The value returned by optab_to_code (OP). */
  75. enum rtx_code fcode;
  76. /* CODE if code_to_optab (CODE) should return OP, otherwise UNKNOWN. */
  77. enum rtx_code rcode;
  78. /* 1: conversion optabs with libcall data,
  79. 2: conversion optabs without libcall data,
  80. 3: non-conversion optabs with libcall data ("normal" and "overflow"
  81. optabs in the optabs.def comment)
  82. 4: non-conversion optabs without libcall data ("direct" optabs). */
  83. unsigned int kind;
  84. };
  85. extern optab_def optabs[];
  86. extern unsigned int num_optabs;
  87. /* Information about an instruction name that matches an optab pattern. */
  88. struct optab_pattern
  89. {
  90. /* The name of the instruction. */
  91. const char *name;
  92. /* The matching optab. */
  93. unsigned int op;
  94. /* The optab modes. M2 is only significant for conversion optabs;
  95. it is zero otherwise. */
  96. unsigned int m1, m2;
  97. /* An index that provides a lexicographical sort of (OP, M2, M1).
  98. Used by genopinit.c. */
  99. unsigned int sort_num;
  100. };
  101. extern rtx add_implicit_parallel (rtvec);
  102. extern rtx_reader *init_rtx_reader_args_cb (int, const char **,
  103. bool (*)(const char *));
  104. extern rtx_reader *init_rtx_reader_args (int, const char **);
  105. extern bool read_md_rtx (md_rtx_info *);
  106. extern unsigned int get_num_insn_codes ();
  107. /* Set this to 0 to disable automatic elision of insn patterns which
  108. can never be used in this configuration. See genconditions.c.
  109. Must be set before calling init_md_reader. */
  110. extern int insn_elision;
  111. /* Return the C test that says whether a definition rtx can be used,
  112. or "" if it can be used unconditionally. */
  113. extern const char *get_c_test (rtx);
  114. /* If the C test passed as the argument can be evaluated at compile
  115. time, return its truth value; else return -1. The test must have
  116. appeared somewhere in the machine description when genconditions
  117. was run. */
  118. extern int maybe_eval_c_test (const char *);
  119. /* Add an entry to the table of conditions. Used by genconditions and
  120. by read-rtl.c. */
  121. extern void add_c_test (const char *, int);
  122. /* This structure is used internally by gensupport.c and genconditions.c. */
  123. struct c_test
  124. {
  125. const char *expr;
  126. int value;
  127. };
  128. #ifdef __HASHTAB_H__
  129. extern hashval_t hash_c_test (const void *);
  130. extern int cmp_c_test (const void *, const void *);
  131. extern void traverse_c_tests (htab_trav, void *);
  132. #endif
  133. /* Predicate handling: helper functions and data structures. */
  134. struct pred_data
  135. {
  136. struct pred_data *next; /* for iterating over the set of all preds */
  137. const char *name; /* predicate name */
  138. bool special; /* special handling of modes? */
  139. /* data used primarily by genpreds.c */
  140. const char *c_block; /* C test block */
  141. rtx exp; /* RTL test expression */
  142. /* data used primarily by genrecog.c */
  143. enum rtx_code singleton; /* if pred takes only one code, that code */
  144. int num_codes; /* number of codes accepted */
  145. bool allows_non_lvalue; /* if pred allows non-lvalue expressions */
  146. bool allows_non_const; /* if pred allows non-const expressions */
  147. bool codes[NUM_RTX_CODE]; /* set of codes accepted */
  148. };
  149. extern struct pred_data *first_predicate;
  150. extern struct pred_data *lookup_predicate (const char *);
  151. extern void add_predicate_code (struct pred_data *, enum rtx_code);
  152. extern void add_predicate (struct pred_data *);
  153. #define FOR_ALL_PREDICATES(p) for (p = first_predicate; p; p = p->next)
  154. struct pattern_stats
  155. {
  156. /* The largest match_operand, match_operator or match_parallel
  157. number found. */
  158. int max_opno;
  159. /* The largest match_dup, match_op_dup or match_par_dup number found. */
  160. int max_dup_opno;
  161. /* The smallest and largest match_scratch number found. */
  162. int min_scratch_opno;
  163. int max_scratch_opno;
  164. /* The number of times match_dup, match_op_dup or match_par_dup appears
  165. in the pattern. */
  166. int num_dups;
  167. /* The number of rtx arguments to the generator function. */
  168. int num_generator_args;
  169. /* The number of rtx operands in an insn. */
  170. int num_insn_operands;
  171. /* The number of operand variables that are needed. */
  172. int num_operand_vars;
  173. };
  174. extern void get_pattern_stats (struct pattern_stats *ranges, rtvec vec);
  175. extern void compute_test_codes (rtx, file_location, char *);
  176. extern file_location get_file_location (rtx);
  177. extern const char *get_emit_function (rtx);
  178. extern bool needs_barrier_p (rtx);
  179. extern bool find_optab (optab_pattern *, const char *);
  180. #endif /* GCC_GENSUPPORT_H */