OSDN Git Service

2007-05-22 H.J. Lu <hongjiu.lu@intel.com>
[pf3gnuchains/gcc-fork.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, 2005
3    Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301, USA.  */
21
22 /* Random number that should be large enough for all purposes.  */
23 #define MAX_RECOG_ALTERNATIVES 30
24
25 /* Types of operands.  */
26 enum op_type {
27   OP_IN,
28   OP_OUT,
29   OP_INOUT
30 };
31
32 struct operand_alternative
33 {
34   /* Pointer to the beginning of the constraint string for this alternative,
35      for easier access by alternative number.  */
36   const char *constraint;
37
38   /* The register class valid for this alternative (possibly NO_REGS).  */
39   enum reg_class cl;
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 'p' was found in the constraint string.  */
65   unsigned int is_address:1;
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
72 extern void init_recog (void);
73 extern void init_recog_no_volatile (void);
74 extern int check_asm_operands (rtx);
75 extern int asm_operand_ok (rtx, const char *);
76 extern int validate_change (rtx, rtx *, rtx, int);
77 extern bool canonicalize_change_group (rtx insn, rtx x);
78 extern int insn_invalid_p (rtx);
79 extern int verify_changes (int);
80 extern void confirm_change_group (void);
81 extern int apply_change_group (void);
82 extern int num_validated_changes (void);
83 extern void cancel_changes (int);
84 extern int constrain_operands (int);
85 extern int constrain_operands_cached (int);
86 extern int memory_address_p (enum machine_mode, rtx);
87 extern int strict_memory_address_p (enum machine_mode, rtx);
88 extern int validate_replace_rtx (rtx, rtx, rtx);
89 extern void validate_replace_rtx_group (rtx, rtx, rtx);
90 extern void validate_replace_src_group (rtx, rtx, rtx);
91 extern bool validate_simplify_insn (rtx insn);
92 extern int num_changes_pending (void);
93 #ifdef HAVE_cc0
94 extern int next_insn_tests_no_inequality (rtx);
95 #endif
96 extern int reg_fits_class_p (rtx, enum reg_class, int, enum machine_mode);
97 extern rtx *find_single_use (rtx, rtx, rtx *);
98
99 extern int offsettable_memref_p (rtx);
100 extern int offsettable_nonstrict_memref_p (rtx);
101 extern int offsettable_address_p (int, enum machine_mode, rtx);
102 extern int mode_dependent_address_p (rtx);
103
104 extern int recog (rtx, rtx, int *);
105 #ifndef GENERATOR_FILE
106 static inline int recog_memoized (rtx insn);
107 #endif
108 extern void add_clobbers (rtx, int);
109 extern int added_clobbers_hard_reg_p (int);
110 extern void insn_extract (rtx);
111 extern void extract_insn (rtx);
112 extern void extract_constrain_insn_cached (rtx);
113 extern void extract_insn_cached (rtx);
114 extern void preprocess_constraints (void);
115 extern rtx peep2_next_insn (int);
116 extern int peep2_regno_dead_p (int, int);
117 extern int peep2_reg_dead_p (int, rtx);
118 #ifdef CLEAR_HARD_REG_SET
119 extern rtx peep2_find_free_register (int, int, const char *,
120                                      enum machine_mode, HARD_REG_SET *);
121 #endif
122 extern rtx peephole2_insns (rtx, rtx, int *);
123
124 extern int store_data_bypass_p (rtx, rtx);
125 extern int if_test_bypass_p (rtx, rtx);
126
127 #ifndef GENERATOR_FILE
128 /* Try recognizing the instruction INSN,
129    and return the code number that results.
130    Remember the code so that repeated calls do not
131    need to spend the time for actual rerecognition.
132
133    This function is the normal interface to instruction recognition.
134    The automatically-generated function `recog' is normally called
135    through this one.  */
136
137 static inline int
138 recog_memoized (rtx insn)
139 {
140   if (INSN_CODE (insn) < 0)
141     INSN_CODE (insn) = recog (PATTERN (insn), insn, 0);
142   return INSN_CODE (insn);
143 }
144 #endif
145
146 /* Nonzero means volatile operands are recognized.  */
147 extern int volatile_ok;
148
149 /* Set by constrain_operands to the number of the alternative that
150    matched.  */
151 extern int which_alternative;
152
153 /* The following vectors hold the results from insn_extract.  */
154
155 struct recog_data
156 {
157   /* It is very tempting to make the 5 operand related arrays into a
158      structure and index on that.  However, to be source compatible
159      with all of the existing md file insn constraints and output
160      templates, we need `operand' as a flat array.  Without that
161      member, making an array for the rest seems pointless.  */
162
163   /* Gives value of operand N.  */
164   rtx operand[MAX_RECOG_OPERANDS];
165
166   /* Gives location where operand N was found.  */
167   rtx *operand_loc[MAX_RECOG_OPERANDS];
168
169   /* Gives the constraint string for operand N.  */
170   const char *constraints[MAX_RECOG_OPERANDS];
171
172   /* Gives the mode of operand N.  */
173   enum machine_mode operand_mode[MAX_RECOG_OPERANDS];
174
175   /* Gives the type (in, out, inout) for operand N.  */
176   enum op_type operand_type[MAX_RECOG_OPERANDS];
177
178   /* Gives location where the Nth duplicate-appearance of an operand
179      was found.  This is something that matched MATCH_DUP.  */
180   rtx *dup_loc[MAX_DUP_OPERANDS];
181
182   /* Gives the operand number that was duplicated in the Nth
183      duplicate-appearance of an operand.  */
184   char dup_num[MAX_DUP_OPERANDS];
185
186   /* ??? Note that these are `char' instead of `unsigned char' to (try to)
187      avoid certain lossage from K&R C, wherein `unsigned char' default
188      promotes to `unsigned int' instead of `int' as in ISO C.  As of 1999,
189      the most common places to bootstrap from K&R C are SunOS and HPUX,
190      both of which have signed characters by default.  The only other
191      supported natives that have both K&R C and unsigned characters are
192      ROMP and Irix 3, and neither have been seen for a while, but do
193      continue to consider unsignedness when performing arithmetic inside
194      a comparison.  */
195
196   /* The number of operands of the insn.  */
197   char n_operands;
198
199   /* The number of MATCH_DUPs in the insn.  */
200   char n_dups;
201
202   /* The number of alternatives in the constraints for the insn.  */
203   char n_alternatives;
204
205   /* In case we are caching, hold insn data was generated for.  */
206   rtx insn;
207 };
208
209 extern struct recog_data recog_data;
210
211 /* Contains a vector of operand_alternative structures for every operand.
212    Set up by preprocess_constraints.  */
213 extern struct operand_alternative recog_op_alt[MAX_RECOG_OPERANDS][MAX_RECOG_ALTERNATIVES];
214
215 /* A table defined in insn-output.c that give information about
216    each insn-code value.  */
217
218 typedef int (*insn_operand_predicate_fn) (rtx, enum machine_mode);
219 typedef const char * (*insn_output_fn) (rtx *, rtx);
220 typedef rtx (*insn_gen_fn) (rtx, ...);
221
222 struct insn_operand_data
223 {
224   const insn_operand_predicate_fn predicate;
225
226   const char *const constraint;
227
228   ENUM_BITFIELD(machine_mode) const mode : 16;
229
230   const char strict_low;
231
232   const char eliminable;
233 };
234
235 /* Legal values for insn_data.output_format.  Indicate what type of data
236    is stored in insn_data.output.  */
237 #define INSN_OUTPUT_FORMAT_NONE         0       /* abort */
238 #define INSN_OUTPUT_FORMAT_SINGLE       1       /* const char * */
239 #define INSN_OUTPUT_FORMAT_MULTI        2       /* const char * const * */
240 #define INSN_OUTPUT_FORMAT_FUNCTION     3       /* const char * (*)(...) */
241
242 struct insn_data
243 {
244   const char *const name;
245 #if HAVE_DESIGNATED_INITIALIZERS
246   union {
247     const char *single;
248     const char *const *multi;
249     insn_output_fn function;
250   } output;
251 #else
252   struct {
253     const char *single;
254     const char *const *multi;
255     insn_output_fn function;
256   } output;
257 #endif
258   const insn_gen_fn genfun;
259   const struct insn_operand_data *const operand;
260
261   const char n_operands;
262   const char n_dups;
263   const char n_alternatives;
264   const char output_format;
265 };
266
267 extern const struct insn_data insn_data[];
268 extern int peep2_current_count;