1 | /* Definitions for code generation pass of GNU compiler.
|
---|
2 | Copyright (C) 2001 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This file is part of GCC.
|
---|
5 |
|
---|
6 | GCC 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 | GCC 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 GCC; see the file COPYING. If not, write to
|
---|
18 | the Free Software Foundation, 59 Temple Place - Suite 330,
|
---|
19 | Boston, MA 02111-1307, USA. */
|
---|
20 |
|
---|
21 | #ifndef GCC_OPTABS_H
|
---|
22 | #define GCC_OPTABS_H
|
---|
23 |
|
---|
24 | #include "insn-codes.h"
|
---|
25 |
|
---|
26 | /* Optabs are tables saying how to generate insn bodies
|
---|
27 | for various machine modes and numbers of operands.
|
---|
28 | Each optab applies to one operation.
|
---|
29 | For example, add_optab applies to addition.
|
---|
30 |
|
---|
31 | The insn_code slot is the enum insn_code that says how to
|
---|
32 | generate an insn for this operation on a particular machine mode.
|
---|
33 | It is CODE_FOR_nothing if there is no such insn on the target machine.
|
---|
34 |
|
---|
35 | The `lib_call' slot is the name of the library function that
|
---|
36 | can be used to perform the operation.
|
---|
37 |
|
---|
38 | A few optabs, such as move_optab and cmp_optab, are used
|
---|
39 | by special code. */
|
---|
40 |
|
---|
41 | struct optab GTY(())
|
---|
42 | {
|
---|
43 | enum rtx_code code;
|
---|
44 | struct optab_handlers {
|
---|
45 | enum insn_code insn_code;
|
---|
46 | rtx libfunc;
|
---|
47 | } handlers [NUM_MACHINE_MODES];
|
---|
48 | };
|
---|
49 | typedef struct optab * optab;
|
---|
50 |
|
---|
51 | /* Given an enum insn_code, access the function to construct
|
---|
52 | the body of that kind of insn. */
|
---|
53 | #define GEN_FCN(CODE) (*insn_data[(int) (CODE)].genfun)
|
---|
54 |
|
---|
55 | /* Enumeration of valid indexes into optab_table. */
|
---|
56 | enum optab_index
|
---|
57 | {
|
---|
58 | OTI_add,
|
---|
59 | OTI_addv,
|
---|
60 | OTI_sub,
|
---|
61 | OTI_subv,
|
---|
62 |
|
---|
63 | /* Signed and fp multiply */
|
---|
64 | OTI_smul,
|
---|
65 | OTI_smulv,
|
---|
66 | /* Signed multiply, return high word */
|
---|
67 | OTI_smul_highpart,
|
---|
68 | OTI_umul_highpart,
|
---|
69 | /* Signed multiply with result one machine mode wider than args */
|
---|
70 | OTI_smul_widen,
|
---|
71 | OTI_umul_widen,
|
---|
72 |
|
---|
73 | /* Signed divide */
|
---|
74 | OTI_sdiv,
|
---|
75 | OTI_sdivv,
|
---|
76 | /* Signed divide-and-remainder in one */
|
---|
77 | OTI_sdivmod,
|
---|
78 | OTI_udiv,
|
---|
79 | OTI_udivmod,
|
---|
80 | /* Signed remainder */
|
---|
81 | OTI_smod,
|
---|
82 | OTI_umod,
|
---|
83 | /* Convert float to integer in float fmt */
|
---|
84 | OTI_ftrunc,
|
---|
85 |
|
---|
86 | /* Logical and */
|
---|
87 | OTI_and,
|
---|
88 | /* Logical or */
|
---|
89 | OTI_ior,
|
---|
90 | /* Logical xor */
|
---|
91 | OTI_xor,
|
---|
92 |
|
---|
93 | /* Arithmetic shift left */
|
---|
94 | OTI_ashl,
|
---|
95 | /* Logical shift right */
|
---|
96 | OTI_lshr,
|
---|
97 | /* Arithmetic shift right */
|
---|
98 | OTI_ashr,
|
---|
99 | /* Rotate left */
|
---|
100 | OTI_rotl,
|
---|
101 | /* Rotate right */
|
---|
102 | OTI_rotr,
|
---|
103 | /* Signed and floating-point minimum value */
|
---|
104 | OTI_smin,
|
---|
105 | /* Signed and floating-point maximum value */
|
---|
106 | OTI_smax,
|
---|
107 | /* Unsigned minimum value */
|
---|
108 | OTI_umin,
|
---|
109 | /* Unsigned maximum value */
|
---|
110 | OTI_umax,
|
---|
111 |
|
---|
112 | /* Move instruction. */
|
---|
113 | OTI_mov,
|
---|
114 | /* Move, preserving high part of register. */
|
---|
115 | OTI_movstrict,
|
---|
116 |
|
---|
117 | /* Unary operations */
|
---|
118 | /* Negation */
|
---|
119 | OTI_neg,
|
---|
120 | OTI_negv,
|
---|
121 | /* Abs value */
|
---|
122 | OTI_abs,
|
---|
123 | OTI_absv,
|
---|
124 | /* Bitwise not */
|
---|
125 | OTI_one_cmpl,
|
---|
126 | /* Find first bit set */
|
---|
127 | OTI_ffs,
|
---|
128 | /* Square root */
|
---|
129 | OTI_sqrt,
|
---|
130 | /* Sine */
|
---|
131 | OTI_sin,
|
---|
132 | /* Cosine */
|
---|
133 | OTI_cos,
|
---|
134 | /* Exponential */
|
---|
135 | OTI_exp,
|
---|
136 | /* Natural Logarithm */
|
---|
137 | OTI_log,
|
---|
138 |
|
---|
139 | /* Compare insn; two operands. */
|
---|
140 | OTI_cmp,
|
---|
141 | /* Used only for libcalls for unsigned comparisons. */
|
---|
142 | OTI_ucmp,
|
---|
143 | /* tst insn; compare one operand against 0 */
|
---|
144 | OTI_tst,
|
---|
145 |
|
---|
146 | /* String length */
|
---|
147 | OTI_strlen,
|
---|
148 |
|
---|
149 | /* Combined compare & jump/store flags/move operations. */
|
---|
150 | OTI_cbranch,
|
---|
151 | OTI_cmov,
|
---|
152 | OTI_cstore,
|
---|
153 |
|
---|
154 | /* Push instruction. */
|
---|
155 | OTI_push,
|
---|
156 |
|
---|
157 | OTI_MAX
|
---|
158 | };
|
---|
159 |
|
---|
160 | extern GTY(()) optab optab_table[OTI_MAX];
|
---|
161 |
|
---|
162 | #define add_optab (optab_table[OTI_add])
|
---|
163 | #define sub_optab (optab_table[OTI_sub])
|
---|
164 | #define smul_optab (optab_table[OTI_smul])
|
---|
165 | #define addv_optab (optab_table[OTI_addv])
|
---|
166 | #define subv_optab (optab_table[OTI_subv])
|
---|
167 | #define smul_highpart_optab (optab_table[OTI_smul_highpart])
|
---|
168 | #define umul_highpart_optab (optab_table[OTI_umul_highpart])
|
---|
169 | #define smul_widen_optab (optab_table[OTI_smul_widen])
|
---|
170 | #define umul_widen_optab (optab_table[OTI_umul_widen])
|
---|
171 | #define sdiv_optab (optab_table[OTI_sdiv])
|
---|
172 | #define smulv_optab (optab_table[OTI_smulv])
|
---|
173 | #define sdivv_optab (optab_table[OTI_sdivv])
|
---|
174 | #define sdivmod_optab (optab_table[OTI_sdivmod])
|
---|
175 | #define udiv_optab (optab_table[OTI_udiv])
|
---|
176 | #define udivmod_optab (optab_table[OTI_udivmod])
|
---|
177 | #define smod_optab (optab_table[OTI_smod])
|
---|
178 | #define umod_optab (optab_table[OTI_umod])
|
---|
179 | #define ftrunc_optab (optab_table[OTI_ftrunc])
|
---|
180 | #define and_optab (optab_table[OTI_and])
|
---|
181 | #define ior_optab (optab_table[OTI_ior])
|
---|
182 | #define xor_optab (optab_table[OTI_xor])
|
---|
183 | #define ashl_optab (optab_table[OTI_ashl])
|
---|
184 | #define lshr_optab (optab_table[OTI_lshr])
|
---|
185 | #define ashr_optab (optab_table[OTI_ashr])
|
---|
186 | #define rotl_optab (optab_table[OTI_rotl])
|
---|
187 | #define rotr_optab (optab_table[OTI_rotr])
|
---|
188 | #define smin_optab (optab_table[OTI_smin])
|
---|
189 | #define smax_optab (optab_table[OTI_smax])
|
---|
190 | #define umin_optab (optab_table[OTI_umin])
|
---|
191 | #define umax_optab (optab_table[OTI_umax])
|
---|
192 |
|
---|
193 | #define mov_optab (optab_table[OTI_mov])
|
---|
194 | #define movstrict_optab (optab_table[OTI_movstrict])
|
---|
195 |
|
---|
196 | #define neg_optab (optab_table[OTI_neg])
|
---|
197 | #define negv_optab (optab_table[OTI_negv])
|
---|
198 | #define abs_optab (optab_table[OTI_abs])
|
---|
199 | #define absv_optab (optab_table[OTI_absv])
|
---|
200 | #define one_cmpl_optab (optab_table[OTI_one_cmpl])
|
---|
201 | #define ffs_optab (optab_table[OTI_ffs])
|
---|
202 | #define sqrt_optab (optab_table[OTI_sqrt])
|
---|
203 | #define sin_optab (optab_table[OTI_sin])
|
---|
204 | #define cos_optab (optab_table[OTI_cos])
|
---|
205 | #define exp_optab (optab_table[OTI_exp])
|
---|
206 | #define log_optab (optab_table[OTI_log])
|
---|
207 |
|
---|
208 | #define cmp_optab (optab_table[OTI_cmp])
|
---|
209 | #define ucmp_optab (optab_table[OTI_ucmp])
|
---|
210 | #define tst_optab (optab_table[OTI_tst])
|
---|
211 |
|
---|
212 | #define strlen_optab (optab_table[OTI_strlen])
|
---|
213 |
|
---|
214 | #define cbranch_optab (optab_table[OTI_cbranch])
|
---|
215 | #define cmov_optab (optab_table[OTI_cmov])
|
---|
216 | #define cstore_optab (optab_table[OTI_cstore])
|
---|
217 | #define push_optab (optab_table[OTI_push])
|
---|
218 |
|
---|
219 | /* Tables of patterns for extending one integer mode to another. */
|
---|
220 | extern enum insn_code extendtab[MAX_MACHINE_MODE][MAX_MACHINE_MODE][2];
|
---|
221 |
|
---|
222 | /* Tables of patterns for converting between fixed and floating point. */
|
---|
223 | extern enum insn_code fixtab[NUM_MACHINE_MODES][NUM_MACHINE_MODES][2];
|
---|
224 | extern enum insn_code fixtrunctab[NUM_MACHINE_MODES][NUM_MACHINE_MODES][2];
|
---|
225 | extern enum insn_code floattab[NUM_MACHINE_MODES][NUM_MACHINE_MODES][2];
|
---|
226 |
|
---|
227 | /* These arrays record the insn_code of insns that may be needed to
|
---|
228 | perform input and output reloads of special objects. They provide a
|
---|
229 | place to pass a scratch register. */
|
---|
230 | extern enum insn_code reload_in_optab[NUM_MACHINE_MODES];
|
---|
231 | extern enum insn_code reload_out_optab[NUM_MACHINE_MODES];
|
---|
232 |
|
---|
233 | /* Contains the optab used for each rtx code. */
|
---|
234 | extern optab code_to_optab[NUM_RTX_CODE + 1];
|
---|
235 |
|
---|
236 | |
---|
237 |
|
---|
238 | typedef rtx (*rtxfun) PARAMS ((rtx));
|
---|
239 |
|
---|
240 | /* Indexed by the rtx-code for a conditional (eg. EQ, LT,...)
|
---|
241 | gives the gen_function to make a branch to test that condition. */
|
---|
242 |
|
---|
243 | extern rtxfun bcc_gen_fctn[NUM_RTX_CODE];
|
---|
244 |
|
---|
245 | /* Indexed by the rtx-code for a conditional (eg. EQ, LT,...)
|
---|
246 | gives the insn code to make a store-condition insn
|
---|
247 | to test that condition. */
|
---|
248 |
|
---|
249 | extern enum insn_code setcc_gen_code[NUM_RTX_CODE];
|
---|
250 |
|
---|
251 | #ifdef HAVE_conditional_move
|
---|
252 | /* Indexed by the machine mode, gives the insn code to make a conditional
|
---|
253 | move insn. */
|
---|
254 |
|
---|
255 | extern enum insn_code movcc_gen_code[NUM_MACHINE_MODES];
|
---|
256 | #endif
|
---|
257 |
|
---|
258 | /* This array records the insn_code of insns to perform block moves. */
|
---|
259 | extern enum insn_code movstr_optab[NUM_MACHINE_MODES];
|
---|
260 |
|
---|
261 | /* This array records the insn_code of insns to perform block clears. */
|
---|
262 | extern enum insn_code clrstr_optab[NUM_MACHINE_MODES];
|
---|
263 |
|
---|
264 | /* Define functions given in optabs.c. */
|
---|
265 |
|
---|
266 | /* Expand a binary operation given optab and rtx operands. */
|
---|
267 | extern rtx expand_binop PARAMS ((enum machine_mode, optab, rtx, rtx, rtx,
|
---|
268 | int, enum optab_methods));
|
---|
269 |
|
---|
270 | /* Expand a binary operation with both signed and unsigned forms. */
|
---|
271 | extern rtx sign_expand_binop PARAMS ((enum machine_mode, optab, optab, rtx,
|
---|
272 | rtx, rtx, int, enum optab_methods));
|
---|
273 |
|
---|
274 | /* Generate code to perform an operation on two operands with two results. */
|
---|
275 | extern int expand_twoval_binop PARAMS ((optab, rtx, rtx, rtx, rtx, int));
|
---|
276 |
|
---|
277 | /* Expand a unary arithmetic operation given optab rtx operand. */
|
---|
278 | extern rtx expand_unop PARAMS ((enum machine_mode, optab, rtx, rtx, int));
|
---|
279 |
|
---|
280 | /* Expand the absolute value operation. */
|
---|
281 | extern rtx expand_abs PARAMS ((enum machine_mode, rtx, rtx, int, int));
|
---|
282 |
|
---|
283 | /* Expand the complex absolute value operation. */
|
---|
284 | extern rtx expand_complex_abs PARAMS ((enum machine_mode, rtx, rtx, int));
|
---|
285 |
|
---|
286 | /* Generate an instruction with a given INSN_CODE with an output and
|
---|
287 | an input. */
|
---|
288 | extern void emit_unop_insn PARAMS ((int, rtx, rtx, enum rtx_code));
|
---|
289 |
|
---|
290 | /* Emit code to perform a series of operations on a multi-word quantity, one
|
---|
291 | word at a time. */
|
---|
292 | extern rtx emit_no_conflict_block PARAMS ((rtx, rtx, rtx, rtx, rtx));
|
---|
293 |
|
---|
294 | /* Emit one rtl instruction to store zero in specified rtx. */
|
---|
295 | extern void emit_clr_insn PARAMS ((rtx));
|
---|
296 |
|
---|
297 | /* Emit one rtl insn to store 1 in specified rtx assuming it contains 0. */
|
---|
298 | extern void emit_0_to_1_insn PARAMS ((rtx));
|
---|
299 |
|
---|
300 | /* Emit one rtl insn to compare two rtx's. */
|
---|
301 | extern void emit_cmp_insn PARAMS ((rtx, rtx, enum rtx_code, rtx,
|
---|
302 | enum machine_mode, int));
|
---|
303 |
|
---|
304 | /* The various uses that a comparison can have; used by can_compare_p:
|
---|
305 | jumps, conditional moves, store flag operations. */
|
---|
306 | enum can_compare_purpose
|
---|
307 | {
|
---|
308 | ccp_jump,
|
---|
309 | ccp_cmov,
|
---|
310 | ccp_store_flag
|
---|
311 | };
|
---|
312 |
|
---|
313 | /* Nonzero if a compare of mode MODE can be done straightforwardly
|
---|
314 | (without splitting it into pieces). */
|
---|
315 | extern int can_compare_p PARAMS ((enum rtx_code, enum machine_mode,
|
---|
316 | enum can_compare_purpose));
|
---|
317 |
|
---|
318 | extern rtx prepare_operand PARAMS ((int, rtx, int, enum machine_mode,
|
---|
319 | enum machine_mode, int));
|
---|
320 |
|
---|
321 | /* Return the INSN_CODE to use for an extend operation. */
|
---|
322 | extern enum insn_code can_extend_p PARAMS ((enum machine_mode,
|
---|
323 | enum machine_mode, int));
|
---|
324 |
|
---|
325 | /* Generate the body of an insn to extend Y (with mode MFROM)
|
---|
326 | into X (with mode MTO). Do zero-extension if UNSIGNEDP is nonzero. */
|
---|
327 | extern rtx gen_extend_insn PARAMS ((rtx, rtx, enum machine_mode,
|
---|
328 | enum machine_mode, int));
|
---|
329 |
|
---|
330 | /* Initialize the tables that control conversion between fixed and
|
---|
331 | floating values. */
|
---|
332 | extern void init_fixtab PARAMS ((void));
|
---|
333 | extern void init_floattab PARAMS ((void));
|
---|
334 |
|
---|
335 | /* Generate code for a FLOAT_EXPR. */
|
---|
336 | extern void expand_float PARAMS ((rtx, rtx, int));
|
---|
337 |
|
---|
338 | /* Generate code for a FIX_EXPR. */
|
---|
339 | extern void expand_fix PARAMS ((rtx, rtx, int));
|
---|
340 |
|
---|
341 | #endif /* GCC_OPTABS_H */
|
---|