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

Go to the source code of this file.

Data Structures

struct  mult_cost
 
struct  algorithm
 
struct  alg_hash_entry
 
struct  expmed_op_cheap
 
struct  expmed_op_costs
 
struct  target_expmed
 

Macros

#define MULT_COST_LESS(X, Y)
 
#define CHEAPER_MULT_COST(X, Y)
 
#define NUM_ALG_HASH_ENTRIES   307
 
#define NUM_MODE_IP_INT   (NUM_MODE_INT + NUM_MODE_PARTIAL_INT)
 
#define NUM_MODE_IPV_INT   (NUM_MODE_IP_INT + NUM_MODE_VECTOR_INT)
 
#define this_target_expmed   (&default_target_expmed)
 

Enumerations

enum  alg_code {
  alg_unknown , alg_zero , alg_m , alg_shift ,
  alg_add_t_m2 , alg_sub_t_m2 , alg_add_factor , alg_sub_factor ,
  alg_add_t2_m , alg_sub_t2_m , alg_impossible
}
 
enum  mult_variant { basic_variant , negate_variant , add_variant }
 

Functions

bool choose_mult_variant (machine_mode, HOST_WIDE_INT, struct algorithm *, enum mult_variant *, int)
 
struct alg_hash_entryalg_hash_entry_ptr (int idx)
 
bool alg_hash_used_p (void)
 
void set_alg_hash_used_p (bool usedp)
 
int expmed_mode_index (machine_mode mode)
 
boolexpmed_op_cheap_ptr (struct expmed_op_cheap *eoc, bool speed, machine_mode mode)
 
int * expmed_op_cost_ptr (struct expmed_op_costs *costs, bool speed, machine_mode mode)
 
boolsdiv_pow2_cheap_ptr (bool speed, machine_mode mode)
 
void set_sdiv_pow2_cheap (bool speed, machine_mode mode, bool cheap_p)
 
bool sdiv_pow2_cheap (bool speed, machine_mode mode)
 
boolsmod_pow2_cheap_ptr (bool speed, machine_mode mode)
 
void set_smod_pow2_cheap (bool speed, machine_mode mode, bool cheap)
 
bool smod_pow2_cheap (bool speed, machine_mode mode)
 
int * zero_cost_ptr (bool speed)
 
void set_zero_cost (bool speed, int cost)
 
int zero_cost (bool speed)
 
int * add_cost_ptr (bool speed, machine_mode mode)
 
void set_add_cost (bool speed, machine_mode mode, int cost)
 
int add_cost (bool speed, machine_mode mode)
 
int * neg_cost_ptr (bool speed, machine_mode mode)
 
void set_neg_cost (bool speed, machine_mode mode, int cost)
 
int neg_cost (bool speed, machine_mode mode)
 
int * shift_cost_ptr (bool speed, machine_mode mode, int bits)
 
void set_shift_cost (bool speed, machine_mode mode, int bits, int cost)
 
int shift_cost (bool speed, machine_mode mode, int bits)
 
int * shiftadd_cost_ptr (bool speed, machine_mode mode, int bits)
 
void set_shiftadd_cost (bool speed, machine_mode mode, int bits, int cost)
 
int shiftadd_cost (bool speed, machine_mode mode, int bits)
 
int * shiftsub0_cost_ptr (bool speed, machine_mode mode, int bits)
 
void set_shiftsub0_cost (bool speed, machine_mode mode, int bits, int cost)
 
int shiftsub0_cost (bool speed, machine_mode mode, int bits)
 
int * shiftsub1_cost_ptr (bool speed, machine_mode mode, int bits)
 
void set_shiftsub1_cost (bool speed, machine_mode mode, int bits, int cost)
 
int shiftsub1_cost (bool speed, machine_mode mode, int bits)
 
int * mul_cost_ptr (bool speed, machine_mode mode)
 
void set_mul_cost (bool speed, machine_mode mode, int cost)
 
int mul_cost (bool speed, machine_mode mode)
 
int * sdiv_cost_ptr (bool speed, machine_mode mode)
 
void set_sdiv_cost (bool speed, machine_mode mode, int cost)
 
int sdiv_cost (bool speed, machine_mode mode)
 
int * udiv_cost_ptr (bool speed, machine_mode mode)
 
void set_udiv_cost (bool speed, machine_mode mode, int cost)
 
int udiv_cost (bool speed, machine_mode mode)
 
int * mul_widen_cost_ptr (bool speed, machine_mode mode)
 
void set_mul_widen_cost (bool speed, machine_mode mode, int cost)
 
int mul_widen_cost (bool speed, machine_mode mode)
 
int * mul_highpart_cost_ptr (bool speed, machine_mode mode)
 
void set_mul_highpart_cost (bool speed, machine_mode mode, int cost)
 
int mul_highpart_cost (bool speed, machine_mode mode)
 
int * convert_cost_ptr (machine_mode to_mode, machine_mode from_mode, bool speed)
 
void set_convert_cost (machine_mode to_mode, machine_mode from_mode, bool speed, int cost)
 
int convert_cost (machine_mode to_mode, machine_mode from_mode, bool speed)
 
int mult_by_coeff_cost (HOST_WIDE_INT, machine_mode, bool)
 
rtx emit_cstore (rtx target, enum insn_code icode, enum rtx_code code, machine_mode mode, machine_mode compare_mode, int unsignedp, rtx x, rtx y, int normalizep, machine_mode target_mode)
 
rtx negate_rtx (machine_mode, rtx)
 
rtx flip_storage_order (machine_mode, rtx)
 
rtx expand_and (machine_mode, rtx, rtx, rtx)
 
rtx emit_store_flag (rtx, enum rtx_code, rtx, rtx, machine_mode, int, int)
 
rtx emit_store_flag_force (rtx, enum rtx_code, rtx, rtx, machine_mode, int, int)
 
void canonicalize_comparison (machine_mode, enum rtx_code *, rtx *)
 
unsigned HOST_WIDE_INT choose_multiplier (unsigned HOST_WIDE_INT, int, int, unsigned HOST_WIDE_INT *, int *)
 
void store_bit_field (rtx, poly_uint64, poly_uint64, poly_uint64, poly_uint64, machine_mode, rtx, bool, bool)
 
rtx extract_bit_field (rtx, poly_uint64, poly_uint64, int, rtx, machine_mode, machine_mode, bool, rtx *)
 
rtx extract_low_bits (machine_mode, machine_mode, rtx)
 
rtx expand_mult (machine_mode, rtx, rtx, rtx, int, bool=false)
 
rtx expand_mult_highpart_adjust (scalar_int_mode, rtx, rtx, rtx, rtx, int)
 
rtx expmed_mult_highpart_optab (scalar_int_mode, rtx, rtx, rtx, int, int)
 
rtx expand_rotate_as_vec_perm (machine_mode, rtx, rtx, rtx)
 

Variables

struct target_expmed default_target_expmed
 

Macro Definition Documentation

◆ CHEAPER_MULT_COST

#define CHEAPER_MULT_COST ( X,
Y )
Value:
((X)->cost < (Y)->cost \
|| ((X)->cost == (Y)->cost \
&& (X)->latency < (Y)->latency))
#define Y
Definition gensupport.cc:203
This macro is used to compare two pointers to mult_costs against
each other.  The macro returns true if X is cheaper than Y.
Currently, the cheaper of two mult_costs is the one with the
lower "cost".  If "cost"s are tied, the lower latency is cheaper.   

Referenced by choose_mult_variant(), and synth_mult().

◆ MULT_COST_LESS

#define MULT_COST_LESS ( X,
Y )
Value:
((X)->cost < (Y) \
|| ((X)->cost == (Y) && (X)->latency < (Y)))
This macro is used to compare a pointer to a mult_cost against an
single integer "rtx_cost" value.  This is equivalent to the macro
CHEAPER_MULT_COST(X,Z) where Z = {Y,Y}.   

Referenced by choose_mult_variant(), and synth_mult().

◆ NUM_ALG_HASH_ENTRIES

#define NUM_ALG_HASH_ENTRIES   307
The number of cache/hash entries.   

Referenced by init_expmed(), and synth_mult().

◆ NUM_MODE_IP_INT

#define NUM_MODE_IP_INT   (NUM_MODE_INT + NUM_MODE_PARTIAL_INT)

◆ NUM_MODE_IPV_INT

#define NUM_MODE_IPV_INT   (NUM_MODE_IP_INT + NUM_MODE_VECTOR_INT)

◆ this_target_expmed

Enumeration Type Documentation

◆ alg_code

enum alg_code
Target-dependent costs for expmed.cc.
   Copyright (C) 1987-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/>.   
Enumerator
alg_unknown 
alg_zero 
alg_m 
alg_shift 
alg_add_t_m2 
alg_sub_t_m2 
alg_add_factor 
alg_sub_factor 
alg_add_t2_m 
alg_sub_t2_m 
alg_impossible 

◆ mult_variant

Indicates the type of fixup needed after a constant multiplication.
BASIC_VARIANT means no fixup is needed, NEGATE_VARIANT means that
the result should be negated, and ADD_VARIANT means that the
multiplicand should be added to the result.   
Enumerator
basic_variant 
negate_variant 
add_variant 

Function Documentation

◆ add_cost()

◆ add_cost_ptr()

int * add_cost_ptr ( bool speed,
machine_mode mode )
inline
Subroutine of {set_,}add_cost.  Not to be used otherwise.   

References expmed_op_cost_ptr(), alg_hash_entry::mode, alg_hash_entry::speed, and this_target_expmed.

Referenced by add_cost(), and set_add_cost().

◆ alg_hash_entry_ptr()

struct alg_hash_entry * alg_hash_entry_ptr ( int idx)
inline
Return a pointer to the alg_hash_entry at IDX.   

References this_target_expmed.

Referenced by init_expmed(), and synth_mult().

◆ alg_hash_used_p()

bool alg_hash_used_p ( void )
inline
Return true if the x_alg_hash field might have been used.   

References this_target_expmed.

Referenced by init_expmed().

◆ canonicalize_comparison()

void canonicalize_comparison ( machine_mode mode,
enum rtx_code * code,
rtx * imm )
extern
Choose the more appropiate immediate in scalar integer comparisons.  The
purpose of this is to end up with an immediate which can be loaded into a
register in fewer moves, if possible.

For each integer comparison there exists an equivalent choice:
  i)   a >  b or a >= b + 1
  ii)  a <= b or a <  b + 1
  iii) a >= b or a >  b - 1
  iv)  a <  b or a <= b - 1

MODE is the mode of the first operand.
CODE points to the comparison code.
IMM points to the rtx containing the immediate.  *IMM must satisfy
CONST_SCALAR_INT_P on entry and continues to satisfy CONST_SCALAR_INT_P
on exit.   

References wi::add(), can_create_pseudo_p, equivalent_cmp_code(), gen_move_insn(), gen_rtx_REG(), immed_wide_int_const(), insn_cost(), LAST_VIRTUAL_REGISTER, expand_operand::mode, wi::OVF_NONE, SCALAR_INT_MODE_P, SIGNED, wi::sub(), UNSIGNED, and unsigned_condition_p().

Referenced by emit_store_flag_1(), and prepare_cmp_insn().

◆ choose_mult_variant()

bool choose_mult_variant ( machine_mode mode,
HOST_WIDE_INT val,
struct algorithm * alg,
enum mult_variant * variant,
int mult_cost )
Find the cheapest way of multiplying a value of mode MODE by VAL.
Try three variations:

    - a shift/add sequence based on VAL itself
    - a shift/add sequence based on -VAL, followed by a negation
    - a shift/add sequence based on VAL - 1, followed by an addition.

Return true if the cheapest of these cost less than MULT_COST,
describing the algorithm in *ALG and final fixup in *VARIANT.   

References add_cost(), add_variant, basic_variant, CHEAPER_MULT_COST, algorithm::cost, mult_cost::cost, GET_MODE_UNIT_BITSIZE, GET_MODE_UNIT_PRECISION, HOST_BITS_PER_INT, HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT_1U, HOST_WIDE_INT_MIN, mult_cost::latency, MULT_COST_LESS, neg_cost(), negate_variant, optimize_insn_for_speed_p(), and synth_mult().

Referenced by expand_expr_real_2(), expand_mult(), expand_widening_mult(), expmed_mult_highpart(), mult_by_coeff_cost(), and vect_synth_mult_by_constant().

◆ choose_multiplier()

unsigned HOST_WIDE_INT choose_multiplier ( unsigned HOST_WIDE_INT d,
int n,
int precision,
unsigned HOST_WIDE_INT * multiplier_ptr,
int * post_shift_ptr )
extern
Choose a minimal N + 1 bit approximation to 2**K / D that can be used to
replace division by D, put the least significant N bits of the result in
*MULTIPLIER_PTR, the value K - N in *POST_SHIFT_PTR, and return the most
significant bit.   
Choose a minimal N + 1 bit approximation to 2**K / D that can be used to
replace division by D, put the least significant N bits of the result in
*MULTIPLIER_PTR, the value K - N in *POST_SHIFT_PTR, and return the most
significant bit.

The width of operations is N (should be <= HOST_BITS_PER_WIDE_INT), the
needed precision is PRECISION (should be <= N).

PRECISION should be as small as possible so this function can choose the
multiplier more freely.  If PRECISION is <= N - 1, the most significant
bit returned by the function will be zero.

Using this function, x / D is equal to (x*m) / 2**N >> (*POST_SHIFT_PTR),
where m is the full N + 1 bit multiplier.   

References ceil_log2(), wi::extract_uhwi(), gcc_assert, HOST_BITS_PER_DOUBLE_INT, HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT_1U, wi::set_bit_in_zero(), generic_wide_int< storage >::to_uhwi(), wi::udiv_trunc(), and wi::uhwi().

Referenced by expand_divmod(), expand_vector_divmod(), and vect_recog_divmod_pattern().

◆ convert_cost()

int convert_cost ( machine_mode to_mode,
machine_mode from_mode,
bool speed )
inline
Return the cost for converting from FROM_MODE to TO_MODE when optimizing
for SPEED.   

References convert_cost_ptr(), and alg_hash_entry::speed.

Referenced by force_expr_to_var_cost(), get_computation_cost(), and stmt_cost().

◆ convert_cost_ptr()

int * convert_cost_ptr ( machine_mode to_mode,
machine_mode from_mode,
bool speed )
inline
Subroutine of {set_,}convert_cost.  Not to be used otherwise.   

References expmed_mode_index(), gcc_assert, IN_RANGE, NUM_MODE_IP_INT, alg_hash_entry::speed, and this_target_expmed.

Referenced by convert_cost(), and set_convert_cost().

◆ emit_cstore()

rtx emit_cstore ( rtx target,
enum insn_code icode,
enum rtx_code code,
machine_mode mode,
machine_mode compare_mode,
int unsignedp,
rtx x,
rtx y,
int normalizep,
machine_mode target_mode )
extern

◆ emit_store_flag()

rtx emit_store_flag ( rtx target,
enum rtx_code code,
rtx op0,
rtx op1,
machine_mode mode,
int unsignedp,
int normalizep )
extern
Emit a store-flag operation.   
Emit a store-flags instruction for comparison CODE on OP0 and OP1
and storing in TARGET.  Normally return TARGET.
Return 0 if that cannot be done.

MODE is the mode to use for OP0 and OP1 should they be CONST_INTs.  If
it is VOIDmode, they cannot both be CONST_INT.

UNSIGNEDP is for the case where we have to widen the operands
to perform the operation.  It says to use zero-extension.

NORMALIZEP is 1 if we should convert the result to be either zero
or one.  Normalize is -1 if we should convert the result to be
either zero or -1.  If NORMALIZEP is zero, the result will be left
"raw" out of the scc insn.   

References can_compare_p(), ccp_store_flag, const0_rtx, CONSTANT_P, delete_insns_since(), emit_conditional_move(), emit_store_flag_1(), emit_store_flag_int(), expand_binop(), gcc_assert, GEN_INT, gen_int_mode(), get_last_insn(), GET_MODE, GET_MODE_CLASS, HONOR_NANS(), HONOR_SNANS(), INTVAL, is_int_mode(), last, expand_operand::mode, NULL_RTX, OPTAB_WIDEN, optimize_insn_for_speed_p(), reverse_condition_maybe_unordered(), rtx_cost(), split_comparison(), STORE_FLAG_VALUE, expand_operand::target, and val_signbit_p().

Referenced by emit_store_flag_1(), emit_store_flag_force(), emit_store_flag_int(), expand_divmod(), expand_POPCOUNT(), expand_sdiv_pow2(), expand_smod_pow2(), noce_emit_store_flag(), and noce_try_sign_mask().

◆ emit_store_flag_force()

◆ expand_and()

rtx expand_and ( machine_mode mode,
rtx op0,
rtx op1,
rtx target )
extern
Expand a logical AND operation.   
Compute the logical-and of OP0 and OP1, storing it in TARGET
and returning TARGET.

If TARGET is 0, a pseudo-register or constant is returned.   

References emit_move_insn(), expand_binop(), GET_MODE, OPTAB_LIB_WIDEN, and simplify_binary_operation().

Referenced by calculate_table_based_CRC(), emit_cstore(), expand_builtin_extract_return_addr(), expand_expr_real_2(), expand_mult_highpart_adjust(), gen_common_operation_to_reflect(), optimize_bitfield_assignment_op(), and reduce_to_bit_field_precision().

◆ expand_mult()

rtx expand_mult ( machine_mode mode,
rtx op0,
rtx op1,
rtx target,
int unsignedp,
bool no_libcall )
extern

◆ expand_mult_highpart_adjust()

rtx expand_mult_highpart_adjust ( scalar_int_mode mode,
rtx adj_operand,
rtx op0,
rtx op1,
rtx target,
int unsignedp )
extern
Emit code to adjust ADJ_OPERAND after multiplication of wrong signedness
flavor of OP0 and OP1.  ADJ_OPERAND is already the high half of the
product OP0 x OP1.  If UNSIGNEDP is nonzero, adjust the signed product
to become unsigned, if UNSIGNEDP is zero, adjust the unsigned product to
become signed.

The result is put in TARGET if that is convenient.

MODE is the mode of operation.   

References expand_and(), expand_shift(), force_operand(), GET_MODE_BITSIZE(), and NULL_RTX.

Referenced by expand_expr_real_2(), and expmed_mult_highpart_optab().

◆ expand_rotate_as_vec_perm()

rtx expand_rotate_as_vec_perm ( machine_mode mode,
rtx dst,
rtx x,
rtx amt )
extern
Expand a vector (left) rotate of MODE of X by an immediate AMT as a vector
permute operation.  Emit code to put the result in DST if successfull and
return it.  Otherwise return NULL.  This is intended to implement vector
rotates by byte amounts using vector permutes when the target does not offer
native vector rotate operations.   

References CONST_INT_P, emit_move_insn(), expand_vec_perm_const(), GET_MODE_INNER, GET_MODE_SIZE(), i, INTVAL, lowpart_subreg(), expand_operand::mode, int_vector_builder< T >::new_vector(), NULL_RTX, qimode_for_vec_perm(), and unwrap_const_vec_duplicate().

◆ expmed_mode_index()

int expmed_mode_index ( machine_mode mode)
inline

◆ expmed_mult_highpart_optab()

◆ expmed_op_cheap_ptr()

bool * expmed_op_cheap_ptr ( struct expmed_op_cheap * eoc,
bool speed,
machine_mode mode )
inline
Return a pointer to a boolean contained in EOC indicating whether
a particular operation performed in MODE is cheap when optimizing
for SPEED.   

References expmed_op_cheap::cheap, expmed_mode_index(), alg_hash_entry::mode, and alg_hash_entry::speed.

Referenced by sdiv_pow2_cheap_ptr(), and smod_pow2_cheap_ptr().

◆ expmed_op_cost_ptr()

int * expmed_op_cost_ptr ( struct expmed_op_costs * costs,
bool speed,
machine_mode mode )
inline
Return a pointer to a cost contained in COSTS when a particular
operation is performed in MODE when optimizing for SPEED.   

References costs::cost, expmed_mode_index(), alg_hash_entry::mode, and alg_hash_entry::speed.

Referenced by add_cost_ptr(), mul_cost_ptr(), neg_cost_ptr(), sdiv_cost_ptr(), and udiv_cost_ptr().

◆ extract_bit_field()

rtx extract_bit_field ( rtx str_rtx,
poly_uint64 bitsize,
poly_uint64 bitnum,
int unsignedp,
rtx target,
machine_mode mode,
machine_mode tmode,
bool reverse,
rtx * alt_rtl )
extern
Generate code to extract a byte-field from STR_RTX
containing BITSIZE bits, starting at BITNUM,
and put it in TARGET if possible (if TARGET is nonzero).
Regardless of TARGET, we return the rtx for where the value is placed.

STR_RTX is the structure containing the byte (a REG or MEM).
UNSIGNEDP is nonzero if this is an unsigned bit field.
MODE is the natural mode of the field value once extracted.
TMODE is the mode the caller would like the value to have;
but the value may be returned with type MODE instead.

If REVERSE is true, the extraction is to be done in reverse order.

If a TARGET is specified and we can store in it at no extra cost,
we do so, and return TARGET.
Otherwise, we return a REG of mode TMODE or MODE, with TMODE preferred
if they are equally easy.

If the result can be stored at TARGET, and ALT_RTL is non-NULL,
then *ALT_RTL is set to TARGET (before legitimziation).   

References adjust_bitfield_address, convert_extracted_bit_field(), copy_to_reg(), extract_bit_field_1(), flip_storage_order(), gcc_assert, GET_MODE, GET_MODE_BITSIZE(), is_a(), poly_int< N, C >::is_constant(), expand_operand::mode, narrow_bit_field_mem(), strict_volatile_bitfield_p(), and expand_operand::target.

Referenced by assign_parm_setup_reg(), copy_blkmode_from_reg(), copy_blkmode_to_reg(), emit_group_load_1(), expand_expr_real_1(), expand_misaligned_mem_ref(), expand_single_bit_test(), load_register_parameters(), read_complex_part(), store_field(), store_integral_bit_field(), and store_unaligned_arguments_into_pseudos().

◆ extract_low_bits()

rtx extract_low_bits ( machine_mode mode,
machine_mode src_mode,
rtx src )
extern
Try to read the low bits of SRC as an rvalue of mode MODE, preserving
the bit pattern.  SRC_MODE is the mode of SRC; if this is smaller than
MODE, fill the upper bits with zeros.  Fail if the layout of either
mode is unknown (as for CC modes) or if the extraction would involve
unprofitable mode punning.  Return the value on success, otherwise
return null.

This is different from gen_lowpart* in these respects:

  - the returned value must always be considered an rvalue

  - when MODE is wider than SRC_MODE, the extraction involves
    a zero extension

  - when MODE is smaller than SRC_MODE, the extraction involves
    a truncation (and is thus subject to TARGET_TRULY_NOOP_TRUNCATION).

In other words, this routine performs a computation, whereas the
gen_lowpart* routines are conceptually lvalue or rvalue subreg
operations.   

References CONSTANT_P, convert_modes(), force_reg(), gen_lowpart, gen_lowpart_common(), gen_rtx_SUBREG(), GET_MODE, GET_MODE_BITSIZE(), GET_MODE_CLASS, int_mode_for_mode(), known_eq, expand_operand::mode, NULL_RTX, simplify_subreg(), subreg_lowpart_offset(), targetm, and validate_subreg().

Referenced by find_shift_sequence(), and get_stored_val().

◆ flip_storage_order()

◆ mul_cost()

int mul_cost ( bool speed,
machine_mode mode )
inline
Return the cost of doing a multiplication in MODE when optimizing
for SPEED.   

References alg_hash_entry::mode, mul_cost_ptr(), and alg_hash_entry::speed.

Referenced by analyze_increments(), expand_divmod(), expand_expr_real_2(), expmed_mult_highpart_optab(), and stmt_cost().

◆ mul_cost_ptr()

int * mul_cost_ptr ( bool speed,
machine_mode mode )
inline
Subroutine of {set_,}mul_cost.  Not to be used otherwise.   

References expmed_op_cost_ptr(), alg_hash_entry::mode, alg_hash_entry::speed, and this_target_expmed.

Referenced by mul_cost(), and set_mul_cost().

◆ mul_highpart_cost()

int mul_highpart_cost ( bool speed,
machine_mode mode )
inline
Return the cost for computing the high part of a multiplication in MODE
when optimizing for SPEED.   

References alg_hash_entry::mode, mul_highpart_cost_ptr(), and alg_hash_entry::speed.

Referenced by expmed_mult_highpart_optab().

◆ mul_highpart_cost_ptr()

int * mul_highpart_cost_ptr ( bool speed,
machine_mode mode )
inline
Subroutine of {set_,}mul_highpart_cost.  Not to be used otherwise.   

References gcc_assert, GET_MODE_CLASS, alg_hash_entry::mode, alg_hash_entry::speed, and this_target_expmed.

Referenced by mul_highpart_cost(), and set_mul_highpart_cost().

◆ mul_widen_cost()

int mul_widen_cost ( bool speed,
machine_mode mode )
inline
Return the cost for computing a widening multiplication in MODE when
optimizing for SPEED.   

References alg_hash_entry::mode, mul_widen_cost_ptr(), and alg_hash_entry::speed.

Referenced by expand_widening_mult(), and expmed_mult_highpart_optab().

◆ mul_widen_cost_ptr()

int * mul_widen_cost_ptr ( bool speed,
machine_mode mode )
inline
Subroutine of {set_,}mul_widen_cost.  Not to be used otherwise.   

References gcc_assert, GET_MODE_CLASS, alg_hash_entry::mode, alg_hash_entry::speed, and this_target_expmed.

Referenced by mul_widen_cost(), and set_mul_widen_cost().

◆ mult_by_coeff_cost()

int mult_by_coeff_cost ( HOST_WIDE_INT coeff,
machine_mode mode,
bool speed )
extern
Return a cost estimate for multiplying a register by the given
COEFFicient in the given MODE and SPEED.   

References choose_mult_variant(), algorithm::cost, mult_cost::cost, gen_raw_REG(), LAST_VIRTUAL_REGISTER, and set_src_cost().

Referenced by analyze_increments(), force_expr_to_var_cost(), get_address_cost(), get_computation_cost(), most_expensive_mult_to_index(), and stmt_cost().

◆ neg_cost()

int neg_cost ( bool speed,
machine_mode mode )
inline
Return the cost of computing a negation in MODE when optimizing for
SPEED.   

References alg_hash_entry::mode, neg_cost_ptr(), and alg_hash_entry::speed.

Referenced by choose_mult_variant(), expand_expr_real_2(), expand_mult(), and stmt_cost().

◆ neg_cost_ptr()

int * neg_cost_ptr ( bool speed,
machine_mode mode )
inline
Subroutine of {set_,}neg_cost.  Not to be used otherwise.   

References expmed_op_cost_ptr(), alg_hash_entry::mode, alg_hash_entry::speed, and this_target_expmed.

Referenced by neg_cost(), and set_neg_cost().

◆ negate_rtx()

rtx negate_rtx ( machine_mode mode,
rtx x )
extern
Arguments MODE, RTX: return an rtx for the negation of that value.
May emit insns.   
Return an rtx representing minus the value of X.
MODE is the intended mode of the result,
useful if X is a CONST_INT.   

References expand_unop(), alg_hash_entry::mode, NULL_RTX, and simplify_unary_operation().

Referenced by expand_binop(), expand_builtin_apply(), expand_expr_real_2(), fill_slots_from_thread(), force_operand(), and push_block().

◆ sdiv_cost()

int sdiv_cost ( bool speed,
machine_mode mode )
inline
Return the cost of doing a signed division in MODE when optimizing
for SPEED.   

References alg_hash_entry::mode, sdiv_cost_ptr(), and alg_hash_entry::speed.

Referenced by expand_divmod().

◆ sdiv_cost_ptr()

int * sdiv_cost_ptr ( bool speed,
machine_mode mode )
inline
Subroutine of {set_,}sdiv_cost.  Not to be used otherwise.   

References expmed_op_cost_ptr(), alg_hash_entry::mode, alg_hash_entry::speed, and this_target_expmed.

Referenced by sdiv_cost(), and set_sdiv_cost().

◆ sdiv_pow2_cheap()

bool sdiv_pow2_cheap ( bool speed,
machine_mode mode )
inline
Return whether a signed division by a power of 2 is cheap in MODE
when optimizing for SPEED.   

References alg_hash_entry::mode, sdiv_pow2_cheap_ptr(), and alg_hash_entry::speed.

Referenced by expand_divmod().

◆ sdiv_pow2_cheap_ptr()

bool * sdiv_pow2_cheap_ptr ( bool speed,
machine_mode mode )
inline
Subroutine of {set_,}sdiv_pow2_cheap.  Not to be used otherwise.   

References expmed_op_cheap_ptr(), alg_hash_entry::mode, alg_hash_entry::speed, and this_target_expmed.

Referenced by sdiv_pow2_cheap(), and set_sdiv_pow2_cheap().

◆ set_add_cost()

void set_add_cost ( bool speed,
machine_mode mode,
int cost )
inline
Set the COST of computing an add in MODE when optimizing for SPEED.   

References add_cost_ptr(), alg_hash_entry::cost, alg_hash_entry::mode, and alg_hash_entry::speed.

Referenced by init_expmed_one_mode().

◆ set_alg_hash_used_p()

void set_alg_hash_used_p ( bool usedp)
inline
Set whether the x_alg_hash field might have been used.   

References this_target_expmed.

Referenced by init_expmed().

◆ set_convert_cost()

void set_convert_cost ( machine_mode to_mode,
machine_mode from_mode,
bool speed,
int cost )
inline
Set the COST for converting from FROM_MODE to TO_MODE when optimizing
for SPEED.   

References convert_cost_ptr(), alg_hash_entry::cost, and alg_hash_entry::speed.

Referenced by init_expmed_one_conv().

◆ set_mul_cost()

void set_mul_cost ( bool speed,
machine_mode mode,
int cost )
inline
Set the COST of doing a multiplication in MODE when optimizing for
SPEED.   

References alg_hash_entry::cost, alg_hash_entry::mode, mul_cost_ptr(), and alg_hash_entry::speed.

Referenced by init_expmed_one_mode().

◆ set_mul_highpart_cost()

void set_mul_highpart_cost ( bool speed,
machine_mode mode,
int cost )
inline
Set the COST for computing the high part of a multiplication in MODE
when optimizing for SPEED.   

References alg_hash_entry::cost, alg_hash_entry::mode, mul_highpart_cost_ptr(), and alg_hash_entry::speed.

Referenced by init_expmed_one_mode().

◆ set_mul_widen_cost()

void set_mul_widen_cost ( bool speed,
machine_mode mode,
int cost )
inline
Set the COST for computing a widening multiplication in MODE when
optimizing for SPEED.   

References alg_hash_entry::cost, alg_hash_entry::mode, mul_widen_cost_ptr(), and alg_hash_entry::speed.

Referenced by init_expmed_one_mode().

◆ set_neg_cost()

void set_neg_cost ( bool speed,
machine_mode mode,
int cost )
inline
Set the COST of computing a negation in MODE when optimizing for SPEED.   

References alg_hash_entry::cost, alg_hash_entry::mode, neg_cost_ptr(), and alg_hash_entry::speed.

Referenced by init_expmed_one_mode().

◆ set_sdiv_cost()

void set_sdiv_cost ( bool speed,
machine_mode mode,
int cost )
inline
Set the COST of doing a signed division in MODE when optimizing
for SPEED.   

References alg_hash_entry::cost, alg_hash_entry::mode, sdiv_cost_ptr(), and alg_hash_entry::speed.

Referenced by init_expmed_one_mode().

◆ set_sdiv_pow2_cheap()

void set_sdiv_pow2_cheap ( bool speed,
machine_mode mode,
bool cheap_p )
inline
Set whether a signed division by a power of 2 is cheap in MODE
when optimizing for SPEED.   

References alg_hash_entry::mode, sdiv_pow2_cheap_ptr(), and alg_hash_entry::speed.

Referenced by init_expmed_one_mode().

◆ set_shift_cost()

void set_shift_cost ( bool speed,
machine_mode mode,
int bits,
int cost )
inline
Set the COST of doing a shift in MODE by BITS when optimizing for SPEED.   

References alg_hash_entry::cost, alg_hash_entry::mode, shift_cost_ptr(), and alg_hash_entry::speed.

Referenced by init_expmed_one_mode().

◆ set_shiftadd_cost()

void set_shiftadd_cost ( bool speed,
machine_mode mode,
int bits,
int cost )
inline
Set the COST of doing a shift in MODE by BITS followed by an add when
optimizing for SPEED.   

References alg_hash_entry::cost, alg_hash_entry::mode, shiftadd_cost_ptr(), and alg_hash_entry::speed.

Referenced by init_expmed_one_mode().

◆ set_shiftsub0_cost()

void set_shiftsub0_cost ( bool speed,
machine_mode mode,
int bits,
int cost )
inline
Set the COST of doing a shift in MODE by BITS and then subtracting a
value when optimizing for SPEED.   

References alg_hash_entry::cost, alg_hash_entry::mode, shiftsub0_cost_ptr(), and alg_hash_entry::speed.

Referenced by init_expmed_one_mode().

◆ set_shiftsub1_cost()

void set_shiftsub1_cost ( bool speed,
machine_mode mode,
int bits,
int cost )
inline
Set the COST of subtracting a shift in MODE by BITS from a value when
optimizing for SPEED.   

References alg_hash_entry::cost, alg_hash_entry::mode, shiftsub1_cost_ptr(), and alg_hash_entry::speed.

Referenced by init_expmed_one_mode().

◆ set_smod_pow2_cheap()

void set_smod_pow2_cheap ( bool speed,
machine_mode mode,
bool cheap )
inline
Set whether a signed modulo by a power of 2 is CHEAP in MODE when
optimizing for SPEED.   

References alg_hash_entry::mode, smod_pow2_cheap_ptr(), and alg_hash_entry::speed.

Referenced by init_expmed_one_mode().

◆ set_udiv_cost()

void set_udiv_cost ( bool speed,
machine_mode mode,
int cost )
inline
Set the COST of doing an unsigned division in MODE when optimizing
for SPEED.   

References alg_hash_entry::cost, alg_hash_entry::mode, alg_hash_entry::speed, and udiv_cost_ptr().

Referenced by init_expmed_one_mode().

◆ set_zero_cost()

void set_zero_cost ( bool speed,
int cost )
inline
Set the COST of loading zero when optimizing for SPEED.   

References alg_hash_entry::cost, alg_hash_entry::speed, and zero_cost_ptr().

Referenced by init_expmed().

◆ shift_cost()

int shift_cost ( bool speed,
machine_mode mode,
int bits )
inline
Return the cost of doing a shift in MODE by BITS when optimizing for
SPEED.   

References alg_hash_entry::mode, shift_cost_ptr(), and alg_hash_entry::speed.

Referenced by expand_divmod(), expand_sdiv_pow2(), expand_shift_1(), expmed_mult_highpart(), expmed_mult_highpart_optab(), get_shiftadd_cost(), and synth_mult().

◆ shift_cost_ptr()

int * shift_cost_ptr ( bool speed,
machine_mode mode,
int bits )
inline
Subroutine of {set_,}shift_cost.  Not to be used otherwise.   

References expmed_mode_index(), alg_hash_entry::mode, alg_hash_entry::speed, and this_target_expmed.

Referenced by set_shift_cost(), and shift_cost().

◆ shiftadd_cost()

int shiftadd_cost ( bool speed,
machine_mode mode,
int bits )
inline
Return the cost of doing a shift in MODE by BITS followed by an add
when optimizing for SPEED.   

References alg_hash_entry::mode, shiftadd_cost_ptr(), and alg_hash_entry::speed.

Referenced by get_shiftadd_cost(), and synth_mult().

◆ shiftadd_cost_ptr()

int * shiftadd_cost_ptr ( bool speed,
machine_mode mode,
int bits )
inline
Subroutine of {set_,}shiftadd_cost.  Not to be used otherwise.   

References expmed_mode_index(), alg_hash_entry::mode, alg_hash_entry::speed, and this_target_expmed.

Referenced by set_shiftadd_cost(), and shiftadd_cost().

◆ shiftsub0_cost()

int shiftsub0_cost ( bool speed,
machine_mode mode,
int bits )
inline
Return the cost of doing a shift in MODE by BITS and then subtracting
a value when optimizing for SPEED.   

References alg_hash_entry::mode, shiftsub0_cost_ptr(), and alg_hash_entry::speed.

Referenced by get_shiftadd_cost(), and synth_mult().

◆ shiftsub0_cost_ptr()

int * shiftsub0_cost_ptr ( bool speed,
machine_mode mode,
int bits )
inline
Subroutine of {set_,}shiftsub0_cost.  Not to be used otherwise.   

References expmed_mode_index(), alg_hash_entry::mode, alg_hash_entry::speed, and this_target_expmed.

Referenced by set_shiftsub0_cost(), and shiftsub0_cost().

◆ shiftsub1_cost()

int shiftsub1_cost ( bool speed,
machine_mode mode,
int bits )
inline
Return the cost of subtracting a shift in MODE by BITS from a value
when optimizing for SPEED.   

References alg_hash_entry::mode, shiftsub1_cost_ptr(), and alg_hash_entry::speed.

Referenced by get_shiftadd_cost(), and synth_mult().

◆ shiftsub1_cost_ptr()

int * shiftsub1_cost_ptr ( bool speed,
machine_mode mode,
int bits )
inline
Subroutine of {set_,}shiftsub1_cost.  Not to be used otherwise.   

References expmed_mode_index(), alg_hash_entry::mode, alg_hash_entry::speed, and this_target_expmed.

Referenced by set_shiftsub1_cost(), and shiftsub1_cost().

◆ smod_pow2_cheap()

bool smod_pow2_cheap ( bool speed,
machine_mode mode )
inline
Return whether a signed modulo by a power of 2 is cheap in MODE
when optimizing for SPEED.   

References alg_hash_entry::mode, smod_pow2_cheap_ptr(), and alg_hash_entry::speed.

Referenced by expand_divmod().

◆ smod_pow2_cheap_ptr()

bool * smod_pow2_cheap_ptr ( bool speed,
machine_mode mode )
inline
Subroutine of {set_,}smod_pow2_cheap.  Not to be used otherwise.   

References expmed_op_cheap_ptr(), alg_hash_entry::mode, alg_hash_entry::speed, and this_target_expmed.

Referenced by set_smod_pow2_cheap(), and smod_pow2_cheap().

◆ store_bit_field()

void store_bit_field ( rtx str_rtx,
poly_uint64 bitsize,
poly_uint64 bitnum,
poly_uint64 bitregion_start,
poly_uint64 bitregion_end,
machine_mode fieldmode,
rtx value,
bool reverse,
bool undefined_p )
extern
Generate code to store value from rtx VALUE
into a bit-field within structure STR_RTX
containing BITSIZE bits starting at bit BITNUM.

BITREGION_START is bitpos of the first bitfield in this region.
BITREGION_END is the bitpos of the ending bitfield in this region.
These two fields are 0, if the C++ memory model does not apply,
or we are not interested in keeping track of bitfield regions.

FIELDMODE is the machine-mode of the FIELD_DECL node for this field.

If REVERSE is true, the store is to be done in reverse order.

If UNDEFINED_P is true then STR_RTX is currently undefined.   

References adjust_bitfield_address, adjust_bitfield_address_size, bits_to_bytes_round_up, copy_to_reg(), emit_move_insn(), flip_storage_order(), gcc_assert, gcc_unreachable, get_best_mode(), GET_MODE_BITSIZE(), INT_MAX, is_a(), poly_int< N, C >::is_constant(), MEM_ALIGN, MEM_P, MEM_VOLATILE_P, narrow_bit_field_mem(), offset, store_bit_field_1(), strict_volatile_bitfield_p(), and expand_operand::value.

Referenced by copy_blkmode_from_reg(), copy_blkmode_to_reg(), emit_group_store(), expand_assignment(), expand_expr_real_2(), noce_emit_move_insn(), store_expr(), store_field(), store_unaligned_arguments_into_pseudos(), and write_complex_part().

◆ udiv_cost()

int udiv_cost ( bool speed,
machine_mode mode )
inline
Return the cost of doing an unsigned division in MODE when
optimizing for SPEED.   

References alg_hash_entry::mode, alg_hash_entry::speed, and udiv_cost_ptr().

Referenced by expand_divmod().

◆ udiv_cost_ptr()

int * udiv_cost_ptr ( bool speed,
machine_mode mode )
inline
Subroutine of {set_,}udiv_cost.  Not to be used otherwise.   

References expmed_op_cost_ptr(), alg_hash_entry::mode, alg_hash_entry::speed, and this_target_expmed.

Referenced by set_udiv_cost(), and udiv_cost().

◆ zero_cost()

int zero_cost ( bool speed)
inline
Return the COST of loading zero when optimizing for SPEED.   

References alg_hash_entry::speed, and zero_cost_ptr().

Referenced by synth_mult().

◆ zero_cost_ptr()

int * zero_cost_ptr ( bool speed)
inline
Subroutine of {set_,}zero_cost.  Not to be used otherwise.   

References alg_hash_entry::speed, and this_target_expmed.

Referenced by set_zero_cost(), and zero_cost().

Variable Documentation

◆ default_target_expmed

struct target_expmed default_target_expmed
extern
Medium-level subroutines: convert bit-field store and extract
   and shifts, multiplies and divides to rtl instructions.
   Copyright (C) 1987-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/>.   
Work around tree-optimization/91825.