You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

229 lines
6.8KB

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