GCC Middle and Back End API 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_pass * | make_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_info > | insn_rr |
static unsigned | current_id |
static vec< du_head_p > | id_to_chain |
static struct du_head * | open_chains |
static bitmap_head | open_chains_set |
static HARD_REG_SET | live_in_chains |
static HARD_REG_SET | live_hard_regs |
static operand_rr_info * | cur_operand |
static bool | fail_current_block |
enum scan_actions |
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.
|
static |
Referenced by regrename_analyze().
|
static |
Build def/use chain.
References asm_noperands(), operand_alternative::cl, constrain_operands(), recog_data_d::constraints, create_new_chain(), recog_data_d::dup_loc, recog_data_d::dup_num, extract_insn(), fail_current_block, find_regno_note(), hide_operands(), HOST_WIDE_INT, live_hard_regs, live_in_chains, mark_access, mark_all_read, mark_read, operand_alternative::matches, memset(), recog_data_d::n_dups, recog_data_d::n_operands, du_head::need_caller_save_reg, du_head::next_chain, note_sets_clobbers(), note_stores(), OP_IN, insn_rr_info::op_info, OP_INOUT, OP_OUT, recog_data_d::operand, recog_data_d::operand_loc, recog_data_d::operand_mode, recog_data_d::operand_type, preprocess_constraints(), recog_data, recog_op_alt, record_out_operands(), remove_from_hard_reg_set(), rename_obstack, restore_operands(), scan_rtx(), scan_rtx_address(), SET, terminate_dead, terminate_write, verify_reg_in_set(), verify_reg_tracked(), and which_alternative.
|
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 |
Create a new chain for THIS_NREGS registers starting at THIS_REGNO, and record its occurrence in *LOC, which is being written to in INSN. This access requires a register of class CL.
References bitmap_copy(), bitmap_default_obstack, bitmap_set_bit(), du_head::cannot_rename, du_head::conflicts, current_id, dump_file, du_head::first, du_head::hard_conflicts, du_head::id, du_chain::insn, du_head::last, live_hard_regs, live_in_chains, du_chain::loc, mark_conflict(), du_head::need_caller_save_reg, du_head::next_chain, du_chain::next_use, du_head::nregs, open_chains, record_operand_use(), du_head::regno, and rename_obstack.
Referenced by build_def_use(), init_rename_info(), and scan_rtx_reg().
|
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 |
References bitmap_clear(), and du_head::conflicts.
Referenced by regrename_finish().
|
static |
|
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().
|
static |
Initialize a rename_info structure P for basic block BB, which starts a new scan.
References bb_rename_info::bb, bitmap_clear(), bitmap_default_obstack, bitmap_set_bit(), create_new_chain(), df_get_artificial_defs(), df_get_live_in(), DF_REF_AT_TOP, dump_file, du_head::id, bb_rename_info::incoming, bb_rename_info::incoming_open_chains_set, basic_block_def::index, live_hard_regs, live_in_chains, incoming_reg_info::nregs, bb_rename_info::open_chains_set, range_in_hard_reg_set_p(), remove_range_from_hard_reg_set(), and incoming_reg_info::unusable.
Referenced by regrename_analyze().
rtl_opt_pass* make_pass_regrename | ( | ) |
|
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 |
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 |
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 |
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 |
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 |
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().
void regrename_analyze | ( | ) |
Analyze the current function and build chains for renaming.
References basic_block_def::aux, bb_rename_info::bb, bitmap_bit_p(), bitmap_clear(), bitmap_copy(), bitmap_default_obstack, build_def_use(), du_head::cannot_rename, current_id, edge_def::dest, df_get_live_in(), df_get_live_out(), dump_def_use_chain(), dump_file, edge_def::flags, free(), du_head::id, bb_rename_info::incoming_open_chains_set, basic_block_def::index, init_rename_info(), live, merge_chains(), du_head::next_chain, du_head::nregs, insn_rr_info::op_info, bb_rename_info::open_chains_set, pre_and_rev_post_order_compute(), basic_block_def::preds, range_overlaps_hard_reg_set_p(), du_head::regno, regrename_chain_from_id(), set_incoming_from_chain(), edge_def::src, and basic_block_def::succs.
Referenced by regrename_optimize().
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_do_replace | ( | ) |
References df_insn_rescan(), du_head::first, gen_raw_REG(), du_chain::insn, du_chain::loc, du_chain::next_use, du_head::nregs, and du_head::regno.
Referenced by rename_chains().
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 |
Perform register renaming on the current function.
References df_analyze(), DF_DEFER_INSN_RESCAN, DF_LR_RUN_DCE, df_note_add_problem(), df_set_flags(), regrename_analyze(), regrename_finish(), regrename_init(), and rename_chains().
|
static |
Perform register renaming on the current function.
References add_to_hard_reg_set(), du_head::cannot_rename, df_set_regs_ever_live(), dump_file, find_best_rename_reg(), du_head::first, global_regs, du_chain::insn, memset(), du_head::need_caller_save_reg, du_chain::next_use, du_head::regno, regrename_do_replace(), this_tick, and tick.
Referenced by regrename_optimize().
|
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 |
References base_reg_class(), du_chain::loc, OP_IN, OP_INOUT, OP_OUT, scan_rtx_address(), scan_rtx_reg(), SET, and verify_reg_tracked().
Referenced by build_def_use(), and record_out_operands().
|
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 |
References bitmap_bit_p(), bitmap_clear_bit(), du_head::cannot_rename, create_new_chain(), dump_file, fail_current_block, du_head::first, du_head::id, du_chain::insn, du_head::last, live_hard_regs, live_in_chains, du_chain::loc, mark_access, mark_read, mark_write, du_head::next_chain, du_chain::next_use, du_head::nregs, OP_OUT, record_operand_use(), du_head::regno, rename_obstack, scan_actions_name, terminate_dead, and terminate_write.
Referenced by scan_rtx(), and scan_rtx_address().
|
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 |
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 |
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().
|
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.
|
static |
The id to be given to the next opened chain.
Referenced by create_new_chain(), and regrename_analyze().
|
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<insn_rr_info> insn_rr |
If nonnull, the code calling into the register renamer requested information about insn operands, and we store it here.
|
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().
|
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().
|
static |
List of currently open chains.
Referenced by create_new_chain(), and record_out_operands().
|
static |
Bitmap of open chains. The bits set always match the list found in open_chains.
|
static |
Referenced by build_def_use(), create_new_chain(), regrename_finish(), regrename_init(), and scan_rtx_reg().
|
static |
Referenced by scan_rtx_reg().
|
static |
Referenced by rename_chains().
|
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().