GCC Middle and Back End API Reference
regrename.c File Reference

Data Structures

struct  incoming_reg_info
struct  bb_rename_info

Enumerations

enum  scan_actions {
  terminate_write, terminate_dead, mark_all_read, mark_read,
  mark_write, mark_access
}

Functions

static void scan_rtx (rtx, rtx *, enum reg_class, enum scan_actions, enum op_type)
static bool build_def_use (basic_block)
du_head_p regrename_chain_from_id ()
static void dump_def_use_chain ()
static void free_chain_data ()
static void mark_conflict ()
static void record_operand_use ()
static du_head_p create_new_chain (unsigned this_regno, unsigned this_nregs, rtx *loc, rtx insn, enum reg_class cl)
static void merge_overlapping_regs ()
static bool check_new_reg_p (int reg, int new_reg, struct du_head *this_head, HARD_REG_SET this_unavailable)
int find_best_rename_reg (du_head_p this_head, enum reg_class super_class, HARD_REG_SET *unavailable, int old_reg)
static void rename_chains ()
static void init_rename_info ()
static void set_incoming_from_chain ()
static void merge_chains ()
void regrename_analyze ()
void regrename_do_replace ()
static bool verify_reg_in_set ()
static bool verify_reg_tracked ()
static void note_sets_clobbers ()
static void scan_rtx_reg (rtx insn, rtx *loc, enum reg_class cl, enum scan_actions action, enum op_type type)
static void scan_rtx_address (rtx insn, rtx *loc, enum reg_class cl, enum scan_actions action, enum machine_mode mode, addr_space_t as)
static void hide_operands (int n_ops, rtx *old_operands, rtx *old_dups, unsigned HOST_WIDE_INT do_not_hide, bool inout_and_ec_only)
static void restore_operands ()
static void record_out_operands ()
static bool build_def_use ()
void regrename_init ()
void regrename_finish ()
static unsigned int regrename_optimize ()
static bool gate_handle_regrename ()
rtl_opt_passmake_pass_regrename ()

Variables

static const char *const scan_actions_name []
static int tick [FIRST_PSEUDO_REGISTER]
static int this_tick = 0
static struct obstack rename_obstack
vec< insn_rr_infoinsn_rr
static unsigned current_id
static vec< du_head_pid_to_chain
static struct du_headopen_chains
static bitmap_head open_chains_set
static HARD_REG_SET live_in_chains
static HARD_REG_SET live_hard_regs
static operand_rr_infocur_operand
static bool fail_current_block

Enumeration Type Documentation

Register renaming for the GNU compiler.
   Copyright (C) 2000-2013 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 implements the RTL register renaming pass of the compiler.  It is
   a semi-local pass whose goal is to maximize the usage of the register file
   of the processor by substituting registers for others in the solution given
   by the register allocator.  The algorithm is as follows:

     1. Local def/use chains are built: within each basic block, chains are
        opened and closed; if a chain isn't closed at the end of the block,
        it is dropped.  We pre-open chains if we have already examined a
        predecessor block and found chains live at the end which match
        live registers at the start of the new block.

     2. We try to combine the local chains across basic block boundaries by
        comparing chains that were open at the start or end of a block to
        those in successor/predecessor blocks.

     3. For each chain, the set of possible renaming registers is computed.
        This takes into account the renaming of previously processed chains.
        Optionally, a preferred class is computed for the renaming register.

     4. The best renaming register is computed for the chain in the above set,
        using a round-robin allocation.  If a preferred class exists, then the
        round-robin allocation is done within the class first, if possible.
        The round-robin allocation of renaming registers itself is global.

     5. If a renaming register has been found, it is substituted in the chain.

  Targets can parameterize the pass by specifying a preferred class for the
  renaming register for a given (super)class of registers to be renamed.   
Enumerator:
terminate_write 
terminate_dead 
mark_all_read 
mark_read 
mark_write 
mark_access 

Function Documentation

static bool build_def_use ( basic_block  )
static

Referenced by regrename_analyze().

static bool check_new_reg_p ( int  reg,
int  new_reg,
struct du_head this_head,
HARD_REG_SET  this_unavailable 
)
static
Check if NEW_REG can be the candidate register to rename for
   REG in THIS_HEAD chain.  THIS_UNAVAILABLE is a set of unavailable hard
   registers.   

References df_regs_ever_live_p(), du_head::first, global_regs, du_chain::insn, du_chain::loc, du_head::need_caller_save_reg, and du_chain::next_use.

Referenced by find_best_rename_reg().

static du_head_p create_new_chain ( unsigned  this_regno,
unsigned  this_nregs,
rtx loc,
rtx  insn,
enum reg_class  cl 
)
static
static void dump_def_use_chain ( )
static
Dump all def/use chains, starting at id FROM.   

References dump_file, du_head::first, du_chain::insn, du_head::next_chain, du_chain::next_use, du_head::nregs, reg_class_names, and du_head::regno.

Referenced by regrename_analyze().

int find_best_rename_reg ( du_head_p  this_head,
enum reg_class  super_class,
HARD_REG_SET unavailable,
int  old_reg 
)
For the chain THIS_HEAD, compute and return the best register to
   rename to.  SUPER_CLASS is the superunion of register classes in
   the chain.  UNAVAILABLE is a set of registers that cannot be used.
   OLD_REG is the register currently used for the chain.   

References check_new_reg_p(), merge_overlapping_regs(), du_head::need_caller_save_reg, targetm, and tick.

Referenced by rename_chains().

static void free_chain_data ( )
static

References bitmap_clear(), and du_head::conflicts.

Referenced by regrename_finish().

static bool gate_handle_regrename ( )
static
static void hide_operands ( int  n_ops,
rtx old_operands,
rtx old_dups,
unsigned HOST_WIDE_INT  do_not_hide,
bool  inout_and_ec_only 
)
static
Hide operands of the current insn (of which there are N_OPS) by
   substituting cc0 for them.
   Previous values are stored in the OLD_OPERANDS and OLD_DUPS.
   For every bit set in DO_NOT_HIDE, we leave the operand alone.
   If INOUT_AND_EC_ONLY is set, we only do this for OP_INOUT type operands
   and earlyclobbers.   

References cc0_rtx, recog_data_d::constraints, recog_data_d::dup_loc, recog_data_d::dup_num, operand_alternative::earlyclobber, recog_data_d::n_dups, OP_INOUT, recog_data_d::operand, recog_data_d::operand_loc, recog_data_d::operand_type, recog_data, recog_op_alt, and which_alternative.

Referenced by build_def_use().

rtl_opt_pass* make_pass_regrename ( )
static void mark_conflict ( )
static
Walk all chains starting with CHAINS and record that they conflict with
   another chain whose id is ID.   

References bitmap_set_bit(), du_head::conflicts, and du_head::next_chain.

Referenced by create_new_chain().

static void merge_chains ( )
static
Merge the two chains C1 and C2 so that all conflict information is
   recorded and C1, and the id of C2 is changed to that of C1.   

References bitmap_ior_into(), du_head::cannot_rename, du_head::conflicts, du_head::first, du_head::hard_conflicts, du_head::id, du_head::last, du_head::need_caller_save_reg, and du_chain::next_use.

Referenced by regrename_analyze().

static void merge_overlapping_regs ( )
static
For a def-use chain HEAD, find which registers overlap its lifetime and
   set the corresponding bits in *PSET.   

References du_head::conflicts, du_head::hard_conflicts, du_head::nregs, du_head::regno, and regrename_chain_from_id().

Referenced by find_best_rename_reg().

static void note_sets_clobbers ( )
static
Called through note_stores.  DATA points to a rtx_code, either SET or
   CLOBBER, which tells us which kind of rtx to look at.  If we have a
   match, record the set register in live_hard_regs and in the hard_conflicts
   bitmap of open chains.   

References add_to_hard_reg_set(), du_head::hard_conflicts, live_hard_regs, and du_head::next_chain.

Referenced by build_def_use().

static void record_operand_use ( )
static
Examine cur_operand, and if it is nonnull, record information about the
   use THIS_DU which is part of the chain HEAD.   

References operand_rr_info::chains, operand_rr_info::heads, and operand_rr_info::n_chains.

Referenced by create_new_chain(), and scan_rtx_reg().

static void record_out_operands ( )
static
For each output operand of INSN, call scan_rtx to create a new
   open chain.  Do this only for normal or earlyclobber outputs,
   depending on EARLYCLOBBER.  If INSN_INFO is nonnull, use it to
   record information about the operands in the insn.   

References asm_noperands(), du_head::cannot_rename, operand_alternative::cl, recog_data_d::dup_loc, recog_data_d::dup_num, operand_alternative::earlyclobber, du_chain::loc, mark_write, recog_data_d::n_dups, recog_data_d::n_operands, insn_rr_info::op_info, OP_OUT, open_chains, recog_data_d::operand_loc, recog_data_d::operand_type, recog_data, recog_op_alt, scan_rtx(), and which_alternative.

Referenced by build_def_use().

du_head_p regrename_chain_from_id ( )
Return the chain corresponding to id number ID.  Take into account that
   chains may have been merged.   

References du_head::id.

Referenced by merge_overlapping_regs(), and regrename_analyze().

void regrename_finish ( void  )
Free all global data used by the register renamer.   

References free_chain_data(), and rename_obstack.

Referenced by regrename_optimize().

void regrename_init ( )
Initialize the register renamer.  If INSN_INFO is true, ensure that
   insn_rr is nonnull.   

References get_max_uid(), and rename_obstack.

Referenced by regrename_optimize().

static unsigned int regrename_optimize ( )
static
static void restore_operands ( )
static
Undo the substitution performed by hide_operands.  INSN is the insn we
   are processing; the arguments are the same as in hide_operands.   

References df_insn_rescan(), recog_data_d::dup_loc, recog_data_d::n_dups, recog_data_d::operand_loc, and recog_data.

Referenced by build_def_use().

static void scan_rtx ( rtx  insn,
rtx loc,
enum reg_class  cl,
enum scan_actions  action,
enum op_type  type 
)
static
static void scan_rtx_address ( rtx  insn,
rtx loc,
enum reg_class  cl,
enum scan_actions  action,
enum machine_mode  mode,
addr_space_t  as 
)
static
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(), du_chain::loc, mark_access, mark_all_read, mark_write, OP_IN, regno_ok_for_base_p(), and scan_rtx_reg().

Referenced by build_def_use(), and scan_rtx().

static void set_incoming_from_chain ( )
static
Record in RI that the block corresponding to it has an incoming
   live value, described by CHAIN.   

References dump_file, bb_rename_info::incoming, du_head::nregs, incoming_reg_info::nregs, du_head::regno, and incoming_reg_info::unusable.

Referenced by regrename_analyze().

static bool verify_reg_in_set ( )
static
Return true if OP is a reg for which all bits are set in PSET, false
   if all bits are clear.
   In other cases, set fail_current_block and return false.   

References fail_current_block.

Referenced by build_def_use(), and verify_reg_tracked().

static bool verify_reg_tracked ( )
static
Return true if OP is a reg that is being tracked already in some form.
   May set fail_current_block if it sees an unhandled case of overlap.   

References live_hard_regs, live_in_chains, and verify_reg_in_set().

Referenced by build_def_use(), and scan_rtx().


Variable Documentation

operand_rr_info* cur_operand
static
Set while scanning RTL if INSN_RR is nonnull, i.e. if the current analysis
   is for a caller that requires operand data.  Used in
   record_operand_use.   
unsigned current_id
static
The id to be given to the next opened chain.   

Referenced by create_new_chain(), and regrename_analyze().

bool fail_current_block
static
True if we found a register with a size mismatch, which means that we
   can't track its lifetime accurately.  If so, we abort the current block
   without renaming.   

Referenced by build_def_use(), scan_rtx_reg(), and verify_reg_in_set().

vec<du_head_p> id_to_chain
static
A mapping of unique id numbers to chains.   
vec<insn_rr_info> insn_rr
If nonnull, the code calling into the register renamer requested
   information about insn operands, and we store it here.   
HARD_REG_SET live_hard_regs
static
Record the registers that are live but not tracked.  The intersection
   between this and live_in_chains is empty.   

Referenced by build_def_use(), create_new_chain(), inherit_in_ebb(), init_rename_info(), note_sets_clobbers(), scan_rtx_reg(), and verify_reg_tracked().

HARD_REG_SET live_in_chains
static
Record the registers being tracked in open_chains.   

Referenced by build_def_use(), create_new_chain(), init_rename_info(), scan_rtx_reg(), and verify_reg_tracked().

struct du_head* open_chains
static
List of currently open chains.   

Referenced by create_new_chain(), and record_out_operands().

bitmap_head open_chains_set
static
Bitmap of open chains.  The bits set always match the list found in
   open_chains.   
struct obstack rename_obstack
static
const char* const scan_actions_name[]
static
Initial value:
{
"terminate_write",
"terminate_dead",
"mark_all_read",
"mark_read",
"mark_write",
"mark_access"
}

Referenced by scan_rtx_reg().

int this_tick = 0
static

Referenced by rename_chains().

int tick[FIRST_PSEUDO_REGISTER]
static
TICK and THIS_TICK are used to record the last time we saw each
   register.   

Referenced by find_best_rename_reg(), fix_inter_tick(), fix_tick_ready(), graphds_dfs(), recompute_todo_spec(), rename_chains(), and restore_pattern().