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