GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "target.h"
#include "rtl.h"
#include "tree.h"
#include "df.h"
#include "memmodel.h"
#include "tm_p.h"
#include "regs.h"
#include "emit-rtl.h"
#include "dumpfile.h"
#include "cselib.h"
#include "function-abi.h"
#include "alias.h"
#include "gt-cselib.h"
Data Structures | |
struct | elt_list |
struct | expand_value_data |
struct | cselib_hasher |
struct | cselib_hasher::key |
struct | cselib_record_autoinc_data |
Macros | |
#define | PRESERVED_VALUE_P(RTX) |
#define | SP_BASED_VALUE_P(RTX) |
#define | SP_DERIVED_VALUE_P(RTX) |
#define | MAX_USELESS_VALUES 32 |
#define | REG_VALUES(i) |
#define | MAX_SETS (FIRST_PSEUDO_REGISTER * 2) |
#define MAX_SETS (FIRST_PSEUDO_REGISTER * 2) |
There is no good way to determine how many elements there can be in a PARALLEL. Since it's fairly cheap, use a really large number.
Referenced by cselib_record_sets().
#define MAX_USELESS_VALUES 32 |
Number of useless values before we remove them from the hash table.
Referenced by cselib_process_insn().
#define PRESERVED_VALUE_P | ( | RTX | ) |
Referenced by cselib_add_permanent_equiv(), cselib_lookup_1(), cselib_preserve_value(), cselib_preserved_value_p(), cselib_record_sets(), cselib_record_sp_cfa_base_equiv(), cselib_useless_value_p(), new_elt_loc_list(), and references_value_p().
#define REG_VALUES | ( | i | ) |
#define SP_BASED_VALUE_P | ( | RTX | ) |
Referenced by cselib_set_value_sp_based(), and cselib_sp_based_value_p().
#define SP_DERIVED_VALUE_P | ( | RTX | ) |
Referenced by autoinc_split(), cselib_hash_plus_const_int(), cselib_lookup_1(), cselib_record_sp_cfa_base_equiv(), cselib_reset_table(), cselib_sp_derived_value_p(), cselib_subst_to_values(), cselib_useless_value_p(), cselib_hasher::equal(), and rtx_equal_for_cselib_1().
|
static |
ADDR_ELT is a value that is used as address. MEM_ELT is the value that contains the data at this address. X is a MEM that represents the value. Update the two value structures to represent this situation.
References cselib_val::addr_list, canonical_cselib_val(), CSELIB_VAL_PTR, first_containing_mem, cselib_val::locs, MEM_ADDR_SPACE, MEM_P, new_elt_list(), new_elt_loc_list(), elt_loc_list::next, cselib_val::next_containing_mem, NULL, promote_debug_loc(), replace_equiv_address_nv(), cselib_val::val_rtx, and XEXP.
Referenced by cselib_lookup_mem(), and cselib_record_set().
If x is a PLUS or an autoinc operation, expand the operation, storing the offset, if any, in *OFF.
References const0_rtx, CONST_INT_P, cselib_lookup(), CSELIB_VAL_PTR, gen_int_mode(), GET_CODE, GET_MODE, GET_MODE_SIZE(), INTVAL, cselib_val::locs, MEM_P, elt_loc_list::next, NULL_RTX, plus_constant(), REG_P, SP_DERIVED_VALUE_P, cselib_val::val_rtx, and XEXP.
Referenced by cselib_hasher::equal(), and rtx_equal_for_cselib_1().
void cselib_add_permanent_equiv | ( | cselib_val * | elt, |
rtx | x, | ||
rtx_insn * | insn ) |
Make ELT and X's VALUE equivalent to each other at INSN.
References cselib_any_perm_equivs, cselib_current_insn, cselib_lookup(), cselib_preserve_value(), elt_list::elt, gcc_checking_assert, GET_MODE, new_elt_loc_list(), PRESERVED_VALUE_P, side_effects_p(), and cselib_val::val_rtx.
Referenced by cselib_record_sets(), record_entry_value(), reverse_op(), and vt_initialize().
void cselib_clear_table | ( | void | ) |
Remove all entries from the hash table. Also used during initialization.
References cselib_reset_table().
Referenced by cselib_finish(), dse_step1(), and local_cprop_pass().
bool cselib_dummy_expand_value_rtx_cb | ( | rtx | orig, |
bitmap | regs_active, | ||
int | max_depth, | ||
cselib_expand_callback | cb, | ||
void * | data ) |
Similar to cselib_expand_value_rtx_cb, but no rtxs are actually copied or simplified. Useful to find out whether cselib_expand_value_rtx_cb would return NULL or non-NULL, without allocating new rtx.
References expand_value_data::callback, expand_value_data::callback_arg, cselib_expand_value_rtx_1(), expand_value_data::dummy, NULL, and expand_value_data::regs_active.
Forward substitute and expand an expression out to its roots. This is the opposite of common subexpression. Because local value numbering is such a weak optimization, the expanded expression is pretty much unique (not from a pointer equals point of view but from a tree shape point of view. This function returns NULL if the expansion fails. The expansion will fail if there is no value number for one of the operands or if one of the operands has been overwritten between the current insn and the beginning of the basic block. For instance x has no expansion in: r1 <- r1 + 3 x <- r1 + 8 REGS_ACTIVE is a scratch bitmap that should be clear when passing in. It is clear on return.
References expand_value_data::callback, expand_value_data::callback_arg, cselib_expand_value_rtx_1(), expand_value_data::dummy, NULL, and expand_value_data::regs_active.
Referenced by canon_address(), get_call_args(), record_store(), and reverse_op().
|
static |
Internal implementation of cselib_expand_value_rtx and cselib_expand_value_rtx_cb.
References bitmap_clear_bit(), bitmap_set_bit, expand_value_data::callback, expand_value_data::callback_arg, CASE_CONST_ANY, cfa_base_preserved_regno, CONST_INT_P, cselib_expand_value_rtx_1(), CSELIB_VAL_PTR, expand_value_data::dummy, dump_file, dump_flags, elt_list::elt, expand_loc(), gcc_unreachable, GET_CODE, GET_MODE, GET_RTX_CLASS, GET_RTX_FORMAT, GET_RTX_LENGTH, HARD_FRAME_POINTER_REGNUM, HARD_REGISTER_NUM_P, i, cselib_val::locs, MEM_P, elt_list::next, NULL, print_rtl_single(), REG_P, REG_VALUES, REGNO, expand_value_data::regs_active, rtvec_alloc(), RTX_BIN_ARITH, RTX_BITFIELD_OPS, RTX_CODE, RTX_COMM_ARITH, RTX_COMM_COMPARE, RTX_COMPARE, RTX_TERNARY, RTX_UNARY, shallow_copy_rtx(), shared_const_p(), simplify_gen_subreg(), simplify_relational_operation(), simplify_rtx(), simplify_ternary_operation(), simplify_unary_operation(), SUBREG_BYTE, SUBREG_REG, TDF_CSELIB, cselib_val::val_rtx, XEXP, XVEC, XVECEXP, and XVECLEN.
Referenced by cselib_dummy_expand_value_rtx_cb(), cselib_expand_value_rtx(), cselib_expand_value_rtx_1(), cselib_expand_value_rtx_cb(), and expand_loc().
rtx cselib_expand_value_rtx_cb | ( | rtx | orig, |
bitmap | regs_active, | ||
int | max_depth, | ||
cselib_expand_callback | cb, | ||
void * | data ) |
Same as cselib_expand_value_rtx, but using a callback to try to resolve some expressions. The CB function should return ORIG if it can't or does not want to deal with a certain RTX. Any other return value, including NULL, will be used as the expansion for VALUE, without any further changes.
References expand_value_data::callback, expand_value_data::callback_arg, cselib_expand_value_rtx_1(), expand_value_data::dummy, and expand_value_data::regs_active.
Referenced by vt_expand_loc(), vt_expand_loc_callback(), and vt_expand_var_loc_chain().
|
static |
Search for X, whose hashcode is HASH, in CSELIB_HASH_TABLE, INSERTing if requested. When X is part of the address of a MEM, MEMMODE should specify the mode of the MEM.
References cselib_hash_table, cselib_preserve_constants, cselib_preserved_hash_table, insert(), lookup(), and NULL.
Referenced by cselib_lookup_1(), and cselib_lookup_mem().
void cselib_finish | ( | void | ) |
Called when the current user is done with cselib.
References cfa_base_preserved_regno, cfa_base_preserved_val, cselib_any_perm_equivs, cselib_clear_table(), cselib_discard_hook, cselib_hash_table, cselib_preserve_constants, cselib_preserved_hash_table, cselib_val_pool, elt_list_pool, elt_loc_list_pool, free(), INVALID_REGNUM, n_debug_values, n_useless_debug_values, n_useless_values, next_uid, NULL, base_pool_allocator< TBlockAllocator >::release(), used_regs, and value_pool.
Referenced by dse_step1(), local_cprop_pass(), reload_cse_regs_1(), thread_jump(), and vt_finalize().
unsigned int cselib_get_next_uid | ( | void | ) |
Return the number of the next value that will be generated.
References next_uid.
Referenced by vt_emit_notes(), and vt_initialize().
|
static |
Helper function for cselib_hash_rtx. Arguments like for cselib_hash_rtx, except that it hashes (plus:P x c).
References inchash::hash::add_hwi(), inchash::hash::add_int(), CONST_INT_P, cselib_lookup(), CSELIB_VAL_PTR, inchash::hash::end(), GET_CODE, GET_MODE, cselib_val::hash, cselib_val::locs, inchash::hash::merge_hash(), elt_loc_list::next, SP_DERIVED_VALUE_P, trunc_int_for_mode(), UINTVAL, cselib_val::val_rtx, and XEXP.
Referenced by cselib_hash_rtx().
|
static |
Hash an rtx. Return 0 if we couldn't hash the rtx. For registers and memory locations, we look up their cselib_val structure and return its VALUE element. Possible reasons for return 0 are: the object is volatile, or we couldn't find a register or memory location in the table and CREATE is zero. If CREATE is nonzero, table elts are created for regs and mem. N.B. this hash function returns the same hash value for RTXes that differ only in the order of operands, thus it is suitable for comparisons that take commutativity into account. If we wanted to also support associative rules, we'd have to use a different strategy to avoid returning spurious 0, e.g. return ~(~0U >> 1) . MEMMODE indicates the mode of an enclosing MEM, and it's only used to compute autoinc values. We used to have a MODE argument for hashing for CONST_INTs, but that didn't make sense, since it caused spurious hash differences between (set (reg:SI 1) (const_int)) (plus:SI (reg:SI 2) (reg:SI 1)) and (plus:SI (reg:SI 2) (const_int)) If the mode is important in any context, it must be checked specifically in a comparison anyway, since relying on hash differences is unsafe.
References inchash::hash::add(), inchash::hash::add_commutative(), inchash::hash::add_hwi(), inchash::hash::add_int(), inchash::hash::add_wide_int(), CODE_LABEL_NUMBER, COMMUTATIVE_P, CONST_DOUBLE_HIGH, CONST_DOUBLE_LOW, CONST_DOUBLE_REAL_VALUE, CONST_FIXED_VALUE, CONST_INT_P, CONST_POLY_INT_COEFFS, CONST_VECTOR_ENCODED_ELT, const_vector_encoded_nelts(), CONST_WIDE_INT_ELT, CONST_WIDE_INT_NUNITS, cselib_hash_plus_const_int(), cselib_hash_rtx(), cselib_lookup(), CSELIB_VAL_PTR, DEBUG_EXPR_TREE_DECL, DEBUG_IMPLICIT_PTR_DECL, DEBUG_PARAMETER_REF_DECL, DEBUG_TEMP_UID, DECL_UID, inchash::hash::end(), ENTRY_VALUE_EXP, fixed_hash(), gcc_assert, gcc_unreachable, gen_int_mode(), GET_CODE, GET_MODE, GET_MODE_SIZE(), GET_RTX_FORMAT, GET_RTX_LENGTH, cselib_val::hash, i, INTVAL, label_ref_label(), MEM_P, MEM_VOLATILE_P, inchash::hash::merge_hash(), NUM_POLY_INT_COEFFS, offset, real_hash(), REG_P, REGNO, SUBREG_BYTE, TARGET_SUPPORTS_WIDE_INT, trunc_int_for_mode(), UINTVAL, XEXP, XINT, XLOC, XSTR, XVECEXP, and XVECLEN.
Referenced by cselib_hash_rtx(), and cselib_lookup_1().
bool cselib_have_permanent_equivalences | ( | void | ) |
Return TRUE if any permanent equivalences have been recorded since the table was last initialized.
References cselib_any_perm_equivs.
Referenced by get_addr().
void cselib_init | ( | int | record_what | ) |
Initialize cselib for one pass. The caller must also call init_alias_analysis.
References callmem, cselib_any_perm_equivs, cselib_hash_table, cselib_nregs, CSELIB_PRESERVE_CONSTANTS, cselib_preserve_constants, cselib_preserved_hash_table, CSELIB_RECORD_MEMORY, cselib_record_memory, free(), gen_rtx_MEM(), max_reg_num(), n_used_regs, next_uid, reg_values, reg_values_size, and used_regs.
Referenced by dse_step1(), local_cprop_pass(), reload_cse_regs_1(), thread_jump(), and vt_initialize().
|
static |
Invalidate any locations in the table which are changed because of a store to MEM_RTX. If this is called because of a non-const call instruction, MEM_RTX is (mem:BLK const0_rtx).
References cselib_val::addr_list, canon_anti_dependence(), canon_rtx(), canonical_cselib_val(), cselib_lookup(), cselib_useless_value_p(), DEBUG_INSN_P, dummy_val, first_containing_mem, gcc_checking_assert, get_addr(), GET_MODE, cselib_val::locs, MEM_P, n_useless_debug_values, n_useless_values, elt_list::next, elt_loc_list::next, cselib_val::next_containing_mem, NULL, elt_loc_list::setting_insn, unchain_one_elt_list(), unchain_one_elt_loc_list(), and XEXP.
Referenced by cselib_invalidate_rtx(), cselib_preserve_only_values(), and cselib_process_insn().
|
static |
Invalidate any entries in reg_values that overlap REGNO. This is called if REGNO is changing. MODE is the mode of the assignment to REGNO, which is used to determine how many hard registers are being changed. If MODE is VOIDmode, then only REGNO is being changed; this is used when invalidating call clobbered registers across a call.
References cfa_base_preserved_regno, cfa_base_preserved_val, cselib_invalidate_regno_val(), end_hard_regno(), gcc_assert, GET_MODE, i, max_value_regs, elt_list::next, NULL, reg_renumber, REG_VALUES, reload_completed, and cselib_val::val_rtx.
Referenced by cselib_invalidate_rtx(), and cselib_preserve_only_values().
|
static |
Invalidate the value at *L, which is part of REG_VALUES (REGNO).
References canonical_cselib_val(), cselib_useless_value_p(), DEBUG_INSN_P, cselib_val::locs, n_useless_debug_values, n_useless_values, elt_list::next, elt_loc_list::next, NULL, REG_P, REG_VALUES, REGNO, elt_loc_list::setting_insn, unchain_one_elt_list(), and unchain_one_elt_loc_list().
Referenced by cselib_invalidate_regno(), and cselib_process_insn().
void cselib_invalidate_rtx | ( | rtx | dest | ) |
Invalidate DEST.
References cselib_invalidate_mem(), cselib_invalidate_regno(), GET_CODE, GET_MODE, MEM_P, REG_P, REGNO, and XEXP.
Referenced by cselib_invalidate_rtx_note_stores(), cselib_process_insn(), cselib_record_sets(), reload_cse_simplify(), variable_post_merge_new_vals(), and vt_initialize().
A wrapper for cselib_invalidate_rtx to be called via note_stores.
References cselib_invalidate_rtx().
Referenced by cselib_record_sets().
|
static |
V is one of the values in REG_VALUES (REGNO). Return true if it would be invalidated by CALLEE_ABI.
References function_abi::clobbers_reg_p(), GET_MODE, REG_VALUES, and cselib_val::val_rtx.
Referenced by cselib_process_insn().
cselib_val * cselib_lookup | ( | rtx | x, |
machine_mode | mode, | ||
int | create, | ||
machine_mode | memmode ) |
Wrapper for cselib_lookup_1, that logs the lookup result and maintains invariants related with debug insns.
References cselib_lookup_1(), dump_file, dump_flags, cselib_val::hash, print_inline_rtx(), TDF_CSELIB, and cselib_val::uid.
Referenced by add_stores(), add_uses(), autoinc_split(), canon_address(), cselib_add_permanent_equiv(), cselib_hash_plus_const_int(), cselib_hash_rtx(), cselib_invalidate_mem(), cselib_lookup_from_insn(), cselib_lookup_mem(), cselib_record_sets(), cselib_redundant_set_p(), cselib_subst_to_values(), do_local_cprop(), find_use_val(), new_cselib_val(), prepare_call_arguments(), reload_cse_simplify_operands(), reload_cse_simplify_set(), replace_expr_with_values(), reverse_op(), rtx_equal_for_cselib_1(), use_narrower_mode_test(), use_type(), variable_post_merge_new_vals(), and vt_initialize().
|
static |
Look up the rtl expression X in our tables and return the value it has. If CREATE is zero, we return NULL if we don't know the value. Otherwise, we create a new one if possible, using mode MODE if X doesn't have a mode (i.e. because it's a constant). When X is part of an address, MEMMODE should be the mode of the enclosing MEM if we're tracking autoinc expressions.
References cselib_find_slot(), cselib_hash_rtx(), cselib_lookup_mem(), cselib_preserve_constants, cselib_subst_to_values(), CSELIB_VAL_PTR, elt_list::elt, GET_CODE, GET_MODE, GET_MODE_SIZE(), hard_regno_nregs(), cselib_val::hash, i, is_int_mode(), cselib_val::locs, lowpart_subreg(), max_value_regs, MEM_P, n_used_regs, new_cselib_val(), new_elt_list(), new_elt_loc_list(), el::next, elt_list::next, elt_loc_list::next, next_uid, NULL, partial_subreg_p(), PRESERVED_VALUE_P, promote_debug_loc(), REG_P, REG_VALUES, REGNO, SP_DERIVED_VALUE_P, stack_pointer_rtx, used_regs, and cselib_val::val_rtx.
Referenced by cselib_lookup().
cselib_val * cselib_lookup_from_insn | ( | rtx | x, |
machine_mode | mode, | ||
int | create, | ||
machine_mode | memmode, | ||
rtx_insn * | insn ) |
Wrapper for cselib_lookup, that indicates X is in INSN.
References cselib_current_insn, cselib_lookup(), gcc_assert, and NULL.
Referenced by cselib_record_sp_cfa_base_equiv(), vt_add_function_parameter(), vt_init_cfa_base(), and vt_initialize().
|
static |
Subroutine of cselib_lookup. Return a value for X, which is a MEM rtx. If CREATE, make a new one if we haven't seen it before.
References add_mem_for_addr(), cselib_val::addr_list, canonical_cselib_val(), cselib_find_slot(), cselib_lookup(), cselib_record_memory, FLOAT_MODE_P, GET_MODE, cselib_val::hash, MEM_ADDR_SPACE, MEM_P, MEM_VOLATILE_P, new_cselib_val(), elt_list::next, elt_loc_list::next, next_uid, promote_debug_loc(), and XEXP.
Referenced by cselib_lookup_1(), and cselib_subst_to_values().
void cselib_preserve_cfa_base_value | ( | cselib_val * | v, |
unsigned int | regno ) |
Arrange for a REG value to be assumed constant through the whole function, never invalidated and preserved across cselib_reset_table calls.
References cfa_base_preserved_regno, cfa_base_preserved_val, cselib_preserve_constants, elt_loc_list::loc, cselib_val::locs, and REG_P.
Referenced by vt_init_cfa_base(), and vt_initialize().
void cselib_preserve_only_values | ( | void | ) |
Clean all non-constant expressions in the hash table, but retain their values.
References callmem, cselib_invalidate_mem(), cselib_invalidate_regno(), dummy_val, first_containing_mem, gcc_assert, i, reg_raw_mode, and remove_useless_values().
Referenced by cselib_process_insn(), and vt_initialize().
void cselib_preserve_value | ( | cselib_val * | v | ) |
Arrange for a value to not be removed from the hash table even if it becomes useless.
References PRESERVED_VALUE_P, and cselib_val::val_rtx.
Referenced by cselib_add_permanent_equiv(), cselib_record_sets(), preserve_value(), and variable_post_merge_new_vals().
bool cselib_preserved_value_p | ( | cselib_val * | v | ) |
Test whether a value is preserved.
References PRESERVED_VALUE_P, and cselib_val::val_rtx.
Referenced by add_stores(), add_uses(), prepare_call_arguments(), reverse_op(), use_type(), val_store(), vt_expand_var_loc_chain(), and vt_initialize().
void cselib_process_insn | ( | rtx_insn * | insn | ) |
Record the effects of INSN.
References CALL_INSN_FUNCTION_USAGE, CALL_P, callmem, cselib_current_insn, cselib_hash_table, cselib_invalidate_mem(), cselib_invalidate_regno_val(), cselib_invalidate_rtx(), cselib_invalidated_by_call_p(), cselib_preserve_constants, cselib_preserve_only_values(), cselib_record_sets(), cselib_reset_table(), find_reg_note(), fp_setter_insn(), frame_pointer_needed, GET_CODE, i, insn_callee_abi(), INSN_P, LABEL_P, MAX_USELESS_VALUES, MEM_P, n_debug_values, n_useless_values, elt_list::next, next_uid, NULL, REG_VALUES, reload_completed, remove_useless_values(), RTL_CONST_OR_PURE_CALL_P, RTL_LOOPING_CONST_OR_PURE_CALL_P, stack_pointer_rtx, and XEXP.
Referenced by dse_step1(), local_cprop_pass(), reload_cse_regs_1(), thread_jump(), and vt_initialize().
|
static |
Callback for for_each_inc_dec. Records in ARG the SETs implied by autoinc RTXs: SRC plus SRCOFF if non-NULL is stored in DEST.
References GET_MODE.
Referenced by cselib_record_sets().
|
static |
Record the result of a SET instruction. DEST is being set; the source contains the value described by SRC_ELT. If DEST is a MEM, DEST_ADDR_ELT describes its address.
References add_mem_for_addr(), cselib_record_memory, cselib_useless_value_p(), elt_list::elt, gcc_assert, max_value_regs, MEM_P, n_used_regs, n_useless_values, new_elt_list(), new_elt_loc_list(), REG_NREGS, REG_P, REG_VALUES, REGNO, side_effects_p(), and used_regs.
Referenced by cselib_record_sets(), and cselib_record_sp_cfa_base_equiv().
|
static |
Record the effects of any sets and autoincs in INSN.
References asm_noperands(), BITS_PER_WORD, COND_EXEC_CODE, COND_EXEC_TEST, const0_rtx, CONSTANT_P, cselib_add_permanent_equiv(), cselib_invalidate_rtx(), cselib_invalidate_rtx_note_stores(), cselib_lookup(), cselib_preserve_value(), cselib_record_autoinc_cb(), cselib_record_memory, cselib_record_set(), cselib_record_sets_hook, cselib_set::dest, cselib_set::dest_addr_elt, find_reg_equal_equiv_note(), for_each_inc_dec(), FOR_EACH_WIDER_MODE, gen_lowpart, get_address_mode(), GET_CODE, GET_MODE, GET_MODE_PRECISION(), HARD_REGISTER_P, i, is_a(), elt_loc_list::loc, cselib_val::locs, MAX_SETS, MEM_P, MEM_READONLY_P, cselib_record_autoinc_data::n_sets, elt_loc_list::next, note_pattern_stores(), NULL, PATTERN(), pc_rtx, PRESERVED_VALUE_P, r, REG_P, opt_mode< T >::require(), rtx_equal_p(), SET, SET_DEST, SET_SRC, cselib_record_autoinc_data::sets, cselib_set::src, cselib_set::src_elt, XEXP, XVECEXP, and XVECLEN.
Referenced by cselib_process_insn().
void cselib_record_sp_cfa_base_equiv | ( | HOST_WIDE_INT | offset, |
rtx_insn * | insn ) |
Record stack_pointer_rtx to be equal to (plus:P cfa_base_preserved_val offset). Used by var-tracking at the start of basic blocks for !frame_pointer_needed functions.
References cfa_base_preserved_val, CONST_INT_P, cselib_lookup_from_insn(), cselib_record_set(), GET_CODE, cselib_val::locs, elt_loc_list::next, NULL, NULL_RTX, offset, plus_constant(), PRESERVED_VALUE_P, SP_DERIVED_VALUE_P, stack_pointer_rtx, UINTVAL, cselib_val::val_rtx, and XEXP.
Referenced by vt_initialize().
Wrapper for rtx_equal_for_cselib_p to determine whether a SET is truly redundant, taking into account aliasing information.
References cselib_lookup(), cselib_reg_set_mode(), gcc_assert, GET_CODE, GET_MODE, cselib_val::locs, MEM_P, mems_same_for_tbaa_p(), elt_loc_list::next, rtx_equal_for_cselib_1(), rtx_equal_for_cselib_p(), SET, SET_DEST, SET_SRC, and XEXP.
Referenced by mark_effect(), and reload_cse_simplify().
machine_mode cselib_reg_set_mode | ( | const_rtx | x | ) |
Return the mode in which a register was last set. If X is not a register, return its mode. If the mode in which the register was set is not known, or the value was already clobbered, return VOIDmode.
References GET_MODE, NULL, REG_P, REG_VALUES, and REGNO.
Referenced by cselib_redundant_set_p().
void cselib_reset_table | ( | unsigned int | num | ) |
Remove all entries from the hash table, arranging for the next value to be numbered NUM.
References cfa_base_preserved_regno, cfa_base_preserved_val, CONST_INT_P, cselib_any_perm_equivs, cselib_current_insn, cselib_hash_table, cselib_preserve_constants, CSELIB_VAL_PTR, dummy_val, first_containing_mem, gcc_assert, gcc_checking_assert, GET_CODE, GET_MODE, hard_regno_nregs(), i, invariant_or_equiv_p(), elt_loc_list::loc, cselib_val::locs, max_value_regs, n_debug_values, n_used_regs, n_useless_debug_values, n_useless_values, new_elt_loc_list(), elt_loc_list::next, next_uid, NULL, plus_constant(), preserve_constants_and_equivs(), REG_VALUES, SP_DERIVED_VALUE_P, UINTVAL, used_regs, cselib_val::val_rtx, and XEXP.
Referenced by cselib_clear_table(), cselib_process_insn(), and vt_initialize().
void cselib_set_value_sp_based | ( | cselib_val * | v | ) |
Arrange for a value to be marked as based on stack pointer for find_base_term purposes.
References SP_BASED_VALUE_P, and cselib_val::val_rtx.
Referenced by add_stores(), and vt_initialize().
bool cselib_sp_based_value_p | ( | cselib_val * | v | ) |
Test whether a value is based on stack pointer for find_base_term purposes.
References SP_BASED_VALUE_P, and cselib_val::val_rtx.
Referenced by find_base_term().
bool cselib_sp_derived_value_p | ( | cselib_val * | v | ) |
Return true if V is SP_DERIVED_VALUE_P (or SP_DERIVED_VALUE_P + CONST_INT) that can be expressed using cfa_base_preserved_val + CONST_INT.
References cfa_base_preserved_val, CONST_INT_P, CSELIB_VAL_PTR, GET_CODE, cselib_val::locs, elt_loc_list::next, SP_DERIVED_VALUE_P, cselib_val::val_rtx, and XEXP.
Referenced by add_stores().
Walk rtx X and replace all occurrences of REG and MEM subexpressions with VALUE expressions. This way, it becomes independent of changes to registers and memory. X isn't actually modified; if modifications are needed, new rtl is allocated. However, the return value can share rtl with X. If X is within a MEM, MEMMODE must be the mode of the MEM.
References CASE_CONST_ANY, const0_rtx, CONST_INT_P, cselib_lookup(), cselib_lookup_mem(), cselib_subst_to_values(), CSELIB_VAL_PTR, elt_list::elt, gcc_assert, gcc_unreachable, GET_CODE, GET_MODE, GET_MODE_SIZE(), GET_RTX_FORMAT, GET_RTX_LENGTH, i, INTVAL, new_cselib_val(), elt_list::next, next_uid, NULL, offset, plus_constant(), REG_VALUES, REGNO, shallow_copy_rtvec(), shallow_copy_rtx(), SP_DERIVED_VALUE_P, cselib_val::val_rtx, XEXP, XVEC, XVECEXP, and XVECLEN.
Referenced by cselib_lookup_1(), cselib_subst_to_values(), cselib_subst_to_values_from_insn(), and replace_expr_with_values().
Wrapper for cselib_subst_to_values, that indicates X is in INSN.
References cselib_current_insn, cselib_subst_to_values(), gcc_assert, and NULL.
|
static |
Return true if V is a useless VALUE and can be discarded as such.
References cselib_val::locs, PRESERVED_VALUE_P, SP_DERIVED_VALUE_P, and cselib_val::val_rtx.
Referenced by cselib_invalidate_mem(), cselib_invalidate_regno_val(), cselib_record_set(), discard_useless_locs(), and discard_useless_values().
int discard_useless_locs | ( | cselib_val ** | x, |
void * | info ) |
For all locations found in X, delete locations that reference useless values (i.e. values without any location). Called through htab_traverse.
References cselib_useless_value_p(), DEBUG_INSN_P, cselib_val::locs, n_useless_debug_values, n_useless_values, elt_loc_list::next, NULL, references_value_p(), elt_loc_list::setting_insn, unchain_one_elt_loc_list(), and values_became_useless.
Referenced by remove_useless_values().
int discard_useless_values | ( | cselib_val ** | x, |
void * | info ) |
If X is a value with no locations, remove it from the hashtable.
References cselib_discard_hook, cselib_hash_table, cselib_useless_value_p(), CSELIB_VAL_PTR, cselib_val::locs, n_useless_values, NULL, unchain_one_value(), and cselib_val::val_rtx.
Referenced by remove_useless_values().
void dump_cselib_table | ( | FILE * | out | ) |
Dump to OUT everything in the CSELIB table.
References cselib_hash_table, cselib_preserved_hash_table, dummy_val, dump_cselib_val(), first_containing_mem, fputc(), next_uid, print_inline_rtx(), and cselib_val::val_rtx.
Referenced by vt_initialize().
int dump_cselib_val | ( | cselib_val ** | x, |
FILE * | out ) |
Dump the cselib_val *X to FILE *OUT.
References cselib_val::addr_list, dummy_val, elt_list::elt, fputc(), INSN_UID(), elt_loc_list::loc, cselib_val::locs, elt_list::next, elt_loc_list::next, cselib_val::next_containing_mem, print_inline_rtx(), elt_loc_list::setting_insn, and cselib_val::val_rtx.
Referenced by dump_cselib_table().
|
static |
Search through the possible substitutions in P. We prefer a non reg substitution because this allows us to expand the tree further. If we find, just a reg, take the lowest regno. There may be several non-reg results, we just take the first one because they will all expand to the same place.
References bitmap_bit_p, cfa_base_preserved_regno, cselib_expand_value_rtx_1(), CSELIB_VAL_PTR, dump_file, dump_flags, find_reg_note(), GET_CODE, HARD_FRAME_POINTER_REGNUM, elt_loc_list::loc, elt_loc_list::next, NULL, NULL_RTX, print_inline_rtx(), REG_P, REGNO, expand_value_data::regs_active, elt_loc_list::setting_insn, TDF_CSELIB, UINT_MAX, and XEXP.
Referenced by cselib_expand_value_rtx_1().
Return true if INSN in the prologue initializes hard_frame_pointer_rtx.
References expr, find_reg_note(), hard_frame_pointer_rtx, modified_in_p(), NULL_RTX, RTX_FRAME_RELATED_P, and XEXP.
Referenced by cselib_process_insn(), and vt_initialize().
|
static |
Return TRUE if V is a constant, a function invariant or a VALUE equivalence; FALSE otherwise.
References cfa_base_preserved_val, CONST_INT_P, CONSTANT_P, CSELIB_VAL_PTR, GET_CODE, invariant_or_equiv_p(), elt_loc_list::loc, cselib_val::locs, elt_loc_list::next, NULL, references_value_p(), and XEXP.
Referenced by cselib_reset_table(), invariant_or_equiv_p(), and preserve_constants_and_equivs().
|
inlinestatic |
Create a new value structure for VALUE and initialize it. The mode of the value is MODE.
References cselib_val::addr_list, base_pool_allocator< TBlockAllocator >::allocate(), cselib_current_insn, cselib_lookup(), cselib_val_pool, CSELIB_VAL_PTR, DEBUG_INSN_P, dump_file, dump_flags, FOR_EACH_MODE_UNTIL, fputc(), gcc_assert, GET_MODE_SIZE(), cselib_val::hash, is_int_mode(), cselib_val::locs, lowpart_subreg(), new_elt_loc_list(), cselib_val::next_containing_mem, next_uid, NULL, print_rtl_single(), PUT_CODE, PUT_MODE(), PUT_MODE_RAW, REG_P, REG_VALUES, REGNO, RTX_HDR_SIZE, shallow_copy_rtx(), TDF_CSELIB, cselib_val::uid, cselib_val::val_rtx, and value_pool.
|
static |
Referenced by cselib_lookup_1(), cselib_lookup_mem(), and cselib_subst_to_values().
|
inlinestatic |
Allocate a struct elt_list and fill in its two elements with the arguments.
References elt_list::elt, elt_list_pool, el::next, and elt_list::next.
Referenced by add_mem_for_addr(), cselib_lookup_1(), and cselib_record_set().
|
inlinestatic |
Allocate a struct elt_loc_list with LOC and prepend it to VAL's loc list.
References addr_list, cselib_val::addr_list, canonical_cselib_val(), cselib_current_insn, CSELIB_VAL_PTR, DEBUG_INSN_P, elt_loc_list_pool, gcc_checking_assert, GET_CODE, last, elt_loc_list::loc, cselib_val::locs, n_debug_values, new_elt_loc_list(), el::next, elt_list::next, elt_loc_list::next, filedep::next, cselib_val::next_containing_mem, NULL, PRESERVED_VALUE_P, elt_loc_list::setting_insn, cselib_val::uid, and cselib_val::val_rtx.
Referenced by add_mem_for_addr(), cselib_add_permanent_equiv(), cselib_lookup_1(), cselib_record_set(), cselib_reset_table(), new_cselib_val(), and new_elt_loc_list().
int preserve_constants_and_equivs | ( | cselib_val ** | x, |
void * | info ) |
Remove from hash table all VALUEs except constants, function invariants and VALUE equivalences.
References cselib_hash_table, cselib_preserved_hash_table, gcc_assert, GET_MODE, cselib_val::hash, invariant_or_equiv_p(), lookup(), and cselib_val::val_rtx.
Referenced by cselib_reset_table().
|
inlinestatic |
Promote loc L to a nondebug cselib_current_insn if L is marked as originating from a debug insn, maintaining the debug values count.
References cselib_current_insn, cselib_preserve_constants, DEBUG_INSN_P, gcc_assert, n_debug_values, elt_loc_list::next, and elt_loc_list::setting_insn.
Referenced by add_mem_for_addr(), cselib_lookup_1(), cselib_lookup_mem(), and cselib_hasher::equal().
Return true if X contains a VALUE rtx. If ONLY_USELESS is set, we only return true for values which point to a cselib_val whose value element has been set to zero, which implies the cselib_val will be removed.
References CSELIB_VAL_PTR, GET_CODE, GET_RTX_FORMAT, GET_RTX_LENGTH, i, PRESERVED_VALUE_P, references_value_p(), XEXP, XVECEXP, and XVECLEN.
Referenced by discard_useless_locs(), invariant_or_equiv_p(), references_value_p(), reload_cse_simplify_set(), and reverse_op().
|
static |
Clean out useless values (i.e. those which no longer have locations associated with them) from the hash table.
References canonical_cselib_val(), cselib_hash_table, cselib_preserve_constants, cselib_preserved_hash_table, discard_useless_locs(), discard_useless_values(), dummy_val, first_containing_mem, gcc_assert, cselib_val::locs, n_debug_values, n_useless_debug_values, n_useless_values, cselib_val::next_containing_mem, NULL, and values_became_useless.
Referenced by cselib_preserve_only_values(), cselib_process_insn(), and dse_step1().
Return true if we can prove that X and Y contain the same value, taking our gathered information into account. MEMMODE holds the mode of the enclosing MEM, if any, as required to deal with autoinc addressing modes. If X and Y are not (known to be) part of addresses, MEMMODE should be VOIDmode.
References autoinc_split(), canonical_cselib_val(), CASE_CONST_UNIQUE, CONST_INT_P, cselib_lookup(), CSELIB_VAL_PTR, DEBUG_IMPLICIT_PTR_DECL, DEBUG_PARAMETER_REF_DECL, ENTRY_VALUE_EXP, gcc_unreachable, GET_CODE, GET_MODE, GET_RTX_FORMAT, GET_RTX_LENGTH, i, label_ref_label(), elt_loc_list::loc, cselib_val::locs, MEM_P, elt_loc_list::next, NULL, NULL_RTX, REG_P, REGNO, rtx_equal_for_cselib_1(), rtx_equal_p(), same_vector_encodings_p(), SP_DERIVED_VALUE_P, SUBREG_BYTE, targetm, cselib_val::val_rtx, XEXP, XINT, XLOC, XSTR, XVECEXP, XVECLEN, XWINT, and y.
Referenced by cselib_redundant_set_p(), cselib_hasher::equal(), rtx_equal_for_cselib_1(), and rtx_equal_for_cselib_p().
|
inlinestatic |
The elt_list at *PL is no longer needed. Unchain it and free its storage.
References elt_list_pool, and elt_list::next.
Referenced by cselib_invalidate_mem(), cselib_invalidate_regno_val(), and unchain_one_value().
|
static |
Likewise for elt_loc_lists.
References elt_loc_list_pool, and elt_loc_list::next.
Referenced by cselib_invalidate_mem(), cselib_invalidate_regno_val(), and discard_useless_locs().
|
static |
Likewise for cselib_vals. This also frees the addr_list associated with V.
References cselib_val::addr_list, cselib_val_pool, and unchain_one_elt_list().
Referenced by discard_useless_values().
|
static |
We pass this to cselib_invalidate_mem to invalidate all of memory for a non-const call instruction.
Referenced by cselib_init(), cselib_preserve_only_values(), and cselib_process_insn().
|
static |
|
static |
If non-NULL, value of the eliminated arg_pointer_rtx or frame_pointer_rtx that is constant through the whole function and should never be eliminated.
Referenced by cselib_finish(), cselib_invalidate_regno(), cselib_preserve_cfa_base_value(), cselib_record_sp_cfa_base_equiv(), cselib_reset_table(), cselib_sp_derived_value_p(), and invariant_or_equiv_p().
|
static |
|
static |
This is a global so we don't have to pass this through every function. It is used in new_elt_loc_list to set SETTING_INSN.
Referenced by cselib_add_permanent_equiv(), cselib_lookup_from_insn(), cselib_process_insn(), cselib_reset_table(), cselib_subst_to_values_from_insn(), cselib_hasher::equal(), new_cselib_val(), new_elt_loc_list(), and promote_debug_loc().
void(* cselib_discard_hook) (cselib_val *) | ( | cselib_val * | ) |
If nonnull, cselib will call this function before freeing useless VALUEs. A VALUE is deemed useless if its "locs" field is null.
Referenced by cselib_finish(), discard_useless_values(), and dse_step1().
|
static |
A table that enables us to look up elts by their value.
Referenced by cselib_find_slot(), cselib_finish(), cselib_init(), cselib_process_insn(), cselib_reset_table(), discard_useless_values(), dump_cselib_table(), preserve_constants_and_equivs(), and remove_useless_values().
|
static |
The number of registers we had when the varrays were last resized.
Referenced by cselib_init().
|
static |
|
static |
A table to hold preserved values.
Referenced by cselib_find_slot(), cselib_finish(), cselib_init(), dump_cselib_table(), preserve_constants_and_equivs(), and remove_useless_values().
|
static |
Referenced by cselib_init(), cselib_lookup_mem(), cselib_record_set(), and cselib_record_sets().
void(* cselib_record_sets_hook) (rtx_insn *insn, struct cselib_set *sets, int n_sets) | ( | rtx_insn * | insn, |
struct cselib_set * | sets, | ||
int | n_sets ) |
If nonnull, cselib will call this function before recording sets or even clobbering outputs of INSN. All the recorded sets will be represented in the array sets[n_sets]. new_val_min can be used to tell whether values present in sets are introduced by this instruction.
Referenced by cselib_record_sets(), and vt_initialize().
|
static |
Referenced by cselib_finish(), new_cselib_val(), and unchain_one_value().
|
static |
Used as stop element of the containing_mem list so we can check presence in the list by checking the next pointer.
Referenced by cselib_invalidate_mem(), cselib_preserve_only_values(), cselib_reset_table(), dump_cselib_table(), dump_cselib_val(), and remove_useless_values().
|
static |
Referenced by cselib_finish(), new_elt_list(), and unchain_one_elt_list().
|
static |
Referenced by cselib_finish(), new_elt_loc_list(), and unchain_one_elt_loc_list().
|
static |
Used to list all values that contain memory reference. May or may not contain the useless values - the list is compacted each time memory is invalidated.
Referenced by add_mem_for_addr(), cselib_invalidate_mem(), cselib_preserve_only_values(), cselib_reset_table(), dump_cselib_table(), and remove_useless_values().
|
static |
The largest number of hard regs used by any entry added to the REG_VALUES table. Cleared on each cselib_clear_table() invocation.
Referenced by cselib_invalidate_regno(), cselib_lookup_1(), cselib_record_set(), cselib_reset_table(), and kill_value_regno().
|
static |
Count values whose locs have been taken exclusively from debug insns for the entire life of the value.
Referenced by cselib_finish(), cselib_process_insn(), cselib_reset_table(), new_elt_loc_list(), promote_debug_loc(), and remove_useless_values().
|
static |
Referenced by cselib_init(), cselib_lookup_1(), cselib_record_set(), and cselib_reset_table().
|
static |
|
static |
Count values without known locations, or with only locations that wouldn't have been known except for debug insns. Whenever this grows too big, we remove these useless values from the table. Counting values with only debug values is a bit tricky. We don't want to increment n_useless_values when we create a value for a debug insn, for this would get n_useless_values out of sync, but we want increment it if all locs in the list that were ever referenced in nondebug insns are removed from the list. In the general case, once we do that, we'd have to stop accepting nondebug expressions in the loc list, to avoid having two values equivalent that, without debug insns, would have been made into separate values. However, because debug insns never introduce equivalences themselves (no assignments), the only means for growing loc lists is through nondebug assignments. If the locs also happen to be referenced in debug insns, it will work just fine. A consequence of this is that there's at most one debug-only loc in each loc list. If we keep it in the first entry, testing whether we have a debug-only loc list takes O(1). Furthermore, since any additional entry in a loc list containing a debug loc would have to come from an assignment (nondebug) that references both the initial debug loc and the newly-equivalent loc, the initial debug loc would be promoted to a nondebug loc, and the loc list would not contain debug locs any more. So the only case we have to be careful with in order to keep n_useless_values in sync between debug and nondebug compilations is to avoid incrementing n_useless_values when removing the single loc from a value that turns out to not appear outside debug values. We increment n_useless_debug_values instead, and leave such values alone until, for other reasons, we garbage-collect useless values.
Referenced by cselib_finish(), cselib_invalidate_mem(), cselib_invalidate_regno_val(), cselib_process_insn(), cselib_record_set(), cselib_reset_table(), discard_useless_locs(), discard_useless_values(), and remove_useless_values().
|
static |
The unique id that the next create value will take.
Referenced by cselib_finish(), cselib_get_next_uid(), cselib_init(), cselib_lookup_1(), cselib_lookup_mem(), cselib_process_insn(), cselib_reset_table(), cselib_subst_to_values(), dump_cselib_table(), and new_cselib_val().
|
static |
This table maps from register number to values. It does not contain pointers to cselib_val structures, but rather elt_lists. The purpose is to be able to refer to the same register in different modes. The first element of the list defines the mode in which the register was set; if the mode is unknown or the value is no longer valid in that mode, ELT will be NULL for the first element.
Referenced by cselib_init().
|
static |
Referenced by cselib_init().
|
static |
Here the set of indices I with REG_VALUES(I) != 0 is saved. This is used in cselib_clear_table() for fast emptying.
Referenced by cselib_finish(), cselib_init(), cselib_lookup_1(), cselib_record_set(), cselib_reset_table(), reload_combine(), and setup_save_areas().
|
static |
Referenced by cselib_finish(), and new_cselib_val().
|
static |
Set by discard_useless_locs if it deleted the last location of any value.
Referenced by discard_useless_locs(), and remove_useless_values().