GCC Middle and Back End API Reference
cselib.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cselib_val
 
struct  elt_loc_list
 
struct  cselib_set
 

Typedefs

typedef rtx(* cselib_expand_callback) (rtx, bitmap, int, void *)
 

Enumerations

enum  cselib_record_what { CSELIB_RECORD_MEMORY = 1 , CSELIB_PRESERVE_CONSTANTS = 2 }
 

Functions

cselib_valcselib_lookup (rtx, machine_mode, int, machine_mode)
 
cselib_valcselib_lookup_from_insn (rtx, machine_mode, int, machine_mode, rtx_insn *)
 
void cselib_init (int)
 
void cselib_clear_table (void)
 
void cselib_finish (void)
 
void cselib_process_insn (rtx_insn *)
 
bool fp_setter_insn (rtx_insn *)
 
machine_mode cselib_reg_set_mode (const_rtx)
 
bool rtx_equal_for_cselib_1 (rtx, rtx, machine_mode, int)
 
bool cselib_redundant_set_p (rtx)
 
bool references_value_p (const_rtx, int)
 
rtx cselib_expand_value_rtx (rtx, bitmap, int)
 
rtx cselib_expand_value_rtx_cb (rtx, bitmap, int, cselib_expand_callback, void *)
 
bool cselib_dummy_expand_value_rtx_cb (rtx, bitmap, int, cselib_expand_callback, void *)
 
rtx cselib_subst_to_values (rtx, machine_mode)
 
rtx cselib_subst_to_values_from_insn (rtx, machine_mode, rtx_insn *)
 
void cselib_invalidate_rtx (rtx)
 
void cselib_reset_table (unsigned int)
 
unsigned int cselib_get_next_uid (void)
 
void cselib_preserve_value (cselib_val *)
 
bool cselib_preserved_value_p (cselib_val *)
 
void cselib_preserve_only_values (void)
 
void cselib_preserve_cfa_base_value (cselib_val *, unsigned int)
 
void cselib_add_permanent_equiv (cselib_val *, rtx, rtx_insn *)
 
bool cselib_have_permanent_equivalences (void)
 
void cselib_set_value_sp_based (cselib_val *)
 
bool cselib_sp_based_value_p (cselib_val *)
 
void cselib_record_sp_cfa_base_equiv (HOST_WIDE_INT, rtx_insn *)
 
bool cselib_sp_derived_value_p (cselib_val *)
 
void dump_cselib_table (FILE *)
 
cselib_valcanonical_cselib_val (cselib_val *val)
 
bool rtx_equal_for_cselib_p (rtx x, rtx y)
 

Variables

void(* cselib_discard_hook )(cselib_val *)
 
void(* cselib_record_sets_hook )(rtx_insn *insn, struct cselib_set *sets, int n_sets)
 

Typedef Documentation

◆ cselib_expand_callback

typedef rtx(* cselib_expand_callback) (rtx, bitmap, int, void *)

Enumeration Type Documentation

◆ cselib_record_what

Enumerator
CSELIB_RECORD_MEMORY 
CSELIB_PRESERVE_CONSTANTS 

Function Documentation

◆ canonical_cselib_val()

◆ cselib_add_permanent_equiv()

void cselib_add_permanent_equiv ( cselib_val * elt,
rtx x,
rtx_insn * insn )
extern

◆ cselib_clear_table()

void cselib_clear_table ( void )
extern
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().

◆ cselib_dummy_expand_value_rtx_cb()

bool cselib_dummy_expand_value_rtx_cb ( rtx orig,
bitmap regs_active,
int max_depth,
cselib_expand_callback cb,
void * data )
extern
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.

◆ cselib_expand_value_rtx()

rtx cselib_expand_value_rtx ( rtx orig,
bitmap regs_active,
int max_depth )
extern
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().

◆ cselib_expand_value_rtx_cb()

rtx cselib_expand_value_rtx_cb ( rtx orig,
bitmap regs_active,
int max_depth,
cselib_expand_callback cb,
void * data )
extern
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().

◆ cselib_finish()

◆ cselib_get_next_uid()

unsigned int cselib_get_next_uid ( void )
extern
Return the number of the next value that will be generated.   

References next_uid.

Referenced by vt_emit_notes(), and vt_initialize().

◆ cselib_have_permanent_equivalences()

bool cselib_have_permanent_equivalences ( void )
extern
Return TRUE if any permanent equivalences have been recorded since
the table was last initialized.   

References cselib_any_perm_equivs.

Referenced by get_addr().

◆ cselib_init()

◆ cselib_invalidate_rtx()

◆ cselib_lookup()

◆ cselib_lookup_from_insn()

cselib_val * cselib_lookup_from_insn ( rtx x,
machine_mode mode,
int create,
machine_mode memmode,
rtx_insn * insn )
extern
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().

◆ cselib_preserve_cfa_base_value()

void cselib_preserve_cfa_base_value ( cselib_val * v,
unsigned int regno )
extern
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().

◆ cselib_preserve_only_values()

void cselib_preserve_only_values ( void )
extern
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().

◆ cselib_preserve_value()

void cselib_preserve_value ( cselib_val * v)
extern
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().

◆ cselib_preserved_value_p()

bool cselib_preserved_value_p ( cselib_val * v)
extern

◆ cselib_process_insn()

◆ cselib_record_sp_cfa_base_equiv()

void cselib_record_sp_cfa_base_equiv ( HOST_WIDE_INT offset,
rtx_insn * insn )
extern
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().

◆ cselib_redundant_set_p()

bool cselib_redundant_set_p ( rtx set)
extern
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().

◆ cselib_reg_set_mode()

machine_mode cselib_reg_set_mode ( const_rtx x)
extern
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().

◆ cselib_reset_table()

◆ cselib_set_value_sp_based()

void cselib_set_value_sp_based ( cselib_val * v)
extern
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().

◆ cselib_sp_based_value_p()

bool cselib_sp_based_value_p ( cselib_val * v)
extern
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().

◆ cselib_sp_derived_value_p()

bool cselib_sp_derived_value_p ( cselib_val * v)
extern
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().

◆ cselib_subst_to_values()

rtx cselib_subst_to_values ( rtx x,
machine_mode memmode )
extern
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().

◆ cselib_subst_to_values_from_insn()

rtx cselib_subst_to_values_from_insn ( rtx x,
machine_mode memmode,
rtx_insn * insn )
extern
Wrapper for cselib_subst_to_values, that indicates X is in INSN.   

References cselib_current_insn, cselib_subst_to_values(), gcc_assert, and NULL.

◆ dump_cselib_table()

void dump_cselib_table ( FILE * out)
extern

◆ fp_setter_insn()

bool fp_setter_insn ( rtx_insn * insn)
extern
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().

◆ references_value_p()

bool references_value_p ( const_rtx x,
int only_useless )
extern
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().

◆ rtx_equal_for_cselib_1()

bool rtx_equal_for_cselib_1 ( rtx x,
rtx y,
machine_mode memmode,
int depth )
extern
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, 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().

◆ rtx_equal_for_cselib_p()

bool rtx_equal_for_cselib_p ( rtx x,
rtx y )
inline
Return true if we can prove that X and Y contain the same value, taking
our gathered information into account.   

References rtx_equal_for_cselib_1(), and y.

Referenced by cselib_redundant_set_p().

Variable Documentation

◆ cselib_discard_hook

void(* cselib_discard_hook) (cselib_val *) ( cselib_val * )
extern
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().

◆ cselib_record_sets_hook

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 )
extern
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().