GCC Middle and Back End API Reference
reload.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  target_reload
 
struct  reg_equivs_t
 

Macros

#define MAX_RELOADS   (2 * MAX_RECOG_OPERANDS * (MAX_REGS_PER_ADDRESS + 1))
 
#define this_target_reload   (&default_target_reload)
 
#define indirect_symref_ok    (this_target_reload->x_indirect_symref_ok)
 
#define double_reg_address_ok    (this_target_reload->x_double_reg_address_ok)
 
#define caller_save_initialized_p    (this_target_reload->x_caller_save_initialized_p)
 
#define reg_equiv_constant(ELT)
 
#define reg_equiv_invariant(ELT)
 
#define reg_equiv_memory_loc(ELT)
 
#define reg_equiv_address(ELT)
 
#define reg_equiv_mem(ELT)
 
#define reg_equiv_alt_mem_list(ELT)
 
#define reg_equiv_init(ELT)
 

Enumerations

enum  reload_type {
  RELOAD_FOR_INPUT , RELOAD_FOR_OUTPUT , RELOAD_FOR_INSN , RELOAD_FOR_INPUT_ADDRESS ,
  RELOAD_FOR_INPADDR_ADDRESS , RELOAD_FOR_OUTPUT_ADDRESS , RELOAD_FOR_OUTADDR_ADDRESS , RELOAD_FOR_OPERAND_ADDRESS ,
  RELOAD_FOR_OPADDR_ADDR , RELOAD_OTHER , RELOAD_FOR_OTHER_ADDRESS
}
 

Functions

int register_move_cost (machine_mode, reg_class_t, reg_class_t)
 
int memory_move_cost (machine_mode, reg_class_t, bool)
 
int memory_move_secondary_cost (machine_mode, reg_class_t, bool)
 
reg_class_t secondary_reload_class (bool, reg_class_t, machine_mode, rtx)
 
rtx get_secondary_mem (rtx, machine_mode, int, enum reload_type)
 
void clear_secondary_mem (void)
 
void transfer_replacements (int, int)
 
int remove_address_replacements (rtx in_rtx)
 
int operands_match_p (rtx, rtx)
 
int safe_from_earlyclobber (rtx, rtx)
 
int find_reloads (rtx_insn *, int, int, int, short *)
 
rtx form_sum (machine_mode, rtx, rtx)
 
void subst_reloads (rtx_insn *)
 
void copy_replacements (rtx, rtx)
 
void move_replacements (rtx *x, rtx *y)
 
rtx find_replacement (rtx *)
 
int reg_overlap_mentioned_for_reload_p (rtx, rtx)
 
rtx find_equiv_reg (rtx, rtx_insn *, enum reg_class, int, short *, int, machine_mode)
 
int regno_clobbered_p (unsigned int, rtx_insn *, machine_mode, int)
 
int earlyclobber_operand_p (rtx)
 
int push_reload (rtx, rtx, rtx *, rtx *, enum reg_class, machine_mode, machine_mode, int, int, int, enum reload_type)
 
void init_reload (void)
 
bool reload (rtx_insn *, int)
 
void mark_home_live (int)
 
rtx eliminate_regs (rtx, machine_mode, rtx)
 
bool elimination_target_reg_p (rtx)
 
void calculate_elim_costs_all_insns (void)
 
void deallocate_reload_reg (int r)
 
void init_caller_save (void)
 
void init_save_areas (void)
 
void setup_save_areas (void)
 
void save_call_clobbered_regs (void)
 
void cleanup_subreg_operands (rtx_insn *)
 
void debug_reload_to_stream (FILE *)
 
void debug_reload (void)
 
rtx reload_adjust_reg_for_mode (rtx, machine_mode)
 
void grow_reg_equivs (void)
 

Variables

struct target_reload default_target_reload
 
vec< reg_equivs_t, va_gc > * reg_equivs
 
int n_earlyclobbers
 
rtx reload_earlyclobbers [MAX_RECOG_OPERANDS]
 
int reload_n_operands
 
int reload_first_uid
 
int num_not_at_initial_offset
 

Macro Definition Documentation

◆ caller_save_initialized_p

#define caller_save_initialized_p    (this_target_reload->x_caller_save_initialized_p)

◆ double_reg_address_ok

#define double_reg_address_ok    (this_target_reload->x_double_reg_address_ok)

◆ indirect_symref_ok

#define indirect_symref_ok    (this_target_reload->x_indirect_symref_ok)

◆ MAX_RELOADS

#define MAX_RELOADS   (2 * MAX_RECOG_OPERANDS * (MAX_REGS_PER_ADDRESS + 1))
Maximum number of reloads we can need.   

Referenced by choose_reload_regs(), choose_reload_regs_init(), and remove_address_replacements().

◆ reg_equiv_address

#define reg_equiv_address ( ELT)

◆ reg_equiv_alt_mem_list

#define reg_equiv_alt_mem_list ( ELT)
Value:
(*reg_equivs)[(ELT)].alt_mem_list

Referenced by delete_output_reload(), free_reg_equiv(), and push_reg_equiv_alt_mem().

◆ reg_equiv_constant

◆ reg_equiv_init

◆ reg_equiv_invariant

#define reg_equiv_invariant ( ELT)

◆ reg_equiv_mem

◆ reg_equiv_memory_loc

◆ this_target_reload

#define this_target_reload   (&default_target_reload)

Enumeration Type Documentation

◆ reload_type

Encode the usage of a reload.  The following codes are supported:

RELOAD_FOR_INPUT                reload of an input operand
RELOAD_FOR_OUTPUT               likewise, for output
RELOAD_FOR_INSN         a reload that must not conflict with anything
                        used in the insn, but may conflict with
                        something used before or after the insn
RELOAD_FOR_INPUT_ADDRESS        reload for parts of the address of an object
                        that is an input reload
RELOAD_FOR_INPADDR_ADDRESS      reload needed for RELOAD_FOR_INPUT_ADDRESS
RELOAD_FOR_OUTPUT_ADDRESS       like RELOAD_FOR INPUT_ADDRESS, for output
RELOAD_FOR_OUTADDR_ADDRESS      reload needed for RELOAD_FOR_OUTPUT_ADDRESS
RELOAD_FOR_OPERAND_ADDRESS      reload for the address of a non-reloaded
                        operand; these don't conflict with
                        any other addresses.
RELOAD_FOR_OPADDR_ADDR  reload needed for RELOAD_FOR_OPERAND_ADDRESS
                             reloads; usually secondary reloads
RELOAD_OTHER                    none of the above, usually multiple uses
RELOAD_FOR_OTHER_ADDRESS     reload for part of the address of an input
                        that is marked RELOAD_OTHER.

This used to be "enum reload_when_needed" but some debuggers have trouble
with an enum tag and variable of the same name.   
Enumerator
RELOAD_FOR_INPUT 
RELOAD_FOR_OUTPUT 
RELOAD_FOR_INSN 
RELOAD_FOR_INPUT_ADDRESS 
RELOAD_FOR_INPADDR_ADDRESS 
RELOAD_FOR_OUTPUT_ADDRESS 
RELOAD_FOR_OUTADDR_ADDRESS 
RELOAD_FOR_OPERAND_ADDRESS 
RELOAD_FOR_OPADDR_ADDR 
RELOAD_OTHER 
RELOAD_FOR_OTHER_ADDRESS 

Function Documentation

◆ calculate_elim_costs_all_insns()

void calculate_elim_costs_all_insns ( void )
extern
Called from the register allocator to estimate costs of eliminating
invariant registers.   
This function is called from the register allocator to set up estimates
for the cost of eliminating pseudos which have REG_EQUIV equivalences to
an invariant.  The structure is similar to calculate_needs_all_insns.   

References cfun, dump_file, elim_bb, eliminate_regs_1(), elimination_costs_in_insn(), FOR_BB_INSNS, FOR_EACH_BB_FN, free(), get_insns(), GET_MODE, i, init_elim_table(), init_eliminable_invariants(), INSN_P, ira_adjust_equiv_reg_cost(), JUMP_P, JUMP_TABLE_DATA_P, LABEL_P, max_regno, NULL, num_eliminable, num_eliminable_invariants, offsets_at, offsets_known_at, optimize_bb_for_speed_p(), reg_equiv_constant, reg_equiv_init, reg_equiv_invariant, REG_FREQ_FROM_BB, REG_NOTES, REG_P, reg_renumber, REGNO, SET_DEST, set_initial_elim_offsets(), set_initial_label_offsets(), set_label_offsets(), SET_SRC, set_src_cost(), single_set(), and update_eliminable_offsets().

Referenced by ira_costs().

◆ cleanup_subreg_operands()

void cleanup_subreg_operands ( rtx_insn * insn)
extern
Replace (subreg (reg)) with the appropriate (reg) for any operands.   
For each operand in INSN, simplify (subreg (reg)) so that it refers
directly to the desired hard register.   

References alter_subreg(), changed, df_insn_rescan(), recog_data_d::dup_loc, extract_insn_cached(), GET_CODE, i, MEM_P, recog_data_d::n_dups, recog_data_d::n_operands, recog_data_d::operand, recog_data_d::operand_loc, recog_data, and walk_alter_subreg().

Referenced by final_scan_insn_1(), reload(), and split_insn().

◆ clear_secondary_mem()

void clear_secondary_mem ( void )
extern
Clear any secondary memory locations we've made.   

References secondary_memlocs.

Referenced by reload().

◆ copy_replacements()

void copy_replacements ( rtx x,
rtx y )
extern
Make a copy of any replacements being done into X and move those copies
to locations in Y, a copy of X.  We only look at the highest level of
the RTL.   
Make a copy of any replacements being done into X and move those
copies to locations in Y, a copy of X.   

References copy_replacements_1(), n_replacements, and y.

Referenced by emit_move_change_mode(), and find_reloads_address().

◆ deallocate_reload_reg()

void deallocate_reload_reg ( int r)
extern
Deallocate the reload register used by reload number R.   
Deallocate the reload register for reload R.  This is called from
remove_address_replacements.   

References clear_reload_reg_in_use(), r, reload_spill_index, rld, spill_reg_order, and true_regnum().

Referenced by remove_address_replacements().

◆ debug_reload()

void debug_reload ( void )
extern

◆ debug_reload_to_stream()

void debug_reload_to_stream ( FILE * f)
extern
Debugging support.   
These functions are used to print the variables set by 'find_reloads'  

References GET_MODE_NAME, insn_data, n_reloads, print_dec(), print_inline_rtx(), r, reg_class_names, reload_when_needed_name, rld, and SIGNED.

Referenced by debug_reload(), emit_reload_insns(), and spill_failure().

◆ earlyclobber_operand_p()

int earlyclobber_operand_p ( rtx x)
extern
Return 1 if X is an operand of an insn that is being earlyclobbered.   
This page contains subroutines used mainly for determining
whether the IN or an OUT of a reload can serve as the
reload register.   
Return 1 if X is an operand of an insn that is being earlyclobbered.   

References i, n_earlyclobbers, and reload_earlyclobbers.

Referenced by combine_reloads(), find_reusable_reload(), push_reload(), refers_to_regno_for_reload_p(), and reload_reg_free_for_value_p().

◆ eliminate_regs()

rtx eliminate_regs ( rtx x,
machine_mode mem_mode,
rtx insn )
extern
Scan X and replace any eliminable registers (such as fp) with a
replacement (such as sp), plus an offset.   

References eliminate_regs_1(), gcc_assert, NULL, reg_eliminate, and targetm.

Referenced by based_loc_descr(), compute_frame_pointer_to_fb_displacement(), delete_output_reload(), eliminate_regs_in_insn(), get_secondary_mem(), make_memloc(), reg_loc_descriptor(), reload(), reload_as_needed(), and vt_initialize().

◆ elimination_target_reg_p()

bool elimination_target_reg_p ( rtx x)
extern
Return true if X is used as the target register of an elimination.   

References elim_table::can_eliminate, NUM_ELIMINABLE_REGS, reg_eliminate, and elim_table::to_rtx.

Referenced by find_reloads().

◆ find_equiv_reg()

rtx find_equiv_reg ( rtx goal,
rtx_insn * insn,
enum reg_class rclass,
int other,
short * reload_reg_p,
int goalreg,
machine_mode mode )
extern
Check the insns before INSN to see if there is a suitable register
containing the same value as GOAL.   
Check the insns before INSN to see if there is a suitable register
containing the same value as GOAL.
If OTHER is -1, look for a register in class RCLASS.
Otherwise, just see if register number OTHER shares GOAL's value.

Return an rtx for the register found, or zero if none is found.

If RELOAD_REG_P is (short *)1,
we reject any hard reg that appears in reload_reg_rtx
because such a hard reg is also needed coming into this insn.

If RELOAD_REG_P is any other nonzero value,
it is a vector indexed by hard reg number
and we reject any hard reg whose element in the vector is nonnegative
as well as any that appears in reload_reg_rtx.

If GOAL is zero, then GOALREG is a register number; we look
for an equivalent for that register.

MODE is the machine mode of the value we want an equivalence for.
If GOAL is nonzero and not VOIDmode, then it must have mode MODE.

This function is used by jump.cc as well as in the reload pass.

If GOAL is the sum of the stack pointer and a constant, we treat it
as if it were a constant except that sp is required to be unchanging.   

References CALL_INSN_FUNCTION_USAGE, CALL_P, function_abi::clobbers_reg_p(), COND_EXEC_CODE, CONST_DOUBLE_AS_FLOAT_P, CONST_INT_P, CONSTANT_ADDRESS_P, CONSTANT_P, DEBUG_INSN_P, end_hard_regno(), END_REGNO(), find_reg_note(), frame_pointer_rtx, GET_CODE, GET_MODE, hard_regno_nregs(), HOST_WIDE_INT_1, i, in_hard_reg_set_p(), insn_callee_abi(), INSN_P, INSN_UID(), LABEL_P, MEM_P, MEM_VOLATILE_P, replacement::mode, n_reloads, NONJUMP_INSN_P, NULL_RTX, operand_subword(), PATTERN(), PREV_INSN(), push_operand(), refers_to_regno_for_reload_p(), reg_class_contents, reg_equiv_memory_loc, REG_NOTE_KIND, REG_NOTES, reg_overlap_mentioned_for_reload_p(), REG_P, REGNO, reload_first_uid, rld, rtx_equal_p(), rtx_renumbered_equal_p(), SCALAR_FLOAT_MODE_P, SET, SET_DEST, SET_SRC, single_set(), stack_pointer_rtx, true_regnum(), volatile_insn_p(), replacement::where, XEXP, XVECEXP, and XVECLEN.

Referenced by choose_reload_regs(), find_reloads(), and push_reload().

◆ find_reloads()

int find_reloads ( rtx_insn * insn,
int replace,
int ind_levels,
int live_known,
short * reload_reg_p )
extern
Search the body of INSN for values that need reloading and record them
with push_reload.  REPLACE nonzero means record also where the values occur
so that subst_reloads can be used.   
Main entry point of this file: search the body of INSN
for values that need reloading and record them with push_reload.
REPLACE nonzero means record also where the values occur
so that subst_reloads can be used.

IND_LEVELS says how many levels of indirection are supported by this
machine; a value of zero means that a memory reference is not a valid
memory address.

LIVE_KNOWN says we have valid information about which hard
regs are live at each point in the program; this is true when
we are called from global_alloc but false when stupid register
allocation has been done.

RELOAD_REG_P if nonzero is a vector indexed by hard reg number
which is nonnegative if the reg has been commandeered for reloading into.
It is copied into STATIC_RELOAD_REG_P and referenced from there
by various subroutines.

Return TRUE if some operands need to be changed, because of swapping
commutative operands, reg_equiv_address substitution, or whatever.   

References add_reg_note(), ADDR_SPACE_GENERIC, alternative_allows_const_pool_ref(), base_reg_class(), CALL_P, class_only_fixed_regs, combine_reloads(), const0_rtx, CONST_INT_P, CONST_POOL_OK_P, CONSTANT_P, constraints, recog_data_d::constraints, decompose(), recog_data_d::dup_loc, recog_data_d::dup_num, dup_replacements(), elimination_target_reg_p(), emit_insn_after(), emit_insn_before(), end(), error_for_asm(), extract_insn(), fatal_insn, find_dummy_reload(), find_equiv_reg(), find_reg_note(), find_reloads(), find_reloads_address(), find_reloads_toplev(), force_const_mem(), gcc_assert, gen_clobber(), gen_rtx_SUBREG(), get_address_mode(), GET_CODE, get_enabled_alternatives(), GET_MODE, GET_MODE_BITSIZE(), GET_MODE_SIZE(), GET_RTX_CLASS, hard_regno_nregs(), hard_regs_live_known, i, immune_p(), INSN_CODE, insn_data, INTVAL, ira_nullify_asm_goto(), ira_reg_class_max_nregs, is_a(), recog_data_d::is_operator, JUMP_P, known_ge, known_le, label_is_jump_target_p(), LABEL_NUSES, LABEL_P, label_ref_label(), LEGITIMATE_PIC_OPERAND_P, LOAD_EXTEND_OP, MATCHES, MEM_ADDR_SPACE, MEM_P, MIN, mode_dependent_address_p(), n_alternatives(), recog_data_d::n_alternatives, recog_data_d::n_dups, n_earlyclobbers, recog_data_d::n_operands, n_reloads, n_replacements, nr, NULL, NULL_RTX, num_not_at_initial_offset, OBJECT_P, offset, offsettable_memref_p(), offsettable_nonstrict_memref_p(), OP_IN, insn_data_d::operand, recog_data_d::operand, recog_data_d::operand_loc, recog_data_d::operand_mode, recog_data_d::operand_type, operands_match_p(), output_reloadnum, paradoxical_subreg_p(), partial_subreg_p(), PATTERN(), push_reload(), PUT_MODE(), recog_data, reg_alternate_class(), reg_class_contents, reg_class_size, reg_class_subset_p(), reg_class_subunion, reg_equiv_address, reg_equiv_constant, reg_equiv_mem, reg_equiv_memory_loc, reg_fits_class_p(), reg_mentioned_p(), REG_P, reg_preferred_class(), reg_renumber, register_move_cost(), REGNO, reject(), reload_earlyclobbers, RELOAD_FOR_INPADDR_ADDRESS, RELOAD_FOR_INPUT, RELOAD_FOR_INPUT_ADDRESS, RELOAD_FOR_INSN, RELOAD_FOR_OPADDR_ADDR, RELOAD_FOR_OPERAND_ADDRESS, RELOAD_FOR_OTHER_ADDRESS, RELOAD_FOR_OUTADDR_ADDRESS, RELOAD_FOR_OUTPUT, RELOAD_FOR_OUTPUT_ADDRESS, reload_n_operands, RELOAD_OTHER, replace_reloads, replacements, rld, RTX_CODE, rtx_equal_p(), RTX_UNARY, secondary_memlocs_elim, secondary_memlocs_elim_used, SET, SET_DEST, SET_SRC, set_unique_reg_note(), simplify_subreg_regno(), single_set(), skip_alternative(), small_register_class_p(), static_reload_reg_p, insn_operand_data::strict_low, SUBREG_BYTE, SUBREG_REG, subreg_regno_offset(), TARGET_MEM_CONSTRAINT, targetm, TEST_BIT, TEST_HARD_REG_BIT, this_insn, this_insn_is_asm, transfer_replacements(), type(), replacement::what, WORD_REGISTER_OPERATIONS, and XEXP.

Referenced by calculate_needs_all_insns(), find_reloads(), and reload_as_needed().

◆ find_replacement()

rtx find_replacement ( rtx * loc)
extern
If LOC was scheduled to be replaced by something, return the replacement.
Otherwise, return *LOC.   

References find_replacement(), GET_CODE, GET_MODE, rtx_def::mode, n_replacements, r, reload_adjust_reg_for_mode(), replacements, rld, simplify_gen_subreg(), SUBREG_BYTE, SUBREG_REG, XEXP, and y.

Referenced by emit_move_multi_word(), find_replacement(), gen_reload(), inc_for_reload(), and replaced_subreg().

◆ form_sum()

rtx form_sum ( machine_mode mode,
rtx x,
rtx y )
extern
Compute the sum of X and Y, making canonicalizations assumed in an
address, namely: sum constant integers, surround the sum of two
constants with a CONST, put the constant as the second operand, and
group the constant on the outermost sum.   
Compute the sum of X and Y, making canonicalizations assumed in an
address, namely: sum constant integers, surround the sum of two
constants with a CONST, put the constant as the second operand, and
group the constant on the outermost sum.

This routine assumes both inputs are already in canonical form.   

References CONST_INT_P, CONSTANT_P, form_sum(), gcc_assert, GET_CODE, GET_MODE, INTVAL, plus_constant(), XEXP, and y.

Referenced by form_sum(), and subst_indexed_address().

◆ get_secondary_mem()

rtx get_secondary_mem ( rtx x,
machine_mode mode,
int opnum,
enum reload_type type )
extern
Return a memory location that will be used to copy X in mode MODE.
If we haven't already made a location for this mode in this insn,
call find_reloads_address on the location being returned.   

References assign_stack_local(), copy_rtx(), eliminate_regs(), find_reloads_address(), GET_MODE_SIZE(), MEM_ADDR_SPACE, NULL_RTX, RELOAD_FOR_INPUT, RELOAD_FOR_INPUT_ADDRESS, RELOAD_FOR_OUTPUT, RELOAD_FOR_OUTPUT_ADDRESS, RELOAD_OTHER, secondary_memlocs, secondary_memlocs_elim, secondary_memlocs_elim_used, strict_memory_address_addr_space_p(), targetm, and XEXP.

Referenced by choose_reload_regs(), gen_reload(), push_reload(), and push_secondary_reload().

◆ grow_reg_equivs()

void grow_reg_equivs ( void )
extern
Allocate or grow the reg_equiv tables, initializing new entries to 0.   
Grow (or allocate) the REG_EQUIVS array from its current size (which may be
zero elements) to MAX_REG_NUM elements.

Initialize all new fields to NULL and update REG_EQUIVS_SIZE.   

References i, max_reg_num(), max_regno, reg_equivs, vec_safe_length(), and vec_safe_reserve().

Referenced by emit_move_list(), fix_reg_equiv_init(), init_eliminable_invariants(), ira(), and reload().

◆ init_caller_save()

void init_caller_save ( void )
extern
Functions in caller-save.cc:   
Initialize for caller-save.   
Initialize for caller-save.

Look at all the hard registers that are used by a call and for which
reginfo.cc has not already excluded from being used across a call.

Ensure that we can find a mode to save the register and that there is a
simple insn to save and restore the register.  This latter check avoids
problems that would occur if we tried to save the MQ register of some
machines directly into memory.   

References ADDR_SPACE_GENERIC, base_reg_class(), caller_save_initialized_p, CLEAR_HARD_REG_BIT, gcc_assert, gen_int_mode(), gen_rtx_INSN(), gen_rtx_MEM(), gen_rtx_REG(), HARD_REGNO_CALLER_SAVE_MODE, HOST_BITS_PER_INT, i, LAST_VIRTUAL_REGISTER, MOVE_MAX_WORDS, offset, reg_class_contents, reg_save_code(), regno_save_mode, restinsn, restpat, savable_regs, saveinsn, savepat, strict_memory_address_p, TEST_HARD_REG_BIT, test_mem, test_reg, and word_mode.

Referenced by ira().

◆ init_reload()

void init_reload ( void )
extern
Functions in reload1.cc:   
Initialize the reload pass once per compilation.   
Initialize the reload pass.  This is called at the beginning of compilation
and may be called again if the target is reinitialized.   

References changed_allocation_pseudos, double_reg_address_ok, gcc_obstack_init, gen_int_mode(), gen_rtx_MEM(), gen_rtx_REG(), HARD_FRAME_POINTER_REGNUM, i, indirect_symref_ok, INIT_REG_SET, LAST_VIRTUAL_REGISTER, memory_address_p, NULL, plus_constant(), pseudos_counted, reload_obstack, reload_startobj, spill_indirect_levels, and spilled_pseudos.

Referenced by backend_init_target().

◆ init_save_areas()

void init_save_areas ( void )
extern
Initialize save areas by showing that we haven't allocated any yet.   

References i, MOVE_MAX_WORDS, regno_save_mem, and save_slots_num.

Referenced by reload().

◆ mark_home_live()

void mark_home_live ( int regno)
extern
Mark the slots in regs_ever_live for the hard regs
used by pseudo-reg number REGNO.   

References mark_home_live_1(), PSEUDO_REGNO_MODE, and reg_renumber.

Referenced by allocno_reload_assign(), and reload().

◆ memory_move_cost()

int memory_move_cost ( machine_mode mode,
reg_class_t rclass,
bool in )
extern
Compute cost of moving registers to/from memory.   

References targetm.

Referenced by choose_reload_regs(), reload_cse_simplify_set(), and setup_class_subset_and_memory_move_costs().

◆ memory_move_secondary_cost()

int memory_move_secondary_cost ( machine_mode mode,
reg_class_t rclass,
bool in )
extern
Compute extra cost of moving registers to/from memory due to reloads.
Only needed if secondary reloads are required for memory moves.   

References memory_move_secondary_cost(), register_move_cost(), secondary_reload_class(), and top_of_stack.

Referenced by default_memory_move_cost(), and memory_move_secondary_cost().

◆ move_replacements()

void move_replacements ( rtx * x,
rtx * y )
extern
Change any replacements being done to *X to be done to *Y  
Change any replacements being done to *X to be done to *Y.   

References i, n_replacements, replacements, replacement::where, and y.

Referenced by find_reloads_address().

◆ operands_match_p()

int operands_match_p ( rtx x,
rtx y )
extern
Like rtx_equal_p except that it allows a REG and a SUBREG to match
if they are the same hard reg, and has special hacks for
autoincrement and autodecrement.   
Like rtx_equal_p except that it allows a REG and a SUBREG to match
if they are the same hard reg, and has special hacks for
autoincrement and autodecrement.
This is specifically intended for find_reloads to use
in determining whether two operands match.
X is the operand whose number is the lower of the two.

The value is 2 if Y contains a pre-increment that matches
a non-incrementing address in X.   
??? To be completely correct, we should arrange to pass
for X the output operand and for Y the input operand.
For now, we assume that the output operand has the lower number
because that is natural in (SET output (... input ...)).   

References CASE_CONST_UNIQUE, gcc_unreachable, GET_CODE, GET_MODE, GET_MODE_SIZE(), GET_RTX_FORMAT, GET_RTX_LENGTH, hard_regno_nregs(), i, is_a(), label_ref_label(), MEM_ADDR_SPACE, operands_match_p(), REG_P, REG_WORDS_BIG_ENDIAN, REGNO, RTX_CODE, same_vector_encodings_p(), simplify_subreg_regno(), SUBREG_BYTE, SUBREG_REG, subreg_regno_offset(), XEXP, XINT, XSTR, XVECEXP, XVECLEN, XWINT, and y.

Referenced by find_reloads(), and operands_match_p().

◆ push_reload()

int push_reload ( rtx in,
rtx out,
rtx * inloc,
rtx * outloc,
enum reg_class rclass,
machine_mode inmode,
machine_mode outmode,
int strict_low,
int optional,
int opnum,
enum reload_type type )
extern
Record one reload that needs to be performed.   
Record one reload that needs to be performed.
IN is an rtx saying where the data are to be found before this instruction.
OUT says where they must be stored after the instruction.
(IN is zero for data not read, and OUT is zero for data not written.)
INLOC and OUTLOC point to the places in the instructions where
IN and OUT were found.
If IN and OUT are both nonzero, it means the same register must be used
to reload both IN and OUT.

RCLASS is a register class required for the reloaded data.
INMODE is the machine mode that the instruction requires
for the reg that replaces IN and OUTMODE is likewise for OUT.

If IN is zero, then OUT's location and mode should be passed as
INLOC and INMODE.

STRICT_LOW is the 1 if there is a containing STRICT_LOW_PART rtx.

OPTIONAL nonzero means this reload does not need to be performed:
it can be discarded if that is more convenient.

OPNUM and TYPE say what the purpose of this reload is.

The return value is the reload-number for this reload.

If both IN and OUT are nonzero, in some rare cases we might
want to make two separate reloads.  (Actually we never do this now.)
Therefore, the reload-number for OUT is stored in
output_reloadnum when we return; the return value applies to IN.
Usually (presently always), when IN and OUT are nonzero,
the two reload-numbers are equal, but the caller should be careful to
distinguish them.   

References bitmap_bit_p, can_reload_into(), cfun, complex_word_subreg_p(), const0_rtx, CONSTANT_P, contains_allocatable_reg_of_mode, DF_LR_OUT, earlyclobber_operand_p(), end_hard_regno(), ENTRY_BLOCK_PTR_FOR_FN, error_for_asm(), find_dummy_reload(), find_equiv_reg(), find_reg_fusage(), find_reusable_reload(), find_valid_class(), find_valid_class_1(), fixed_regs, gcc_assert, gen_rtx_REG(), GET_CODE, GET_MODE, GET_MODE_SIZE(), get_secondary_mem(), hard_reg_set_here_p(), hard_regno_nregs(), hard_regs_live_known, i, in_hard_reg_set_p(), is_a(), known_le, LOAD_EXTEND_OP, MAX, maybe_gt, MEM_ADDR_SPACE, MEM_P, MERGE_TO_OTHER, MIN, rtx_def::mode, mode_dependent_address_p(), n_reloads, n_replacements, NULL, NULL_RTX, ORIGINAL_REGNO, output_reloadnum, paradoxical_subreg_p(), partial_subreg_p(), PATTERN(), push_reload(), push_secondary_reload(), r, refers_to_regno_for_reload_p(), REG_CAN_CHANGE_MODE_P, reg_class_contents, reg_class_subset_p(), reg_equiv_constant, reg_equiv_mem, reg_mentioned_p(), REG_NOTE_KIND, REG_NOTES, REG_NREGS, reg_or_subregno(), reg_overlap_mentioned_for_reload_p(), REG_P, reg_renumber, REGNO, RELOAD_FOR_OUTPUT, reload_inner_reg_of_subreg(), RELOAD_OTHER, remove_address_replacements(), replace_equiv_address_nv(), replace_reloads, replacements, rld, rtx_equal_p(), secondary_reload_class(), static_reload_reg_p, SUBREG_BYTE, subreg_lowpart_p(), SUBREG_REG, subreg_regno(), subreg_regno_offset(), targetm, TEST_HARD_REG_BIT, this_insn, this_insn_is_asm, type(), replacement::what, word_mode, WORD_REGISTER_OPERATIONS, and XEXP.

Referenced by find_reloads(), find_reloads_address(), find_reloads_address_1(), find_reloads_address_part(), find_reloads_subreg_address(), and push_reload().

◆ reg_overlap_mentioned_for_reload_p()

int reg_overlap_mentioned_for_reload_p ( rtx x,
rtx in )
extern
Nonzero if modifying X will affect IN.   
Nonzero if modifying X will affect IN.  If X is a register or a SUBREG,
we check if any register number in X conflicts with the relevant register
numbers.  If X is a constant, return 0.  If X is a MEM, return 1 iff IN
contains a MEM (we don't bother checking for memory addresses that can't
conflict because we expect this to be a rare case.

This function is similar to reg_overlap_mentioned_p in rtlanal.cc except
that we look at equivalences for pseudos that didn't get hard registers.   

References CONSTANT_P, END_REGNO(), gcc_assert, GET_CODE, GET_MODE, GET_RTX_CLASS, MEM_P, refers_to_mem_for_reload_p(), refers_to_regno_for_reload_p(), reg_equiv_constant, reg_equiv_memory_loc, reg_mentioned_p(), reg_overlap_mentioned_for_reload_p(), REG_P, REGNO, RTX_AUTOINC, rtx_equal_p(), SUBREG_BYTE, subreg_nregs(), SUBREG_REG, subreg_regno_offset(), and XEXP.

Referenced by choose_reload_regs(), combine_reloads(), find_equiv_reg(), push_reload(), and reg_overlap_mentioned_for_reload_p().

◆ register_move_cost()

int register_move_cost ( machine_mode mode,
reg_class_t from,
reg_class_t to )
extern
Communication between reload.cc, reload1.cc and the rest of compiler.
   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/>.   
If secondary reloads are the same for inputs and outputs, define those
macros here.   
Compute cost of moving data from a register of class FROM to one of
TO, using MODE.   

References targetm.

Referenced by choose_reload_regs(), find_reloads(), find_valid_class(), find_valid_class_1(), ira_init_register_move_cost(), memory_move_secondary_cost(), and reload_cse_simplify_set().

◆ regno_clobbered_p()

int regno_clobbered_p ( unsigned int regno,
rtx_insn * insn,
machine_mode mode,
int sets )
extern
Return 1 if register REGNO is the subject of a clobber in insn INSN.   
Return 1 if register REGNO is the subject of a clobber in insn INSN.
If SETS is 1, also consider SETs.  If SETS is 2, enable checking
REG_INC.  REGNO must refer to a hard register.   

References end_hard_regno(), gcc_assert, GET_CODE, i, replacement::mode, PATTERN(), reg_inc_found_and_valid_p(), REG_P, REGNO, SET, XEXP, XVECEXP, and XVECLEN.

Referenced by choose_reload_regs(), emit_output_reload_insns(), find_reloads_address(), and find_reloads_address_1().

◆ reload()

bool reload ( rtx_insn * first,
int global )
extern
The reload pass itself.   
Main entry point for the reload pass.

FIRST is the first insn of the function being compiled.

GLOBAL nonzero means we were called from global_alloc
and should attempt to reallocate any pseudoregs that we
displace from hard regs we will use for reloads.
If GLOBAL is zero, we do not have enough information to do that,
so any pseudo reg that is spilled must go to the stack.

Return value is TRUE if reload likely left dead insns in the
stream and a DCE pass should be run to elimiante them.  Else the
return value is FALSE.   

References add_auto_inc_notes(), alter_reg(), asm_noperands(), assign_stack_local(), AUTO_INC_DEC, bad_spill_regs_global, bitmap_clear_bit(), bitmap_empty_p(), bitmap_ones(), calculate_needs_all_insns(), CALL_INSN_FUNCTION_USAGE, CALL_P, caller_save_needed, elim_table::can_eliminate, cfun, changed_allocation_pseudos, cleanup_subreg_operands(), CLEAR_HARD_REG_SET, CLEAR_REG_SET, clear_secondary_mem(), commit_edge_insertions(), CONSTANT_P, constrain_operands(), crtl, DEBUG_BIND_INSN_P, delete_caller_save_insns(), delete_insn(), df_get_live_in(), df_insn_rescan_debug_internal(), DF_REF_INSN, DF_REF_NEXT_REG, DF_REG_USE_CHAIN, df_set_regs_ever_live(), eliminate_regs(), emit_note(), error_for_asm(), extract_insn(), failure, find_many_sub_basic_blocks(), find_reg_note(), finish_spills(), fixed_regs, fixup_abnormal_edges(), FOR_EACH_BB_FN, frame_pointer_needed, free(), free_reg_equiv(), elim_table::from, gcc_assert, gen_rtx_UNKNOWN_VAR_LOC, GET_CODE, get_enabled_alternatives(), get_frame_size(), get_max_uid(), GET_MODE, grow_reg_equivs(), HARD_FRAME_POINTER_IS_FRAME_POINTER, HARD_FRAME_POINTER_REGNUM, has_nonexceptional_receiver(), i, init_elim_table(), init_eliminable_invariants(), init_recog(), init_save_areas(), INSN_P, INSN_VAR_LOCATION_LOC, insns_need_reload, ira_conflicts_p, ira_sort_regnos_for_alter_reg(), known_eq, last_basic_block_for_fn, last_spill_reg, LAST_VIRTUAL_REGISTER, LOCAL_REGNO, mark_elimination(), mark_home_live(), mark_not_eliminable(), max_regno, MAY_HAVE_DEBUG_BIND_INSNS, maybe_fix_stack_asms(), MEM_ADDR_SPACE, MEM_ATTRS, MEM_COPY_ATTRIBUTES, MEM_NOTRAP_P, MEM_P, n_spills, need_dce, NEXT_INSN(), NONJUMP_INSN_P, note_pattern_stores(), NULL, NULL_RTX, num_eliminable, NUM_ELIMINABLE_REGS, PATTERN(), pseudo_forbidden_regs, pseudo_previous_regs, PUT_CODE, reg_eliminate, reg_equiv_address, reg_equiv_constant, reg_equiv_init, reg_equiv_invariant, reg_equiv_mem, reg_equiv_memory_loc, REG_FUNCTION_VALUE_P, reg_max_ref_mode, REG_NOTE_KIND, REG_NOTES, reg_old_renumber, REG_P, reg_renumber, REG_USERVAR_P, REGNO, REGNO_POINTER_ALIGN, regno_reg_rtx, reload_as_needed(), reload_completed, reload_first_uid, reload_firstobj, reload_in_progress, reload_obstack, reload_startobj, remove_init_insns(), replace_pseudos_in(), save_call_clobbered_regs(), select_reload_regs(), SET, SET_DEST, SET_HARD_REG_BIT, set_initial_elim_offsets(), set_initial_label_offsets(), SET_SRC, setup_save_areas(), simplify_replace_rtx(), something_needs_elimination, something_needs_operands_changed, something_was_spilled, spill_hard_reg, spill_regs, spill_stack_slot, spill_stack_slot_width, spilled_pseudos, stack_pointer_rtx, strict_memory_address_addr_space_p(), substitute_stack, targetm, temp_pseudo_reg_arr, elim_table::to, unshare_all_rtl_again(), unused_insn_chains, update_eliminables_and_spill(), used_spill_regs, verify_initial_elim_offsets(), and XEXP.

Referenced by copy_reloads(), do_reload(), find_reg(), and find_reload_regs().

◆ reload_adjust_reg_for_mode()

rtx reload_adjust_reg_for_mode ( rtx reloadreg,
machine_mode mode )
extern
Compute the actual register we should reload to, in case we're
reloading to/from a register that is wider than a word.   
Find the low part, with mode MODE, of a hard regno RELOADREG.   

References gen_rtx_REG(), GET_MODE, hard_regno_nregs(), replacement::mode, REG_NREGS, REG_WORDS_BIG_ENDIAN, and REGNO.

Referenced by do_input_reload(), do_output_reload(), emit_output_reload_insns(), find_replacement(), reload_adjust_reg_for_temp(), and subst_reloads().

◆ remove_address_replacements()

int remove_address_replacements ( rtx in_rtx)
extern
IN_RTX is the value loaded by a reload that we now decided to inherit,
or a subpart of it.  If we have any replacements registered for IN_RTX,
cancel the reloads that were supposed to load them.
Return nonzero if we canceled any reloads.   

References deallocate_reload_reg(), i, loc_mentioned_in_p(), MAX_RELOADS, n_reloads, n_replacements, remove_address_replacements(), replacements, rld, replacement::what, and replacement::where.

Referenced by choose_reload_regs(), push_reload(), and remove_address_replacements().

◆ safe_from_earlyclobber()

int safe_from_earlyclobber ( rtx op,
rtx clobber )
extern
Return 1 if altering OP will not modify the value of CLOBBER.   
Similar, but calls decompose.   

References decompose(), and immune_p().

Referenced by constrain_operands().

◆ save_call_clobbered_regs()

◆ secondary_reload_class()

reg_class_t secondary_reload_class ( bool in_p,
reg_class_t rclass,
machine_mode mode,
rtx x )
extern
Functions from reload.cc:   
If a secondary reload is needed, return its class.  If both an intermediate
register and a scratch register is needed, we return the class of the
intermediate register.   

References secondary_reload_info::icode, NULL, secondary_reload_info::prev_sri, scratch_reload_class(), and targetm.

Referenced by choose_reload_regs(), emit_output_reload_insns(), memory_move_secondary_cost(), and push_reload().

◆ setup_save_areas()

void setup_save_areas ( void )
extern
Allocate save areas for any hard registers that might need saving.   
Allocate save areas for any hard registers that might need saving.
We take a conservative approach here and look for call-clobbered hard
registers that are assigned to pseudos that cross calls.  This may
overestimate slightly (especially if some of these registers are later
used as spill registers), but it should not be significant.

For IRA we use priority coloring to decrease stack slots needed for
saving hard registers through calls.  We build conflicts for them
to do coloring.

Future work:

  In the fallback case we should iterate backwards across all possible
  modes for the save, choosing the largest available one instead of
  falling back to the smallest mode immediately.  (eg TF -> DF -> SF).

  We do not try to use "move multiple" instructions that exist
  on some machines (such as the 68k moveml).  It could be a win to try
  and use them when possible.  The hard part is doing it in a way that is
  machine independent since they might be saving non-consecutive
  registers. (imagine caller-saving d0,d1,a0,a1 on the 68k)  

References adjust_address_nv, all_saved_regs, ASLK_REDUCE_ALIGN, assign_stack_local_1(), BLOCK_FOR_INSN(), saved_hard_reg::call_freq, CALL_P, CLEAR_HARD_REG_SET, crtl, dump_file, EXECUTE_IF_SET_IN_REG_SET, find_reg_note(), finish_saved_hard_regs(), saved_hard_reg::first_p, fixed_reg_set, free(), function_abi::full_reg_clobbers(), gcc_assert, get_frame_alias_set(), GET_MODE, GET_MODE_SIZE(), hard_reg_map, saved_hard_reg::hard_regno, hard_regno_nregs(), i, initiate_saved_hard_regs(), insn_callee_abi(), known_le, mark_set_regs(), MOVE_MAX_WORDS, new_saved_hard_reg(), saved_hard_reg::next, note_stores(), NULL, NULL_RTX, saved_hard_reg::num, PSEUDO_REGNO_MODE, qsort, r, REG_FREQ_FROM_BB, reg_renumber, REG_SET_TO_HARD_REG_SET, regno_reg_rtx, regno_save_mem, regno_save_mode, reload_insn_chain, savable_regs, save_slots, save_slots_num, saved_hard_reg_compare_func(), saved_regs_num, SET_HARD_REG_BIT, set_mem_alias_set(), SIBLING_CALL_P, saved_hard_reg::slot, TEST_HARD_REG_BIT, used_regs, and XEXP.

Referenced by reload().

◆ subst_reloads()

void subst_reloads ( rtx_insn * insn)
extern
Substitute into the current INSN the registers into which we have reloaded
the things that need reloading.   
Substitute into the current INSN the registers into which we have reloaded
the things that need reloading.  The array `replacements'
contains the locations of all pointers that must be changed
and says what to replace them with.

Return the rtx that X translates into; usually X, but modified.   

References find_reg_note(), gcc_assert, GET_CODE, GET_MODE, i, JUMP_P, label_is_jump_target_p(), max_regno, rtx_def::mode, n_replacements, r, reload_adjust_reg_for_mode(), replacements, rld, and XEXP.

Referenced by reload_as_needed().

◆ transfer_replacements()

void transfer_replacements ( int to,
int from )
extern
Transfer all replacements that used to be in reload FROM to be in
reload TO.   

References i, n_replacements, replacements, and replacement::what.

Referenced by find_reloads().

Variable Documentation

◆ default_target_reload

struct target_reload default_target_reload
extern
Reload pseudo regs into hard regs for insns that require hard regs.
   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/>.   
This file contains the reload pass of the compiler, which is
run after register allocation has been done.  It checks that
each insn is valid (operands required to be in registers really
are in registers of the proper class) and fixes up invalid ones
by copying values temporarily into registers for the insns
that need them.

The results of register allocation are described by the vector
reg_renumber; the insns still contain pseudo regs, but reg_renumber
can be used to find which hard reg, if any, a pseudo reg is in.

The technique we always use is to free up a few hard regs that are
called ``reload regs'', and for each place where a pseudo reg
must be in a hard reg, copy it temporarily into one of the reload regs.

Reload regs are allocated locally for every instruction that needs
reloads.  When there are pseudos which are allocated to a register that
has been chosen as a reload reg, such pseudos must be ``spilled''.
This means that they go to other hard regs, or to stack slots if no other
available hard regs can be found.  Spilling can invalidate more
insns, requiring additional need for reloads, so we must keep checking
until the process stabilizes.

For machines with different classes of registers, we must keep track
of the register class needed for each reload, and make sure that
we allocate enough reload registers of each class.

The file reload.cc contains the code that checks one insn for
validity and reports the reloads that it needs.  This file
is in charge of scanning the entire rtl code, accumulating the
reload needs, spilling, assigning reload registers to use for
fixing up each insn, and generating the new insns to copy values
into the reload registers.   

◆ n_earlyclobbers

int n_earlyclobbers
extern
All the "earlyclobber" operands of the current insn
are recorded here.   

Referenced by choose_reload_regs(), earlyclobber_operand_p(), and find_reloads().

◆ num_not_at_initial_offset

int num_not_at_initial_offset
extern
Record the number of pending eliminations that have an offset not equal
to their initial offset.  If nonzero, we use a new copy of each
replacement result in any insns encountered.   

Referenced by emit_input_reload_insns(), find_reloads(), find_reloads_address(), find_reloads_address_1(), find_reloads_toplev(), set_initial_elim_offsets(), set_offsets_for_label(), subst_reg_equivs(), and update_eliminable_offsets().

◆ reg_equivs

◆ reload_earlyclobbers

rtx reload_earlyclobbers[MAX_RECOG_OPERANDS]
extern

◆ reload_first_uid

int reload_first_uid
extern
First uid used by insns created by reload in this function.
Used in find_equiv_reg.   

Referenced by delete_address_reloads_1(), find_equiv_reg(), and reload().

◆ reload_n_operands

int reload_n_operands
extern