]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/recog.h
Makefile.in (recog.o): Don't depend on resource.h.
[thirdparty/gcc.git] / gcc / recog.h
CommitLineData
64a93ac5 1/* Declarations for interface to insn recognizer and insn-output.c.
af841dbd
JL
2 Copyright (C) 1987, 1996, 1997, 1998,
3 1999, 2000 Free Software Foundation, Inc.
64a93ac5
CH
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING. If not, write to
e99215a3
RK
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, 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). */
39 enum reg_class class;
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. */
55 unsigned int memory_ok:1;
56 /* Nonzero if 'o' was found in the constraint string. */
57 unsigned int offmem_ok:1;
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;
64 /* Nonzero if 'X' was found in the constraint string, or if the constraint
65 string for this alternative was empty. */
66 unsigned int anything_ok:1;
67};
68
69
13536812
KG
70extern void init_recog PARAMS ((void));
71extern void init_recog_no_volatile PARAMS ((void));
72extern int recog_memoized PARAMS ((rtx));
73extern int check_asm_operands PARAMS ((rtx));
74extern int asm_operand_ok PARAMS ((rtx, const char *));
75extern int validate_change PARAMS ((rtx, rtx *, rtx, int));
76extern int apply_change_group PARAMS ((void));
77extern int num_validated_changes PARAMS ((void));
78extern void cancel_changes PARAMS ((int));
79extern int constrain_operands PARAMS ((int));
80extern int memory_address_p PARAMS ((enum machine_mode, rtx));
81extern int strict_memory_address_p PARAMS ((enum machine_mode, rtx));
82extern int validate_replace_rtx PARAMS ((rtx, rtx, rtx));
83extern void validate_replace_rtx_group PARAMS ((rtx, rtx, rtx));
84extern int validate_replace_src PARAMS ((rtx, rtx, rtx));
523bb0ba 85#ifdef HAVE_cc0
13536812 86extern int next_insn_tests_no_inequality PARAMS ((rtx));
523bb0ba 87#endif
13536812 88extern int reg_fits_class_p PARAMS ((rtx, enum reg_class, int,
31031edd 89 enum machine_mode));
13536812
KG
90extern rtx *find_single_use PARAMS ((rtx, rtx, rtx *));
91
92extern int general_operand PARAMS ((rtx, enum machine_mode));
93extern int address_operand PARAMS ((rtx, enum machine_mode));
94extern int register_operand PARAMS ((rtx, enum machine_mode));
95extern int pmode_register_operand PARAMS ((rtx, enum machine_mode));
96extern int scratch_operand PARAMS ((rtx, enum machine_mode));
97extern int immediate_operand PARAMS ((rtx, enum machine_mode));
98extern int const_int_operand PARAMS ((rtx, enum machine_mode));
99extern int const_double_operand PARAMS ((rtx, enum machine_mode));
100extern int nonimmediate_operand PARAMS ((rtx, enum machine_mode));
101extern int nonmemory_operand PARAMS ((rtx, enum machine_mode));
102extern int push_operand PARAMS ((rtx, enum machine_mode));
103extern int pop_operand PARAMS ((rtx, enum machine_mode));
104extern int memory_operand PARAMS ((rtx, enum machine_mode));
105extern int indirect_operand PARAMS ((rtx, enum machine_mode));
106extern int mode_independent_operand PARAMS ((rtx, enum machine_mode));
107extern int comparison_operator PARAMS ((rtx, enum machine_mode));
108
109extern int offsettable_memref_p PARAMS ((rtx));
110extern int offsettable_nonstrict_memref_p PARAMS ((rtx));
111extern int offsettable_address_p PARAMS ((int, enum machine_mode, rtx));
112extern int mode_dependent_address_p PARAMS ((rtx));
113
114extern int recog PARAMS ((rtx, rtx, int *));
115extern void add_clobbers PARAMS ((rtx, int));
116extern void insn_extract PARAMS ((rtx));
117extern void extract_insn PARAMS ((rtx));
118extern void preprocess_constraints PARAMS ((void));
23280139
RH
119extern rtx peep2_next_insn PARAMS ((int));
120extern int peep2_regno_dead_p PARAMS ((int, int));
121extern int peep2_reg_dead_p PARAMS ((int, rtx));
122#ifdef CLEAR_HARD_REG_SET
123extern rtx peep2_find_free_register PARAMS ((int, int, const char *,
124 enum machine_mode,
125 HARD_REG_SET *));
126#endif
13536812 127extern void peephole2_optimize PARAMS ((FILE *));
23280139 128extern rtx peephole2_insns PARAMS ((rtx, rtx, int *));
64a93ac5
CH
129
130/* Nonzero means volatile operands are recognized. */
64a93ac5
CH
131extern int volatile_ok;
132
0a578fee
BS
133/* Set by constrain_operands to the number of the alternative that
134 matched. */
135extern int which_alternative;
136
64a93ac5
CH
137/* The following vectors hold the results from insn_extract. */
138
1ccbefce
RH
139struct recog_data
140{
141 /* It is very tempting to make the 5 operand related arrays into a
142 structure and index on that. However, to be source compatible
143 with all of the existing md file insn constraints and output
144 templates, we need `operand' as a flat array. Without that
145 member, making an array for the rest seems pointless. */
64a93ac5 146
1ccbefce
RH
147 /* Gives value of operand N. */
148 rtx operand[MAX_RECOG_OPERANDS];
64a93ac5 149
1ccbefce
RH
150 /* Gives location where operand N was found. */
151 rtx *operand_loc[MAX_RECOG_OPERANDS];
64a93ac5 152
1ccbefce
RH
153 /* Gives the constraint string for operand N. */
154 const char *constraints[MAX_RECOG_OPERANDS];
64a93ac5 155
1ccbefce
RH
156 /* Gives the mode of operand N. */
157 enum machine_mode operand_mode[MAX_RECOG_OPERANDS];
0a578fee 158
1ccbefce
RH
159 /* Gives the type (in, out, inout) for operand N. */
160 enum op_type operand_type[MAX_RECOG_OPERANDS];
0a578fee 161
1ccbefce
RH
162 /* Gives location where the Nth duplicate-appearance of an operand
163 was found. This is something that matched MATCH_DUP. */
164 rtx *dup_loc[MAX_DUP_OPERANDS];
0a578fee 165
1ccbefce
RH
166 /* Gives the operand number that was duplicated in the Nth
167 duplicate-appearance of an operand. */
88e6fdcb 168 char dup_num[MAX_DUP_OPERANDS];
0a578fee 169
88e6fdcb
RH
170 /* ??? Note that these are `char' instead of `unsigned char' to (try to)
171 avoid certain lossage from K&R C, wherein `unsigned char' default
172 promotes to `unsigned int' instead of `int' as in ISO C. As of 1999,
173 the most common places to bootstrap from K&R C are SunOS and HPUX,
174 both of which have signed characters by default. The only other
175 supported natives that have both K&R C and unsigned characters are
176 ROMP and Irix 3, and neither have been seen for a while, but do
177 continue to consider unsignedness when performing arithmetic inside
178 a comparison. */
179
1ccbefce 180 /* The number of operands of the insn. */
88e6fdcb 181 char n_operands;
0a578fee 182
1ccbefce 183 /* The number of MATCH_DUPs in the insn. */
88e6fdcb 184 char n_dups;
0eadeb15 185
1ccbefce 186 /* The number of alternatives in the constraints for the insn. */
88e6fdcb 187 char n_alternatives;
1ccbefce
RH
188};
189
190extern struct recog_data recog_data;
0a578fee 191
f62a15e3
BS
192/* Contains a vector of operand_alternative structures for every operand.
193 Set up by preprocess_constraints. */
b0983bb9 194extern struct operand_alternative recog_op_alt[MAX_RECOG_OPERANDS][MAX_RECOG_ALTERNATIVES];
f62a15e3 195
a995e389 196/* A table defined in insn-output.c that give information about
64a93ac5
CH
197 each insn-code value. */
198
13536812
KG
199typedef int (*insn_operand_predicate_fn) PARAMS ((rtx, enum machine_mode));
200typedef const char * (*insn_output_fn) PARAMS ((rtx *, rtx));
13536812 201typedef rtx (*insn_gen_fn) PARAMS ((rtx, ...));
64a93ac5 202
a995e389
RH
203struct insn_operand_data
204{
205 insn_operand_predicate_fn predicate;
64a93ac5 206
a995e389 207 const char *constraint;
64a93ac5 208
a995e389
RH
209 enum machine_mode mode;
210
a995e389 211 char strict_low;
dfac187e
BS
212
213 char eliminable;
a995e389 214};
64a93ac5 215
4bbf910e
RH
216/* Legal values for insn_data.output_format. Indicate what type of data
217 is stored in insn_data.output. */
218#define INSN_OUTPUT_FORMAT_NONE 0 /* abort */
219#define INSN_OUTPUT_FORMAT_SINGLE 1 /* const char * */
220#define INSN_OUTPUT_FORMAT_MULTI 2 /* const char * const * */
221#define INSN_OUTPUT_FORMAT_FUNCTION 3 /* const char * (*)(...) */
222
a995e389
RH
223struct insn_data
224{
225 const char *name;
4bbf910e 226 const PTR output;
a995e389
RH
227 insn_gen_fn genfun;
228 const struct insn_operand_data *operand;
64a93ac5 229
88e6fdcb
RH
230 char n_operands;
231 char n_dups;
232 char n_alternatives;
233 char output_format;
a995e389 234};
64a93ac5 235
a995e389 236extern const struct insn_data insn_data[];