]> gcc.gnu.org Git - gcc.git/blame - gcc/recog.h
trans-io.c (set_string): Use fold_build2 and build_int_cst instead of build2 and...
[gcc.git] / gcc / recog.h
CommitLineData
64a93ac5 1/* Declarations for interface to insn recognizer and insn-output.c.
9fcdd891 2 Copyright (C) 1987, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
751aa7cc 3 Free Software Foundation, Inc.
64a93ac5 4
1322177d 5This file is part of GCC.
64a93ac5 6
1322177d
LB
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.
64a93ac5 11
1322177d
LB
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.
64a93ac5
CH
16
17You should have received a copy of the GNU General Public License
1322177d 18along with GCC; see the file COPYING. If not, write to the Free
366ccddb
KC
19Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
2002110-1301, USA. */
64a93ac5 21
f62a15e3
BS
22/* Random number that should be large enough for all purposes. */
23#define MAX_RECOG_ALTERNATIVES 30
24
0eadeb15
BS
25/* Types of operands. */
26enum op_type {
27 OP_IN,
28 OP_OUT,
29 OP_INOUT
30};
31
f62a15e3
BS
32struct operand_alternative
33{
34 /* Pointer to the beginning of the constraint string for this alternative,
35 for easier access by alternative number. */
9b3142b3 36 const char *constraint;
f62a15e3
BS
37
38 /* The register class valid for this alternative (possibly NO_REGS). */
e3a64162 39 enum reg_class cl;
f62a15e3
BS
40
41 /* "Badness" of this alternative, computed from number of '?' and '!'
42 characters in the constraint string. */
43 unsigned int reject;
44
45 /* -1 if no matching constraint was found, or an operand number. */
46 int matches;
47 /* The same information, but reversed: -1 if this operand is not
48 matched by any other, or the operand number of the operand that
49 matches this one. */
50 int matched;
51
52 /* Nonzero if '&' was found in the constraint string. */
53 unsigned int earlyclobber:1;
54 /* Nonzero if 'm' was found in the constraint string. */
0c20a65f 55 unsigned int memory_ok:1;
f62a15e3 56 /* Nonzero if 'o' was found in the constraint string. */
0c20a65f 57 unsigned int offmem_ok:1;
f62a15e3
BS
58 /* Nonzero if 'V' was found in the constraint string. */
59 unsigned int nonoffmem_ok:1;
60 /* Nonzero if '<' was found in the constraint string. */
61 unsigned int decmem_ok:1;
62 /* Nonzero if '>' was found in the constraint string. */
63 unsigned int incmem_ok:1;
541f7d56
BS
64 /* Nonzero if 'p' was found in the constraint string. */
65 unsigned int is_address:1;
f62a15e3
BS
66 /* Nonzero if 'X' was found in the constraint string, or if the constraint
67 string for this alternative was empty. */
68 unsigned int anything_ok:1;
69};
70
71
0c20a65f
AJ
72extern void init_recog (void);
73extern void init_recog_no_volatile (void);
0c20a65f
AJ
74extern int check_asm_operands (rtx);
75extern int asm_operand_ok (rtx, const char *);
76extern int validate_change (rtx, rtx *, rtx, int);
77extern int insn_invalid_p (rtx);
7d22e898 78extern int verify_changes (int);
0a634832 79extern void confirm_change_group (void);
0c20a65f
AJ
80extern int apply_change_group (void);
81extern int num_validated_changes (void);
82extern void cancel_changes (int);
83extern int constrain_operands (int);
84extern int constrain_operands_cached (int);
85extern int memory_address_p (enum machine_mode, rtx);
86extern int strict_memory_address_p (enum machine_mode, rtx);
0c20a65f
AJ
87extern int validate_replace_rtx (rtx, rtx, rtx);
88extern void validate_replace_rtx_group (rtx, rtx, rtx);
0c20a65f
AJ
89extern void validate_replace_src_group (rtx, rtx, rtx);
90extern int num_changes_pending (void);
523bb0ba 91#ifdef HAVE_cc0
0c20a65f 92extern int next_insn_tests_no_inequality (rtx);
523bb0ba 93#endif
0c20a65f
AJ
94extern int reg_fits_class_p (rtx, enum reg_class, int, enum machine_mode);
95extern rtx *find_single_use (rtx, rtx, rtx *);
96
0c20a65f
AJ
97extern int offsettable_memref_p (rtx);
98extern int offsettable_nonstrict_memref_p (rtx);
99extern int offsettable_address_p (int, enum machine_mode, rtx);
100extern int mode_dependent_address_p (rtx);
101
102extern int recog (rtx, rtx, int *);
9fcdd891 103#ifndef GENERATOR_FILE
f5523e6d 104static inline int recog_memoized (rtx insn);
9fcdd891 105#endif
0c20a65f
AJ
106extern void add_clobbers (rtx, int);
107extern int added_clobbers_hard_reg_p (int);
108extern void insn_extract (rtx);
109extern void extract_insn (rtx);
110extern void extract_constrain_insn_cached (rtx);
111extern void extract_insn_cached (rtx);
112extern void preprocess_constraints (void);
113extern rtx peep2_next_insn (int);
114extern int peep2_regno_dead_p (int, int);
115extern int peep2_reg_dead_p (int, rtx);
23280139 116#ifdef CLEAR_HARD_REG_SET
0c20a65f
AJ
117extern rtx peep2_find_free_register (int, int, const char *,
118 enum machine_mode, HARD_REG_SET *);
23280139 119#endif
0c20a65f 120extern rtx peephole2_insns (rtx, rtx, int *);
64a93ac5 121
0c20a65f
AJ
122extern int store_data_bypass_p (rtx, rtx);
123extern int if_test_bypass_p (rtx, rtx);
b37c2614 124
9fcdd891 125#ifndef GENERATOR_FILE
f5523e6d
MA
126/* Try recognizing the instruction INSN,
127 and return the code number that results.
128 Remember the code so that repeated calls do not
129 need to spend the time for actual rerecognition.
130
131 This function is the normal interface to instruction recognition.
132 The automatically-generated function `recog' is normally called
425de739 133 through this one. */
f5523e6d
MA
134
135static inline int
136recog_memoized (rtx insn)
137{
138 if (INSN_CODE (insn) < 0)
139 INSN_CODE (insn) = recog (PATTERN (insn), insn, 0);
140 return INSN_CODE (insn);
141}
9fcdd891 142#endif
f5523e6d 143
64a93ac5 144/* Nonzero means volatile operands are recognized. */
64a93ac5
CH
145extern int volatile_ok;
146
0a578fee
BS
147/* Set by constrain_operands to the number of the alternative that
148 matched. */
149extern int which_alternative;
150
64a93ac5
CH
151/* The following vectors hold the results from insn_extract. */
152
1ccbefce
RH
153struct recog_data
154{
155 /* It is very tempting to make the 5 operand related arrays into a
156 structure and index on that. However, to be source compatible
157 with all of the existing md file insn constraints and output
158 templates, we need `operand' as a flat array. Without that
159 member, making an array for the rest seems pointless. */
64a93ac5 160
1ccbefce
RH
161 /* Gives value of operand N. */
162 rtx operand[MAX_RECOG_OPERANDS];
64a93ac5 163
1ccbefce
RH
164 /* Gives location where operand N was found. */
165 rtx *operand_loc[MAX_RECOG_OPERANDS];
64a93ac5 166
1ccbefce
RH
167 /* Gives the constraint string for operand N. */
168 const char *constraints[MAX_RECOG_OPERANDS];
64a93ac5 169
1ccbefce
RH
170 /* Gives the mode of operand N. */
171 enum machine_mode operand_mode[MAX_RECOG_OPERANDS];
0a578fee 172
1ccbefce
RH
173 /* Gives the type (in, out, inout) for operand N. */
174 enum op_type operand_type[MAX_RECOG_OPERANDS];
0a578fee 175
1ccbefce
RH
176 /* Gives location where the Nth duplicate-appearance of an operand
177 was found. This is something that matched MATCH_DUP. */
178 rtx *dup_loc[MAX_DUP_OPERANDS];
0a578fee 179
1ccbefce
RH
180 /* Gives the operand number that was duplicated in the Nth
181 duplicate-appearance of an operand. */
88e6fdcb 182 char dup_num[MAX_DUP_OPERANDS];
0a578fee 183
88e6fdcb 184 /* ??? Note that these are `char' instead of `unsigned char' to (try to)
0c20a65f 185 avoid certain lossage from K&R C, wherein `unsigned char' default
88e6fdcb
RH
186 promotes to `unsigned int' instead of `int' as in ISO C. As of 1999,
187 the most common places to bootstrap from K&R C are SunOS and HPUX,
188 both of which have signed characters by default. The only other
189 supported natives that have both K&R C and unsigned characters are
190 ROMP and Irix 3, and neither have been seen for a while, but do
191 continue to consider unsignedness when performing arithmetic inside
192 a comparison. */
193
1ccbefce 194 /* The number of operands of the insn. */
88e6fdcb 195 char n_operands;
0a578fee 196
1ccbefce 197 /* The number of MATCH_DUPs in the insn. */
88e6fdcb 198 char n_dups;
0eadeb15 199
1ccbefce 200 /* The number of alternatives in the constraints for the insn. */
88e6fdcb 201 char n_alternatives;
d90ffc8d
JH
202
203 /* In case we are caching, hold insn data was generated for. */
204 rtx insn;
1ccbefce
RH
205};
206
207extern struct recog_data recog_data;
0a578fee 208
f62a15e3
BS
209/* Contains a vector of operand_alternative structures for every operand.
210 Set up by preprocess_constraints. */
b0983bb9 211extern struct operand_alternative recog_op_alt[MAX_RECOG_OPERANDS][MAX_RECOG_ALTERNATIVES];
f62a15e3 212
a995e389 213/* A table defined in insn-output.c that give information about
64a93ac5
CH
214 each insn-code value. */
215
0c20a65f
AJ
216typedef int (*insn_operand_predicate_fn) (rtx, enum machine_mode);
217typedef const char * (*insn_output_fn) (rtx *, rtx);
218typedef rtx (*insn_gen_fn) (rtx, ...);
64a93ac5 219
a995e389
RH
220struct insn_operand_data
221{
8b60264b 222 const insn_operand_predicate_fn predicate;
64a93ac5 223
8b60264b 224 const char *const constraint;
64a93ac5 225
7e7c843f 226 ENUM_BITFIELD(machine_mode) const mode : 16;
a995e389 227
8b60264b 228 const char strict_low;
dfac187e 229
8b60264b 230 const char eliminable;
a995e389 231};
64a93ac5 232
4bbf910e
RH
233/* Legal values for insn_data.output_format. Indicate what type of data
234 is stored in insn_data.output. */
235#define INSN_OUTPUT_FORMAT_NONE 0 /* abort */
236#define INSN_OUTPUT_FORMAT_SINGLE 1 /* const char * */
237#define INSN_OUTPUT_FORMAT_MULTI 2 /* const char * const * */
238#define INSN_OUTPUT_FORMAT_FUNCTION 3 /* const char * (*)(...) */
239
a995e389
RH
240struct insn_data
241{
8b60264b 242 const char *const name;
3897f229
JM
243#if HAVE_DESIGNATED_INITIALIZERS
244 union {
245 const char *single;
246 const char *const *multi;
247 insn_output_fn function;
248 } output;
249#else
250 struct {
251 const char *single;
252 const char *const *multi;
253 insn_output_fn function;
254 } output;
255#endif
8b60264b
KG
256 const insn_gen_fn genfun;
257 const struct insn_operand_data *const operand;
64a93ac5 258
8b60264b
KG
259 const char n_operands;
260 const char n_dups;
261 const char n_alternatives;
262 const char output_format;
a995e389 263};
64a93ac5 264
a995e389 265extern const struct insn_data insn_data[];
0cd6c85a 266extern int peep2_current_count;
This page took 3.13484 seconds and 5 git commands to generate.