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