OSDN Git Service

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