]>
Commit | Line | Data |
---|---|---|
64a93ac5 | 1 | /* Declarations for interface to insn recognizer and insn-output.c. |
9311a396 | 2 | Copyright (C) 1987, 96-99, 2000 Free Software Foundation, Inc. |
64a93ac5 CH |
3 | |
4 | This file is part of GNU CC. | |
5 | ||
6 | GNU CC is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GNU CC is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU CC; see the file COPYING. If not, write to | |
e99215a3 RK |
18 | the Free Software Foundation, 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. */ | |
64a93ac5 | 20 | |
f62a15e3 BS |
21 | /* Random number that should be large enough for all purposes. */ |
22 | #define MAX_RECOG_ALTERNATIVES 30 | |
23 | ||
0eadeb15 BS |
24 | /* Types of operands. */ |
25 | enum op_type { | |
26 | OP_IN, | |
27 | OP_OUT, | |
28 | OP_INOUT | |
29 | }; | |
30 | ||
f62a15e3 BS |
31 | struct operand_alternative |
32 | { | |
33 | /* Pointer to the beginning of the constraint string for this alternative, | |
34 | for easier access by alternative number. */ | |
9b3142b3 | 35 | const char *constraint; |
f62a15e3 BS |
36 | |
37 | /* The register class valid for this alternative (possibly NO_REGS). */ | |
38 | enum reg_class class; | |
39 | ||
40 | /* "Badness" of this alternative, computed from number of '?' and '!' | |
41 | characters in the constraint string. */ | |
42 | unsigned int reject; | |
43 | ||
44 | /* -1 if no matching constraint was found, or an operand number. */ | |
45 | int matches; | |
46 | /* The same information, but reversed: -1 if this operand is not | |
47 | matched by any other, or the operand number of the operand that | |
48 | matches this one. */ | |
49 | int matched; | |
50 | ||
51 | /* Nonzero if '&' was found in the constraint string. */ | |
52 | unsigned int earlyclobber:1; | |
53 | /* Nonzero if 'm' was found in the constraint string. */ | |
54 | unsigned int memory_ok:1; | |
55 | /* Nonzero if 'o' was found in the constraint string. */ | |
56 | unsigned int offmem_ok:1; | |
57 | /* Nonzero if 'V' was found in the constraint string. */ | |
58 | unsigned int nonoffmem_ok:1; | |
59 | /* Nonzero if '<' was found in the constraint string. */ | |
60 | unsigned int decmem_ok:1; | |
61 | /* Nonzero if '>' was found in the constraint string. */ | |
62 | unsigned int incmem_ok:1; | |
63 | /* Nonzero if 'X' was found in the constraint string, or if the constraint | |
64 | string for this alternative was empty. */ | |
65 | unsigned int anything_ok:1; | |
66 | }; | |
67 | ||
68 | ||
13536812 KG |
69 | extern void init_recog PARAMS ((void)); |
70 | extern void init_recog_no_volatile PARAMS ((void)); | |
71 | extern int recog_memoized PARAMS ((rtx)); | |
72 | extern int check_asm_operands PARAMS ((rtx)); | |
73 | extern int asm_operand_ok PARAMS ((rtx, const char *)); | |
74 | extern int validate_change PARAMS ((rtx, rtx *, rtx, int)); | |
75 | extern int apply_change_group PARAMS ((void)); | |
76 | extern int num_validated_changes PARAMS ((void)); | |
77 | extern void cancel_changes PARAMS ((int)); | |
78 | extern int constrain_operands PARAMS ((int)); | |
79 | extern int memory_address_p PARAMS ((enum machine_mode, rtx)); | |
80 | extern int strict_memory_address_p PARAMS ((enum machine_mode, rtx)); | |
81 | extern int validate_replace_rtx PARAMS ((rtx, rtx, rtx)); | |
82 | extern void validate_replace_rtx_group PARAMS ((rtx, rtx, rtx)); | |
83 | extern int validate_replace_src PARAMS ((rtx, rtx, rtx)); | |
523bb0ba | 84 | #ifdef HAVE_cc0 |
13536812 | 85 | extern int next_insn_tests_no_inequality PARAMS ((rtx)); |
523bb0ba | 86 | #endif |
13536812 | 87 | extern int reg_fits_class_p PARAMS ((rtx, enum reg_class, int, |
31031edd | 88 | enum machine_mode)); |
13536812 KG |
89 | extern rtx *find_single_use PARAMS ((rtx, rtx, rtx *)); |
90 | ||
91 | extern int general_operand PARAMS ((rtx, enum machine_mode)); | |
92 | extern int address_operand PARAMS ((rtx, enum machine_mode)); | |
93 | extern int register_operand PARAMS ((rtx, enum machine_mode)); | |
94 | extern int pmode_register_operand PARAMS ((rtx, enum machine_mode)); | |
95 | extern int scratch_operand PARAMS ((rtx, enum machine_mode)); | |
96 | extern int immediate_operand PARAMS ((rtx, enum machine_mode)); | |
97 | extern int const_int_operand PARAMS ((rtx, enum machine_mode)); | |
98 | extern int const_double_operand PARAMS ((rtx, enum machine_mode)); | |
99 | extern int nonimmediate_operand PARAMS ((rtx, enum machine_mode)); | |
100 | extern int nonmemory_operand PARAMS ((rtx, enum machine_mode)); | |
101 | extern int push_operand PARAMS ((rtx, enum machine_mode)); | |
102 | extern int pop_operand PARAMS ((rtx, enum machine_mode)); | |
103 | extern int memory_operand PARAMS ((rtx, enum machine_mode)); | |
104 | extern int indirect_operand PARAMS ((rtx, enum machine_mode)); | |
105 | extern int mode_independent_operand PARAMS ((rtx, enum machine_mode)); | |
106 | extern int comparison_operator PARAMS ((rtx, enum machine_mode)); | |
107 | ||
108 | extern int offsettable_memref_p PARAMS ((rtx)); | |
109 | extern int offsettable_nonstrict_memref_p PARAMS ((rtx)); | |
110 | extern int offsettable_address_p PARAMS ((int, enum machine_mode, rtx)); | |
111 | extern int mode_dependent_address_p PARAMS ((rtx)); | |
112 | ||
113 | extern int recog PARAMS ((rtx, rtx, int *)); | |
114 | extern void add_clobbers PARAMS ((rtx, int)); | |
115 | extern void insn_extract PARAMS ((rtx)); | |
116 | extern void extract_insn PARAMS ((rtx)); | |
117 | extern void preprocess_constraints PARAMS ((void)); | |
118 | extern rtx recog_next_insn PARAMS ((rtx, int)); | |
119 | extern void peephole2_optimize PARAMS ((FILE *)); | |
120 | extern rtx peephole2_insns PARAMS ((rtx, rtx, rtx *)); | |
64a93ac5 CH |
121 | |
122 | /* Nonzero means volatile operands are recognized. */ | |
64a93ac5 CH |
123 | extern int volatile_ok; |
124 | ||
0a578fee BS |
125 | /* Set by constrain_operands to the number of the alternative that |
126 | matched. */ | |
127 | extern int which_alternative; | |
128 | ||
64a93ac5 CH |
129 | /* The following vectors hold the results from insn_extract. */ |
130 | ||
1ccbefce RH |
131 | struct recog_data |
132 | { | |
133 | /* It is very tempting to make the 5 operand related arrays into a | |
134 | structure and index on that. However, to be source compatible | |
135 | with all of the existing md file insn constraints and output | |
136 | templates, we need `operand' as a flat array. Without that | |
137 | member, making an array for the rest seems pointless. */ | |
64a93ac5 | 138 | |
1ccbefce RH |
139 | /* Gives value of operand N. */ |
140 | rtx operand[MAX_RECOG_OPERANDS]; | |
64a93ac5 | 141 | |
1ccbefce RH |
142 | /* Gives location where operand N was found. */ |
143 | rtx *operand_loc[MAX_RECOG_OPERANDS]; | |
64a93ac5 | 144 | |
1ccbefce RH |
145 | /* Gives the constraint string for operand N. */ |
146 | const char *constraints[MAX_RECOG_OPERANDS]; | |
64a93ac5 | 147 | |
1ccbefce RH |
148 | /* Gives the mode of operand N. */ |
149 | enum machine_mode operand_mode[MAX_RECOG_OPERANDS]; | |
0a578fee | 150 | |
1ccbefce RH |
151 | /* Gives the type (in, out, inout) for operand N. */ |
152 | enum op_type operand_type[MAX_RECOG_OPERANDS]; | |
0a578fee | 153 | |
1ccbefce RH |
154 | /* Gives location where the Nth duplicate-appearance of an operand |
155 | was found. This is something that matched MATCH_DUP. */ | |
156 | rtx *dup_loc[MAX_DUP_OPERANDS]; | |
0a578fee | 157 | |
1ccbefce RH |
158 | /* Gives the operand number that was duplicated in the Nth |
159 | duplicate-appearance of an operand. */ | |
88e6fdcb | 160 | char dup_num[MAX_DUP_OPERANDS]; |
0a578fee | 161 | |
88e6fdcb RH |
162 | /* ??? Note that these are `char' instead of `unsigned char' to (try to) |
163 | avoid certain lossage from K&R C, wherein `unsigned char' default | |
164 | promotes to `unsigned int' instead of `int' as in ISO C. As of 1999, | |
165 | the most common places to bootstrap from K&R C are SunOS and HPUX, | |
166 | both of which have signed characters by default. The only other | |
167 | supported natives that have both K&R C and unsigned characters are | |
168 | ROMP and Irix 3, and neither have been seen for a while, but do | |
169 | continue to consider unsignedness when performing arithmetic inside | |
170 | a comparison. */ | |
171 | ||
1ccbefce | 172 | /* The number of operands of the insn. */ |
88e6fdcb | 173 | char n_operands; |
0a578fee | 174 | |
1ccbefce | 175 | /* The number of MATCH_DUPs in the insn. */ |
88e6fdcb | 176 | char n_dups; |
0eadeb15 | 177 | |
1ccbefce | 178 | /* The number of alternatives in the constraints for the insn. */ |
88e6fdcb | 179 | char n_alternatives; |
1ccbefce RH |
180 | }; |
181 | ||
182 | extern struct recog_data recog_data; | |
0a578fee | 183 | |
f62a15e3 BS |
184 | /* Contains a vector of operand_alternative structures for every operand. |
185 | Set up by preprocess_constraints. */ | |
b0983bb9 | 186 | extern struct operand_alternative recog_op_alt[MAX_RECOG_OPERANDS][MAX_RECOG_ALTERNATIVES]; |
f62a15e3 | 187 | |
64a93ac5 CH |
188 | /* Access the output function for CODE. */ |
189 | ||
a995e389 | 190 | #define OUT_FCN(CODE) (*insn_data[(int) (CODE)].outfun) |
64a93ac5 | 191 | |
a995e389 | 192 | /* A table defined in insn-output.c that give information about |
64a93ac5 CH |
193 | each insn-code value. */ |
194 | ||
13536812 KG |
195 | typedef int (*insn_operand_predicate_fn) PARAMS ((rtx, enum machine_mode)); |
196 | typedef const char * (*insn_output_fn) PARAMS ((rtx *, rtx)); | |
a995e389 | 197 | #ifndef NO_MD_PROTOTYPES |
13536812 | 198 | typedef rtx (*insn_gen_fn) PARAMS ((rtx, ...)); |
a995e389 RH |
199 | #else |
200 | typedef rtx (*insn_gen_fn) (); | |
201 | #endif | |
64a93ac5 | 202 | |
a995e389 RH |
203 | struct 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 |
223 | struct 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 | 236 | extern const struct insn_data insn_data[]; |