GCC Middle and Back End API Reference
regcprop.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "df.h"
#include "memmodel.h"
#include "tm_p.h"
#include "insn-config.h"
#include "regs.h"
#include "emit-rtl.h"
#include "recog.h"
#include "diagnostic-core.h"
#include "addresses.h"
#include "tree-pass.h"
#include "rtl-iter.h"
#include "cfgrtl.h"
#include "target.h"
#include "function-abi.h"
Include dependency graph for regcprop.cc:

Data Structures

struct  queued_debug_insn_change
struct  value_data_entry
struct  value_data
struct  kill_set_value_data


static void kill_value_one_regno (unsigned, struct value_data *)
static void kill_value_regno (unsigned, unsigned, struct value_data *)
static void kill_value (const_rtx, struct value_data *)
static void set_value_regno (unsigned, machine_mode, struct value_data *)
static void init_value_data (struct value_data *)
static void kill_clobbered_value (rtx, const_rtx, void *)
static void kill_set_value (rtx, const_rtx, void *)
static void copy_value (rtx, rtx, struct value_data *)
static bool mode_change_ok (machine_mode, machine_mode, unsigned int)
static rtx maybe_mode_change (machine_mode, machine_mode, machine_mode, unsigned int, unsigned int)
static rtx find_oldest_value_reg (enum reg_class, rtx, struct value_data *)
static bool replace_oldest_value_reg (rtx *, enum reg_class, rtx_insn *, struct value_data *)
static bool replace_oldest_value_addr (rtx *, enum reg_class, machine_mode, addr_space_t, rtx_insn *, struct value_data *)
static bool replace_oldest_value_mem (rtx, rtx_insn *, struct value_data *)
static bool copyprop_hardreg_forward_1 (basic_block, struct value_data *)
void debug_value_data (struct value_data *)
static void validate_value_data (struct value_data *)
static void free_debug_insn_changes (struct value_data *vd, unsigned int regno)
static void kill_value_one_regno (unsigned int regno, struct value_data *vd)
static void kill_value_regno (unsigned int regno, unsigned int nregs, struct value_data *vd)
static void set_value_regno (unsigned int regno, machine_mode mode, struct value_data *vd)
static void kill_autoinc_value (rtx_insn *insn, struct value_data *vd)
static void apply_debug_insn_changes (struct value_data *vd, unsigned int regno)
static void cprop_find_used_regs (rtx *loc, void *data)
static void kill_clobbered_values (rtx_insn *insn, struct value_data *vd)
void copyprop_hardreg_forward_bb_without_debug_insn (basic_block bb)
rtl_opt_passmake_pass_cprop_hardreg (gcc::context *ctxt)


static object_allocator< queued_debug_insn_changequeued_debug_insn_change_pool ("debug insn changes pool")
static bool skip_debug_insn_p

Function Documentation

◆ apply_debug_insn_changes()

static void apply_debug_insn_changes ( struct value_data * vd,
unsigned int regno )
Apply all queued updates for DEBUG_INSNs that change some reg to
register REGNO.   

References apply_change_group(), value_data_entry::debug_insn_changes, value_data::e, ggc_alloc(), queued_debug_insn_change::insn, and validate_change().

Referenced by cprop_find_used_regs().

◆ copy_value()

◆ copyprop_hardreg_forward_1()

static bool copyprop_hardreg_forward_1 ( basic_block bb,
struct value_data * vd )
Perform the forward copy propagation on basic block BB.   

References ADDR_SPACE_GENERIC, alternative_class(), apply_change_group(), asm_noperands(), BB_END, BB_HEAD, CALL_INSN_FUNCTION_USAGE, CALL_P, changed, recog_data_d::constraints, copy_value(), cprop_find_used_regs(), DEBUG_BIND_INSN_P, delete_insn(), df_insn_rescan(), dump_file, recog_data_d::dup_loc, recog_data_d::dup_num, value_data::e, exp(), extract_constrain_insn(), find_oldest_value_reg(), find_reg_note(), GET_CODE, GET_MODE, ggc_alloc(), hard_regno_nregs(), i, insn_callee_abi(), INSN_UID(), INSN_VAR_LOCATION_LOC, INVALID_REGNUM, kill_autoinc_value(), kill_clobbered_values(), kill_set_value(), kill_value(), kill_value_regno(), last, may_trap_p(), maybe_mode_change(), MEM_P, value_data_entry::mode, value_data::n_debug_insn_changes, recog_data_d::n_dups, recog_data_d::n_operands, NEXT_INSN(), value_data_entry::next_regno, NONDEBUG_INSN_P, NONJUMP_INSN_P, noop_move_p(), note_stores(), note_uses(), NULL, NULL_RTX, value_data_entry::oldest_regno, OP_IN, OP_INOUT, OP_OUT, recog_data_d::operand, recog_data_d::operand_loc, recog_data_d::operand_type, ORIGINAL_REGNO, partial_subreg_p(), PATTERN(), preprocess_constraints(), recog_data, REG_ATTRS, REG_NOTE_KIND, REG_NOTES, REG_NREGS, reg_overlap_mentioned_p(), REG_P, REG_POINTER, REGNO, replace_oldest_value_addr(), replace_oldest_value_mem(), replace_oldest_value_reg(), rtx_equal_p(), RTX_FRAME_RELATED_P, SET, SET_DEST, SET_SRC, set_value_regno(), side_effects_p(), single_set(), stack_pointer_rtx, subreg_lowpart_offset(), targetm, validate_change(), validate_unshare_change(), VAR_LOC_UNKNOWN_P, kill_set_value_data::vd, which_op_alt(), and XEXP.

Referenced by copyprop_hardreg_forward_bb_without_debug_insn().

◆ copyprop_hardreg_forward_bb_without_debug_insn()

void copyprop_hardreg_forward_bb_without_debug_insn ( basic_block bb)
Do copyprop_hardreg_forward_1 for a single basic block BB.
DEBUG_INSN is skipped since we do not want to involve DF related
staff as how it is handled in function pass_cprop_hardreg::execute.

NOTE: Currently it is only used for shrink-wrap.  Maybe extend it
to handle DEBUG_INSN for other uses.   

References copyprop_hardreg_forward_1(), free(), ggc_alloc(), init_value_data(), and skip_debug_insn_p.

Referenced by prepare_shrink_wrap().

◆ cprop_find_used_regs()

static void cprop_find_used_regs ( rtx * loc,
void * data )
Called via note_uses, for all used registers in a real insn
apply DEBUG_INSN changes that change registers to the used

References apply_debug_insn_changes(), value_data_entry::debug_insn_changes, value_data::e, FOR_EACH_SUBRTX, free_debug_insn_changes(), ggc_alloc(), REG_P, and REGNO.

Referenced by copyprop_hardreg_forward_1().

◆ debug_value_data()

◆ find_oldest_value_reg()

static rtx find_oldest_value_reg ( enum reg_class cl,
rtx reg,
struct value_data * vd )
Find the oldest copy of the value contained in REGNO that is in
register class CL and has mode MODE.  If found, return an rtx
of that oldest register, otherwise return NULL.   

References value_data::e, gcc_assert, GET_MODE, ggc_alloc(), hard_regno_nregs(), i, in_hard_reg_set_p(), maybe_mode_change(), value_data_entry::mode, value_data_entry::next_regno, NULL_RTX, value_data_entry::oldest_regno, ORIGINAL_REGNO, REG_ATTRS, REG_CAN_CHANGE_MODE_P, reg_class_contents, REG_NREGS, REG_POINTER, REGNO, stack_pointer_rtx, and kill_set_value_data::vd.

Referenced by copyprop_hardreg_forward_1(), and replace_oldest_value_reg().

◆ free_debug_insn_changes()

static void free_debug_insn_changes ( struct value_data * vd,
unsigned int regno )
Free all queued updates for DEBUG_INSNs that change some reg to
register REGNO.   

References value_data_entry::debug_insn_changes, value_data::e, value_data::n_debug_insn_changes, queued_debug_insn_change::next, NULL, and queued_debug_insn_change_pool.

Referenced by cprop_find_used_regs(), and kill_value_one_regno().

◆ init_value_data()

◆ kill_autoinc_value()

static void kill_autoinc_value ( rtx_insn * insn,
struct value_data * vd )
Kill any register used in X as the base of an auto-increment expression,
and install that register as the root of its own value list.   

References FOR_EACH_SUBRTX, GET_CODE, GET_MODE, GET_RTX_CLASS, ggc_alloc(), kill_value(), PATTERN(), REGNO, RTX_AUTOINC, set_value_regno(), kill_set_value_data::vd, and XEXP.

Referenced by copyprop_hardreg_forward_1().

◆ kill_clobbered_value()

static void kill_clobbered_value ( rtx x,
const_rtx set,
void * data )
Called through note_stores.  If X is clobbered, kill its value.   

References GET_CODE, ggc_alloc(), and kill_value().

Referenced by kill_clobbered_values().

◆ kill_clobbered_values()

static void kill_clobbered_values ( rtx_insn * insn,
struct value_data * vd )
Apply clobbers of INSN in PATTERN and C_I_F_U to value_data VD.   

References kill_clobbered_value(), and note_stores().

Referenced by copyprop_hardreg_forward_1().

◆ kill_set_value()

static void kill_set_value ( rtx x,
const_rtx set,
void * data )
Called through note_stores.  If X is set, not clobbered, kill its
current value and install it as the root of its own value list.   

References GET_CODE, GET_MODE, ggc_alloc(), kill_value(), REG_P, REGNO, rtx_equal_p(), and set_value_regno().

Referenced by copyprop_hardreg_forward_1().

◆ kill_value()

static void kill_value ( const_rtx x,
struct value_data * vd )
Kill X.  This is a convenience function wrapping kill_value_regno
so that we mind the mode the register is in.   

References GET_CODE, GET_MODE, ggc_alloc(), kill_value_regno(), REG_NREGS, REG_P, REGNO, simplify_subreg(), SUBREG_BYTE, and SUBREG_REG.

Referenced by copyprop_hardreg_forward_1(), kill_autoinc_value(), kill_clobbered_value(), and kill_set_value().

◆ kill_value_one_regno() [1/2]

static void kill_value_one_regno ( unsigned int regno,
struct value_data * vd )
Kill register REGNO.  This involves removing it from any value
lists, and resetting the value mode to VOIDmode.  This is only a
helper function; it does not handle any hard registers overlapping
with REGNO.   

References value_data_entry::debug_insn_changes, value_data::e, free_debug_insn_changes(), ggc_alloc(), i, INVALID_REGNUM, value_data_entry::mode, queued_debug_insn_change::next, value_data_entry::next_regno, value_data_entry::oldest_regno, and validate_value_data().

◆ kill_value_one_regno() [2/2]

static void kill_value_one_regno ( unsigned ,
struct value_data *  )

Referenced by kill_value_regno().

◆ kill_value_regno() [1/2]

static void kill_value_regno ( unsigned int regno,
unsigned int nregs,
struct value_data * vd )
Kill the value in register REGNO for NREGS, and any other registers
whose values overlap.   

References value_data::e, ggc_alloc(), hard_regno_nregs(), i, kill_value_one_regno(), max_value_regs, value_data::max_value_regs, and value_data_entry::mode.

◆ kill_value_regno() [2/2]

static void kill_value_regno ( unsigned ,
unsigned ,
struct value_data *  )

◆ make_pass_cprop_hardreg()

rtl_opt_pass * make_pass_cprop_hardreg ( gcc::context * ctxt)

References ggc_alloc().

◆ maybe_mode_change()

static rtx maybe_mode_change ( machine_mode orig_mode,
machine_mode copy_mode,
machine_mode new_mode,
unsigned int regno,
unsigned int copy_regno )
Register REGNO was originally set in ORIG_MODE.  It - or a copy of it -
was copied in COPY_MODE to COPY_REGNO, and then COPY_REGNO was accessed
Return a NEW_MODE rtx for REGNO if that's OK, otherwise return NULL_RTX.   

References gen_raw_REG(), GET_MODE, GET_MODE_SIZE(), ggc_alloc(), hard_regno_nregs(), mode_change_ok(), new_mode(), NULL_RTX, offset, partial_subreg_p(), stack_pointer_rtx, subreg_regno_offset(), subreg_size_lowpart_offset(), and targetm.

Referenced by copyprop_hardreg_forward_1(), and find_oldest_value_reg().

◆ mode_change_ok()

static bool mode_change_ok ( machine_mode orig_mode,
machine_mode new_mode,
unsigned int regno )
Return true if a mode change from ORIG to NEW is allowed for REGNO.   

References new_mode(), partial_subreg_p(), and REG_CAN_CHANGE_MODE_P.

Referenced by maybe_mode_change().

◆ replace_oldest_value_addr()

static bool replace_oldest_value_addr ( rtx * loc,
enum reg_class cl,
machine_mode mode,
addr_space_t as,
rtx_insn * insn,
struct value_data * vd )
Similar to replace_oldest_value_reg, but *LOC contains an address.
Adapted from find_reloads_address_1.  CL is INDEX_REG_CLASS or
BASE_REG_CLASS depending on how the register is being considered.   

References base_reg_class(), changed, DEBUG_INSN_P, GET_CODE, GET_RTX_FORMAT, GET_RTX_LENGTH, ggc_alloc(), i, queued_debug_insn_change::insn, queued_debug_insn_change::loc, NULL, REGNO, regno_ok_for_base_p(), replace_oldest_value_addr(), replace_oldest_value_mem(), replace_oldest_value_reg(), RTX_CODE, SUBREG_REG, XEXP, XVECEXP, and XVECLEN.

Referenced by copyprop_hardreg_forward_1(), replace_oldest_value_addr(), and replace_oldest_value_mem().

◆ replace_oldest_value_mem()

static bool replace_oldest_value_mem ( rtx x,
rtx_insn * insn,
struct value_data * vd )

◆ replace_oldest_value_reg()

◆ set_value_regno() [1/2]

static void set_value_regno ( unsigned int regno,
machine_mode mode,
struct value_data * vd )
Remember that REGNO is valid in MODE.   

References value_data::e, hard_regno_nregs(), value_data::max_value_regs, and value_data_entry::mode.

◆ set_value_regno() [2/2]

static void set_value_regno ( unsigned ,
machine_mode ,
struct value_data *  )

◆ validate_value_data()

Variable Documentation

◆ queued_debug_insn_change_pool

object_allocator< queued_debug_insn_change > queued_debug_insn_change_pool("debug insn changes pool") ( "debug insn changes pool" )

◆ skip_debug_insn_p