1 /* Definitions for code generation pass of GNU compiler.
2 Copyright (C) 2001 Free Software Foundation, Inc.
4 This file is part of GCC.
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)
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.
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. */
24 #include "insn-codes.h"
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.
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.
35 The `lib_call' slot is the name of the library function that
36 can be used to perform the operation.
38 A few optabs, such as move_optab and cmp_optab, are used
44 struct optab_handlers
{
45 enum insn_code insn_code
;
47 } handlers
[NUM_MACHINE_MODES
];
49 typedef struct optab
* optab
;
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)
55 /* Enumeration of valid indexes into optab_table. */
63 /* Signed and fp multiply */
66 /* Signed multiply, return high word */
69 /* Signed multiply with result one machine mode wider than args */
76 /* Signed divide-and-remainder in one */
80 /* Signed remainder */
83 /* Convert float to integer in float fmt */
93 /* Arithmetic shift left */
95 /* Logical shift right */
97 /* Arithmetic shift right */
103 /* Signed and floating-point minimum value */
105 /* Signed and floating-point maximum value */
107 /* Unsigned minimum value */
109 /* Unsigned maximum value */
112 /* Move instruction. */
114 /* Move, preserving high part of register. */
117 /* Unary operations */
126 /* Find first bit set */
135 /* Compare insn; two operands. */
137 /* Used only for libcalls for unsigned comparisons. */
139 /* tst insn; compare one operand against 0 */
145 /* Combined compare & jump/store flags/move operations. */
150 /* Push instruction. */
156 extern GTY(()) optab optab_table
[OTI_MAX
];
158 #define add_optab (optab_table[OTI_add])
159 #define sub_optab (optab_table[OTI_sub])
160 #define smul_optab (optab_table[OTI_smul])
161 #define addv_optab (optab_table[OTI_addv])
162 #define subv_optab (optab_table[OTI_subv])
163 #define smul_highpart_optab (optab_table[OTI_smul_highpart])
164 #define umul_highpart_optab (optab_table[OTI_umul_highpart])
165 #define smul_widen_optab (optab_table[OTI_smul_widen])
166 #define umul_widen_optab (optab_table[OTI_umul_widen])
167 #define sdiv_optab (optab_table[OTI_sdiv])
168 #define smulv_optab (optab_table[OTI_smulv])
169 #define sdivv_optab (optab_table[OTI_sdivv])
170 #define sdivmod_optab (optab_table[OTI_sdivmod])
171 #define udiv_optab (optab_table[OTI_udiv])
172 #define udivmod_optab (optab_table[OTI_udivmod])
173 #define smod_optab (optab_table[OTI_smod])
174 #define umod_optab (optab_table[OTI_umod])
175 #define ftrunc_optab (optab_table[OTI_ftrunc])
176 #define and_optab (optab_table[OTI_and])
177 #define ior_optab (optab_table[OTI_ior])
178 #define xor_optab (optab_table[OTI_xor])
179 #define ashl_optab (optab_table[OTI_ashl])
180 #define lshr_optab (optab_table[OTI_lshr])
181 #define ashr_optab (optab_table[OTI_ashr])
182 #define rotl_optab (optab_table[OTI_rotl])
183 #define rotr_optab (optab_table[OTI_rotr])
184 #define smin_optab (optab_table[OTI_smin])
185 #define smax_optab (optab_table[OTI_smax])
186 #define umin_optab (optab_table[OTI_umin])
187 #define umax_optab (optab_table[OTI_umax])
189 #define mov_optab (optab_table[OTI_mov])
190 #define movstrict_optab (optab_table[OTI_movstrict])
192 #define neg_optab (optab_table[OTI_neg])
193 #define negv_optab (optab_table[OTI_negv])
194 #define abs_optab (optab_table[OTI_abs])
195 #define absv_optab (optab_table[OTI_absv])
196 #define one_cmpl_optab (optab_table[OTI_one_cmpl])
197 #define ffs_optab (optab_table[OTI_ffs])
198 #define sqrt_optab (optab_table[OTI_sqrt])
199 #define sin_optab (optab_table[OTI_sin])
200 #define cos_optab (optab_table[OTI_cos])
202 #define cmp_optab (optab_table[OTI_cmp])
203 #define ucmp_optab (optab_table[OTI_ucmp])
204 #define tst_optab (optab_table[OTI_tst])
206 #define strlen_optab (optab_table[OTI_strlen])
208 #define cbranch_optab (optab_table[OTI_cbranch])
209 #define cmov_optab (optab_table[OTI_cmov])
210 #define cstore_optab (optab_table[OTI_cstore])
211 #define push_optab (optab_table[OTI_push])
213 /* Tables of patterns for extending one integer mode to another. */
214 extern enum insn_code extendtab
[MAX_MACHINE_MODE
][MAX_MACHINE_MODE
][2];
216 /* Tables of patterns for converting between fixed and floating point. */
217 extern enum insn_code fixtab
[NUM_MACHINE_MODES
][NUM_MACHINE_MODES
][2];
218 extern enum insn_code fixtrunctab
[NUM_MACHINE_MODES
][NUM_MACHINE_MODES
][2];
219 extern enum insn_code floattab
[NUM_MACHINE_MODES
][NUM_MACHINE_MODES
][2];
221 /* These arrays record the insn_code of insns that may be needed to
222 perform input and output reloads of special objects. They provide a
223 place to pass a scratch register. */
224 extern enum insn_code reload_in_optab
[NUM_MACHINE_MODES
];
225 extern enum insn_code reload_out_optab
[NUM_MACHINE_MODES
];
227 /* Contains the optab used for each rtx code. */
228 extern optab code_to_optab
[NUM_RTX_CODE
+ 1];
231 typedef rtx (*rtxfun
) PARAMS ((rtx
));
233 /* Indexed by the rtx-code for a conditional (eg. EQ, LT,...)
234 gives the gen_function to make a branch to test that condition. */
236 extern rtxfun bcc_gen_fctn
[NUM_RTX_CODE
];
238 /* Indexed by the rtx-code for a conditional (eg. EQ, LT,...)
239 gives the insn code to make a store-condition insn
240 to test that condition. */
242 extern enum insn_code setcc_gen_code
[NUM_RTX_CODE
];
244 #ifdef HAVE_conditional_move
245 /* Indexed by the machine mode, gives the insn code to make a conditional
248 extern enum insn_code movcc_gen_code
[NUM_MACHINE_MODES
];
251 /* This array records the insn_code of insns to perform block moves. */
252 extern enum insn_code movstr_optab
[NUM_MACHINE_MODES
];
254 /* This array records the insn_code of insns to perform block clears. */
255 extern enum insn_code clrstr_optab
[NUM_MACHINE_MODES
];
257 /* Define functions given in optabs.c. */
259 /* Expand a binary operation given optab and rtx operands. */
260 extern rtx expand_binop
PARAMS ((enum machine_mode
, optab
, rtx
, rtx
, rtx
,
261 int, enum optab_methods
));
263 /* Expand a binary operation with both signed and unsigned forms. */
264 extern rtx sign_expand_binop
PARAMS ((enum machine_mode
, optab
, optab
, rtx
,
265 rtx
, rtx
, int, enum optab_methods
));
267 /* Generate code to perform an operation on two operands with two results. */
268 extern int expand_twoval_binop
PARAMS ((optab
, rtx
, rtx
, rtx
, rtx
, int));
270 /* Expand a unary arithmetic operation given optab rtx operand. */
271 extern rtx expand_unop
PARAMS ((enum machine_mode
, optab
, rtx
, rtx
, int));
273 /* Expand the absolute value operation. */
274 extern rtx expand_abs
PARAMS ((enum machine_mode
, rtx
, rtx
, int, int));
276 /* Expand the complex absolute value operation. */
277 extern rtx expand_complex_abs
PARAMS ((enum machine_mode
, rtx
, rtx
, int));
279 /* Generate an instruction with a given INSN_CODE with an output and
281 extern void emit_unop_insn
PARAMS ((int, rtx
, rtx
, enum rtx_code
));
283 /* Emit code to perform a series of operations on a multi-word quantity, one
285 extern rtx emit_no_conflict_block
PARAMS ((rtx
, rtx
, rtx
, rtx
, rtx
));
287 /* Emit one rtl instruction to store zero in specified rtx. */
288 extern void emit_clr_insn
PARAMS ((rtx
));
290 /* Emit one rtl insn to store 1 in specified rtx assuming it contains 0. */
291 extern void emit_0_to_1_insn
PARAMS ((rtx
));
293 /* Emit one rtl insn to compare two rtx's. */
294 extern void emit_cmp_insn
PARAMS ((rtx
, rtx
, enum rtx_code
, rtx
,
295 enum machine_mode
, int));
297 /* The various uses that a comparison can have; used by can_compare_p:
298 jumps, conditional moves, store flag operations. */
299 enum can_compare_purpose
306 /* Nonzero if a compare of mode MODE can be done straightforwardly
307 (without splitting it into pieces). */
308 extern int can_compare_p
PARAMS ((enum rtx_code
, enum machine_mode
,
309 enum can_compare_purpose
));
311 extern rtx prepare_operand
PARAMS ((int, rtx
, int, enum machine_mode
,
312 enum machine_mode
, int));
314 /* Return the INSN_CODE to use for an extend operation. */
315 extern enum insn_code can_extend_p
PARAMS ((enum machine_mode
,
316 enum machine_mode
, int));
318 /* Generate the body of an insn to extend Y (with mode MFROM)
319 into X (with mode MTO). Do zero-extension if UNSIGNEDP is nonzero. */
320 extern rtx gen_extend_insn
PARAMS ((rtx
, rtx
, enum machine_mode
,
321 enum machine_mode
, int));
323 /* Initialize the tables that control conversion between fixed and
325 extern void init_fixtab
PARAMS ((void));
326 extern void init_floattab
PARAMS ((void));
328 /* Generate code for a FLOAT_EXPR. */
329 extern void expand_float
PARAMS ((rtx
, rtx
, int));
331 /* Generate code for a FIX_EXPR. */
332 extern void expand_fix
PARAMS ((rtx
, rtx
, int));
334 #endif /* GCC_OPTABS_H */