Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
[dragonfly.git] / contrib / gcc-3.4 / gcc / recog.h
CommitLineData
003757ed
MD
1/* Declarations for interface to insn recognizer and insn-output.c.
2 Copyright (C) 1987, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004
3 Free Software Foundation, Inc.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 2, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING. If not, write to the Free
19Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2002111-1307, USA. */
21
22/* Random number that should be large enough for all purposes. */
23#define MAX_RECOG_ALTERNATIVES 30
24#define recog_memoized(I) (INSN_CODE (I) >= 0 \
25 ? INSN_CODE (I) : recog_memoized_1 (I))
26
27/* Types of operands. */
28enum op_type {
29 OP_IN,
30 OP_OUT,
31 OP_INOUT
32};
33
34struct operand_alternative
35{
36 /* Pointer to the beginning of the constraint string for this alternative,
37 for easier access by alternative number. */
38 const char *constraint;
39
40 /* The register class valid for this alternative (possibly NO_REGS). */
41 enum reg_class class;
42
43 /* "Badness" of this alternative, computed from number of '?' and '!'
44 characters in the constraint string. */
45 unsigned int reject;
46
47 /* -1 if no matching constraint was found, or an operand number. */
48 int matches;
49 /* The same information, but reversed: -1 if this operand is not
50 matched by any other, or the operand number of the operand that
51 matches this one. */
52 int matched;
53
54 /* Nonzero if '&' was found in the constraint string. */
55 unsigned int earlyclobber:1;
56 /* Nonzero if 'm' was found in the constraint string. */
57 unsigned int memory_ok:1;
58 /* Nonzero if 'o' was found in the constraint string. */
59 unsigned int offmem_ok:1;
60 /* Nonzero if 'V' was found in the constraint string. */
61 unsigned int nonoffmem_ok:1;
62 /* Nonzero if '<' was found in the constraint string. */
63 unsigned int decmem_ok:1;
64 /* Nonzero if '>' was found in the constraint string. */
65 unsigned int incmem_ok:1;
66 /* Nonzero if 'p' was found in the constraint string. */
67 unsigned int is_address:1;
68 /* Nonzero if 'X' was found in the constraint string, or if the constraint
69 string for this alternative was empty. */
70 unsigned int anything_ok:1;
71};
72
73
74extern void init_recog (void);
75extern void init_recog_no_volatile (void);
76extern int recog_memoized_1 (rtx);
77extern int check_asm_operands (rtx);
78extern int asm_operand_ok (rtx, const char *);
79extern int validate_change (rtx, rtx *, rtx, int);
80extern int insn_invalid_p (rtx);
81extern int apply_change_group (void);
82extern int num_validated_changes (void);
83extern void cancel_changes (int);
84extern int constrain_operands (int);
85extern int constrain_operands_cached (int);
86extern int memory_address_p (enum machine_mode, rtx);
87extern int strict_memory_address_p (enum machine_mode, rtx);
88extern int validate_replace_rtx_subexp (rtx, rtx, rtx, rtx *);
89extern int validate_replace_rtx (rtx, rtx, rtx);
90extern void validate_replace_rtx_group (rtx, rtx, rtx);
91extern int validate_replace_src (rtx, rtx, rtx);
92extern void validate_replace_src_group (rtx, rtx, rtx);
93extern int num_changes_pending (void);
94#ifdef HAVE_cc0
95extern int next_insn_tests_no_inequality (rtx);
96#endif
97extern int reg_fits_class_p (rtx, enum reg_class, int, enum machine_mode);
98extern rtx *find_single_use (rtx, rtx, rtx *);
99
100extern int general_operand (rtx, enum machine_mode);
101extern int address_operand (rtx, enum machine_mode);
102extern int register_operand (rtx, enum machine_mode);
103extern int pmode_register_operand (rtx, enum machine_mode);
104extern int scratch_operand (rtx, enum machine_mode);
105extern int immediate_operand (rtx, enum machine_mode);
106extern int const_int_operand (rtx, enum machine_mode);
107extern int const_double_operand (rtx, enum machine_mode);
108extern int nonimmediate_operand (rtx, enum machine_mode);
109extern int nonmemory_operand (rtx, enum machine_mode);
110extern int push_operand (rtx, enum machine_mode);
111extern int pop_operand (rtx, enum machine_mode);
112extern int memory_operand (rtx, enum machine_mode);
113extern int indirect_operand (rtx, enum machine_mode);
114extern int comparison_operator (rtx, enum machine_mode);
115
116extern int offsettable_memref_p (rtx);
117extern int offsettable_nonstrict_memref_p (rtx);
118extern int offsettable_address_p (int, enum machine_mode, rtx);
119extern int mode_dependent_address_p (rtx);
120
121extern int recog (rtx, rtx, int *);
122extern void add_clobbers (rtx, int);
123extern int added_clobbers_hard_reg_p (int);
124extern void insn_extract (rtx);
125extern void extract_insn (rtx);
126extern void extract_constrain_insn_cached (rtx);
127extern void extract_insn_cached (rtx);
128extern void preprocess_constraints (void);
129extern rtx peep2_next_insn (int);
130extern int peep2_regno_dead_p (int, int);
131extern int peep2_reg_dead_p (int, rtx);
132#ifdef CLEAR_HARD_REG_SET
133extern rtx peep2_find_free_register (int, int, const char *,
134 enum machine_mode, HARD_REG_SET *);
135#endif
136extern void peephole2_optimize (FILE *);
137extern rtx peephole2_insns (rtx, rtx, int *);
138
139extern int store_data_bypass_p (rtx, rtx);
140extern int if_test_bypass_p (rtx, rtx);
141
142/* Nonzero means volatile operands are recognized. */
143extern int volatile_ok;
144
145/* Set by constrain_operands to the number of the alternative that
146 matched. */
147extern int which_alternative;
148
149/* The following vectors hold the results from insn_extract. */
150
151struct recog_data
152{
153 /* It is very tempting to make the 5 operand related arrays into a
154 structure and index on that. However, to be source compatible
155 with all of the existing md file insn constraints and output
156 templates, we need `operand' as a flat array. Without that
157 member, making an array for the rest seems pointless. */
158
159 /* Gives value of operand N. */
160 rtx operand[MAX_RECOG_OPERANDS];
161
162 /* Gives location where operand N was found. */
163 rtx *operand_loc[MAX_RECOG_OPERANDS];
164
165 /* Gives the constraint string for operand N. */
166 const char *constraints[MAX_RECOG_OPERANDS];
167
168 /* Gives the mode of operand N. */
169 enum machine_mode operand_mode[MAX_RECOG_OPERANDS];
170
171 /* Gives the type (in, out, inout) for operand N. */
172 enum op_type operand_type[MAX_RECOG_OPERANDS];
173
174 /* Gives location where the Nth duplicate-appearance of an operand
175 was found. This is something that matched MATCH_DUP. */
176 rtx *dup_loc[MAX_DUP_OPERANDS];
177
178 /* Gives the operand number that was duplicated in the Nth
179 duplicate-appearance of an operand. */
180 char dup_num[MAX_DUP_OPERANDS];
181
182 /* ??? Note that these are `char' instead of `unsigned char' to (try to)
183 avoid certain lossage from K&R C, wherein `unsigned char' default
184 promotes to `unsigned int' instead of `int' as in ISO C. As of 1999,
185 the most common places to bootstrap from K&R C are SunOS and HPUX,
186 both of which have signed characters by default. The only other
187 supported natives that have both K&R C and unsigned characters are
188 ROMP and Irix 3, and neither have been seen for a while, but do
189 continue to consider unsignedness when performing arithmetic inside
190 a comparison. */
191
192 /* The number of operands of the insn. */
193 char n_operands;
194
195 /* The number of MATCH_DUPs in the insn. */
196 char n_dups;
197
198 /* The number of alternatives in the constraints for the insn. */
199 char n_alternatives;
200
201 /* In case we are caching, hold insn data was generated for. */
202 rtx insn;
203};
204
205extern struct recog_data recog_data;
206
207/* Contains a vector of operand_alternative structures for every operand.
208 Set up by preprocess_constraints. */
209extern struct operand_alternative recog_op_alt[MAX_RECOG_OPERANDS][MAX_RECOG_ALTERNATIVES];
210
211/* A table defined in insn-output.c that give information about
212 each insn-code value. */
213
214typedef int (*insn_operand_predicate_fn) (rtx, enum machine_mode);
215typedef const char * (*insn_output_fn) (rtx *, rtx);
216typedef rtx (*insn_gen_fn) (rtx, ...);
217
218struct insn_operand_data
219{
220 const insn_operand_predicate_fn predicate;
221
222 const char *const constraint;
223
224 ENUM_BITFIELD(machine_mode) const mode : 16;
225
226 const char strict_low;
227
228 const char eliminable;
229};
230
231/* Legal values for insn_data.output_format. Indicate what type of data
232 is stored in insn_data.output. */
233#define INSN_OUTPUT_FORMAT_NONE 0 /* abort */
234#define INSN_OUTPUT_FORMAT_SINGLE 1 /* const char * */
235#define INSN_OUTPUT_FORMAT_MULTI 2 /* const char * const * */
236#define INSN_OUTPUT_FORMAT_FUNCTION 3 /* const char * (*)(...) */
237
238struct insn_data
239{
240 const char *const name;
241#if HAVE_DESIGNATED_INITIALIZERS
242 union {
243 const char *single;
244 const char *const *multi;
245 insn_output_fn function;
246 } output;
247#else
248 struct {
249 const char *single;
250 const char *const *multi;
251 insn_output_fn function;
252 } output;
253#endif
254 const insn_gen_fn genfun;
255 const struct insn_operand_data *const operand;
256
257 const char n_operands;
258 const char n_dups;
259 const char n_alternatives;
260 const char output_format;
261};
262
263extern const struct insn_data insn_data[];