1 /* Definitions for code generation pass of GNU compiler.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
3 2010, 2012 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 insn_code slot is the enum insn_code that says how to
33 generate an insn for this operation on a particular machine mode.
34 It is CODE_FOR_nothing if there is no such insn on the target machine.
36 The `lib_call' slot is the name of the library function that
37 can be used to perform the operation.
39 A few optabs, such as move_optab, are used by special code. */
43 enum insn_code insn_code
;
46 struct widening_optab_handlers
48 struct optab_handlers handlers
[NUM_MACHINE_MODES
][NUM_MACHINE_MODES
];
55 const char *libcall_basename
;
56 void (*libcall_gen
)(struct optab_d
*, const char *name
, char suffix
,
58 struct optab_handlers handlers
[NUM_MACHINE_MODES
];
59 struct widening_optab_handlers
*widening
;
61 typedef struct optab_d
* optab
;
63 /* A convert_optab is for some sort of conversion operation between
64 modes. The first array index is the destination mode, the second
65 is the source mode. */
66 struct convert_optab_d
69 const char *libcall_basename
;
70 void (*libcall_gen
)(struct convert_optab_d
*, const char *name
,
73 struct optab_handlers handlers
[NUM_MACHINE_MODES
][NUM_MACHINE_MODES
];
75 typedef struct convert_optab_d
*convert_optab
;
77 /* Given an enum insn_code, access the function to construct
78 the body of that kind of insn. */
79 #define GEN_FCN(CODE) (insn_data[CODE].genfun)
81 /* Enumeration of valid indexes into optab_table. */
84 /* Fixed-point operators with signed/unsigned saturation */
103 /* Signed and fp multiply */
106 /* Signed multiply, return high word */
109 /* Signed multiply with result one machine mode wider than args */
112 /* Widening multiply of one unsigned and one signed operand. */
114 /* Signed multiply and add with the result and addend one machine mode
115 wider than the multiplicand and multiplier. */
117 /* Unsigned multiply and add with the result and addend one machine mode
118 wider than the multiplicand and multiplier. */
120 /* Signed multiply and add with the result and addend one machine mode
121 wider than the multiplicand and multiplier.
122 All involved operations are saturating. */
124 /* Unsigned multiply and add with the result and addend one machine mode
125 wider than the multiplicand and multiplier.
126 All involved operations are saturating. */
128 /* Signed multiply and subtract the result and minuend one machine mode
129 wider than the multiplicand and multiplier. */
131 /* Unsigned multiply and subtract the result and minuend one machine mode
132 wider than the multiplicand and multiplier. */
134 /* Signed multiply and subtract the result and minuend one machine mode
135 wider than the multiplicand and multiplier.
136 All involved operations are saturating. */
138 /* Unsigned multiply and subtract the result and minuend one machine mode
139 wider than the multiplicand and multiplier.
140 All involved operations are saturating. */
146 /* Signed divide-and-remainder in one */
150 /* Signed remainder */
153 /* Floating point remainder functions */
156 /* Convert float to integer in float fmt */
166 /* Arithmetic shift left */
168 /* Logical shift right */
170 /* Arithmetic shift right */
177 /* Arithmetic shift left of vector by vector */
179 /* Logical shift right of vector by vector */
181 /* Arithmetic shift right of vector by vector */
183 /* Rotate left of vector by vector */
185 /* Rotate right of vector by vector */
188 /* Signed and floating-point minimum value */
190 /* Signed and floating-point maximum value */
192 /* Unsigned minimum value */
194 /* Unsigned maximum value */
198 /* Arc tangent of y/x */
200 /* Floating multiply/add */
206 /* Move instruction. */
208 /* Move, preserving high part of register. */
210 /* Move, with a misaligned memory. */
212 /* Nontemporal store. */
215 /* Unary operations */
226 /* Bit scanning and counting */
247 /* Base-10 Exponential */
249 /* Base-2 Exponential */
253 /* Load exponent of a floating point number */
255 /* Multiply floating-point number by integral power of radix */
257 /* Mantissa of a floating-point number */
259 /* Radix-independent exponent */
262 /* Natural Logarithm */
264 /* Base-10 Logarithm */
266 /* Base-2 Logarithm */
268 /* logarithm of 1 plus argument */
270 /* Rounding functions */
279 /* Inverse tangent */
285 /* Test for infinite value */
288 /* Compare insn; two operands. Used only for libcalls. */
292 /* Floating point comparison optabs - used primarily for libfuncs */
304 /* Combined compare & jump/move/store flags/trap operations. */
310 /* Push instruction. */
313 /* Conditional add instruction. */
316 /* Reduction operations on a vector operand. */
324 /* Summation, with result machine mode one or more wider than args. */
328 /* Dot product, with result machine mode one or more wider than args. */
332 /* Set specified field of vector operand. */
334 /* Extract specified field of vector operand. */
336 /* Initialize vector operand. */
338 /* Whole vector shift. The shift amount is in bits. */
341 /* Extract specified elements from vectors, for vector load. */
342 OTI_vec_realign_load
,
343 /* Widening multiplication.
344 The high/low part of the resulting vector of products is returned. */
345 OTI_vec_widen_umult_hi
,
346 OTI_vec_widen_umult_lo
,
347 OTI_vec_widen_smult_hi
,
348 OTI_vec_widen_smult_lo
,
349 /* Widening shift left.
350 The high/low part of the resulting vector is returned. */
351 OTI_vec_widen_ushiftl_hi
,
352 OTI_vec_widen_ushiftl_lo
,
353 OTI_vec_widen_sshiftl_hi
,
354 OTI_vec_widen_sshiftl_lo
,
355 /* Extract and widen the high/low part of a vector of signed or
356 floating point elements. */
359 /* Extract and widen the high/low part of a vector of unsigned
364 /* Extract, convert to floating point and widen the high/low part of
365 a vector of signed or unsigned integer elements. */
366 OTI_vec_unpacks_float_hi
,
367 OTI_vec_unpacks_float_lo
,
368 OTI_vec_unpacku_float_hi
,
369 OTI_vec_unpacku_float_lo
,
371 /* Narrow (demote) and merge the elements of two vectors. */
376 /* Convert to signed/unsigned integer, narrow and merge elements
377 of two vectors of floating point elements. */
378 OTI_vec_pack_sfix_trunc
,
379 OTI_vec_pack_ufix_trunc
,
381 /* Perform a raise to the power of integer. */
384 /* Atomic compare and swap. */
385 OTI_sync_compare_and_swap
,
387 /* Atomic exchange with acquire semantics. */
388 OTI_sync_lock_test_and_set
,
390 /* This second set is atomic operations in which we return the value
391 that existed in memory before the operation. */
399 /* This third set is atomic operations in which we return the value
400 that resulted after performing the operation. */
411 #define ssadd_optab (&optab_table[OTI_ssadd])
412 #define usadd_optab (&optab_table[OTI_usadd])
413 #define sssub_optab (&optab_table[OTI_sssub])
414 #define ussub_optab (&optab_table[OTI_ussub])
415 #define ssmul_optab (&optab_table[OTI_ssmul])
416 #define usmul_optab (&optab_table[OTI_usmul])
417 #define ssdiv_optab (&optab_table[OTI_ssdiv])
418 #define usdiv_optab (&optab_table[OTI_usdiv])
419 #define ssneg_optab (&optab_table[OTI_ssneg])
420 #define usneg_optab (&optab_table[OTI_usneg])
421 #define ssashl_optab (&optab_table[OTI_ssashl])
422 #define usashl_optab (&optab_table[OTI_usashl])
424 #define add_optab (&optab_table[OTI_add])
425 #define sub_optab (&optab_table[OTI_sub])
426 #define smul_optab (&optab_table[OTI_smul])
427 #define addv_optab (&optab_table[OTI_addv])
428 #define subv_optab (&optab_table[OTI_subv])
429 #define smul_highpart_optab (&optab_table[OTI_smul_highpart])
430 #define umul_highpart_optab (&optab_table[OTI_umul_highpart])
431 #define smul_widen_optab (&optab_table[OTI_smul_widen])
432 #define umul_widen_optab (&optab_table[OTI_umul_widen])
433 #define usmul_widen_optab (&optab_table[OTI_usmul_widen])
434 #define smadd_widen_optab (&optab_table[OTI_smadd_widen])
435 #define umadd_widen_optab (&optab_table[OTI_umadd_widen])
436 #define ssmadd_widen_optab (&optab_table[OTI_ssmadd_widen])
437 #define usmadd_widen_optab (&optab_table[OTI_usmadd_widen])
438 #define smsub_widen_optab (&optab_table[OTI_smsub_widen])
439 #define umsub_widen_optab (&optab_table[OTI_umsub_widen])
440 #define ssmsub_widen_optab (&optab_table[OTI_ssmsub_widen])
441 #define usmsub_widen_optab (&optab_table[OTI_usmsub_widen])
442 #define sdiv_optab (&optab_table[OTI_sdiv])
443 #define smulv_optab (&optab_table[OTI_smulv])
444 #define sdivv_optab (&optab_table[OTI_sdivv])
445 #define sdivmod_optab (&optab_table[OTI_sdivmod])
446 #define udiv_optab (&optab_table[OTI_udiv])
447 #define udivmod_optab (&optab_table[OTI_udivmod])
448 #define smod_optab (&optab_table[OTI_smod])
449 #define umod_optab (&optab_table[OTI_umod])
450 #define fmod_optab (&optab_table[OTI_fmod])
451 #define remainder_optab (&optab_table[OTI_remainder])
452 #define ftrunc_optab (&optab_table[OTI_ftrunc])
453 #define and_optab (&optab_table[OTI_and])
454 #define ior_optab (&optab_table[OTI_ior])
455 #define xor_optab (&optab_table[OTI_xor])
456 #define ashl_optab (&optab_table[OTI_ashl])
457 #define lshr_optab (&optab_table[OTI_lshr])
458 #define ashr_optab (&optab_table[OTI_ashr])
459 #define rotl_optab (&optab_table[OTI_rotl])
460 #define rotr_optab (&optab_table[OTI_rotr])
461 #define vashl_optab (&optab_table[OTI_vashl])
462 #define vlshr_optab (&optab_table[OTI_vlshr])
463 #define vashr_optab (&optab_table[OTI_vashr])
464 #define vrotl_optab (&optab_table[OTI_vrotl])
465 #define vrotr_optab (&optab_table[OTI_vrotr])
466 #define smin_optab (&optab_table[OTI_smin])
467 #define smax_optab (&optab_table[OTI_smax])
468 #define umin_optab (&optab_table[OTI_umin])
469 #define umax_optab (&optab_table[OTI_umax])
470 #define pow_optab (&optab_table[OTI_pow])
471 #define atan2_optab (&optab_table[OTI_atan2])
472 #define fma_optab (&optab_table[OTI_fma])
473 #define fms_optab (&optab_table[OTI_fms])
474 #define fnma_optab (&optab_table[OTI_fnma])
475 #define fnms_optab (&optab_table[OTI_fnms])
477 #define mov_optab (&optab_table[OTI_mov])
478 #define movstrict_optab (&optab_table[OTI_movstrict])
479 #define movmisalign_optab (&optab_table[OTI_movmisalign])
480 #define storent_optab (&optab_table[OTI_storent])
482 #define neg_optab (&optab_table[OTI_neg])
483 #define negv_optab (&optab_table[OTI_negv])
484 #define abs_optab (&optab_table[OTI_abs])
485 #define absv_optab (&optab_table[OTI_absv])
486 #define one_cmpl_optab (&optab_table[OTI_one_cmpl])
487 #define bswap_optab (&optab_table[OTI_bswap])
488 #define ffs_optab (&optab_table[OTI_ffs])
489 #define clz_optab (&optab_table[OTI_clz])
490 #define ctz_optab (&optab_table[OTI_ctz])
491 #define clrsb_optab (&optab_table[OTI_clrsb])
492 #define popcount_optab (&optab_table[OTI_popcount])
493 #define parity_optab (&optab_table[OTI_parity])
494 #define sqrt_optab (&optab_table[OTI_sqrt])
495 #define sincos_optab (&optab_table[OTI_sincos])
496 #define sin_optab (&optab_table[OTI_sin])
497 #define asin_optab (&optab_table[OTI_asin])
498 #define cos_optab (&optab_table[OTI_cos])
499 #define acos_optab (&optab_table[OTI_acos])
500 #define exp_optab (&optab_table[OTI_exp])
501 #define exp10_optab (&optab_table[OTI_exp10])
502 #define exp2_optab (&optab_table[OTI_exp2])
503 #define expm1_optab (&optab_table[OTI_expm1])
504 #define ldexp_optab (&optab_table[OTI_ldexp])
505 #define scalb_optab (&optab_table[OTI_scalb])
506 #define significand_optab (&optab_table[OTI_significand])
507 #define logb_optab (&optab_table[OTI_logb])
508 #define ilogb_optab (&optab_table[OTI_ilogb])
509 #define log_optab (&optab_table[OTI_log])
510 #define log10_optab (&optab_table[OTI_log10])
511 #define log2_optab (&optab_table[OTI_log2])
512 #define log1p_optab (&optab_table[OTI_log1p])
513 #define floor_optab (&optab_table[OTI_floor])
514 #define ceil_optab (&optab_table[OTI_ceil])
515 #define btrunc_optab (&optab_table[OTI_btrunc])
516 #define round_optab (&optab_table[OTI_round])
517 #define nearbyint_optab (&optab_table[OTI_nearbyint])
518 #define rint_optab (&optab_table[OTI_rint])
519 #define tan_optab (&optab_table[OTI_tan])
520 #define atan_optab (&optab_table[OTI_atan])
521 #define copysign_optab (&optab_table[OTI_copysign])
522 #define signbit_optab (&optab_table[OTI_signbit])
523 #define isinf_optab (&optab_table[OTI_isinf])
525 #define cmp_optab (&optab_table[OTI_cmp])
526 #define ucmp_optab (&optab_table[OTI_ucmp])
528 #define eq_optab (&optab_table[OTI_eq])
529 #define ne_optab (&optab_table[OTI_ne])
530 #define gt_optab (&optab_table[OTI_gt])
531 #define ge_optab (&optab_table[OTI_ge])
532 #define lt_optab (&optab_table[OTI_lt])
533 #define le_optab (&optab_table[OTI_le])
534 #define unord_optab (&optab_table[OTI_unord])
536 #define strlen_optab (&optab_table[OTI_strlen])
538 #define cbranch_optab (&optab_table[OTI_cbranch])
539 #define cmov_optab (&optab_table[OTI_cmov])
540 #define cstore_optab (&optab_table[OTI_cstore])
541 #define ctrap_optab (&optab_table[OTI_ctrap])
543 #define push_optab (&optab_table[OTI_push])
544 #define addcc_optab (&optab_table[OTI_addcc])
546 #define reduc_smax_optab (&optab_table[OTI_reduc_smax])
547 #define reduc_umax_optab (&optab_table[OTI_reduc_umax])
548 #define reduc_smin_optab (&optab_table[OTI_reduc_smin])
549 #define reduc_umin_optab (&optab_table[OTI_reduc_umin])
550 #define reduc_splus_optab (&optab_table[OTI_reduc_splus])
551 #define reduc_uplus_optab (&optab_table[OTI_reduc_uplus])
553 #define ssum_widen_optab (&optab_table[OTI_ssum_widen])
554 #define usum_widen_optab (&optab_table[OTI_usum_widen])
555 #define sdot_prod_optab (&optab_table[OTI_sdot_prod])
556 #define udot_prod_optab (&optab_table[OTI_udot_prod])
558 #define vec_set_optab (&optab_table[OTI_vec_set])
559 #define vec_extract_optab (&optab_table[OTI_vec_extract])
560 #define vec_init_optab (&optab_table[OTI_vec_init])
561 #define vec_shl_optab (&optab_table[OTI_vec_shl])
562 #define vec_shr_optab (&optab_table[OTI_vec_shr])
563 #define vec_realign_load_optab (&optab_table[OTI_vec_realign_load])
564 #define vec_widen_umult_hi_optab (&optab_table[OTI_vec_widen_umult_hi])
565 #define vec_widen_umult_lo_optab (&optab_table[OTI_vec_widen_umult_lo])
566 #define vec_widen_smult_hi_optab (&optab_table[OTI_vec_widen_smult_hi])
567 #define vec_widen_smult_lo_optab (&optab_table[OTI_vec_widen_smult_lo])
568 #define vec_widen_ushiftl_hi_optab (&optab_table[OTI_vec_widen_ushiftl_hi])
569 #define vec_widen_ushiftl_lo_optab (&optab_table[OTI_vec_widen_ushiftl_lo])
570 #define vec_widen_sshiftl_hi_optab (&optab_table[OTI_vec_widen_sshiftl_hi])
571 #define vec_widen_sshiftl_lo_optab (&optab_table[OTI_vec_widen_sshiftl_lo])
572 #define vec_unpacks_hi_optab (&optab_table[OTI_vec_unpacks_hi])
573 #define vec_unpacks_lo_optab (&optab_table[OTI_vec_unpacks_lo])
574 #define vec_unpacku_hi_optab (&optab_table[OTI_vec_unpacku_hi])
575 #define vec_unpacku_lo_optab (&optab_table[OTI_vec_unpacku_lo])
576 #define vec_unpacks_float_hi_optab (&optab_table[OTI_vec_unpacks_float_hi])
577 #define vec_unpacks_float_lo_optab (&optab_table[OTI_vec_unpacks_float_lo])
578 #define vec_unpacku_float_hi_optab (&optab_table[OTI_vec_unpacku_float_hi])
579 #define vec_unpacku_float_lo_optab (&optab_table[OTI_vec_unpacku_float_lo])
580 #define vec_pack_trunc_optab (&optab_table[OTI_vec_pack_trunc])
581 #define vec_pack_ssat_optab (&optab_table[OTI_vec_pack_ssat])
582 #define vec_pack_usat_optab (&optab_table[OTI_vec_pack_usat])
583 #define vec_pack_sfix_trunc_optab (&optab_table[OTI_vec_pack_sfix_trunc])
584 #define vec_pack_ufix_trunc_optab (&optab_table[OTI_vec_pack_ufix_trunc])
586 #define powi_optab (&optab_table[OTI_powi])
588 #define sync_compare_and_swap_optab \
589 (&optab_table[(int) OTI_sync_compare_and_swap])
590 #define sync_lock_test_and_set_optab \
591 (&optab_table[(int) OTI_sync_lock_test_and_set])
592 #define sync_old_add_optab (&optab_table[(int) OTI_sync_old_add])
593 #define sync_old_sub_optab (&optab_table[(int) OTI_sync_old_sub])
594 #define sync_old_ior_optab (&optab_table[(int) OTI_sync_old_ior])
595 #define sync_old_and_optab (&optab_table[(int) OTI_sync_old_and])
596 #define sync_old_xor_optab (&optab_table[(int) OTI_sync_old_xor])
597 #define sync_old_nand_optab (&optab_table[(int) OTI_sync_old_nand])
598 #define sync_new_add_optab (&optab_table[(int) OTI_sync_new_add])
599 #define sync_new_sub_optab (&optab_table[(int) OTI_sync_new_sub])
600 #define sync_new_ior_optab (&optab_table[(int) OTI_sync_new_ior])
601 #define sync_new_and_optab (&optab_table[(int) OTI_sync_new_and])
602 #define sync_new_xor_optab (&optab_table[(int) OTI_sync_new_xor])
603 #define sync_new_nand_optab (&optab_table[(int) OTI_sync_new_nand])
605 /* Conversion optabs have their own table and indexes. */
606 enum convert_optab_index
634 /* Vector conditional operations. */
641 #define sext_optab (&convert_optab_table[COI_sext])
642 #define zext_optab (&convert_optab_table[COI_zext])
643 #define trunc_optab (&convert_optab_table[COI_trunc])
644 #define sfix_optab (&convert_optab_table[COI_sfix])
645 #define ufix_optab (&convert_optab_table[COI_ufix])
646 #define sfixtrunc_optab (&convert_optab_table[COI_sfixtrunc])
647 #define ufixtrunc_optab (&convert_optab_table[COI_ufixtrunc])
648 #define sfloat_optab (&convert_optab_table[COI_sfloat])
649 #define ufloat_optab (&convert_optab_table[COI_ufloat])
650 #define lrint_optab (&convert_optab_table[COI_lrint])
651 #define lround_optab (&convert_optab_table[COI_lround])
652 #define lfloor_optab (&convert_optab_table[COI_lfloor])
653 #define lceil_optab (&convert_optab_table[COI_lceil])
654 #define fract_optab (&convert_optab_table[COI_fract])
655 #define fractuns_optab (&convert_optab_table[COI_fractuns])
656 #define satfract_optab (&convert_optab_table[COI_satfract])
657 #define satfractuns_optab (&convert_optab_table[COI_satfractuns])
658 #define vec_load_lanes_optab (&convert_optab_table[COI_vec_load_lanes])
659 #define vec_store_lanes_optab (&convert_optab_table[COI_vec_store_lanes])
660 #define vcond_optab (&convert_optab_table[(int) COI_vcond])
661 #define vcondu_optab (&convert_optab_table[(int) COI_vcondu])
663 /* Contains the optab used for each rtx code. */
664 extern optab code_to_optab
[NUM_RTX_CODE
+ 1];
667 typedef rtx (*rtxfun
) (rtx
);
669 /* Enumerates operations that have a named .md pattern associated
670 with them, but which are not implemented as library functions. */
671 enum direct_optab_index
673 #ifdef HAVE_conditional_move
674 /* Conditional move operations. */
678 /* Operations that use a scratch register to perform input and output
679 reloads of special objects. */
683 /* Block move operation. */
686 /* Block set operation. */
689 /* Various types of block compare operation. */
694 /* Atomic clear with release semantics. */
695 DOI_sync_lock_release
,
697 /* Atomic operation with no resulting value. */
705 /* Atomic operations with memory model parameters. */
707 DOI_atomic_compare_and_swap
,
710 DOI_atomic_add_fetch
,
711 DOI_atomic_sub_fetch
,
712 DOI_atomic_and_fetch
,
713 DOI_atomic_nand_fetch
,
714 DOI_atomic_xor_fetch
,
716 DOI_atomic_fetch_add
,
717 DOI_atomic_fetch_sub
,
718 DOI_atomic_fetch_and
,
719 DOI_atomic_fetch_nand
,
720 DOI_atomic_fetch_xor
,
728 DOI_atomic_always_lock_free
,
729 DOI_atomic_is_lock_free
,
730 DOI_atomic_thread_fence
,
731 DOI_atomic_signal_fence
,
733 /* Vector permutation. */
740 /* A structure that says which insn should be used to perform an operation
741 in a particular mode. */
742 struct direct_optab_d
744 struct optab_handlers handlers
[NUM_MACHINE_MODES
];
746 typedef struct direct_optab_d
*direct_optab
;
748 #ifdef HAVE_conditional_move
749 #define movcc_optab (&direct_optab_table[(int) DOI_movcc])
751 #define reload_in_optab (&direct_optab_table[(int) DOI_reload_in])
752 #define reload_out_optab (&direct_optab_table[(int) DOI_reload_out])
753 #define movmem_optab (&direct_optab_table[(int) DOI_movmem])
754 #define setmem_optab (&direct_optab_table[(int) DOI_setmem])
755 #define cmpstr_optab (&direct_optab_table[(int) DOI_cmpstr])
756 #define cmpstrn_optab (&direct_optab_table[(int) DOI_cmpstrn])
757 #define cmpmem_optab (&direct_optab_table[(int) DOI_cmpmem])
758 #define sync_lock_release_optab \
759 (&direct_optab_table[(int) DOI_sync_lock_release])
760 #define sync_add_optab (&direct_optab_table[(int) DOI_sync_add])
761 #define sync_sub_optab (&direct_optab_table[(int) DOI_sync_sub])
762 #define sync_ior_optab (&direct_optab_table[(int) DOI_sync_ior])
763 #define sync_and_optab (&direct_optab_table[(int) DOI_sync_and])
764 #define sync_xor_optab (&direct_optab_table[(int) DOI_sync_xor])
765 #define sync_nand_optab (&direct_optab_table[(int) DOI_sync_nand])
767 #define atomic_exchange_optab \
768 (&direct_optab_table[(int) DOI_atomic_exchange])
769 #define atomic_compare_and_swap_optab \
770 (&direct_optab_table[(int) DOI_atomic_compare_and_swap])
771 #define atomic_load_optab \
772 (&direct_optab_table[(int) DOI_atomic_load])
773 #define atomic_store_optab \
774 (&direct_optab_table[(int) DOI_atomic_store])
775 #define atomic_add_fetch_optab \
776 (&direct_optab_table[(int) DOI_atomic_add_fetch])
777 #define atomic_sub_fetch_optab \
778 (&direct_optab_table[(int) DOI_atomic_sub_fetch])
779 #define atomic_and_fetch_optab \
780 (&direct_optab_table[(int) DOI_atomic_and_fetch])
781 #define atomic_nand_fetch_optab \
782 (&direct_optab_table[(int) DOI_atomic_nand_fetch])
783 #define atomic_xor_fetch_optab \
784 (&direct_optab_table[(int) DOI_atomic_xor_fetch])
785 #define atomic_or_fetch_optab \
786 (&direct_optab_table[(int) DOI_atomic_or_fetch])
787 #define atomic_fetch_add_optab \
788 (&direct_optab_table[(int) DOI_atomic_fetch_add])
789 #define atomic_fetch_sub_optab \
790 (&direct_optab_table[(int) DOI_atomic_fetch_sub])
791 #define atomic_fetch_and_optab \
792 (&direct_optab_table[(int) DOI_atomic_fetch_and])
793 #define atomic_fetch_nand_optab \
794 (&direct_optab_table[(int) DOI_atomic_fetch_nand])
795 #define atomic_fetch_xor_optab \
796 (&direct_optab_table[(int) DOI_atomic_fetch_xor])
797 #define atomic_fetch_or_optab \
798 (&direct_optab_table[(int) DOI_atomic_fetch_or])
799 #define atomic_add_optab \
800 (&direct_optab_table[(int) DOI_atomic_add])
801 #define atomic_sub_optab \
802 (&direct_optab_table[(int) DOI_atomic_sub])
803 #define atomic_and_optab \
804 (&direct_optab_table[(int) DOI_atomic_and])
805 #define atomic_nand_optab \
806 (&direct_optab_table[(int) DOI_atomic_nand])
807 #define atomic_xor_optab \
808 (&direct_optab_table[(int) DOI_atomic_xor])
809 #define atomic_or_optab \
810 (&direct_optab_table[(int) DOI_atomic_or])
811 #define atomic_always_lock_free_optab \
812 (&direct_optab_table[(int) DOI_atomic_always_lock_free])
813 #define atomic_is_lock_free_optab \
814 (&direct_optab_table[(int) DOI_atomic_is_lock_free])
815 #define atomic_thread_fence_optab \
816 (&direct_optab_table[(int) DOI_atomic_thread_fence])
817 #define atomic_signal_fence_optab \
818 (&direct_optab_table[(int) DOI_atomic_signal_fence])
820 #define vec_perm_optab (&direct_optab_table[DOI_vec_perm])
821 #define vec_perm_const_optab (&direct_optab_table[(int) DOI_vec_perm_const])
823 /* Target-dependent globals. */
824 struct target_optabs
{
825 /* Tables of patterns that may have an associated libcall. */
826 struct optab_d x_optab_table
[(int) OTI_MAX
];
828 /* Tables of patterns for converting one mode to another. */
829 struct convert_optab_d x_convert_optab_table
[(int) COI_MAX
];
831 /* Tables of patterns for direct optabs (i.e. those which cannot be
832 implemented using a libcall). */
833 struct direct_optab_d x_direct_optab_table
[(int) DOI_MAX
];
836 extern struct target_optabs default_target_optabs
;
837 #if SWITCHABLE_TARGET
838 extern struct target_optabs
*this_target_optabs
;
840 #define this_target_optabs (&default_target_optabs)
843 #define optab_table \
844 (this_target_optabs->x_optab_table)
845 #define convert_optab_table \
846 (this_target_optabs->x_convert_optab_table)
847 #define direct_optab_table \
848 (this_target_optabs->x_direct_optab_table)
850 /* Define functions given in optabs.c. */
852 extern rtx
expand_widen_pattern_expr (sepops ops
, rtx op0
, rtx op1
, rtx wide_op
,
853 rtx target
, int unsignedp
);
855 extern rtx
expand_ternary_op (enum machine_mode mode
, optab ternary_optab
,
856 rtx op0
, rtx op1
, rtx op2
, rtx target
,
859 /* Expand a binary operation given optab and rtx operands. */
860 extern rtx
expand_binop (enum machine_mode
, optab
, rtx
, rtx
, rtx
, int,
863 extern rtx
simplify_expand_binop (enum machine_mode mode
, optab binoptab
,
864 rtx op0
, rtx op1
, rtx target
, int unsignedp
,
865 enum optab_methods methods
);
867 extern bool force_expand_binop (enum machine_mode
, optab
, rtx
, rtx
, rtx
, int,
870 /* Expand a binary operation with both signed and unsigned forms. */
871 extern rtx
sign_expand_binop (enum machine_mode
, optab
, optab
, rtx
, rtx
,
872 rtx
, int, enum optab_methods
);
874 /* Generate code to perform an operation on one operand with two results. */
875 extern int expand_twoval_unop (optab
, rtx
, rtx
, rtx
, int);
877 /* Generate code to perform an operation on two operands with two results. */
878 extern int expand_twoval_binop (optab
, rtx
, rtx
, rtx
, rtx
, int);
880 /* Generate code to perform an operation on two operands with two
881 results, using a library function. */
882 extern bool expand_twoval_binop_libfunc (optab
, rtx
, rtx
, rtx
, rtx
,
885 /* Expand a unary arithmetic operation given optab rtx operand. */
886 extern rtx
expand_unop (enum machine_mode
, optab
, rtx
, rtx
, int);
888 /* Expand the absolute value operation. */
889 extern rtx
expand_abs_nojump (enum machine_mode
, rtx
, rtx
, int);
890 extern rtx
expand_abs (enum machine_mode
, rtx
, rtx
, int, int);
892 /* Expand the one's complement absolute value operation. */
893 extern rtx
expand_one_cmpl_abs_nojump (enum machine_mode
, rtx
, rtx
);
895 /* Expand the copysign operation. */
896 extern rtx
expand_copysign (rtx
, rtx
, rtx
);
898 /* Generate an instruction with a given INSN_CODE with an output and
900 extern void emit_unop_insn (enum insn_code
, rtx
, rtx
, enum rtx_code
);
901 extern bool maybe_emit_unop_insn (enum insn_code
, rtx
, rtx
, enum rtx_code
);
903 /* Find a widening optab even if it doesn't widen as much as we want. */
904 #define find_widening_optab_handler(A,B,C,D) \
905 find_widening_optab_handler_and_mode (A, B, C, D, NULL)
906 extern enum insn_code
find_widening_optab_handler_and_mode (optab
,
910 enum machine_mode
*);
912 /* An extra flag to control optab_for_tree_code's behavior. This is needed to
913 distinguish between machines with a vector shift that takes a scalar for the
914 shift amount vs. machines that take a vector for the shift amount. */
922 /* Return the optab used for computing the given operation on the type given by
923 the second argument. The third argument distinguishes between the types of
924 vector shifts and rotates */
925 extern optab
optab_for_tree_code (enum tree_code
, const_tree
, enum optab_subtype
);
927 /* The various uses that a comparison can have; used by can_compare_p:
928 jumps, conditional moves, store flag operations. */
929 enum can_compare_purpose
936 /* Nonzero if a compare of mode MODE can be done straightforwardly
937 (without splitting it into pieces). */
938 extern int can_compare_p (enum rtx_code
, enum machine_mode
,
939 enum can_compare_purpose
);
941 /* Return the INSN_CODE to use for an extend operation. */
942 extern enum insn_code
can_extend_p (enum machine_mode
, enum machine_mode
, int);
944 /* Generate the body of an insn to extend Y (with mode MFROM)
945 into X (with mode MTO). Do zero-extension if UNSIGNEDP is nonzero. */
946 extern rtx
gen_extend_insn (rtx
, rtx
, enum machine_mode
,
947 enum machine_mode
, int);
949 /* Call this to reset the function entry for one optab. */
950 extern void set_optab_libfunc (optab
, enum machine_mode
, const char *);
951 extern void set_conv_libfunc (convert_optab
, enum machine_mode
,
952 enum machine_mode
, const char *);
954 /* Call this to install all of the __sync libcalls up to size MAX. */
955 extern void init_sync_libfuncs (int max
);
957 /* Generate code for a FIXED_CONVERT_EXPR. */
958 extern void expand_fixed_convert (rtx
, rtx
, int, int);
960 /* Generate code for a FLOAT_EXPR. */
961 extern void expand_float (rtx
, rtx
, int);
963 /* Return the insn_code for a FLOAT_EXPR. */
964 enum insn_code
can_float_p (enum machine_mode
, enum machine_mode
, int);
966 /* Return true if there is an inline compare and swap pattern. */
967 extern bool can_compare_and_swap_p (enum machine_mode
, bool);
969 /* Return true if there is an inline atomic exchange pattern. */
970 extern bool can_atomic_exchange_p (enum machine_mode
, bool);
972 /* Generate code for a compare and swap. */
973 extern bool expand_atomic_compare_and_swap (rtx
*, rtx
*, rtx
, rtx
, rtx
, bool,
974 enum memmodel
, enum memmodel
);
976 /* Generate memory barriers. */
977 extern void expand_mem_thread_fence (enum memmodel
);
978 extern void expand_mem_signal_fence (enum memmodel
);
980 /* Check whether an operation represented by the code CODE is a
981 convert operation that is supported by the target platform in
983 bool supportable_convert_operation (enum tree_code
, tree
, tree
, tree
*,
986 /* Generate code for a FIX_EXPR. */
987 extern void expand_fix (rtx
, rtx
, int);
989 /* Generate code for float to integral conversion. */
990 extern bool expand_sfix_optab (rtx
, rtx
, convert_optab
);
992 /* Generate code for a widening multiply. */
993 extern rtx
expand_widening_mult (enum machine_mode
, rtx
, rtx
, rtx
, int, optab
);
995 /* Return tree if target supports vector operations for COND_EXPR. */
996 bool expand_vec_cond_expr_p (tree
, tree
);
998 /* Generate code for VEC_COND_EXPR. */
999 extern rtx
expand_vec_cond_expr (tree
, tree
, tree
, tree
, rtx
);
1000 /* Generate code for VEC_LSHIFT_EXPR and VEC_RSHIFT_EXPR. */
1001 extern rtx
expand_vec_shift_expr (sepops
, rtx
);
1003 /* Return tree if target supports vector operations for VEC_PERM_EXPR. */
1004 extern bool can_vec_perm_p (enum machine_mode
, bool, const unsigned char *);
1006 /* Generate code for VEC_PERM_EXPR. */
1007 extern rtx
expand_vec_perm (enum machine_mode
, rtx
, rtx
, rtx
, rtx
);
1009 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
1010 if the target does not have such an insn. */
1012 static inline enum insn_code
1013 optab_handler (optab op
, enum machine_mode mode
)
1015 return op
->handlers
[(int) mode
].insn_code
;
1018 /* Like optab_handler, but for widening_operations that have a TO_MODE and
1021 static inline enum insn_code
1022 widening_optab_handler (optab op
, enum machine_mode to_mode
,
1023 enum machine_mode from_mode
)
1025 if (to_mode
== from_mode
|| from_mode
== VOIDmode
)
1026 return optab_handler (op
, to_mode
);
1029 return op
->widening
->handlers
[(int) to_mode
][(int) from_mode
].insn_code
;
1031 return CODE_FOR_nothing
;
1034 /* Record that insn CODE should be used to implement mode MODE of OP. */
1037 set_optab_handler (optab op
, enum machine_mode mode
, enum insn_code code
)
1039 op
->handlers
[(int) mode
].insn_code
= code
;
1042 /* Like set_optab_handler, but for widening operations that have a TO_MODE
1046 set_widening_optab_handler (optab op
, enum machine_mode to_mode
,
1047 enum machine_mode from_mode
, enum insn_code code
)
1049 if (to_mode
== from_mode
)
1050 set_optab_handler (op
, to_mode
, code
);
1053 if (op
->widening
== NULL
)
1054 op
->widening
= (struct widening_optab_handlers
*)
1055 xcalloc (1, sizeof (struct widening_optab_handlers
));
1057 op
->widening
->handlers
[(int) to_mode
][(int) from_mode
].insn_code
= code
;
1061 /* Return the insn used to perform conversion OP from mode FROM_MODE
1062 to mode TO_MODE; return CODE_FOR_nothing if the target does not have
1065 static inline enum insn_code
1066 convert_optab_handler (convert_optab op
, enum machine_mode to_mode
,
1067 enum machine_mode from_mode
)
1069 return op
->handlers
[(int) to_mode
][(int) from_mode
].insn_code
;
1072 /* Record that insn CODE should be used to perform conversion OP
1073 from mode FROM_MODE to mode TO_MODE. */
1076 set_convert_optab_handler (convert_optab op
, enum machine_mode to_mode
,
1077 enum machine_mode from_mode
, enum insn_code code
)
1079 op
->handlers
[(int) to_mode
][(int) from_mode
].insn_code
= code
;
1082 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
1083 if the target does not have such an insn. */
1085 static inline enum insn_code
1086 direct_optab_handler (direct_optab op
, enum machine_mode mode
)
1088 return op
->handlers
[(int) mode
].insn_code
;
1091 /* Record that insn CODE should be used to implement mode MODE of OP. */
1094 set_direct_optab_handler (direct_optab op
, enum machine_mode mode
,
1095 enum insn_code code
)
1097 op
->handlers
[(int) mode
].insn_code
= code
;
1100 /* Return true if UNOPTAB is for a trapping-on-overflow operation. */
1103 trapv_unoptab_p (optab unoptab
)
1105 return (unoptab
== negv_optab
1106 || unoptab
== absv_optab
);
1109 /* Return true if BINOPTAB is for a trapping-on-overflow operation. */
1112 trapv_binoptab_p (optab binoptab
)
1114 return (binoptab
== addv_optab
1115 || binoptab
== subv_optab
1116 || binoptab
== smulv_optab
);
1119 extern rtx
optab_libfunc (optab optab
, enum machine_mode mode
);
1120 extern rtx
convert_optab_libfunc (convert_optab optab
, enum machine_mode mode1
,
1121 enum machine_mode mode2
);
1123 extern bool insn_operand_matches (enum insn_code icode
, unsigned int opno
,
1126 /* Describes the type of an expand_operand. Each value is associated
1127 with a create_*_operand function; see the comments above those
1128 functions for details. */
1129 enum expand_operand_type
{
1134 EXPAND_CONVERT_FROM
,
1139 /* Information about an operand for instruction expansion. */
1140 struct expand_operand
{
1141 /* The type of operand. */
1142 ENUM_BITFIELD (expand_operand_type
) type
: 8;
1144 /* True if any conversion should treat VALUE as being unsigned
1145 rather than signed. Only meaningful for certain types. */
1146 unsigned int unsigned_p
: 1;
1148 /* Unused; available for future use. */
1149 unsigned int unused
: 7;
1151 /* The mode passed to the convert_*_operand function. It has a
1152 type-dependent meaning. */
1153 ENUM_BITFIELD (machine_mode
) mode
: 16;
1155 /* The value of the operand. */
1159 /* Initialize OP with the given fields. Initialise the other fields
1160 to their default values. */
1163 create_expand_operand (struct expand_operand
*op
,
1164 enum expand_operand_type type
,
1165 rtx value
, enum machine_mode mode
,
1169 op
->unsigned_p
= unsigned_p
;
1175 /* Make OP describe an operand that must use rtx X, even if X is volatile. */
1178 create_fixed_operand (struct expand_operand
*op
, rtx x
)
1180 create_expand_operand (op
, EXPAND_FIXED
, x
, VOIDmode
, false);
1183 /* Make OP describe an output operand that must have mode MODE.
1184 X, if nonnull, is a suggestion for where the output should be stored.
1185 It is OK for VALUE to be inconsistent with MODE, although it will just
1186 be ignored in that case. */
1189 create_output_operand (struct expand_operand
*op
, rtx x
,
1190 enum machine_mode mode
)
1192 create_expand_operand (op
, EXPAND_OUTPUT
, x
, mode
, false);
1195 /* Make OP describe an input operand that must have mode MODE and
1196 value VALUE; MODE cannot be VOIDmode. The backend may request that
1197 VALUE be copied into a different kind of rtx before being passed
1201 create_input_operand (struct expand_operand
*op
, rtx value
,
1202 enum machine_mode mode
)
1204 create_expand_operand (op
, EXPAND_INPUT
, value
, mode
, false);
1207 /* Like create_input_operand, except that VALUE must first be converted
1208 to mode MODE. UNSIGNED_P says whether VALUE is unsigned. */
1211 create_convert_operand_to (struct expand_operand
*op
, rtx value
,
1212 enum machine_mode mode
, bool unsigned_p
)
1214 create_expand_operand (op
, EXPAND_CONVERT_TO
, value
, mode
, unsigned_p
);
1217 /* Make OP describe an input operand that should have the same value
1218 as VALUE, after any mode conversion that the backend might request.
1219 If VALUE is a CONST_INT, it should be treated as having mode MODE.
1220 UNSIGNED_P says whether VALUE is unsigned. */
1223 create_convert_operand_from (struct expand_operand
*op
, rtx value
,
1224 enum machine_mode mode
, bool unsigned_p
)
1226 create_expand_operand (op
, EXPAND_CONVERT_FROM
, value
, mode
, unsigned_p
);
1229 extern void create_convert_operand_from_type (struct expand_operand
*op
,
1230 rtx value
, tree type
);
1232 /* Make OP describe an input Pmode address operand. VALUE is the value
1233 of the address, but it may need to be converted to Pmode first. */
1236 create_address_operand (struct expand_operand
*op
, rtx value
)
1238 create_expand_operand (op
, EXPAND_ADDRESS
, value
, Pmode
, false);
1241 /* Make OP describe an input operand that has value INTVAL and that has
1242 no inherent mode. This function should only be used for operands that
1243 are always expand-time constants. The backend may request that INTVAL
1244 be copied into a different kind of rtx, but it must specify the mode
1245 of that rtx if so. */
1248 create_integer_operand (struct expand_operand
*op
, HOST_WIDE_INT intval
)
1250 create_expand_operand (op
, EXPAND_INTEGER
, GEN_INT (intval
), VOIDmode
, false);
1253 extern bool valid_multiword_target_p (rtx
);
1255 extern bool maybe_legitimize_operands (enum insn_code icode
,
1256 unsigned int opno
, unsigned int nops
,
1257 struct expand_operand
*ops
);
1258 extern rtx
maybe_gen_insn (enum insn_code icode
, unsigned int nops
,
1259 struct expand_operand
*ops
);
1260 extern bool maybe_expand_insn (enum insn_code icode
, unsigned int nops
,
1261 struct expand_operand
*ops
);
1262 extern bool maybe_expand_jump_insn (enum insn_code icode
, unsigned int nops
,
1263 struct expand_operand
*ops
);
1264 extern void expand_insn (enum insn_code icode
, unsigned int nops
,
1265 struct expand_operand
*ops
);
1266 extern void expand_jump_insn (enum insn_code icode
, unsigned int nops
,
1267 struct expand_operand
*ops
);
1269 extern rtx
prepare_operand (enum insn_code
, rtx
, int, enum machine_mode
,
1270 enum machine_mode
, int);
1272 #endif /* GCC_OPTABS_H */