aarch64-simd.md (aarch64_simd_vec_<su>mult_lo_<mode>, [...]): Separate instruction...
[gcc.git] / gcc / recog.h
1 /* Declarations for interface to insn recognizer and insn-output.c.
2 Copyright (C) 1987, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004,
3 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
21
22 #ifndef GCC_RECOG_H
23 #define GCC_RECOG_H
24
25 /* Random number that should be large enough for all purposes. */
26 #define MAX_RECOG_ALTERNATIVES 30
27
28 /* Types of operands. */
29 enum op_type {
30 OP_IN,
31 OP_OUT,
32 OP_INOUT
33 };
34
35 struct operand_alternative
36 {
37 /* Pointer to the beginning of the constraint string for this alternative,
38 for easier access by alternative number. */
39 const char *constraint;
40
41 /* The register class valid for this alternative (possibly NO_REGS). */
42 enum reg_class cl;
43
44 /* "Badness" of this alternative, computed from number of '?' and '!'
45 characters in the constraint string. */
46 unsigned int reject;
47
48 /* -1 if no matching constraint was found, or an operand number. */
49 int matches;
50 /* The same information, but reversed: -1 if this operand is not
51 matched by any other, or the operand number of the operand that
52 matches this one. */
53 int matched;
54
55 /* Nonzero if '&' was found in the constraint string. */
56 unsigned int earlyclobber:1;
57 /* Nonzero if TARGET_MEM_CONSTRAINT was found in the constraint
58 string. */
59 unsigned int memory_ok:1;
60 /* Nonzero if 'o' was found in the constraint string. */
61 unsigned int offmem_ok:1;
62 /* Nonzero if 'V' was found in the constraint string. */
63 unsigned int nonoffmem_ok:1;
64 /* Nonzero if '<' was found in the constraint string. */
65 unsigned int decmem_ok:1;
66 /* Nonzero if '>' was found in the constraint string. */
67 unsigned int incmem_ok:1;
68 /* Nonzero if 'p' was found in the constraint string. */
69 unsigned int is_address:1;
70 /* Nonzero if 'X' was found in the constraint string, or if the constraint
71 string for this alternative was empty. */
72 unsigned int anything_ok:1;
73 };
74
75
76 extern void init_recog (void);
77 extern void init_recog_no_volatile (void);
78 extern int check_asm_operands (rtx);
79 extern int asm_operand_ok (rtx, const char *, const char **);
80 extern bool validate_change (rtx, rtx *, rtx, bool);
81 extern bool validate_unshare_change (rtx, rtx *, rtx, bool);
82 extern bool canonicalize_change_group (rtx insn, rtx x);
83 extern int insn_invalid_p (rtx, bool);
84 extern int verify_changes (int);
85 extern void confirm_change_group (void);
86 extern int apply_change_group (void);
87 extern int num_validated_changes (void);
88 extern void cancel_changes (int);
89 extern int constrain_operands (int);
90 extern int constrain_operands_cached (int);
91 extern int memory_address_addr_space_p (enum machine_mode, rtx, addr_space_t);
92 #define memory_address_p(mode,addr) \
93 memory_address_addr_space_p ((mode), (addr), ADDR_SPACE_GENERIC)
94 extern int strict_memory_address_addr_space_p (enum machine_mode, rtx,
95 addr_space_t);
96 #define strict_memory_address_p(mode,addr) \
97 strict_memory_address_addr_space_p ((mode), (addr), ADDR_SPACE_GENERIC)
98 extern int validate_replace_rtx_subexp (rtx, rtx, rtx, rtx *);
99 extern int validate_replace_rtx (rtx, rtx, rtx);
100 extern int validate_replace_rtx_part (rtx, rtx, rtx *, rtx);
101 extern int validate_replace_rtx_part_nosimplify (rtx, rtx, rtx *, rtx);
102 extern void validate_replace_rtx_group (rtx, rtx, rtx);
103 extern void validate_replace_src_group (rtx, rtx, rtx);
104 extern bool validate_simplify_insn (rtx insn);
105 extern int num_changes_pending (void);
106 #ifdef HAVE_cc0
107 extern int next_insn_tests_no_inequality (rtx);
108 #endif
109 extern bool reg_fits_class_p (const_rtx, reg_class_t, int, enum machine_mode);
110
111 extern int offsettable_memref_p (rtx);
112 extern int offsettable_nonstrict_memref_p (rtx);
113 extern int offsettable_address_addr_space_p (int, enum machine_mode, rtx,
114 addr_space_t);
115 #define offsettable_address_p(strict,mode,addr) \
116 offsettable_address_addr_space_p ((strict), (mode), (addr), \
117 ADDR_SPACE_GENERIC)
118 extern bool mode_dependent_address_p (rtx, addr_space_t);
119
120 extern int recog (rtx, rtx, int *);
121 #ifndef GENERATOR_FILE
122 static inline int recog_memoized (rtx insn);
123 #endif
124 extern void add_clobbers (rtx, int);
125 extern int added_clobbers_hard_reg_p (int);
126 extern void insn_extract (rtx);
127 extern void extract_insn (rtx);
128 extern void extract_constrain_insn_cached (rtx);
129 extern void extract_insn_cached (rtx);
130 extern void preprocess_constraints (void);
131 extern rtx peep2_next_insn (int);
132 extern int peep2_regno_dead_p (int, int);
133 extern int peep2_reg_dead_p (int, rtx);
134 #ifdef CLEAR_HARD_REG_SET
135 extern rtx peep2_find_free_register (int, int, const char *,
136 enum machine_mode, HARD_REG_SET *);
137 #endif
138 extern rtx peephole2_insns (rtx, rtx, int *);
139
140 extern int store_data_bypass_p (rtx, rtx);
141 extern int if_test_bypass_p (rtx, rtx);
142
143 #ifndef GENERATOR_FILE
144 /* Try recognizing the instruction INSN,
145 and return the code number that results.
146 Remember the code so that repeated calls do not
147 need to spend the time for actual rerecognition.
148
149 This function is the normal interface to instruction recognition.
150 The automatically-generated function `recog' is normally called
151 through this one. */
152
153 static inline int
154 recog_memoized (rtx insn)
155 {
156 if (INSN_CODE (insn) < 0)
157 INSN_CODE (insn) = recog (PATTERN (insn), insn, 0);
158 return INSN_CODE (insn);
159 }
160 #endif
161
162 /* Skip chars until the next ',' or the end of the string. This is
163 useful to skip alternatives in a constraint string. */
164 static inline const char *
165 skip_alternative (const char *p)
166 {
167 const char *r = p;
168 while (*r != '\0' && *r != ',')
169 r++;
170 if (*r == ',')
171 r++;
172 return r;
173 }
174
175 /* Nonzero means volatile operands are recognized. */
176 extern int volatile_ok;
177
178 /* Set by constrain_operands to the number of the alternative that
179 matched. */
180 extern int which_alternative;
181
182 /* The following vectors hold the results from insn_extract. */
183
184 struct recog_data
185 {
186 /* It is very tempting to make the 5 operand related arrays into a
187 structure and index on that. However, to be source compatible
188 with all of the existing md file insn constraints and output
189 templates, we need `operand' as a flat array. Without that
190 member, making an array for the rest seems pointless. */
191
192 /* Gives value of operand N. */
193 rtx operand[MAX_RECOG_OPERANDS];
194
195 /* Gives location where operand N was found. */
196 rtx *operand_loc[MAX_RECOG_OPERANDS];
197
198 /* Gives the constraint string for operand N. */
199 const char *constraints[MAX_RECOG_OPERANDS];
200
201 /* Nonzero if operand N is a match_operator or a match_parallel. */
202 char is_operator[MAX_RECOG_OPERANDS];
203
204 /* Gives the mode of operand N. */
205 enum machine_mode operand_mode[MAX_RECOG_OPERANDS];
206
207 /* Gives the type (in, out, inout) for operand N. */
208 enum op_type operand_type[MAX_RECOG_OPERANDS];
209
210 /* Gives location where the Nth duplicate-appearance of an operand
211 was found. This is something that matched MATCH_DUP. */
212 rtx *dup_loc[MAX_DUP_OPERANDS];
213
214 /* Gives the operand number that was duplicated in the Nth
215 duplicate-appearance of an operand. */
216 char dup_num[MAX_DUP_OPERANDS];
217
218 /* ??? Note that these are `char' instead of `unsigned char' to (try to)
219 avoid certain lossage from K&R C, wherein `unsigned char' default
220 promotes to `unsigned int' instead of `int' as in ISO C. As of 1999,
221 the most common places to bootstrap from K&R C are SunOS and HPUX,
222 both of which have signed characters by default. The only other
223 supported natives that have both K&R C and unsigned characters are
224 ROMP and Irix 3, and neither have been seen for a while, but do
225 continue to consider unsignedness when performing arithmetic inside
226 a comparison. */
227
228 /* The number of operands of the insn. */
229 char n_operands;
230
231 /* The number of MATCH_DUPs in the insn. */
232 char n_dups;
233
234 /* The number of alternatives in the constraints for the insn. */
235 char n_alternatives;
236
237 /* True if insn is ASM_OPERANDS. */
238 bool is_asm;
239
240 /* Specifies whether an insn alternative is enabled using the
241 `enabled' attribute in the insn pattern definition. For back
242 ends not using the `enabled' attribute the array fields are
243 always set to `true' in expand_insn. */
244 bool alternative_enabled_p [MAX_RECOG_ALTERNATIVES];
245
246 /* In case we are caching, hold insn data was generated for. */
247 rtx insn;
248 };
249
250 extern struct recog_data recog_data;
251
252 /* Contains a vector of operand_alternative structures for every operand.
253 Set up by preprocess_constraints. */
254 extern struct operand_alternative recog_op_alt[MAX_RECOG_OPERANDS][MAX_RECOG_ALTERNATIVES];
255
256 /* A table defined in insn-output.c that give information about
257 each insn-code value. */
258
259 typedef int (*insn_operand_predicate_fn) (rtx, enum machine_mode);
260 typedef const char * (*insn_output_fn) (rtx *, rtx);
261 typedef rtx (*insn_gen_fn) (rtx, ...);
262
263 struct insn_operand_data
264 {
265 const insn_operand_predicate_fn predicate;
266
267 const char *const constraint;
268
269 ENUM_BITFIELD(machine_mode) const mode : 16;
270
271 const char strict_low;
272
273 const char is_operator;
274
275 const char eliminable;
276
277 const char allows_mem;
278 };
279
280 /* Legal values for insn_data.output_format. Indicate what type of data
281 is stored in insn_data.output. */
282 #define INSN_OUTPUT_FORMAT_NONE 0 /* abort */
283 #define INSN_OUTPUT_FORMAT_SINGLE 1 /* const char * */
284 #define INSN_OUTPUT_FORMAT_MULTI 2 /* const char * const * */
285 #define INSN_OUTPUT_FORMAT_FUNCTION 3 /* const char * (*)(...) */
286
287 struct insn_data_d
288 {
289 const char *const name;
290 #if HAVE_DESIGNATED_UNION_INITIALIZERS
291 union {
292 const char *single;
293 const char *const *multi;
294 insn_output_fn function;
295 } output;
296 #else
297 struct {
298 const char *single;
299 const char *const *multi;
300 insn_output_fn function;
301 } output;
302 #endif
303 const insn_gen_fn genfun;
304 const struct insn_operand_data *const operand;
305
306 const char n_generator_args;
307 const char n_operands;
308 const char n_dups;
309 const char n_alternatives;
310 const char output_format;
311 };
312
313 extern const struct insn_data_d insn_data[];
314 extern int peep2_current_count;
315
316 #endif /* GCC_RECOG_H */