PR target/44750
[official-gcc.git] / gcc / optabs.h
blobc4dfa60b83d31366ab030cbd88535b8bd0e2bab9
1 /* Definitions for code generation pass of GNU compiler.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
3 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC 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 3, or (at your option)
10 any later version.
12 GCC 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.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_OPTABS_H
22 #define GCC_OPTABS_H
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.
30 For example, add_optab applies to addition.
32 The `lib_call' slot is the name of the library function that
33 can be used to perform the operation.
35 A few optabs, such as move_optab, are used by special code. */
37 struct optab_handlers
39 /* I - CODE_FOR_nothing, where I is either the insn code of the
40 associated insn generator or CODE_FOR_nothing if there is no such
41 insn on the target machine. */
42 int insn_code;
45 struct optab_d
47 enum rtx_code code;
48 char libcall_suffix;
49 const char *libcall_basename;
50 void (*libcall_gen)(struct optab_d *, const char *name, char suffix,
51 enum machine_mode);
52 struct optab_handlers handlers[NUM_MACHINE_MODES];
54 typedef struct optab_d * optab;
56 /* A convert_optab is for some sort of conversion operation between
57 modes. The first array index is the destination mode, the second
58 is the source mode. */
59 struct convert_optab_d
61 enum rtx_code code;
62 const char *libcall_basename;
63 void (*libcall_gen)(struct convert_optab_d *, const char *name,
64 enum machine_mode,
65 enum machine_mode);
66 struct optab_handlers handlers[NUM_MACHINE_MODES][NUM_MACHINE_MODES];
68 typedef struct convert_optab_d *convert_optab;
70 /* Given an enum insn_code, access the function to construct
71 the body of that kind of insn. */
72 #define GEN_FCN(CODE) (insn_data[CODE].genfun)
74 /* Enumeration of valid indexes into optab_table. */
75 enum optab_index
77 /* Fixed-point operators with signed/unsigned saturation */
78 OTI_ssadd,
79 OTI_usadd,
80 OTI_sssub,
81 OTI_ussub,
82 OTI_ssmul,
83 OTI_usmul,
84 OTI_ssdiv,
85 OTI_usdiv,
86 OTI_ssneg,
87 OTI_usneg,
88 OTI_ssashl,
89 OTI_usashl,
91 OTI_add,
92 OTI_addv,
93 OTI_sub,
94 OTI_subv,
96 /* Signed and fp multiply */
97 OTI_smul,
98 OTI_smulv,
99 /* Signed multiply, return high word */
100 OTI_smul_highpart,
101 OTI_umul_highpart,
102 /* Signed multiply with result one machine mode wider than args */
103 OTI_smul_widen,
104 OTI_umul_widen,
105 /* Widening multiply of one unsigned and one signed operand. */
106 OTI_usmul_widen,
107 /* Signed multiply and add with the result and addend one machine mode
108 wider than the multiplicand and multiplier. */
109 OTI_smadd_widen,
110 /* Unsigned multiply and add with the result and addend one machine mode
111 wider than the multiplicand and multiplier. */
112 OTI_umadd_widen,
113 /* Signed multiply and add with the result and addend one machine mode
114 wider than the multiplicand and multiplier.
115 All involved operations are saturating. */
116 OTI_ssmadd_widen,
117 /* Unsigned multiply and add with the result and addend one machine mode
118 wider than the multiplicand and multiplier.
119 All involved operations are saturating. */
120 OTI_usmadd_widen,
121 /* Signed multiply and subtract the result and minuend one machine mode
122 wider than the multiplicand and multiplier. */
123 OTI_smsub_widen,
124 /* Unsigned multiply and subtract the result and minuend one machine mode
125 wider than the multiplicand and multiplier. */
126 OTI_umsub_widen,
127 /* Signed multiply and subtract the result and minuend one machine mode
128 wider than the multiplicand and multiplier.
129 All involved operations are saturating. */
130 OTI_ssmsub_widen,
131 /* Unsigned multiply and subtract the result and minuend one machine mode
132 wider than the multiplicand and multiplier.
133 All involved operations are saturating. */
134 OTI_usmsub_widen,
136 /* Signed divide */
137 OTI_sdiv,
138 OTI_sdivv,
139 /* Signed divide-and-remainder in one */
140 OTI_sdivmod,
141 OTI_udiv,
142 OTI_udivmod,
143 /* Signed remainder */
144 OTI_smod,
145 OTI_umod,
146 /* Floating point remainder functions */
147 OTI_fmod,
148 OTI_remainder,
149 /* Convert float to integer in float fmt */
150 OTI_ftrunc,
152 /* Logical and */
153 OTI_and,
154 /* Logical or */
155 OTI_ior,
156 /* Logical xor */
157 OTI_xor,
159 /* Arithmetic shift left */
160 OTI_ashl,
161 /* Logical shift right */
162 OTI_lshr,
163 /* Arithmetic shift right */
164 OTI_ashr,
165 /* Rotate left */
166 OTI_rotl,
167 /* Rotate right */
168 OTI_rotr,
170 /* Arithmetic shift left of vector by vector */
171 OTI_vashl,
172 /* Logical shift right of vector by vector */
173 OTI_vlshr,
174 /* Arithmetic shift right of vector by vector */
175 OTI_vashr,
176 /* Rotate left of vector by vector */
177 OTI_vrotl,
178 /* Rotate right of vector by vector */
179 OTI_vrotr,
181 /* Signed and floating-point minimum value */
182 OTI_smin,
183 /* Signed and floating-point maximum value */
184 OTI_smax,
185 /* Unsigned minimum value */
186 OTI_umin,
187 /* Unsigned maximum value */
188 OTI_umax,
189 /* Power */
190 OTI_pow,
191 /* Arc tangent of y/x */
192 OTI_atan2,
193 /* Floating multiply/add */
194 OTI_fma,
195 OTI_fms,
196 OTI_fnma,
197 OTI_fnms,
199 /* Move instruction. */
200 OTI_mov,
201 /* Move, preserving high part of register. */
202 OTI_movstrict,
203 /* Move, with a misaligned memory. */
204 OTI_movmisalign,
205 /* Nontemporal store. */
206 OTI_storent,
208 /* Unary operations */
209 /* Negation */
210 OTI_neg,
211 OTI_negv,
212 /* Abs value */
213 OTI_abs,
214 OTI_absv,
215 /* Byteswap */
216 OTI_bswap,
217 /* Bitwise not */
218 OTI_one_cmpl,
219 /* Bit scanning and counting */
220 OTI_ffs,
221 OTI_clz,
222 OTI_ctz,
223 OTI_popcount,
224 OTI_parity,
225 /* Square root */
226 OTI_sqrt,
227 /* Sine-Cosine */
228 OTI_sincos,
229 /* Sine */
230 OTI_sin,
231 /* Inverse sine */
232 OTI_asin,
233 /* Cosine */
234 OTI_cos,
235 /* Inverse cosine */
236 OTI_acos,
237 /* Exponential */
238 OTI_exp,
239 /* Base-10 Exponential */
240 OTI_exp10,
241 /* Base-2 Exponential */
242 OTI_exp2,
243 /* Exponential - 1*/
244 OTI_expm1,
245 /* Load exponent of a floating point number */
246 OTI_ldexp,
247 /* Multiply floating-point number by integral power of radix */
248 OTI_scalb,
249 /* Mantissa of a floating-point number */
250 OTI_significand,
251 /* Radix-independent exponent */
252 OTI_logb,
253 OTI_ilogb,
254 /* Natural Logarithm */
255 OTI_log,
256 /* Base-10 Logarithm */
257 OTI_log10,
258 /* Base-2 Logarithm */
259 OTI_log2,
260 /* logarithm of 1 plus argument */
261 OTI_log1p,
262 /* Rounding functions */
263 OTI_floor,
264 OTI_ceil,
265 OTI_btrunc,
266 OTI_round,
267 OTI_nearbyint,
268 OTI_rint,
269 /* Tangent */
270 OTI_tan,
271 /* Inverse tangent */
272 OTI_atan,
273 /* Copy sign */
274 OTI_copysign,
275 /* Signbit */
276 OTI_signbit,
277 /* Test for infinite value */
278 OTI_isinf,
280 /* Compare insn; two operands. Used only for libcalls. */
281 OTI_cmp,
282 OTI_ucmp,
284 /* Floating point comparison optabs - used primarily for libfuncs */
285 OTI_eq,
286 OTI_ne,
287 OTI_gt,
288 OTI_ge,
289 OTI_lt,
290 OTI_le,
291 OTI_unord,
293 /* String length */
294 OTI_strlen,
296 /* Combined compare & jump/move/store flags/trap operations. */
297 OTI_cbranch,
298 OTI_cmov,
299 OTI_cstore,
300 OTI_ctrap,
302 /* Push instruction. */
303 OTI_push,
305 /* Conditional add instruction. */
306 OTI_addcc,
308 /* Reduction operations on a vector operand. */
309 OTI_reduc_smax,
310 OTI_reduc_umax,
311 OTI_reduc_smin,
312 OTI_reduc_umin,
313 OTI_reduc_splus,
314 OTI_reduc_uplus,
316 /* Summation, with result machine mode one or more wider than args. */
317 OTI_ssum_widen,
318 OTI_usum_widen,
320 /* Dot product, with result machine mode one or more wider than args. */
321 OTI_sdot_prod,
322 OTI_udot_prod,
324 /* Set specified field of vector operand. */
325 OTI_vec_set,
326 /* Extract specified field of vector operand. */
327 OTI_vec_extract,
328 /* Extract even/odd fields of vector operands. */
329 OTI_vec_extract_even,
330 OTI_vec_extract_odd,
331 /* Interleave fields of vector operands. */
332 OTI_vec_interleave_high,
333 OTI_vec_interleave_low,
334 /* Initialize vector operand. */
335 OTI_vec_init,
336 /* Whole vector shift. The shift amount is in bits. */
337 OTI_vec_shl,
338 OTI_vec_shr,
339 /* Extract specified elements from vectors, for vector load. */
340 OTI_vec_realign_load,
341 /* Widening multiplication.
342 The high/low part of the resulting vector of products is returned. */
343 OTI_vec_widen_umult_hi,
344 OTI_vec_widen_umult_lo,
345 OTI_vec_widen_smult_hi,
346 OTI_vec_widen_smult_lo,
347 /* Extract and widen the high/low part of a vector of signed or
348 floating point elements. */
349 OTI_vec_unpacks_hi,
350 OTI_vec_unpacks_lo,
351 /* Extract and widen the high/low part of a vector of unsigned
352 elements. */
353 OTI_vec_unpacku_hi,
354 OTI_vec_unpacku_lo,
356 /* Extract, convert to floating point and widen the high/low part of
357 a vector of signed or unsigned integer elements. */
358 OTI_vec_unpacks_float_hi,
359 OTI_vec_unpacks_float_lo,
360 OTI_vec_unpacku_float_hi,
361 OTI_vec_unpacku_float_lo,
363 /* Narrow (demote) and merge the elements of two vectors. */
364 OTI_vec_pack_trunc,
365 OTI_vec_pack_usat,
366 OTI_vec_pack_ssat,
368 /* Convert to signed/unsigned integer, narrow and merge elements
369 of two vectors of floating point elements. */
370 OTI_vec_pack_sfix_trunc,
371 OTI_vec_pack_ufix_trunc,
373 /* Perform a raise to the power of integer. */
374 OTI_powi,
376 OTI_MAX
379 #define ssadd_optab (&optab_table[OTI_ssadd])
380 #define usadd_optab (&optab_table[OTI_usadd])
381 #define sssub_optab (&optab_table[OTI_sssub])
382 #define ussub_optab (&optab_table[OTI_ussub])
383 #define ssmul_optab (&optab_table[OTI_ssmul])
384 #define usmul_optab (&optab_table[OTI_usmul])
385 #define ssdiv_optab (&optab_table[OTI_ssdiv])
386 #define usdiv_optab (&optab_table[OTI_usdiv])
387 #define ssneg_optab (&optab_table[OTI_ssneg])
388 #define usneg_optab (&optab_table[OTI_usneg])
389 #define ssashl_optab (&optab_table[OTI_ssashl])
390 #define usashl_optab (&optab_table[OTI_usashl])
392 #define add_optab (&optab_table[OTI_add])
393 #define sub_optab (&optab_table[OTI_sub])
394 #define smul_optab (&optab_table[OTI_smul])
395 #define addv_optab (&optab_table[OTI_addv])
396 #define subv_optab (&optab_table[OTI_subv])
397 #define smul_highpart_optab (&optab_table[OTI_smul_highpart])
398 #define umul_highpart_optab (&optab_table[OTI_umul_highpart])
399 #define smul_widen_optab (&optab_table[OTI_smul_widen])
400 #define umul_widen_optab (&optab_table[OTI_umul_widen])
401 #define usmul_widen_optab (&optab_table[OTI_usmul_widen])
402 #define smadd_widen_optab (&optab_table[OTI_smadd_widen])
403 #define umadd_widen_optab (&optab_table[OTI_umadd_widen])
404 #define ssmadd_widen_optab (&optab_table[OTI_ssmadd_widen])
405 #define usmadd_widen_optab (&optab_table[OTI_usmadd_widen])
406 #define smsub_widen_optab (&optab_table[OTI_smsub_widen])
407 #define umsub_widen_optab (&optab_table[OTI_umsub_widen])
408 #define ssmsub_widen_optab (&optab_table[OTI_ssmsub_widen])
409 #define usmsub_widen_optab (&optab_table[OTI_usmsub_widen])
410 #define sdiv_optab (&optab_table[OTI_sdiv])
411 #define smulv_optab (&optab_table[OTI_smulv])
412 #define sdivv_optab (&optab_table[OTI_sdivv])
413 #define sdivmod_optab (&optab_table[OTI_sdivmod])
414 #define udiv_optab (&optab_table[OTI_udiv])
415 #define udivmod_optab (&optab_table[OTI_udivmod])
416 #define smod_optab (&optab_table[OTI_smod])
417 #define umod_optab (&optab_table[OTI_umod])
418 #define fmod_optab (&optab_table[OTI_fmod])
419 #define remainder_optab (&optab_table[OTI_remainder])
420 #define ftrunc_optab (&optab_table[OTI_ftrunc])
421 #define and_optab (&optab_table[OTI_and])
422 #define ior_optab (&optab_table[OTI_ior])
423 #define xor_optab (&optab_table[OTI_xor])
424 #define ashl_optab (&optab_table[OTI_ashl])
425 #define lshr_optab (&optab_table[OTI_lshr])
426 #define ashr_optab (&optab_table[OTI_ashr])
427 #define rotl_optab (&optab_table[OTI_rotl])
428 #define rotr_optab (&optab_table[OTI_rotr])
429 #define vashl_optab (&optab_table[OTI_vashl])
430 #define vlshr_optab (&optab_table[OTI_vlshr])
431 #define vashr_optab (&optab_table[OTI_vashr])
432 #define vrotl_optab (&optab_table[OTI_vrotl])
433 #define vrotr_optab (&optab_table[OTI_vrotr])
434 #define smin_optab (&optab_table[OTI_smin])
435 #define smax_optab (&optab_table[OTI_smax])
436 #define umin_optab (&optab_table[OTI_umin])
437 #define umax_optab (&optab_table[OTI_umax])
438 #define pow_optab (&optab_table[OTI_pow])
439 #define atan2_optab (&optab_table[OTI_atan2])
440 #define fma_optab (&optab_table[OTI_fma])
441 #define fms_optab (&optab_table[OTI_fms])
442 #define fnma_optab (&optab_table[OTI_fnma])
443 #define fnms_optab (&optab_table[OTI_fnms])
445 #define mov_optab (&optab_table[OTI_mov])
446 #define movstrict_optab (&optab_table[OTI_movstrict])
447 #define movmisalign_optab (&optab_table[OTI_movmisalign])
448 #define storent_optab (&optab_table[OTI_storent])
450 #define neg_optab (&optab_table[OTI_neg])
451 #define negv_optab (&optab_table[OTI_negv])
452 #define abs_optab (&optab_table[OTI_abs])
453 #define absv_optab (&optab_table[OTI_absv])
454 #define one_cmpl_optab (&optab_table[OTI_one_cmpl])
455 #define bswap_optab (&optab_table[OTI_bswap])
456 #define ffs_optab (&optab_table[OTI_ffs])
457 #define clz_optab (&optab_table[OTI_clz])
458 #define ctz_optab (&optab_table[OTI_ctz])
459 #define popcount_optab (&optab_table[OTI_popcount])
460 #define parity_optab (&optab_table[OTI_parity])
461 #define sqrt_optab (&optab_table[OTI_sqrt])
462 #define sincos_optab (&optab_table[OTI_sincos])
463 #define sin_optab (&optab_table[OTI_sin])
464 #define asin_optab (&optab_table[OTI_asin])
465 #define cos_optab (&optab_table[OTI_cos])
466 #define acos_optab (&optab_table[OTI_acos])
467 #define exp_optab (&optab_table[OTI_exp])
468 #define exp10_optab (&optab_table[OTI_exp10])
469 #define exp2_optab (&optab_table[OTI_exp2])
470 #define expm1_optab (&optab_table[OTI_expm1])
471 #define ldexp_optab (&optab_table[OTI_ldexp])
472 #define scalb_optab (&optab_table[OTI_scalb])
473 #define significand_optab (&optab_table[OTI_significand])
474 #define logb_optab (&optab_table[OTI_logb])
475 #define ilogb_optab (&optab_table[OTI_ilogb])
476 #define log_optab (&optab_table[OTI_log])
477 #define log10_optab (&optab_table[OTI_log10])
478 #define log2_optab (&optab_table[OTI_log2])
479 #define log1p_optab (&optab_table[OTI_log1p])
480 #define floor_optab (&optab_table[OTI_floor])
481 #define ceil_optab (&optab_table[OTI_ceil])
482 #define btrunc_optab (&optab_table[OTI_btrunc])
483 #define round_optab (&optab_table[OTI_round])
484 #define nearbyint_optab (&optab_table[OTI_nearbyint])
485 #define rint_optab (&optab_table[OTI_rint])
486 #define tan_optab (&optab_table[OTI_tan])
487 #define atan_optab (&optab_table[OTI_atan])
488 #define copysign_optab (&optab_table[OTI_copysign])
489 #define signbit_optab (&optab_table[OTI_signbit])
490 #define isinf_optab (&optab_table[OTI_isinf])
492 #define cmp_optab (&optab_table[OTI_cmp])
493 #define ucmp_optab (&optab_table[OTI_ucmp])
495 #define eq_optab (&optab_table[OTI_eq])
496 #define ne_optab (&optab_table[OTI_ne])
497 #define gt_optab (&optab_table[OTI_gt])
498 #define ge_optab (&optab_table[OTI_ge])
499 #define lt_optab (&optab_table[OTI_lt])
500 #define le_optab (&optab_table[OTI_le])
501 #define unord_optab (&optab_table[OTI_unord])
503 #define strlen_optab (&optab_table[OTI_strlen])
505 #define cbranch_optab (&optab_table[OTI_cbranch])
506 #define cmov_optab (&optab_table[OTI_cmov])
507 #define cstore_optab (&optab_table[OTI_cstore])
508 #define ctrap_optab (&optab_table[OTI_ctrap])
510 #define push_optab (&optab_table[OTI_push])
511 #define addcc_optab (&optab_table[OTI_addcc])
513 #define reduc_smax_optab (&optab_table[OTI_reduc_smax])
514 #define reduc_umax_optab (&optab_table[OTI_reduc_umax])
515 #define reduc_smin_optab (&optab_table[OTI_reduc_smin])
516 #define reduc_umin_optab (&optab_table[OTI_reduc_umin])
517 #define reduc_splus_optab (&optab_table[OTI_reduc_splus])
518 #define reduc_uplus_optab (&optab_table[OTI_reduc_uplus])
520 #define ssum_widen_optab (&optab_table[OTI_ssum_widen])
521 #define usum_widen_optab (&optab_table[OTI_usum_widen])
522 #define sdot_prod_optab (&optab_table[OTI_sdot_prod])
523 #define udot_prod_optab (&optab_table[OTI_udot_prod])
525 #define vec_set_optab (&optab_table[OTI_vec_set])
526 #define vec_extract_optab (&optab_table[OTI_vec_extract])
527 #define vec_extract_even_optab (&optab_table[OTI_vec_extract_even])
528 #define vec_extract_odd_optab (&optab_table[OTI_vec_extract_odd])
529 #define vec_interleave_high_optab (&optab_table[OTI_vec_interleave_high])
530 #define vec_interleave_low_optab (&optab_table[OTI_vec_interleave_low])
531 #define vec_init_optab (&optab_table[OTI_vec_init])
532 #define vec_shl_optab (&optab_table[OTI_vec_shl])
533 #define vec_shr_optab (&optab_table[OTI_vec_shr])
534 #define vec_realign_load_optab (&optab_table[OTI_vec_realign_load])
535 #define vec_widen_umult_hi_optab (&optab_table[OTI_vec_widen_umult_hi])
536 #define vec_widen_umult_lo_optab (&optab_table[OTI_vec_widen_umult_lo])
537 #define vec_widen_smult_hi_optab (&optab_table[OTI_vec_widen_smult_hi])
538 #define vec_widen_smult_lo_optab (&optab_table[OTI_vec_widen_smult_lo])
539 #define vec_unpacks_hi_optab (&optab_table[OTI_vec_unpacks_hi])
540 #define vec_unpacks_lo_optab (&optab_table[OTI_vec_unpacks_lo])
541 #define vec_unpacku_hi_optab (&optab_table[OTI_vec_unpacku_hi])
542 #define vec_unpacku_lo_optab (&optab_table[OTI_vec_unpacku_lo])
543 #define vec_unpacks_float_hi_optab (&optab_table[OTI_vec_unpacks_float_hi])
544 #define vec_unpacks_float_lo_optab (&optab_table[OTI_vec_unpacks_float_lo])
545 #define vec_unpacku_float_hi_optab (&optab_table[OTI_vec_unpacku_float_hi])
546 #define vec_unpacku_float_lo_optab (&optab_table[OTI_vec_unpacku_float_lo])
547 #define vec_pack_trunc_optab (&optab_table[OTI_vec_pack_trunc])
548 #define vec_pack_ssat_optab (&optab_table[OTI_vec_pack_ssat])
549 #define vec_pack_usat_optab (&optab_table[OTI_vec_pack_usat])
550 #define vec_pack_sfix_trunc_optab (&optab_table[OTI_vec_pack_sfix_trunc])
551 #define vec_pack_ufix_trunc_optab (&optab_table[OTI_vec_pack_ufix_trunc])
553 #define powi_optab (&optab_table[OTI_powi])
555 /* Conversion optabs have their own table and indexes. */
556 enum convert_optab_index
558 COI_sext,
559 COI_zext,
560 COI_trunc,
562 COI_sfix,
563 COI_ufix,
565 COI_sfixtrunc,
566 COI_ufixtrunc,
568 COI_sfloat,
569 COI_ufloat,
571 COI_lrint,
572 COI_lround,
573 COI_lfloor,
574 COI_lceil,
576 COI_fract,
577 COI_fractuns,
578 COI_satfract,
579 COI_satfractuns,
581 COI_MAX
584 #define sext_optab (&convert_optab_table[COI_sext])
585 #define zext_optab (&convert_optab_table[COI_zext])
586 #define trunc_optab (&convert_optab_table[COI_trunc])
587 #define sfix_optab (&convert_optab_table[COI_sfix])
588 #define ufix_optab (&convert_optab_table[COI_ufix])
589 #define sfixtrunc_optab (&convert_optab_table[COI_sfixtrunc])
590 #define ufixtrunc_optab (&convert_optab_table[COI_ufixtrunc])
591 #define sfloat_optab (&convert_optab_table[COI_sfloat])
592 #define ufloat_optab (&convert_optab_table[COI_ufloat])
593 #define lrint_optab (&convert_optab_table[COI_lrint])
594 #define lround_optab (&convert_optab_table[COI_lround])
595 #define lfloor_optab (&convert_optab_table[COI_lfloor])
596 #define lceil_optab (&convert_optab_table[COI_lceil])
597 #define fract_optab (&convert_optab_table[COI_fract])
598 #define fractuns_optab (&convert_optab_table[COI_fractuns])
599 #define satfract_optab (&convert_optab_table[COI_satfract])
600 #define satfractuns_optab (&convert_optab_table[COI_satfractuns])
602 /* Contains the optab used for each rtx code. */
603 extern optab code_to_optab[NUM_RTX_CODE + 1];
606 typedef rtx (*rtxfun) (rtx);
608 /* Enumerates operations that have a named .md pattern associated
609 with them, but which are not implemented as library functions. */
610 enum direct_optab_index
612 #ifdef HAVE_conditional_move
613 /* Conditional move operations. */
614 DOI_movcc,
615 #endif
617 /* Operations that use a scratch register to perform input and output
618 reloads of special objects. */
619 DOI_reload_in,
620 DOI_reload_out,
622 /* Vector conditional operations. */
623 DOI_vcond,
624 DOI_vcondu,
626 /* Block move operation. */
627 DOI_movmem,
629 /* Block set operation. */
630 DOI_setmem,
632 /* Various types of block compare operation. */
633 DOI_cmpstr,
634 DOI_cmpstrn,
635 DOI_cmpmem,
637 /* Synchronization primitives. This first set is atomic operation for
638 which we don't care about the resulting value. */
639 DOI_sync_add,
640 DOI_sync_sub,
641 DOI_sync_ior,
642 DOI_sync_and,
643 DOI_sync_xor,
644 DOI_sync_nand,
646 /* This second set is atomic operations in which we return the value
647 that existed in memory before the operation. */
648 DOI_sync_old_add,
649 DOI_sync_old_sub,
650 DOI_sync_old_ior,
651 DOI_sync_old_and,
652 DOI_sync_old_xor,
653 DOI_sync_old_nand,
655 /* This third set is atomic operations in which we return the value
656 that resulted after performing the operation. */
657 DOI_sync_new_add,
658 DOI_sync_new_sub,
659 DOI_sync_new_ior,
660 DOI_sync_new_and,
661 DOI_sync_new_xor,
662 DOI_sync_new_nand,
664 /* Atomic compare and swap. */
665 DOI_sync_compare_and_swap,
667 /* Atomic exchange with acquire semantics. */
668 DOI_sync_lock_test_and_set,
670 /* Atomic clear with release semantics. */
671 DOI_sync_lock_release,
673 DOI_MAX
676 /* A structure that says which insn should be used to perform an operation
677 in a particular mode. */
678 struct direct_optab_d
680 struct optab_handlers handlers[NUM_MACHINE_MODES];
682 typedef struct direct_optab_d *direct_optab;
684 #ifdef HAVE_conditional_move
685 #define movcc_optab (&direct_optab_table[(int) DOI_movcc])
686 #endif
687 #define reload_in_optab (&direct_optab_table[(int) DOI_reload_in])
688 #define reload_out_optab (&direct_optab_table[(int) DOI_reload_out])
689 #define vcond_optab (&direct_optab_table[(int) DOI_vcond])
690 #define vcondu_optab (&direct_optab_table[(int) DOI_vcondu])
691 #define movmem_optab (&direct_optab_table[(int) DOI_movmem])
692 #define setmem_optab (&direct_optab_table[(int) DOI_setmem])
693 #define cmpstr_optab (&direct_optab_table[(int) DOI_cmpstr])
694 #define cmpstrn_optab (&direct_optab_table[(int) DOI_cmpstrn])
695 #define cmpmem_optab (&direct_optab_table[(int) DOI_cmpmem])
696 #define sync_add_optab (&direct_optab_table[(int) DOI_sync_add])
697 #define sync_sub_optab (&direct_optab_table[(int) DOI_sync_sub])
698 #define sync_ior_optab (&direct_optab_table[(int) DOI_sync_ior])
699 #define sync_and_optab (&direct_optab_table[(int) DOI_sync_and])
700 #define sync_xor_optab (&direct_optab_table[(int) DOI_sync_xor])
701 #define sync_nand_optab (&direct_optab_table[(int) DOI_sync_nand])
702 #define sync_old_add_optab (&direct_optab_table[(int) DOI_sync_old_add])
703 #define sync_old_sub_optab (&direct_optab_table[(int) DOI_sync_old_sub])
704 #define sync_old_ior_optab (&direct_optab_table[(int) DOI_sync_old_ior])
705 #define sync_old_and_optab (&direct_optab_table[(int) DOI_sync_old_and])
706 #define sync_old_xor_optab (&direct_optab_table[(int) DOI_sync_old_xor])
707 #define sync_old_nand_optab (&direct_optab_table[(int) DOI_sync_old_nand])
708 #define sync_new_add_optab (&direct_optab_table[(int) DOI_sync_new_add])
709 #define sync_new_sub_optab (&direct_optab_table[(int) DOI_sync_new_sub])
710 #define sync_new_ior_optab (&direct_optab_table[(int) DOI_sync_new_ior])
711 #define sync_new_and_optab (&direct_optab_table[(int) DOI_sync_new_and])
712 #define sync_new_xor_optab (&direct_optab_table[(int) DOI_sync_new_xor])
713 #define sync_new_nand_optab (&direct_optab_table[(int) DOI_sync_new_nand])
714 #define sync_compare_and_swap_optab \
715 (&direct_optab_table[(int) DOI_sync_compare_and_swap])
716 #define sync_lock_test_and_set_optab \
717 (&direct_optab_table[(int) DOI_sync_lock_test_and_set])
718 #define sync_lock_release_optab \
719 (&direct_optab_table[(int) DOI_sync_lock_release])
721 /* Target-dependent globals. */
722 struct target_optabs {
723 /* Tables of patterns that may have an associated libcall. */
724 struct optab_d x_optab_table[(int) OTI_MAX];
726 /* Tables of patterns for converting one mode to another. */
727 struct convert_optab_d x_convert_optab_table[(int) COI_MAX];
729 /* Tables of patterns for direct optabs (i.e. those which cannot be
730 implemented using a libcall). */
731 struct direct_optab_d x_direct_optab_table[(int) DOI_MAX];
734 extern struct target_optabs default_target_optabs;
735 #if SWITCHABLE_TARGET
736 extern struct target_optabs *this_target_optabs;
737 #else
738 #define this_target_optabs (&default_target_optabs)
739 #endif
741 #define optab_table \
742 (this_target_optabs->x_optab_table)
743 #define convert_optab_table \
744 (this_target_optabs->x_convert_optab_table)
745 #define direct_optab_table \
746 (this_target_optabs->x_direct_optab_table)
748 /* Define functions given in optabs.c. */
750 extern rtx expand_widen_pattern_expr (sepops ops, rtx op0, rtx op1, rtx wide_op,
751 rtx target, int unsignedp);
753 extern rtx expand_ternary_op (enum machine_mode mode, optab ternary_optab,
754 rtx op0, rtx op1, rtx op2, rtx target,
755 int unsignedp);
757 /* Expand a binary operation given optab and rtx operands. */
758 extern rtx expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int,
759 enum optab_methods);
761 extern bool force_expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int,
762 enum optab_methods);
764 /* Expand a binary operation with both signed and unsigned forms. */
765 extern rtx sign_expand_binop (enum machine_mode, optab, optab, rtx, rtx,
766 rtx, int, enum optab_methods);
768 /* Generate code to perform an operation on one operand with two results. */
769 extern int expand_twoval_unop (optab, rtx, rtx, rtx, int);
771 /* Generate code to perform an operation on two operands with two results. */
772 extern int expand_twoval_binop (optab, rtx, rtx, rtx, rtx, int);
774 /* Generate code to perform an operation on two operands with two
775 results, using a library function. */
776 extern bool expand_twoval_binop_libfunc (optab, rtx, rtx, rtx, rtx,
777 enum rtx_code);
779 /* Expand a unary arithmetic operation given optab rtx operand. */
780 extern rtx expand_unop (enum machine_mode, optab, rtx, rtx, int);
782 /* Expand the absolute value operation. */
783 extern rtx expand_abs_nojump (enum machine_mode, rtx, rtx, int);
784 extern rtx expand_abs (enum machine_mode, rtx, rtx, int, int);
786 /* Expand the one's complement absolute value operation. */
787 extern rtx expand_one_cmpl_abs_nojump (enum machine_mode, rtx, rtx);
789 /* Expand the copysign operation. */
790 extern rtx expand_copysign (rtx, rtx, rtx);
792 /* Generate an instruction with a given INSN_CODE with an output and
793 an input. */
794 extern void emit_unop_insn (int, rtx, rtx, enum rtx_code);
795 extern bool maybe_emit_unop_insn (int, rtx, rtx, enum rtx_code);
797 /* An extra flag to control optab_for_tree_code's behavior. This is needed to
798 distinguish between machines with a vector shift that takes a scalar for the
799 shift amount vs. machines that take a vector for the shift amount. */
800 enum optab_subtype
802 optab_default,
803 optab_scalar,
804 optab_vector
807 /* Return the optab used for computing the given operation on the type given by
808 the second argument. The third argument distinguishes between the types of
809 vector shifts and rotates */
810 extern optab optab_for_tree_code (enum tree_code, const_tree, enum optab_subtype);
812 /* The various uses that a comparison can have; used by can_compare_p:
813 jumps, conditional moves, store flag operations. */
814 enum can_compare_purpose
816 ccp_jump,
817 ccp_cmov,
818 ccp_store_flag
821 /* Nonzero if a compare of mode MODE can be done straightforwardly
822 (without splitting it into pieces). */
823 extern int can_compare_p (enum rtx_code, enum machine_mode,
824 enum can_compare_purpose);
826 /* Return the INSN_CODE to use for an extend operation. */
827 extern enum insn_code can_extend_p (enum machine_mode, enum machine_mode, int);
829 /* Generate the body of an insn to extend Y (with mode MFROM)
830 into X (with mode MTO). Do zero-extension if UNSIGNEDP is nonzero. */
831 extern rtx gen_extend_insn (rtx, rtx, enum machine_mode,
832 enum machine_mode, int);
834 /* Call this to reset the function entry for one optab. */
835 extern void set_optab_libfunc (optab, enum machine_mode, const char *);
836 extern void set_conv_libfunc (convert_optab, enum machine_mode,
837 enum machine_mode, const char *);
839 /* Generate code for a FIXED_CONVERT_EXPR. */
840 extern void expand_fixed_convert (rtx, rtx, int, int);
842 /* Generate code for a FLOAT_EXPR. */
843 extern void expand_float (rtx, rtx, int);
845 /* Generate code for a FIX_EXPR. */
846 extern void expand_fix (rtx, rtx, int);
848 /* Generate code for float to integral conversion. */
849 extern bool expand_sfix_optab (rtx, rtx, convert_optab);
851 /* Generate code for a widening multiply. */
852 extern rtx expand_widening_mult (enum machine_mode, rtx, rtx, rtx, int, optab);
854 /* Return tree if target supports vector operations for COND_EXPR. */
855 bool expand_vec_cond_expr_p (tree, enum machine_mode);
857 /* Generate code for VEC_COND_EXPR. */
858 extern rtx expand_vec_cond_expr (tree, tree, tree, tree, rtx);
859 /* Generate code for VEC_LSHIFT_EXPR and VEC_RSHIFT_EXPR. */
860 extern rtx expand_vec_shift_expr (sepops, rtx);
862 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
863 if the target does not have such an insn. */
865 static inline enum insn_code
866 optab_handler (optab op, enum machine_mode mode)
868 return (enum insn_code) (op->handlers[(int) mode].insn_code
869 + (int) CODE_FOR_nothing);
872 /* Record that insn CODE should be used to implement mode MODE of OP. */
874 static inline void
875 set_optab_handler (optab op, enum machine_mode mode, enum insn_code code)
877 op->handlers[(int) mode].insn_code = (int) code - (int) CODE_FOR_nothing;
880 /* Return the insn used to perform conversion OP from mode FROM_MODE
881 to mode TO_MODE; return CODE_FOR_nothing if the target does not have
882 such an insn. */
884 static inline enum insn_code
885 convert_optab_handler (convert_optab op, enum machine_mode to_mode,
886 enum machine_mode from_mode)
888 return ((enum insn_code)
889 (op->handlers[(int) to_mode][(int) from_mode].insn_code
890 + (int) CODE_FOR_nothing));
893 /* Record that insn CODE should be used to perform conversion OP
894 from mode FROM_MODE to mode TO_MODE. */
896 static inline void
897 set_convert_optab_handler (convert_optab op, enum machine_mode to_mode,
898 enum machine_mode from_mode, enum insn_code code)
900 op->handlers[(int) to_mode][(int) from_mode].insn_code
901 = (int) code - (int) CODE_FOR_nothing;
904 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
905 if the target does not have such an insn. */
907 static inline enum insn_code
908 direct_optab_handler (direct_optab op, enum machine_mode mode)
910 return (enum insn_code) (op->handlers[(int) mode].insn_code
911 + (int) CODE_FOR_nothing);
914 /* Record that insn CODE should be used to implement mode MODE of OP. */
916 static inline void
917 set_direct_optab_handler (direct_optab op, enum machine_mode mode,
918 enum insn_code code)
920 op->handlers[(int) mode].insn_code = (int) code - (int) CODE_FOR_nothing;
923 extern rtx optab_libfunc (optab optab, enum machine_mode mode);
924 extern rtx convert_optab_libfunc (convert_optab optab, enum machine_mode mode1,
925 enum machine_mode mode2);
926 #endif /* GCC_OPTABS_H */