1 /* Definitions for code generation pass of GNU compiler.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
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)
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/>. */
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. */
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. */
45 struct widening_optab_handlers
47 struct optab_handlers handlers
[NUM_MACHINE_MODES
][NUM_MACHINE_MODES
];
54 const char *libcall_basename
;
55 void (*libcall_gen
)(struct optab_d
*, const char *name
, char suffix
,
57 struct optab_handlers handlers
[NUM_MACHINE_MODES
];
58 struct widening_optab_handlers
*widening
;
60 typedef struct optab_d
* optab
;
62 /* A convert_optab is for some sort of conversion operation between
63 modes. The first array index is the destination mode, the second
64 is the source mode. */
65 struct convert_optab_d
68 const char *libcall_basename
;
69 void (*libcall_gen
)(struct convert_optab_d
*, const char *name
,
72 struct optab_handlers handlers
[NUM_MACHINE_MODES
][NUM_MACHINE_MODES
];
74 typedef struct convert_optab_d
*convert_optab
;
76 /* Given an enum insn_code, access the function to construct
77 the body of that kind of insn. */
78 #define GEN_FCN(CODE) (insn_data[CODE].genfun)
80 /* Enumeration of valid indexes into optab_table. */
83 /* Fixed-point operators with signed/unsigned saturation */
102 /* Signed and fp multiply */
105 /* Signed multiply, return high word */
108 /* Signed multiply with result one machine mode wider than args */
111 /* Widening multiply of one unsigned and one signed operand. */
113 /* Signed multiply and add with the result and addend one machine mode
114 wider than the multiplicand and multiplier. */
116 /* Unsigned multiply and add with the result and addend one machine mode
117 wider than the multiplicand and multiplier. */
119 /* Signed multiply and add with the result and addend one machine mode
120 wider than the multiplicand and multiplier.
121 All involved operations are saturating. */
123 /* Unsigned multiply and add with the result and addend one machine mode
124 wider than the multiplicand and multiplier.
125 All involved operations are saturating. */
127 /* Signed multiply and subtract the result and minuend one machine mode
128 wider than the multiplicand and multiplier. */
130 /* Unsigned multiply and subtract the result and minuend one machine mode
131 wider than the multiplicand and multiplier. */
133 /* Signed multiply and subtract the result and minuend one machine mode
134 wider than the multiplicand and multiplier.
135 All involved operations are saturating. */
137 /* Unsigned multiply and subtract the result and minuend one machine mode
138 wider than the multiplicand and multiplier.
139 All involved operations are saturating. */
145 /* Signed divide-and-remainder in one */
149 /* Signed remainder */
152 /* Floating point remainder functions */
155 /* Convert float to integer in float fmt */
165 /* Arithmetic shift left */
167 /* Logical shift right */
169 /* Arithmetic shift right */
176 /* Arithmetic shift left of vector by vector */
178 /* Logical shift right of vector by vector */
180 /* Arithmetic shift right of vector by vector */
182 /* Rotate left of vector by vector */
184 /* Rotate right of vector by vector */
187 /* Signed and floating-point minimum value */
189 /* Signed and floating-point maximum value */
191 /* Unsigned minimum value */
193 /* Unsigned maximum value */
197 /* Arc tangent of y/x */
199 /* Floating multiply/add */
205 /* Move instruction. */
207 /* Move, preserving high part of register. */
209 /* Move, with a misaligned memory. */
211 /* Nontemporal store. */
214 /* Unary operations */
225 /* Bit scanning and counting */
246 /* Base-10 Exponential */
248 /* Base-2 Exponential */
252 /* Load exponent of a floating point number */
254 /* Multiply floating-point number by integral power of radix */
256 /* Mantissa of a floating-point number */
258 /* Radix-independent exponent */
261 /* Natural Logarithm */
263 /* Base-10 Logarithm */
265 /* Base-2 Logarithm */
267 /* logarithm of 1 plus argument */
269 /* Rounding functions */
278 /* Inverse tangent */
284 /* Test for infinite value */
287 /* Compare insn; two operands. Used only for libcalls. */
291 /* Floating point comparison optabs - used primarily for libfuncs */
303 /* Combined compare & jump/move/store flags/trap operations. */
309 /* Push instruction. */
312 /* Conditional add instruction. */
315 /* Reduction operations on a vector operand. */
323 /* Summation, with result machine mode one or more wider than args. */
327 /* Dot product, with result machine mode one or more wider than args. */
331 /* Set specified field of vector operand. */
333 /* Extract specified field of vector operand. */
335 /* Extract even/odd fields of vector operands. */
336 OTI_vec_extract_even
,
338 /* Interleave fields of vector operands. */
339 OTI_vec_interleave_high
,
340 OTI_vec_interleave_low
,
341 /* Initialize vector operand. */
343 /* Whole vector shift. The shift amount is in bits. */
346 /* Extract specified elements from vectors, for vector load. */
347 OTI_vec_realign_load
,
348 /* Widening multiplication.
349 The high/low part of the resulting vector of products is returned. */
350 OTI_vec_widen_umult_hi
,
351 OTI_vec_widen_umult_lo
,
352 OTI_vec_widen_smult_hi
,
353 OTI_vec_widen_smult_lo
,
354 /* Widening shift left.
355 The high/low part of the resulting vector is returned. */
356 OTI_vec_widen_ushiftl_hi
,
357 OTI_vec_widen_ushiftl_lo
,
358 OTI_vec_widen_sshiftl_hi
,
359 OTI_vec_widen_sshiftl_lo
,
360 /* Extract and widen the high/low part of a vector of signed or
361 floating point elements. */
364 /* Extract and widen the high/low part of a vector of unsigned
369 /* Extract, convert to floating point and widen the high/low part of
370 a vector of signed or unsigned integer elements. */
371 OTI_vec_unpacks_float_hi
,
372 OTI_vec_unpacks_float_lo
,
373 OTI_vec_unpacku_float_hi
,
374 OTI_vec_unpacku_float_lo
,
376 /* Narrow (demote) and merge the elements of two vectors. */
381 /* Convert to signed/unsigned integer, narrow and merge elements
382 of two vectors of floating point elements. */
383 OTI_vec_pack_sfix_trunc
,
384 OTI_vec_pack_ufix_trunc
,
386 /* Perform a raise to the power of integer. */
392 #define ssadd_optab (&optab_table[OTI_ssadd])
393 #define usadd_optab (&optab_table[OTI_usadd])
394 #define sssub_optab (&optab_table[OTI_sssub])
395 #define ussub_optab (&optab_table[OTI_ussub])
396 #define ssmul_optab (&optab_table[OTI_ssmul])
397 #define usmul_optab (&optab_table[OTI_usmul])
398 #define ssdiv_optab (&optab_table[OTI_ssdiv])
399 #define usdiv_optab (&optab_table[OTI_usdiv])
400 #define ssneg_optab (&optab_table[OTI_ssneg])
401 #define usneg_optab (&optab_table[OTI_usneg])
402 #define ssashl_optab (&optab_table[OTI_ssashl])
403 #define usashl_optab (&optab_table[OTI_usashl])
405 #define add_optab (&optab_table[OTI_add])
406 #define sub_optab (&optab_table[OTI_sub])
407 #define smul_optab (&optab_table[OTI_smul])
408 #define addv_optab (&optab_table[OTI_addv])
409 #define subv_optab (&optab_table[OTI_subv])
410 #define smul_highpart_optab (&optab_table[OTI_smul_highpart])
411 #define umul_highpart_optab (&optab_table[OTI_umul_highpart])
412 #define smul_widen_optab (&optab_table[OTI_smul_widen])
413 #define umul_widen_optab (&optab_table[OTI_umul_widen])
414 #define usmul_widen_optab (&optab_table[OTI_usmul_widen])
415 #define smadd_widen_optab (&optab_table[OTI_smadd_widen])
416 #define umadd_widen_optab (&optab_table[OTI_umadd_widen])
417 #define ssmadd_widen_optab (&optab_table[OTI_ssmadd_widen])
418 #define usmadd_widen_optab (&optab_table[OTI_usmadd_widen])
419 #define smsub_widen_optab (&optab_table[OTI_smsub_widen])
420 #define umsub_widen_optab (&optab_table[OTI_umsub_widen])
421 #define ssmsub_widen_optab (&optab_table[OTI_ssmsub_widen])
422 #define usmsub_widen_optab (&optab_table[OTI_usmsub_widen])
423 #define sdiv_optab (&optab_table[OTI_sdiv])
424 #define smulv_optab (&optab_table[OTI_smulv])
425 #define sdivv_optab (&optab_table[OTI_sdivv])
426 #define sdivmod_optab (&optab_table[OTI_sdivmod])
427 #define udiv_optab (&optab_table[OTI_udiv])
428 #define udivmod_optab (&optab_table[OTI_udivmod])
429 #define smod_optab (&optab_table[OTI_smod])
430 #define umod_optab (&optab_table[OTI_umod])
431 #define fmod_optab (&optab_table[OTI_fmod])
432 #define remainder_optab (&optab_table[OTI_remainder])
433 #define ftrunc_optab (&optab_table[OTI_ftrunc])
434 #define and_optab (&optab_table[OTI_and])
435 #define ior_optab (&optab_table[OTI_ior])
436 #define xor_optab (&optab_table[OTI_xor])
437 #define ashl_optab (&optab_table[OTI_ashl])
438 #define lshr_optab (&optab_table[OTI_lshr])
439 #define ashr_optab (&optab_table[OTI_ashr])
440 #define rotl_optab (&optab_table[OTI_rotl])
441 #define rotr_optab (&optab_table[OTI_rotr])
442 #define vashl_optab (&optab_table[OTI_vashl])
443 #define vlshr_optab (&optab_table[OTI_vlshr])
444 #define vashr_optab (&optab_table[OTI_vashr])
445 #define vrotl_optab (&optab_table[OTI_vrotl])
446 #define vrotr_optab (&optab_table[OTI_vrotr])
447 #define smin_optab (&optab_table[OTI_smin])
448 #define smax_optab (&optab_table[OTI_smax])
449 #define umin_optab (&optab_table[OTI_umin])
450 #define umax_optab (&optab_table[OTI_umax])
451 #define pow_optab (&optab_table[OTI_pow])
452 #define atan2_optab (&optab_table[OTI_atan2])
453 #define fma_optab (&optab_table[OTI_fma])
454 #define fms_optab (&optab_table[OTI_fms])
455 #define fnma_optab (&optab_table[OTI_fnma])
456 #define fnms_optab (&optab_table[OTI_fnms])
458 #define mov_optab (&optab_table[OTI_mov])
459 #define movstrict_optab (&optab_table[OTI_movstrict])
460 #define movmisalign_optab (&optab_table[OTI_movmisalign])
461 #define storent_optab (&optab_table[OTI_storent])
463 #define neg_optab (&optab_table[OTI_neg])
464 #define negv_optab (&optab_table[OTI_negv])
465 #define abs_optab (&optab_table[OTI_abs])
466 #define absv_optab (&optab_table[OTI_absv])
467 #define one_cmpl_optab (&optab_table[OTI_one_cmpl])
468 #define bswap_optab (&optab_table[OTI_bswap])
469 #define ffs_optab (&optab_table[OTI_ffs])
470 #define clz_optab (&optab_table[OTI_clz])
471 #define ctz_optab (&optab_table[OTI_ctz])
472 #define clrsb_optab (&optab_table[OTI_clrsb])
473 #define popcount_optab (&optab_table[OTI_popcount])
474 #define parity_optab (&optab_table[OTI_parity])
475 #define sqrt_optab (&optab_table[OTI_sqrt])
476 #define sincos_optab (&optab_table[OTI_sincos])
477 #define sin_optab (&optab_table[OTI_sin])
478 #define asin_optab (&optab_table[OTI_asin])
479 #define cos_optab (&optab_table[OTI_cos])
480 #define acos_optab (&optab_table[OTI_acos])
481 #define exp_optab (&optab_table[OTI_exp])
482 #define exp10_optab (&optab_table[OTI_exp10])
483 #define exp2_optab (&optab_table[OTI_exp2])
484 #define expm1_optab (&optab_table[OTI_expm1])
485 #define ldexp_optab (&optab_table[OTI_ldexp])
486 #define scalb_optab (&optab_table[OTI_scalb])
487 #define significand_optab (&optab_table[OTI_significand])
488 #define logb_optab (&optab_table[OTI_logb])
489 #define ilogb_optab (&optab_table[OTI_ilogb])
490 #define log_optab (&optab_table[OTI_log])
491 #define log10_optab (&optab_table[OTI_log10])
492 #define log2_optab (&optab_table[OTI_log2])
493 #define log1p_optab (&optab_table[OTI_log1p])
494 #define floor_optab (&optab_table[OTI_floor])
495 #define ceil_optab (&optab_table[OTI_ceil])
496 #define btrunc_optab (&optab_table[OTI_btrunc])
497 #define round_optab (&optab_table[OTI_round])
498 #define nearbyint_optab (&optab_table[OTI_nearbyint])
499 #define rint_optab (&optab_table[OTI_rint])
500 #define tan_optab (&optab_table[OTI_tan])
501 #define atan_optab (&optab_table[OTI_atan])
502 #define copysign_optab (&optab_table[OTI_copysign])
503 #define signbit_optab (&optab_table[OTI_signbit])
504 #define isinf_optab (&optab_table[OTI_isinf])
506 #define cmp_optab (&optab_table[OTI_cmp])
507 #define ucmp_optab (&optab_table[OTI_ucmp])
509 #define eq_optab (&optab_table[OTI_eq])
510 #define ne_optab (&optab_table[OTI_ne])
511 #define gt_optab (&optab_table[OTI_gt])
512 #define ge_optab (&optab_table[OTI_ge])
513 #define lt_optab (&optab_table[OTI_lt])
514 #define le_optab (&optab_table[OTI_le])
515 #define unord_optab (&optab_table[OTI_unord])
517 #define strlen_optab (&optab_table[OTI_strlen])
519 #define cbranch_optab (&optab_table[OTI_cbranch])
520 #define cmov_optab (&optab_table[OTI_cmov])
521 #define cstore_optab (&optab_table[OTI_cstore])
522 #define ctrap_optab (&optab_table[OTI_ctrap])
524 #define push_optab (&optab_table[OTI_push])
525 #define addcc_optab (&optab_table[OTI_addcc])
527 #define reduc_smax_optab (&optab_table[OTI_reduc_smax])
528 #define reduc_umax_optab (&optab_table[OTI_reduc_umax])
529 #define reduc_smin_optab (&optab_table[OTI_reduc_smin])
530 #define reduc_umin_optab (&optab_table[OTI_reduc_umin])
531 #define reduc_splus_optab (&optab_table[OTI_reduc_splus])
532 #define reduc_uplus_optab (&optab_table[OTI_reduc_uplus])
534 #define ssum_widen_optab (&optab_table[OTI_ssum_widen])
535 #define usum_widen_optab (&optab_table[OTI_usum_widen])
536 #define sdot_prod_optab (&optab_table[OTI_sdot_prod])
537 #define udot_prod_optab (&optab_table[OTI_udot_prod])
539 #define vec_set_optab (&optab_table[OTI_vec_set])
540 #define vec_extract_optab (&optab_table[OTI_vec_extract])
541 #define vec_extract_even_optab (&optab_table[OTI_vec_extract_even])
542 #define vec_extract_odd_optab (&optab_table[OTI_vec_extract_odd])
543 #define vec_interleave_high_optab (&optab_table[OTI_vec_interleave_high])
544 #define vec_interleave_low_optab (&optab_table[OTI_vec_interleave_low])
545 #define vec_init_optab (&optab_table[OTI_vec_init])
546 #define vec_shl_optab (&optab_table[OTI_vec_shl])
547 #define vec_shr_optab (&optab_table[OTI_vec_shr])
548 #define vec_realign_load_optab (&optab_table[OTI_vec_realign_load])
549 #define vec_widen_umult_hi_optab (&optab_table[OTI_vec_widen_umult_hi])
550 #define vec_widen_umult_lo_optab (&optab_table[OTI_vec_widen_umult_lo])
551 #define vec_widen_smult_hi_optab (&optab_table[OTI_vec_widen_smult_hi])
552 #define vec_widen_smult_lo_optab (&optab_table[OTI_vec_widen_smult_lo])
553 #define vec_widen_ushiftl_hi_optab (&optab_table[OTI_vec_widen_ushiftl_hi])
554 #define vec_widen_ushiftl_lo_optab (&optab_table[OTI_vec_widen_ushiftl_lo])
555 #define vec_widen_sshiftl_hi_optab (&optab_table[OTI_vec_widen_sshiftl_hi])
556 #define vec_widen_sshiftl_lo_optab (&optab_table[OTI_vec_widen_sshiftl_lo])
557 #define vec_unpacks_hi_optab (&optab_table[OTI_vec_unpacks_hi])
558 #define vec_unpacks_lo_optab (&optab_table[OTI_vec_unpacks_lo])
559 #define vec_unpacku_hi_optab (&optab_table[OTI_vec_unpacku_hi])
560 #define vec_unpacku_lo_optab (&optab_table[OTI_vec_unpacku_lo])
561 #define vec_unpacks_float_hi_optab (&optab_table[OTI_vec_unpacks_float_hi])
562 #define vec_unpacks_float_lo_optab (&optab_table[OTI_vec_unpacks_float_lo])
563 #define vec_unpacku_float_hi_optab (&optab_table[OTI_vec_unpacku_float_hi])
564 #define vec_unpacku_float_lo_optab (&optab_table[OTI_vec_unpacku_float_lo])
565 #define vec_pack_trunc_optab (&optab_table[OTI_vec_pack_trunc])
566 #define vec_pack_ssat_optab (&optab_table[OTI_vec_pack_ssat])
567 #define vec_pack_usat_optab (&optab_table[OTI_vec_pack_usat])
568 #define vec_pack_sfix_trunc_optab (&optab_table[OTI_vec_pack_sfix_trunc])
569 #define vec_pack_ufix_trunc_optab (&optab_table[OTI_vec_pack_ufix_trunc])
571 #define powi_optab (&optab_table[OTI_powi])
573 /* Conversion optabs have their own table and indexes. */
574 enum convert_optab_index
602 /* Vector conditional operations. */
609 #define sext_optab (&convert_optab_table[COI_sext])
610 #define zext_optab (&convert_optab_table[COI_zext])
611 #define trunc_optab (&convert_optab_table[COI_trunc])
612 #define sfix_optab (&convert_optab_table[COI_sfix])
613 #define ufix_optab (&convert_optab_table[COI_ufix])
614 #define sfixtrunc_optab (&convert_optab_table[COI_sfixtrunc])
615 #define ufixtrunc_optab (&convert_optab_table[COI_ufixtrunc])
616 #define sfloat_optab (&convert_optab_table[COI_sfloat])
617 #define ufloat_optab (&convert_optab_table[COI_ufloat])
618 #define lrint_optab (&convert_optab_table[COI_lrint])
619 #define lround_optab (&convert_optab_table[COI_lround])
620 #define lfloor_optab (&convert_optab_table[COI_lfloor])
621 #define lceil_optab (&convert_optab_table[COI_lceil])
622 #define fract_optab (&convert_optab_table[COI_fract])
623 #define fractuns_optab (&convert_optab_table[COI_fractuns])
624 #define satfract_optab (&convert_optab_table[COI_satfract])
625 #define satfractuns_optab (&convert_optab_table[COI_satfractuns])
626 #define vec_load_lanes_optab (&convert_optab_table[COI_vec_load_lanes])
627 #define vec_store_lanes_optab (&convert_optab_table[COI_vec_store_lanes])
628 #define vcond_optab (&convert_optab_table[(int) COI_vcond])
629 #define vcondu_optab (&convert_optab_table[(int) COI_vcondu])
631 /* Contains the optab used for each rtx code. */
632 extern optab code_to_optab
[NUM_RTX_CODE
+ 1];
635 typedef rtx (*rtxfun
) (rtx
);
637 /* Enumerates operations that have a named .md pattern associated
638 with them, but which are not implemented as library functions. */
639 enum direct_optab_index
641 #ifdef HAVE_conditional_move
642 /* Conditional move operations. */
646 /* Operations that use a scratch register to perform input and output
647 reloads of special objects. */
651 /* Block move operation. */
654 /* Block set operation. */
657 /* Various types of block compare operation. */
662 /* Synchronization primitives. This first set is atomic operation for
663 which we don't care about the resulting value. */
671 /* This second set is atomic operations in which we return the value
672 that existed in memory before the operation. */
680 /* This third set is atomic operations in which we return the value
681 that resulted after performing the operation. */
689 /* Atomic compare and swap. */
690 DOI_sync_compare_and_swap
,
692 /* Atomic exchange with acquire semantics. */
693 DOI_sync_lock_test_and_set
,
695 /* Atomic clear with release semantics. */
696 DOI_sync_lock_release
,
698 /* Vector permutation. */
705 /* A structure that says which insn should be used to perform an operation
706 in a particular mode. */
707 struct direct_optab_d
709 struct optab_handlers handlers
[NUM_MACHINE_MODES
];
711 typedef struct direct_optab_d
*direct_optab
;
713 #ifdef HAVE_conditional_move
714 #define movcc_optab (&direct_optab_table[(int) DOI_movcc])
716 #define reload_in_optab (&direct_optab_table[(int) DOI_reload_in])
717 #define reload_out_optab (&direct_optab_table[(int) DOI_reload_out])
718 #define movmem_optab (&direct_optab_table[(int) DOI_movmem])
719 #define setmem_optab (&direct_optab_table[(int) DOI_setmem])
720 #define cmpstr_optab (&direct_optab_table[(int) DOI_cmpstr])
721 #define cmpstrn_optab (&direct_optab_table[(int) DOI_cmpstrn])
722 #define cmpmem_optab (&direct_optab_table[(int) DOI_cmpmem])
723 #define sync_add_optab (&direct_optab_table[(int) DOI_sync_add])
724 #define sync_sub_optab (&direct_optab_table[(int) DOI_sync_sub])
725 #define sync_ior_optab (&direct_optab_table[(int) DOI_sync_ior])
726 #define sync_and_optab (&direct_optab_table[(int) DOI_sync_and])
727 #define sync_xor_optab (&direct_optab_table[(int) DOI_sync_xor])
728 #define sync_nand_optab (&direct_optab_table[(int) DOI_sync_nand])
729 #define sync_old_add_optab (&direct_optab_table[(int) DOI_sync_old_add])
730 #define sync_old_sub_optab (&direct_optab_table[(int) DOI_sync_old_sub])
731 #define sync_old_ior_optab (&direct_optab_table[(int) DOI_sync_old_ior])
732 #define sync_old_and_optab (&direct_optab_table[(int) DOI_sync_old_and])
733 #define sync_old_xor_optab (&direct_optab_table[(int) DOI_sync_old_xor])
734 #define sync_old_nand_optab (&direct_optab_table[(int) DOI_sync_old_nand])
735 #define sync_new_add_optab (&direct_optab_table[(int) DOI_sync_new_add])
736 #define sync_new_sub_optab (&direct_optab_table[(int) DOI_sync_new_sub])
737 #define sync_new_ior_optab (&direct_optab_table[(int) DOI_sync_new_ior])
738 #define sync_new_and_optab (&direct_optab_table[(int) DOI_sync_new_and])
739 #define sync_new_xor_optab (&direct_optab_table[(int) DOI_sync_new_xor])
740 #define sync_new_nand_optab (&direct_optab_table[(int) DOI_sync_new_nand])
741 #define sync_compare_and_swap_optab \
742 (&direct_optab_table[(int) DOI_sync_compare_and_swap])
743 #define sync_lock_test_and_set_optab \
744 (&direct_optab_table[(int) DOI_sync_lock_test_and_set])
745 #define sync_lock_release_optab \
746 (&direct_optab_table[(int) DOI_sync_lock_release])
747 #define vec_perm_optab (&direct_optab_table[DOI_vec_perm])
748 #define vec_perm_const_optab (&direct_optab_table[(int) DOI_vec_perm_const])
750 /* Target-dependent globals. */
751 struct target_optabs
{
752 /* Tables of patterns that may have an associated libcall. */
753 struct optab_d x_optab_table
[(int) OTI_MAX
];
755 /* Tables of patterns for converting one mode to another. */
756 struct convert_optab_d x_convert_optab_table
[(int) COI_MAX
];
758 /* Tables of patterns for direct optabs (i.e. those which cannot be
759 implemented using a libcall). */
760 struct direct_optab_d x_direct_optab_table
[(int) DOI_MAX
];
763 extern struct target_optabs default_target_optabs
;
764 #if SWITCHABLE_TARGET
765 extern struct target_optabs
*this_target_optabs
;
767 #define this_target_optabs (&default_target_optabs)
770 #define optab_table \
771 (this_target_optabs->x_optab_table)
772 #define convert_optab_table \
773 (this_target_optabs->x_convert_optab_table)
774 #define direct_optab_table \
775 (this_target_optabs->x_direct_optab_table)
777 /* Define functions given in optabs.c. */
779 extern rtx
expand_widen_pattern_expr (sepops ops
, rtx op0
, rtx op1
, rtx wide_op
,
780 rtx target
, int unsignedp
);
782 extern rtx
expand_ternary_op (enum machine_mode mode
, optab ternary_optab
,
783 rtx op0
, rtx op1
, rtx op2
, rtx target
,
786 /* Expand a binary operation given optab and rtx operands. */
787 extern rtx
expand_binop (enum machine_mode
, optab
, rtx
, rtx
, rtx
, int,
790 extern bool force_expand_binop (enum machine_mode
, optab
, rtx
, rtx
, rtx
, int,
793 /* Expand a binary operation with both signed and unsigned forms. */
794 extern rtx
sign_expand_binop (enum machine_mode
, optab
, optab
, rtx
, rtx
,
795 rtx
, int, enum optab_methods
);
797 /* Generate code to perform an operation on one operand with two results. */
798 extern int expand_twoval_unop (optab
, rtx
, rtx
, rtx
, int);
800 /* Generate code to perform an operation on two operands with two results. */
801 extern int expand_twoval_binop (optab
, rtx
, rtx
, rtx
, rtx
, int);
803 /* Generate code to perform an operation on two operands with two
804 results, using a library function. */
805 extern bool expand_twoval_binop_libfunc (optab
, rtx
, rtx
, rtx
, rtx
,
808 /* Expand a unary arithmetic operation given optab rtx operand. */
809 extern rtx
expand_unop (enum machine_mode
, optab
, rtx
, rtx
, int);
811 /* Expand the absolute value operation. */
812 extern rtx
expand_abs_nojump (enum machine_mode
, rtx
, rtx
, int);
813 extern rtx
expand_abs (enum machine_mode
, rtx
, rtx
, int, int);
815 /* Expand the one's complement absolute value operation. */
816 extern rtx
expand_one_cmpl_abs_nojump (enum machine_mode
, rtx
, rtx
);
818 /* Expand the copysign operation. */
819 extern rtx
expand_copysign (rtx
, rtx
, rtx
);
821 /* Generate an instruction with a given INSN_CODE with an output and
823 extern void emit_unop_insn (enum insn_code
, rtx
, rtx
, enum rtx_code
);
824 extern bool maybe_emit_unop_insn (enum insn_code
, rtx
, rtx
, enum rtx_code
);
826 /* Find a widening optab even if it doesn't widen as much as we want. */
827 #define find_widening_optab_handler(A,B,C,D) \
828 find_widening_optab_handler_and_mode (A, B, C, D, NULL)
829 extern enum insn_code
find_widening_optab_handler_and_mode (optab
,
833 enum machine_mode
*);
835 /* An extra flag to control optab_for_tree_code's behavior. This is needed to
836 distinguish between machines with a vector shift that takes a scalar for the
837 shift amount vs. machines that take a vector for the shift amount. */
845 /* Return the optab used for computing the given operation on the type given by
846 the second argument. The third argument distinguishes between the types of
847 vector shifts and rotates */
848 extern optab
optab_for_tree_code (enum tree_code
, const_tree
, enum optab_subtype
);
850 /* The various uses that a comparison can have; used by can_compare_p:
851 jumps, conditional moves, store flag operations. */
852 enum can_compare_purpose
859 /* Nonzero if a compare of mode MODE can be done straightforwardly
860 (without splitting it into pieces). */
861 extern int can_compare_p (enum rtx_code
, enum machine_mode
,
862 enum can_compare_purpose
);
864 /* Return the INSN_CODE to use for an extend operation. */
865 extern enum insn_code
can_extend_p (enum machine_mode
, enum machine_mode
, int);
867 /* Generate the body of an insn to extend Y (with mode MFROM)
868 into X (with mode MTO). Do zero-extension if UNSIGNEDP is nonzero. */
869 extern rtx
gen_extend_insn (rtx
, rtx
, enum machine_mode
,
870 enum machine_mode
, int);
872 /* Call this to reset the function entry for one optab. */
873 extern void set_optab_libfunc (optab
, enum machine_mode
, const char *);
874 extern void set_conv_libfunc (convert_optab
, enum machine_mode
,
875 enum machine_mode
, const char *);
877 /* Generate code for a FIXED_CONVERT_EXPR. */
878 extern void expand_fixed_convert (rtx
, rtx
, int, int);
880 /* Generate code for a FLOAT_EXPR. */
881 extern void expand_float (rtx
, rtx
, int);
883 /* Return the insn_code for a FLOAT_EXPR. */
884 enum insn_code
can_float_p (enum machine_mode
, enum machine_mode
, int);
886 /* Check whether an operation represented by the code CODE is a
887 convert operation that is supported by the target platform in
889 bool supportable_convert_operation (enum tree_code
, tree
, tree
, tree
*,
892 /* Generate code for a FIX_EXPR. */
893 extern void expand_fix (rtx
, rtx
, int);
895 /* Generate code for float to integral conversion. */
896 extern bool expand_sfix_optab (rtx
, rtx
, convert_optab
);
898 /* Generate code for a widening multiply. */
899 extern rtx
expand_widening_mult (enum machine_mode
, rtx
, rtx
, rtx
, int, optab
);
901 /* Return tree if target supports vector operations for COND_EXPR. */
902 bool expand_vec_cond_expr_p (tree
, tree
);
904 /* Generate code for VEC_COND_EXPR. */
905 extern rtx
expand_vec_cond_expr (tree
, tree
, tree
, tree
, rtx
);
906 /* Generate code for VEC_LSHIFT_EXPR and VEC_RSHIFT_EXPR. */
907 extern rtx
expand_vec_shift_expr (sepops
, rtx
);
909 /* Return tree if target supports vector operations for VEC_PERM_EXPR. */
910 extern bool can_vec_perm_p (enum machine_mode
, bool, const unsigned char *);
912 /* Return true if target supports vector operations using VEC_PERM_EXPR. */
913 extern bool can_vec_perm_for_code_p (enum tree_code
, enum machine_mode
, rtx
*);
915 /* Generate code for VEC_PERM_EXPR. */
916 extern rtx
expand_vec_perm (enum machine_mode
, rtx
, rtx
, rtx
, rtx
);
918 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
919 if the target does not have such an insn. */
921 static inline enum insn_code
922 optab_handler (optab op
, enum machine_mode mode
)
924 return (enum insn_code
) (op
->handlers
[(int) mode
].insn_code
925 + (int) CODE_FOR_nothing
);
928 /* Like optab_handler, but for widening_operations that have a TO_MODE and
931 static inline enum insn_code
932 widening_optab_handler (optab op
, enum machine_mode to_mode
,
933 enum machine_mode from_mode
)
935 if (to_mode
== from_mode
|| from_mode
== VOIDmode
)
936 return optab_handler (op
, to_mode
);
939 return (enum insn_code
) (op
->widening
->handlers
[(int) to_mode
][(int) from_mode
].insn_code
940 + (int) CODE_FOR_nothing
);
942 return CODE_FOR_nothing
;
945 /* Record that insn CODE should be used to implement mode MODE of OP. */
948 set_optab_handler (optab op
, enum machine_mode mode
, enum insn_code code
)
950 op
->handlers
[(int) mode
].insn_code
= (int) code
- (int) CODE_FOR_nothing
;
953 /* Like set_optab_handler, but for widening operations that have a TO_MODE
957 set_widening_optab_handler (optab op
, enum machine_mode to_mode
,
958 enum machine_mode from_mode
, enum insn_code code
)
960 if (to_mode
== from_mode
)
961 set_optab_handler (op
, to_mode
, code
);
964 if (op
->widening
== NULL
)
965 op
->widening
= (struct widening_optab_handlers
*)
966 xcalloc (1, sizeof (struct widening_optab_handlers
));
968 op
->widening
->handlers
[(int) to_mode
][(int) from_mode
].insn_code
969 = (int) code
- (int) CODE_FOR_nothing
;
973 /* Return the insn used to perform conversion OP from mode FROM_MODE
974 to mode TO_MODE; return CODE_FOR_nothing if the target does not have
977 static inline enum insn_code
978 convert_optab_handler (convert_optab op
, enum machine_mode to_mode
,
979 enum machine_mode from_mode
)
981 return ((enum insn_code
)
982 (op
->handlers
[(int) to_mode
][(int) from_mode
].insn_code
983 + (int) CODE_FOR_nothing
));
986 /* Record that insn CODE should be used to perform conversion OP
987 from mode FROM_MODE to mode TO_MODE. */
990 set_convert_optab_handler (convert_optab op
, enum machine_mode to_mode
,
991 enum machine_mode from_mode
, enum insn_code code
)
993 op
->handlers
[(int) to_mode
][(int) from_mode
].insn_code
994 = (int) code
- (int) CODE_FOR_nothing
;
997 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
998 if the target does not have such an insn. */
1000 static inline enum insn_code
1001 direct_optab_handler (direct_optab op
, enum machine_mode mode
)
1003 return (enum insn_code
) (op
->handlers
[(int) mode
].insn_code
1004 + (int) CODE_FOR_nothing
);
1007 /* Record that insn CODE should be used to implement mode MODE of OP. */
1010 set_direct_optab_handler (direct_optab op
, enum machine_mode mode
,
1011 enum insn_code code
)
1013 op
->handlers
[(int) mode
].insn_code
= (int) code
- (int) CODE_FOR_nothing
;
1016 extern rtx
optab_libfunc (optab optab
, enum machine_mode mode
);
1017 extern rtx
convert_optab_libfunc (convert_optab optab
, enum machine_mode mode1
,
1018 enum machine_mode mode2
);
1020 extern bool insn_operand_matches (enum insn_code icode
, unsigned int opno
,
1023 /* Describes the type of an expand_operand. Each value is associated
1024 with a create_*_operand function; see the comments above those
1025 functions for details. */
1026 enum expand_operand_type
{
1031 EXPAND_CONVERT_FROM
,
1036 /* Information about an operand for instruction expansion. */
1037 struct expand_operand
{
1038 /* The type of operand. */
1039 ENUM_BITFIELD (expand_operand_type
) type
: 8;
1041 /* True if any conversion should treat VALUE as being unsigned
1042 rather than signed. Only meaningful for certain types. */
1043 unsigned int unsigned_p
: 1;
1045 /* Unused; available for future use. */
1046 unsigned int unused
: 7;
1048 /* The mode passed to the convert_*_operand function. It has a
1049 type-dependent meaning. */
1050 ENUM_BITFIELD (machine_mode
) mode
: 16;
1052 /* The value of the operand. */
1056 /* Initialize OP with the given fields. Initialise the other fields
1057 to their default values. */
1060 create_expand_operand (struct expand_operand
*op
,
1061 enum expand_operand_type type
,
1062 rtx value
, enum machine_mode mode
,
1066 op
->unsigned_p
= unsigned_p
;
1072 /* Make OP describe an operand that must use rtx X, even if X is volatile. */
1075 create_fixed_operand (struct expand_operand
*op
, rtx x
)
1077 create_expand_operand (op
, EXPAND_FIXED
, x
, VOIDmode
, false);
1080 /* Make OP describe an output operand that must have mode MODE.
1081 X, if nonnull, is a suggestion for where the output should be stored.
1082 It is OK for VALUE to be inconsistent with MODE, although it will just
1083 be ignored in that case. */
1086 create_output_operand (struct expand_operand
*op
, rtx x
,
1087 enum machine_mode mode
)
1089 create_expand_operand (op
, EXPAND_OUTPUT
, x
, mode
, false);
1092 /* Make OP describe an input operand that must have mode MODE and
1093 value VALUE; MODE cannot be VOIDmode. The backend may request that
1094 VALUE be copied into a different kind of rtx before being passed
1098 create_input_operand (struct expand_operand
*op
, rtx value
,
1099 enum machine_mode mode
)
1101 create_expand_operand (op
, EXPAND_INPUT
, value
, mode
, false);
1104 /* Like create_input_operand, except that VALUE must first be converted
1105 to mode MODE. UNSIGNED_P says whether VALUE is unsigned. */
1108 create_convert_operand_to (struct expand_operand
*op
, rtx value
,
1109 enum machine_mode mode
, bool unsigned_p
)
1111 create_expand_operand (op
, EXPAND_CONVERT_TO
, value
, mode
, unsigned_p
);
1114 /* Make OP describe an input operand that should have the same value
1115 as VALUE, after any mode conversion that the backend might request.
1116 If VALUE is a CONST_INT, it should be treated as having mode MODE.
1117 UNSIGNED_P says whether VALUE is unsigned. */
1120 create_convert_operand_from (struct expand_operand
*op
, rtx value
,
1121 enum machine_mode mode
, bool unsigned_p
)
1123 create_expand_operand (op
, EXPAND_CONVERT_FROM
, value
, mode
, unsigned_p
);
1126 extern void create_convert_operand_from_type (struct expand_operand
*op
,
1127 rtx value
, tree type
);
1129 /* Make OP describe an input Pmode address operand. VALUE is the value
1130 of the address, but it may need to be converted to Pmode first. */
1133 create_address_operand (struct expand_operand
*op
, rtx value
)
1135 create_expand_operand (op
, EXPAND_ADDRESS
, value
, Pmode
, false);
1138 /* Make OP describe an input operand that has value INTVAL and that has
1139 no inherent mode. This function should only be used for operands that
1140 are always expand-time constants. The backend may request that INTVAL
1141 be copied into a different kind of rtx, but it must specify the mode
1142 of that rtx if so. */
1145 create_integer_operand (struct expand_operand
*op
, HOST_WIDE_INT intval
)
1147 create_expand_operand (op
, EXPAND_INTEGER
, GEN_INT (intval
), VOIDmode
, false);
1150 extern bool valid_multiword_target_p (rtx
);
1152 extern bool maybe_legitimize_operands (enum insn_code icode
,
1153 unsigned int opno
, unsigned int nops
,
1154 struct expand_operand
*ops
);
1155 extern rtx
maybe_gen_insn (enum insn_code icode
, unsigned int nops
,
1156 struct expand_operand
*ops
);
1157 extern bool maybe_expand_insn (enum insn_code icode
, unsigned int nops
,
1158 struct expand_operand
*ops
);
1159 extern bool maybe_expand_jump_insn (enum insn_code icode
, unsigned int nops
,
1160 struct expand_operand
*ops
);
1161 extern void expand_insn (enum insn_code icode
, unsigned int nops
,
1162 struct expand_operand
*ops
);
1163 extern void expand_jump_insn (enum insn_code icode
, unsigned int nops
,
1164 struct expand_operand
*ops
);
1166 extern rtx
prepare_operand (enum insn_code
, rtx
, int, enum machine_mode
,
1167 enum machine_mode
, int);
1169 #endif /* GCC_OPTABS_H */