GCC Middle and Back End API Reference
optabs-query.h File Reference
#include "insn-opinit.h"
#include "target.h"
Include dependency graph for optabs-query.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  extraction_insn
 

Macros

#define find_widening_optab_handler(A, B, C)    find_widening_optab_handler_and_mode (A, B, C, NULL)
 

Enumerations

enum  extraction_pattern { EP_insv , EP_extv , EP_extzv }
 

Functions

bool convert_optab_p (optab op)
 
enum insn_code optab_handler (optab op, machine_mode mode)
 
enum insn_code convert_optab_handler (convert_optab op, machine_mode to_mode, machine_mode from_mode)
 
enum insn_code convert_optab_handler (convert_optab, machine_mode, machine_mode, optimization_type)
 
enum insn_code direct_optab_handler (direct_optab op, machine_mode mode)
 
enum insn_code direct_optab_handler (convert_optab, machine_mode, optimization_type)
 
bool trapv_unoptab_p (optab unoptab)
 
bool trapv_binoptab_p (optab binoptab)
 
enum insn_code get_vec_cmp_icode (machine_mode vmode, machine_mode mask_mode, bool uns)
 
enum insn_code get_vec_cmp_eq_icode (machine_mode vmode, machine_mode mask_mode)
 
enum insn_code get_vcond_icode (machine_mode vmode, machine_mode cmode, bool uns)
 
enum insn_code get_vcond_mask_icode (machine_mode vmode, machine_mode mmode)
 
enum insn_code get_vcond_eq_icode (machine_mode vmode, machine_mode cmode)
 
bool get_best_reg_extraction_insn (extraction_insn *, enum extraction_pattern, unsigned HOST_WIDE_INT, machine_mode)
 
bool get_best_mem_extraction_insn (extraction_insn *, enum extraction_pattern, HOST_WIDE_INT, HOST_WIDE_INT, machine_mode)
 
enum insn_code can_extend_p (machine_mode, machine_mode, int)
 
enum insn_code can_float_p (machine_mode, machine_mode, int)
 
enum insn_code can_fix_p (machine_mode, machine_mode, int, bool *)
 
bool can_conditionally_move_p (machine_mode mode)
 
opt_machine_mode qimode_for_vec_perm (machine_mode)
 
bool selector_fits_mode_p (machine_mode, const vec_perm_indices &)
 
bool can_vec_perm_var_p (machine_mode)
 
bool can_vec_perm_const_p (machine_mode, machine_mode, const vec_perm_indices &, bool=true)
 
enum insn_code find_widening_optab_handler_and_mode (optab, machine_mode, machine_mode, machine_mode *)
 
int can_mult_highpart_p (machine_mode, bool)
 
bool can_compare_and_swap_p (machine_mode, bool)
 
bool can_atomic_exchange_p (machine_mode, bool)
 
bool can_atomic_load_p (machine_mode)
 
bool lshift_cheap_p (bool)
 
bool supports_vec_gather_load_p (machine_mode=E_VOIDmode)
 
bool supports_vec_scatter_store_p (machine_mode=E_VOIDmode)
 
bool can_vec_extract (machine_mode, machine_mode)
 
template<typename T >
enum insn_code find_widening_optab_handler_and_mode (optab op, const T &to_mode, const T &from_mode, T *found_mode)
 

Macro Definition Documentation

◆ find_widening_optab_handler

#define find_widening_optab_handler ( A,
B,
C )    find_widening_optab_handler_and_mode (A, B, C, NULL)
Find a widening optab even if it doesn't widen as much as we want.   

Referenced by can_widen_mult_without_libcall(), expand_binop(), expand_expr_real_2(), and expand_widen_pattern_expr().

Enumeration Type Documentation

◆ extraction_pattern

Enumerates the possible extraction_insn operations.   
Enumerator
EP_insv 
EP_extv 
EP_extzv 

Function Documentation

◆ can_atomic_exchange_p()

bool can_atomic_exchange_p ( machine_mode mode,
bool allow_libcall )
Return true if an atomic exchange can be performed.   

References can_compare_and_swap_p(), and direct_optab_handler().

Referenced by expand_omp_atomic_store().

◆ can_atomic_load_p()

◆ can_compare_and_swap_p()

◆ can_conditionally_move_p()

bool can_conditionally_move_p ( machine_mode mode)
Return nonzero if a conditional move of mode MODE is supported.

This function is for combine so it can tell whether an insn that looks
like a conditional move is actually supported by the hardware.  If we
guess wrong we lose a bit on optimization, but that's it.   
??? sparc64 supports conditionally moving integers values based on fp
comparisons, and vice versa.  How do we handle them?   

References direct_optab_handler().

Referenced by bb_ok_for_noce_convert_multiple_sets(), expand_cond_expr_using_cmove(), expand_expr_real_2(), noce_try_cmove_arith(), and simplify_set().

◆ can_extend_p()

enum insn_code can_extend_p ( machine_mode to_mode,
machine_mode from_mode,
int unsignedp )
Return the insn code used to extend FROM_MODE to TO_MODE.
UNSIGNEDP specifies zero-extension instead of sign-extension.  If
no such operation exists, CODE_FOR_nothing will be returned.   

References convert_optab_handler(), and targetm.

Referenced by assign_parm_setup_reg(), compress_float_constant(), convert_mode_scalar(), gen_extend_insn(), init_expr_target(), and supportable_convert_operation().

◆ can_fix_p()

enum insn_code can_fix_p ( machine_mode fixmode,
machine_mode fltmode,
int unsignedp,
bool * truncp_ptr )
Return the insn code to convert floating-point mode FLTMODE to fixed-point
mode FIXMODE, or CODE_FOR_nothing if no such instruction exists.
UNSIGNEDP specifies whether FIXMODE is unsigned.

On a successful return, set *TRUNCP_PTR to true if it is necessary to
output an explicit FTRUNC before the instruction.   

References convert_optab_handler(), and optab_handler().

Referenced by expand_fix(), and supportable_convert_operation().

◆ can_float_p()

enum insn_code can_float_p ( machine_mode fltmode,
machine_mode fixmode,
int unsignedp )
Return the insn code to convert fixed-point mode FIXMODE to floating-point
mode FLTMODE, or CODE_FOR_nothing if no such instruction exists.
UNSIGNEDP specifies whether FIXMODE is unsigned.   

References convert_optab_handler().

Referenced by expand_float(), simplify_using_ranges::simplify_float_conversion_using_ranges(), and supportable_convert_operation().

◆ can_mult_highpart_p()

int can_mult_highpart_p ( machine_mode mode,
bool uns_p )
Return non-zero if a highpart multiply is supported or can be synthesized.
For the benefit of expand_mult_highpart, the return value is 1 for direct,
2 for integral widening, 3 for even/odd widening, 4 for hi/lo widening.   

References BITS_PER_WORD, can_vec_perm_const_p(), convert_optab_handler(), GET_MODE_BITSIZE(), GET_MODE_CLASS, GET_MODE_NUNITS(), GET_MODE_WIDER_MODE(), i, is_a(), and optab_handler().

Referenced by default_preferred_div_as_shifts_over_mult(), expand_mul_overflow(), expand_mult_highpart(), expand_vector_divmod(), get_compute_type(), match_arith_overflow(), vect_recog_divmod_pattern(), and vectorizable_operation().

◆ can_vec_extract()

bool can_vec_extract ( machine_mode mode,
machine_mode extr_mode )
Whether we can extract part of the vector mode MODE as
(scalar or vector) mode EXTR_MODE.   

References convert_optab_handler(), GET_MODE_BITSIZE(), GET_MODE_SIZE(), int_mode_for_size(), related_vector_mode(), and VECTOR_MODE_P.

Referenced by vect_find_reusable_accumulator().

◆ can_vec_perm_const_p()

bool can_vec_perm_const_p ( machine_mode mode,
machine_mode op_mode,
const vec_perm_indices & sel,
bool allow_variable_p )
Return true if the target directly supports VEC_PERM_EXPRs on vectors
of mode OP_MODE and result vector of mode MODE using the selector SEL.
ALLOW_VARIABLE_P is true if it is acceptable to force the selector into a
register and use a variable permute (if the target supports that).

Note that additional permutations representing whole-vector shifts may
also be handled via the vec_shr or vec_shl optab, but only where the
second input vector is entirely constant zeroes; this case is not dealt
with here.   

References direct_optab_handler(), GET_MODE_UNIT_SIZE, vec_perm_indices::new_expanded_vector(), NULL, NULL_RTX, qimode_for_vec_perm(), selector_fits_mode_p(), targetm, and VECTOR_MODE_P.

Referenced by can_duplicate_and_interleave_p(), can_mult_highpart_p(), have_whole_vector_shift(), interleave_supported_p(), lower_vec_perm(), perm_mask_for_reverse(), scan_store_can_perm_p(), simplify_vector_constructor(), vect_gen_perm_mask_checked(), vect_grouped_load_supported(), vect_grouped_store_supported(), vect_recog_rotate_pattern(), vect_shift_permute_load_chain(), vect_transform_slp_perm_load_1(), vectorizable_bswap(), vectorizable_nonlinear_induction(), vectorizable_recurr(), and vectorizable_slp_permutation_1().

◆ can_vec_perm_var_p()

bool can_vec_perm_var_p ( machine_mode mode)
Return true if VEC_PERM_EXPRs with variable selector operands can be
expanded using SIMD extensions of the CPU.  MODE is the mode of the
vectors being permuted.   

References direct_optab_handler(), GET_MODE_MASK, GET_MODE_NUNITS(), GET_MODE_UNIT_SIZE, maybe_gt, optab_handler(), qimode_for_vec_perm(), and VECTOR_MODE_P.

Referenced by lower_vec_perm().

◆ convert_optab_handler() [1/2]

enum insn_code convert_optab_handler ( convert_optab op,
machine_mode to_mode,
machine_mode from_mode )
inline
Return the insn used to perform conversion OP from mode FROM_MODE
to mode TO_MODE; return CODE_FOR_nothing if the target does not have
such an insn.   

References convert_optab_p(), and gcc_assert.

Referenced by get_vcond_eq_icode(), get_vcond_icode(), get_vcond_mask_icode(), get_vec_cmp_eq_icode(), and get_vec_cmp_icode().

◆ convert_optab_handler() [2/2]

◆ convert_optab_p()

bool convert_optab_p ( optab op)
inline
IR-agnostic target query functions relating to optabs
   Copyright (C) 2001-2024 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Return true if OP is a conversion optab.   

References unknown_optab.

Referenced by convert_optab_handler(), and expand_binop().

◆ direct_optab_handler() [1/2]

enum insn_code direct_optab_handler ( convert_optab optab,
machine_mode mode,
optimization_type opt_type )
Return the insn used to implement mode MODE of OP; return
CODE_FOR_nothing if the target does not have such an insn,
or if it is unsuitable for optimization type OPT_TYPE.   

References direct_optab_handler(), and targetm.

Referenced by can_atomic_exchange_p(), can_atomic_load_p(), can_compare_and_swap_p(), can_conditionally_move_p(), can_vec_perm_const_p(), can_vec_perm_var_p(), default_secondary_reload(), direct_optab_handler(), direct_optab_supported_p(), emit_block_cmp_via_cmpmem(), emit_block_move_via_pattern(), emit_conditional_move(), emit_conditional_move_1(), emit_conditional_neg_or_complement(), expand_atomic_compare_and_swap(), expand_atomic_load(), expand_atomic_store(), expand_builtin_feclear_feraise_except(), expand_builtin_fegetround(), expand_builtin_set_thread_pointer(), expand_builtin_strcmp(), expand_builtin_strncmp(), expand_builtin_thread_pointer(), expand_direct_optab_fn(), expand_ifn_atomic_bit_test_and(), expand_ifn_atomic_op_fetch_cmp_0(), expand_partial_load_optab_fn(), expand_partial_store_optab_fn(), expand_RAWMEMCHR(), expand_vec_perm_const(), expand_vec_perm_var(), expand_vec_series_expr(), get_optab_extraction_insn(), if_convert(), internal_check_ptrs_fn_supported_p(), internal_len_load_store_bias(), maybe_emit_atomic_exchange(), maybe_emit_op(), optimize_atomic_compare_exchange_p(), prepare_cmp_insn(), set_storage_via_setmem(), target_supports_len_load_store_p(), loop_distribution::transform_reduction_loop(), validate_test_and_branch(), and vectorizable_early_exit().

◆ direct_optab_handler() [2/2]

enum insn_code direct_optab_handler ( direct_optab op,
machine_mode mode )
inline
Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
if the target does not have such an insn.   

References optab_handler().

◆ find_widening_optab_handler_and_mode() [1/2]

template<typename T >
enum insn_code find_widening_optab_handler_and_mode ( optab op,
const T & to_mode,
const T & from_mode,
T * found_mode )
inline
Version of find_widening_optab_handler_and_mode that operates on
specific mode types.   

References as_a(), and find_widening_optab_handler_and_mode().

◆ find_widening_optab_handler_and_mode() [2/2]

enum insn_code find_widening_optab_handler_and_mode ( optab op,
machine_mode to_mode,
machine_mode from_mode,
machine_mode * found_mode )
Find a widening optab even if it doesn't widen as much as we want.
E.g. if from_mode is HImode, and to_mode is DImode, and there is no
direct HI->SI insn, then return SI->DI, if that exists.   

References convert_optab_handler(), FOR_EACH_MODE, gcc_checking_assert, GET_MODE_CLASS, GET_MODE_PRECISION(), GET_MODE_WIDER_MODE(), is_a(), and known_lt.

Referenced by convert_mult_to_widen(), convert_plusminus_to_widen(), and find_widening_optab_handler_and_mode().

◆ get_best_mem_extraction_insn()

bool get_best_mem_extraction_insn ( extraction_insn * insn,
enum extraction_pattern pattern,
HOST_WIDE_INT bitsize,
HOST_WIDE_INT bitnum,
machine_mode field_mode )
Return true if an instruction exists to access a field of BITSIZE
bits starting BITNUM bits into a memory structure.  Describe the
"best" such instruction in *INSN if so.  PATTERN describes the type
of insertion or extraction we want to perform and FIELDMODE is the
natural mode of the extracted field.

The instructions considered here only access bytes that overlap
the bitfield; they do not touch any surrounding bytes.   

References ET_unaligned_mem, and get_best_extraction_insn().

Referenced by extract_integral_bit_field(), and store_integral_bit_field().

◆ get_best_reg_extraction_insn()

bool get_best_reg_extraction_insn ( extraction_insn * insn,
enum extraction_pattern pattern,
unsigned HOST_WIDE_INT struct_bits,
machine_mode field_mode )
Return true if an instruction exists to access a field of mode
FIELDMODE in a register structure that has STRUCT_BITS significant bits.
Describe the "best" such instruction in *INSN if so.  PATTERN describes
the type of insertion or extraction we want to perform.

For an insertion, the number of significant structure bits includes
all bits of the target.  For an extraction, it need only include the
most significant bit of the field.  Larger widths are acceptable
in both cases.   

References ET_reg, and get_best_extraction_insn().

Referenced by adjust_bit_field_mem_for_reg(), extract_integral_bit_field(), make_extraction(), and store_integral_bit_field().

◆ get_vcond_eq_icode()

enum insn_code get_vcond_eq_icode ( machine_mode vmode,
machine_mode cmode )
inline
Return insn code for a conditional operator with a comparison in
mode CMODE (only EQ/NE), resulting in a value of mode VMODE.   

References convert_optab_handler().

Referenced by vcond_eq_icode_p().

◆ get_vcond_icode()

enum insn_code get_vcond_icode ( machine_mode vmode,
machine_mode cmode,
bool uns )
inline
Return insn code for a conditional operator with a comparison in
mode CMODE, unsigned if UNS is true, resulting in a value of mode VMODE.   

References convert_optab_handler().

Referenced by can_vcond_compare_p(), and gimple_expand_vec_cond_expr().

◆ get_vcond_mask_icode()

enum insn_code get_vcond_mask_icode ( machine_mode vmode,
machine_mode mmode )
inline
Return insn code for a conditional operator with a mask mode
MMODE resulting in a value of mode VMODE.   

References convert_optab_handler().

Referenced by expand_vec_cond_expr_p(), and gimple_expand_vec_cond_expr().

◆ get_vec_cmp_eq_icode()

enum insn_code get_vec_cmp_eq_icode ( machine_mode vmode,
machine_mode mask_mode )
inline
Return insn code for a comparison operator with VMODE
resultin MASK_MODE (only for EQ/NE).   

References convert_optab_handler().

Referenced by expand_vec_cmp_expr(), and vec_cmp_eq_icode_p().

◆ get_vec_cmp_icode()

enum insn_code get_vec_cmp_icode ( machine_mode vmode,
machine_mode mask_mode,
bool uns )
inline
Return insn code for a comparison operator with VMODE
resultin MASK_MODE, unsigned if UNS is true.   

References convert_optab_handler().

Referenced by can_vec_cmp_compare_p(), and expand_vec_cmp_expr().

◆ lshift_cheap_p()

bool lshift_cheap_p ( bool speed_p)
Determine whether "1 << x" is relatively cheap in word_mode.   

References const1_rtx, COSTS_N_INSNS, gen_raw_REG(), optab_handler(), set_src_cost(), and word_mode.

Referenced by optimize_range_tests().

◆ optab_handler()

enum insn_code optab_handler ( optab op,
machine_mode mode )
inline
Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
if the target does not have such an insn.   

References gcc_assert.

Referenced by add_rshift(), assign_parm_adjust_stack_rtl(), assign_parm_setup_reg(), assign_parm_setup_stack(), build_constant_desc(), builtin_memset_gen_str(), by_pieces_mode_supported_p(), by_pieces_ninsns(), can_compare_and_swap_p(), can_compare_p(), can_fix_p(), can_mult_highpart_p(), can_store_by_pieces(), can_vec_perm_var_p(), can_vec_set_var_idx_p(), check_scan_store(), convert_expand_mult_copysign(), convert_mult_to_highpart(), default_builtin_support_vector_misalignment(), direct_optab_handler(), directly_supported_p(), emit_cmp_and_jump_insn_1(), emit_conditional_add(), emit_move_ccmode(), emit_move_complex(), emit_move_insn(), emit_move_insn_1(), emit_move_via_integer(), emit_store_flag_1(), emit_store_flag_int(), emit_storent_insn(), expand_abs_nojump(), expand_addsub_overflow(), expand_assignment(), expand_atomic_compare_and_swap(), expand_binop(), expand_builtin_cexpi(), expand_builtin_issignaling(), expand_builtin_mathfn_3(), expand_builtin_mathfn_ternary(), expand_builtin_signbit(), expand_builtin_sincos(), expand_builtin_strlen(), expand_ccmp_expr(), expand_clrsb_using_clz(), expand_copysign(), expand_copysign_absneg(), expand_ctz(), expand_DIVMOD(), expand_divmod(), expand_doubleword_clz_ctz_ffs(), expand_doubleword_mod(), expand_expr_real_1(), expand_expr_real_2(), expand_ffs(), expand_fix(), expand_misaligned_mem_ref(), expand_mul_overflow(), expand_mult(), expand_mult_highpart(), expand_neg_overflow(), expand_omp_for_init_vars(), expand_one_cmpl_abs_nojump(), expand_parity(), expand_shift_1(), expand_smod_pow2(), expand_SPACESHIP(), expand_ternary_op(), expand_twoval_binop(), expand_twoval_unop(), expand_UADDC(), expand_unop(), expand_unop_direct(), expand_vec_perm_const(), expand_vec_set_optab_fn(), expand_vector_broadcast(), expand_vector_conversion(), expand_vector_divmod(), expand_vector_operations_1(), expand_vector_ubsan_overflow(), expand_widen_pattern_expr(), expmed_mult_highpart_optab(), expression_expensive_p(), find_if_header(), find_reloads_address_1(), gen_add2_insn(), gen_add3_insn(), gen_addptr3_insn(), gen_cond_trap(), gen_reload(), gen_sub2_insn(), gen_sub3_insn(), get_compute_type(), gimple_expand_builtin_cabs(), gimple_expand_builtin_pow(), gimple_expand_vec_cond_expr(), gimple_fold_builtin_memory_op(), have_add2_insn(), have_addptr3_insn(), have_insn_for(), have_sub2_insn(), have_whole_vector_shift(), hoist_adjacent_loads(), interclass_mathfn_icode(), lower_vec_perm(), lshift_cheap_p(), match_arith_overflow(), match_uaddc_usubc(), maybe_emit_op(), maybe_emit_sync_lock_test_and_set(), nontemporal_store_p(), optimize_atomic_bit_test_and(), optimize_atomic_compare_exchange_p(), optimize_atomic_op_fetch_cmp_0(), optimize_spaceship(), optimize_vector_constructor(), prepare_cmp_insn(), compare_by_pieces_d::prepare_mode(), move_by_pieces_d::prepare_mode(), store_by_pieces_d::prepare_mode(), reverse_rotate_by_imm_p(), scan_store_can_perm_p(), simplify_vector_constructor(), store_bit_field_1(), store_constructor(), store_integral_bit_field(), supportable_half_widening_operation(), supportable_narrowing_operation(), supportable_widening_operation(), target_has_vecop_for_code(), target_supports_divmod_p(), target_supports_op_p(), type_for_widest_vector_mode(), undistribute_bitref_for_vector(), vect_maybe_permute_loop_masks(), vect_recog_divmod_pattern(), vect_recog_mult_pattern(), vect_recog_rotate_pattern(), vect_supportable_direct_optab_p(), vect_supportable_dr_alignment(), vect_supportable_shift(), vectorizable_comparison_1(), vectorizable_condition(), vectorizable_load(), vectorizable_operation(), vectorizable_shift(), vectorizable_store(), widen_bswap(), and widen_leading().

◆ qimode_for_vec_perm()

opt_machine_mode qimode_for_vec_perm ( machine_mode mode)
If a target doesn't implement a permute on a vector with multibyte
elements, we can try to do the same permute on byte elements.
If this makes sense for vector mode MODE then return the appropriate
byte vector mode.   

References GET_MODE_INNER, GET_MODE_SIZE(), and related_vector_mode().

Referenced by can_vec_perm_const_p(), can_vec_perm_var_p(), expand_vec_perm_const(), and expand_vec_perm_var().

◆ selector_fits_mode_p()

bool selector_fits_mode_p ( machine_mode mode,
const vec_perm_indices & sel )
Return true if selector SEL can be represented in the integer
equivalent of vector mode MODE.   

References vec_perm_indices::all_in_range_p(), GET_MODE_INNER, GET_MODE_MASK, and HOST_WIDE_INT_M1U.

Referenced by can_vec_perm_const_p(), and expand_vec_perm_const().

◆ supports_vec_gather_load_p()

bool supports_vec_gather_load_p ( machine_mode mode)
If MODE is not VOIDmode, return true if vec_gather_load is available for
that mode.  If MODE is VOIDmode, return true if gather_load is available
for at least one vector mode.   

References supports_vec_convert_optab_p(), and this_fn_optabs.

Referenced by vect_check_gather_scatter().

◆ supports_vec_scatter_store_p()

bool supports_vec_scatter_store_p ( machine_mode mode)
If MODE is not VOIDmode, return true if vec_scatter_store is available for
that mode.  If MODE is VOIDmode, return true if scatter_store is available
for at least one vector mode.   

References supports_vec_convert_optab_p(), and this_fn_optabs.

Referenced by vect_check_gather_scatter().

◆ trapv_binoptab_p()

bool trapv_binoptab_p ( optab binoptab)
inline
Return true if BINOPTAB is for a trapping-on-overflow operation.   

Referenced by expand_binop(), and gen_int_libfunc().

◆ trapv_unoptab_p()

bool trapv_unoptab_p ( optab unoptab)
inline
Return true if UNOPTAB is for a trapping-on-overflow operation.   

Referenced by expand_unop(), and gen_int_libfunc().