|
GCC Middle and Back End API 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 "cfgcleanup.h"
Data Structures | |
| struct | queued_debug_insn_change |
| struct | value_data_entry |
| struct | value_data |
| struct | kill_set_value_data |
Functions | |
| 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 *, bool frame_related) |
| 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 bool | incompatible_frame_status (bool, bool) |
| static rtx | find_oldest_value_reg (enum reg_class, rtx, struct value_data *, bool frame_related) |
| 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_pass * | make_pass_cprop_hardreg (gcc::context *ctxt) |
Variables | |
| static object_allocator< queued_debug_insn_change > | queued_debug_insn_change_pool ("debug insn changes pool") |
| static bool | skip_debug_insn_p |
|
static |
Apply all queued updates for DEBUG_INSNs that change some reg to register REGNO.
References apply_change_group(), apply_debug_insn_changes(), value_data_entry::debug_insn_changes, value_data::e, queued_debug_insn_change::insn, queued_debug_insn_change::loc, queued_debug_insn_change::new_rtx, queued_debug_insn_change::next, and validate_change().
Referenced by apply_debug_insn_changes(), and cprop_find_used_regs().
|
static |
Assert that SRC has been copied to DEST. Adjust the data structures to reflect that SRC contains an older copy of the shared value.
References copy_value(), value_data::e, fixed_regs, frame_pointer_needed, value_data_entry::frame_related, GET_MODE, GET_MODE_PRECISION(), global_regs, HARD_FRAME_POINTER_REGNUM, hard_regno_nregs(), i, INVALID_REGNUM, value_data_entry::mode, value_data_entry::next_regno, value_data_entry::oldest_regno, partial_subreg_p(), REG_CAN_CHANGE_MODE_P, REG_NREGS, REGNO, set_value_regno(), subreg_lowpart_offset(), validate_value_data(), and kill_set_value_data::vd.
Referenced by copy_value(), copyprop_hardreg_forward_1(), and set_value_regno().
|
static |
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, function_abi::clobbers_reg_p(), copy_value(), copyprop_hardreg_forward_1(), cprop_find_used_regs(), DEBUG_BIND_INSN_P, delete_insn(), delete_insn_and_edges(), df_insn_rescan(), dump_file, value_data::e, exp(), extract_constrain_insn(), find_oldest_value_reg(), find_reg_note(), value_data_entry::frame_related, GET_CODE, GET_MODE, hard_regno_nregs(), i, kill_set_value_data::ignore_set_reg, incompatible_frame_status(), insn_callee_abi(), kill_set_value_data::insn_is_frame_related, INSN_UID(), INSN_VAR_LOCATION_LOC, INVALID_REGNUM, kill_autoinc_value(), kill_clobbered_values(), kill_set_value(), kill_value(), kill_value_regno(), operand_alternative::matches, may_trap_p(), maybe_mode_change(), MEM_P, value_data_entry::mode, value_data::n_debug_insn_changes, 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, 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_1(), copyprop_hardreg_forward_bb_without_debug_insn(), and set_value_regno().
| 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.
Copy propagation on hard registers. Copyright (C) 1989-2026 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/>.
References copyprop_hardreg_forward_1(), copyprop_hardreg_forward_bb_without_debug_insn(), free(), init_value_data(), and skip_debug_insn_p.
Referenced by copyprop_hardreg_forward_bb_without_debug_insn(), and prepare_shrink_wrap().
|
static |
Called via note_uses, for all used registers in a real insn apply DEBUG_INSN changes that change registers to the used registers.
References apply_debug_insn_changes(), cprop_find_used_regs(), value_data_entry::debug_insn_changes, value_data::e, FOR_EACH_SUBRTX, free_debug_insn_changes(), REG_P, and REGNO.
Referenced by copyprop_hardreg_forward_1(), and cprop_find_used_regs().
|
extern |
Dump the value chain data to stderr.
References CLEAR_HARD_REG_SET, debug_value_data(), value_data::e, fputc(), GET_MODE_NAME, i, INVALID_REGNUM, value_data_entry::mode, value_data_entry::next_regno, value_data_entry::oldest_regno, SET_HARD_REG_BIT, TEST_HARD_REG_BIT, and kill_set_value_data::vd.
Referenced by debug_value_data(), and set_value_regno().
|
static |
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, find_oldest_value_reg(), value_data_entry::frame_related, gcc_assert, GET_MODE, hard_regno_nregs(), i, in_hard_reg_set_p(), incompatible_frame_status(), 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(), find_oldest_value_reg(), replace_oldest_value_reg(), and set_value_regno().
|
static |
Free all queued updates for DEBUG_INSNs that change some reg to register REGNO.
References value_data_entry::debug_insn_changes, value_data::e, free_debug_insn_changes(), value_data::n_debug_insn_changes, queued_debug_insn_change::next, NULL, and queued_debug_insn_change_pool.
Referenced by cprop_find_used_regs(), free_debug_insn_changes(), and kill_value_one_regno().
Copy propagation must not replace a value in a frame-related instruction with one produced by a non–frame-related instruction. Doing so may cause the DCE pass to delete the original frame-related instruction, which would in turn produce incorrect DWARF information (see PR122274). TO_FRAME_RELATED indicates whether the destination instruction receiving the propagated value is frame-related. FROM_FRAME_RELATED indicates whether the instruction providing that value is frame-related. Return true if copy propagation is not permitted.
References incompatible_frame_status().
Referenced by copyprop_hardreg_forward_1(), find_oldest_value_reg(), incompatible_frame_status(), and set_value_regno().
|
static |
Initialize VD such that there are no known relationships between regs.
References value_data_entry::debug_insn_changes, value_data::e, value_data_entry::frame_related, i, init_value_data(), INVALID_REGNUM, value_data::max_value_regs, value_data_entry::mode, value_data::n_debug_insn_changes, value_data_entry::next_regno, NULL, and value_data_entry::oldest_regno.
Referenced by copyprop_hardreg_forward_bb_without_debug_insn(), init_value_data(), and set_value_regno().
|
static |
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 value_data::e, FOR_EACH_SUBRTX, value_data_entry::frame_related, GET_CODE, GET_MODE, GET_RTX_CLASS, kill_autoinc_value(), kill_value(), PATTERN(), REGNO, RTX_AUTOINC, RTX_FRAME_RELATED_P, set_value_regno(), kill_set_value_data::vd, and XEXP.
Referenced by copyprop_hardreg_forward_1(), and kill_autoinc_value().
Called through note_stores. If X is clobbered, kill its value.
References GET_CODE, kill_clobbered_value(), and kill_value().
Referenced by kill_clobbered_value(), kill_clobbered_values(), and set_value_regno().
|
static |
Apply clobbers of INSN in PATTERN and C_I_F_U to value_data VD.
References kill_clobbered_value(), kill_clobbered_values(), and note_stores().
Referenced by copyprop_hardreg_forward_1(), and kill_clobbered_values().
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 value_data::e, value_data_entry::frame_related, GET_CODE, GET_MODE, kill_set_value_data::ignore_set_reg, kill_set_value_data::insn_is_frame_related, kill_set_value(), kill_value(), REG_P, REGNO, rtx_equal_p(), set_value_regno(), and kill_set_value_data::vd.
Referenced by copyprop_hardreg_forward_1(), kill_set_value(), and set_value_regno().
|
static |
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, kill_value(), 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(), kill_set_value(), kill_value(), and kill_value_regno().
|
static |
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, value_data_entry::frame_related, free_debug_insn_changes(), i, INVALID_REGNUM, kill_value_one_regno(), value_data_entry::mode, queued_debug_insn_change::next, value_data_entry::next_regno, value_data_entry::oldest_regno, and validate_value_data().
|
static |
References kill_value_one_regno().
Referenced by kill_value_one_regno(), kill_value_one_regno(), and kill_value_regno().
|
static |
Kill the value in register REGNO for NREGS, and any other registers whose values overlap.
References value_data::e, hard_regno_nregs(), i, kill_value_one_regno(), kill_value_regno(), value_data::max_value_regs, and value_data_entry::mode.
|
static |
References kill_value(), and kill_value_regno().
Referenced by copyprop_hardreg_forward_1(), kill_value(), kill_value_regno(), and kill_value_regno().
| rtl_opt_pass * make_pass_cprop_hardreg | ( | gcc::context * | ctxt | ) |
References make_pass_cprop_hardreg().
Referenced by make_pass_cprop_hardreg(), and make_pass_value_profile_transformations().
|
static |
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 in NEW_MODE. Return a NEW_MODE rtx for REGNO if that's OK, otherwise return NULL_RTX.
References gen_raw_REG(), GET_MODE, GET_MODE_PRECISION(), GET_MODE_SIZE(), hard_regno_nregs(), maybe_mode_change(), mode_change_ok(), NULL_RTX, partial_subreg_p(), stack_pointer_rtx, subreg_regno_offset(), subreg_size_lowpart_offset(), and targetm.
Referenced by copyprop_hardreg_forward_1(), find_oldest_value_reg(), maybe_mode_change(), and set_value_regno().
|
static |
Return true if a mode change from ORIG to NEW is allowed for REGNO.
References mode_change_ok(), partial_subreg_p(), and REG_CAN_CHANGE_MODE_P.
Referenced by maybe_mode_change(), mode_change_ok(), and set_value_regno().
|
static |
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(), DEBUG_INSN_P, GET_CODE, GET_RTX_FORMAT, GET_RTX_LENGTH, 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(), replace_oldest_value_mem(), and set_value_regno().
|
static |
Similar to replace_oldest_value_reg, but X contains a memory.
References base_reg_class(), DEBUG_INSN_P, GET_MODE, queued_debug_insn_change::insn, MEM_ADDR_SPACE, replace_oldest_value_addr(), replace_oldest_value_mem(), and XEXP.
Referenced by copyprop_hardreg_forward_1(), replace_oldest_value_addr(), replace_oldest_value_mem(), and set_value_regno().
|
static |
If possible, replace the register at *LOC with the oldest register in register class CL. Return true if successfully replaced.
References value_data_entry::debug_insn_changes, DEBUG_INSN_P, dump_file, value_data::e, find_oldest_value_reg(), queued_debug_insn_change::insn, INSN_UID(), queued_debug_insn_change::loc, value_data::n_debug_insn_changes, queued_debug_insn_change::new_rtx, queued_debug_insn_change::next, queued_debug_insn_change_pool, REGNO, replace_oldest_value_reg(), RTX_FRAME_RELATED_P, skip_debug_insn_p, validate_change(), and kill_set_value_data::vd.
Referenced by copyprop_hardreg_forward_1(), replace_oldest_value_addr(), replace_oldest_value_reg(), and set_value_regno().
|
static |
Remember that REGNO is valid in MODE.
References value_data::e, hard_regno_nregs(), value_data::max_value_regs, value_data_entry::mode, and set_value_regno().
|
static |
References copy_value(), copyprop_hardreg_forward_1(), debug_value_data(), find_oldest_value_reg(), incompatible_frame_status(), init_value_data(), kill_clobbered_value(), kill_set_value(), maybe_mode_change(), mode_change_ok(), replace_oldest_value_addr(), replace_oldest_value_mem(), replace_oldest_value_reg(), set_value_regno(), and validate_value_data().
Referenced by copy_value(), copyprop_hardreg_forward_1(), kill_autoinc_value(), kill_set_value(), set_value_regno(), and set_value_regno().
|
static |
References CLEAR_HARD_REG_SET, value_data::e, GET_MODE_NAME, i, internal_error(), INVALID_REGNUM, value_data_entry::mode, value_data_entry::next_regno, value_data_entry::oldest_regno, SET_HARD_REG_BIT, TEST_HARD_REG_BIT, and validate_value_data().
Referenced by copy_value(), kill_value_one_regno(), set_value_regno(), and validate_value_data().
|
static |
Referenced by free_debug_insn_changes(), and replace_oldest_value_reg().
|
static |
Referenced by copyprop_hardreg_forward_bb_without_debug_insn(), and replace_oldest_value_reg().