GCC Middle and Back End API Reference
tree-ssa-address.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "target.h"
#include "rtl.h"
#include "tree.h"
#include "gimple.h"
#include "memmodel.h"
#include "stringpool.h"
#include "tree-vrp.h"
#include "tree-ssanames.h"
#include "expmed.h"
#include "insn-config.h"
#include "emit-rtl.h"
#include "recog.h"
#include "tree-pretty-print.h"
#include "fold-const.h"
#include "stor-layout.h"
#include "gimple-iterator.h"
#include "gimplify-me.h"
#include "tree-ssa-loop-ivopts.h"
#include "expr.h"
#include "tree-dfa.h"
#include "dumpfile.h"
#include "tree-affine.h"
#include "gimplify.h"
#include "builtins.h"
#include "tree-ssa-address.h"
#include "gt-tree-ssa-address.h"
Include dependency graph for tree-ssa-address.cc:

Data Structures

struct  mem_addr_template
 

Macros

#define TEMPL_IDX(AS, SYMBOL, BASE, INDEX, STEP, OFFSET)
 
#define MAX_RATIO   128
 

Functions

static void gen_addr_rtx (machine_mode address_mode, rtx symbol, rtx base, rtx index, rtx step, rtx offset, rtx *addr, rtx **step_p, rtx **offset_p)
 
rtx addr_for_mem_ref (struct mem_address *addr, addr_space_t as, bool really_expand)
 
rtx addr_for_mem_ref (tree exp, addr_space_t as, bool really_expand)
 
tree tree_mem_ref_addr (tree type, tree mem_ref)
 
bool valid_mem_ref_p (machine_mode mode, addr_space_t as, struct mem_address *addr, code_helper ch)
 
static tree create_mem_ref_raw (tree type, tree alias_ptr_type, struct mem_address *addr, bool verify)
 
static bool fixed_address_object_p (tree obj)
 
void move_fixed_address_to_symbol (struct mem_address *parts, aff_tree *addr)
 
static bool move_hint_to_base (tree type, struct mem_address *parts, tree base_hint, aff_tree *addr)
 
static void move_pointer_to_base (struct mem_address *parts, aff_tree *addr)
 
static void move_variant_to_index (struct mem_address *parts, aff_tree *addr, tree v)
 
static void add_to_parts (struct mem_address *parts, tree elt)
 
static bool multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, machine_mode mode, addr_space_t as)
 
static void most_expensive_mult_to_index (tree type, struct mem_address *parts, aff_tree *addr, bool speed)
 
static void addr_to_parts (tree type, aff_tree *addr, tree iv_cand, tree base_hint, struct mem_address *parts, bool *var_in_base, bool speed)
 
static void gimplify_mem_ref_parts (gimple_stmt_iterator *gsi, struct mem_address *parts)
 
static bool mem_ref_valid_without_offset_p (tree type, mem_address parts)
 
static void add_offset_to_base (gimple_stmt_iterator *gsi, mem_address *parts)
 
tree create_mem_ref (gimple_stmt_iterator *gsi, tree type, aff_tree *addr, tree alias_ptr_type, tree iv_cand, tree base_hint, bool speed)
 
void get_address_description (tree op, struct mem_address *addr)
 
void copy_ref_info (tree new_ref, tree old_ref)
 
tree maybe_fold_tmr (tree ref)
 
unsigned int preferred_mem_scale_factor (tree base, machine_mode mem_mode, bool speed)
 
void dump_mem_address (FILE *, struct mem_address *)
 

Variables

static vec< mem_addr_template, va_gc > * mem_addr_template_list
 

Macro Definition Documentation

◆ MAX_RATIO

#define MAX_RATIO   128

◆ TEMPL_IDX

#define TEMPL_IDX ( AS,
SYMBOL,
BASE,
INDEX,
STEP,
OFFSET )
Value:
(((int) (AS) << 5) \
| ((SYMBOL != 0) << 4) \
| ((BASE != 0) << 3) \
| ((INDEX != 0) << 2) \
| ((STEP != 0) << 1) \
| (OFFSET != 0))
#define BASE
Definition double-int.cc:71
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184

Referenced by addr_for_mem_ref().

Function Documentation

◆ add_offset_to_base()

static void add_offset_to_base ( gimple_stmt_iterator * gsi,
mem_address * parts )
static
Fold PARTS->offset into PARTS->base, so that there is no longer
a separate offset.  Emit any new instructions before GSI.   

References fold_build_pointer_plus, force_gimple_operand_gsi_1(), ggc_alloc(), GSI_SAME_STMT, is_gimple_mem_ref_addr(), and NULL_TREE.

Referenced by create_mem_ref().

◆ add_to_parts()

static void add_to_parts ( struct mem_address * parts,
tree elt )
static

◆ addr_for_mem_ref() [1/2]

◆ addr_for_mem_ref() [2/2]

rtx addr_for_mem_ref ( tree exp,
addr_space_t as,
bool really_expand )
implement addr_for_mem_ref() directly from a tree, which avoids exporting
the mem_address structure.   

References addr_for_mem_ref(), exp(), get_address_description(), and ggc_alloc().

◆ addr_to_parts()

static void addr_to_parts ( tree type,
aff_tree * addr,
tree iv_cand,
tree base_hint,
struct mem_address * parts,
bool * var_in_base,
bool speed )
static
Splits address ADDR for a memory access of type TYPE into PARTS.
If BASE_HINT is non-NULL, it specifies an SSA name to be used
preferentially as base of the reference, and IV_CAND is the selected
iv candidate used in ADDR.  Store true to VAR_IN_BASE if variant
part of address is split to PARTS.base.

TODO -- be more clever about the distribution of the elements of ADDR
to PARTS.  Some architectures do not support anything but single
register in address, possibly with a small integer offset; while
create_mem_ref will simplify the address to an acceptable shape
later, it would be more efficient to know that asking for complicated
addressing modes is useless.   

References add_to_parts(), aff_comb_elt::coef, aff_tree::elts, fold_build2, fold_convert, ggc_alloc(), i, most_expensive_mult_to_index(), move_fixed_address_to_symbol(), move_hint_to_base(), move_pointer_to_base(), move_variant_to_index(), aff_tree::n, NULL, NULL_TREE, aff_tree::offset, aff_tree::rest, sizetype, aff_comb_elt::val, and wide_int_to_tree().

Referenced by create_mem_ref().

◆ copy_ref_info()

◆ create_mem_ref()

tree create_mem_ref ( gimple_stmt_iterator * gsi,
tree type,
aff_tree * addr,
tree alias_ptr_type,
tree iv_cand,
tree base_hint,
bool speed )
Creates and returns a TARGET_MEM_REF for address ADDR.  If necessary
computations are emitted in front of GSI.  TYPE is the mode
of created memory reference. IV_CAND is the selected iv candidate in ADDR,
and BASE_HINT is non NULL if IV_CAND comes from a base address
object.   

References add_offset_to_base(), addr_to_parts(), create_mem_ref_raw(), fold_build2, fold_build_pointer_plus, force_gimple_operand_gsi(), force_gimple_operand_gsi_1(), gcc_assert, gcc_unreachable, ggc_alloc(), gimplify_mem_ref_parts(), GSI_SAME_STMT, integer_onep(), integer_zerop(), is_gimple_mem_ref_addr(), is_gimple_val(), mem_ref_valid_without_offset_p(), NULL_TREE, sizetype, TREE_TYPE, unshare_expr(), and useless_type_conversion_p().

Referenced by rewrite_use_address().

◆ create_mem_ref_raw()

static tree create_mem_ref_raw ( tree type,
tree alias_ptr_type,
struct mem_address * addr,
bool verify )
static
Checks whether a TARGET_MEM_REF with type TYPE and parameters given by ADDR
is valid on the current target and if so, creates and returns the
TARGET_MEM_REF.  If VERIFY is false omit the verification step.   

References mem_address::base, build5(), build_int_cst(), build_pointer_type(), fold_build2, fold_convert, ggc_alloc(), mem_address::index, integer_zerop(), NULL_TREE, mem_address::offset, POINTER_TYPE_P, mem_address::step, mem_address::symbol, TREE_CODE, TREE_TYPE, TYPE_ADDR_SPACE, TYPE_MODE, and valid_mem_ref_p().

Referenced by create_mem_ref(), and maybe_fold_tmr().

◆ dump_mem_address()

void dump_mem_address ( FILE * file,
struct mem_address * parts )
extern
Dump PARTS to FILE.   

References ggc_alloc(), print_generic_expr(), TDF_SLIM, and TREE_OPERAND.

◆ fixed_address_object_p()

static bool fixed_address_object_p ( tree obj)
static
Returns true if OBJ is an object whose address is a link time constant.   

References DECL_DLLIMPORT_P, DECL_EXTERNAL, TREE_STATIC, and VAR_P.

Referenced by move_fixed_address_to_symbol().

◆ gen_addr_rtx()

static void gen_addr_rtx ( machine_mode address_mode,
rtx symbol,
rtx base,
rtx index,
rtx step,
rtx offset,
rtx * addr,
rtx ** step_p,
rtx ** offset_p )
static
Stores address for memory reference with parameters SYMBOL, BASE, INDEX,
STEP and OFFSET to *ADDR using address mode ADDRESS_MODE.  Stores pointers
to where step is placed to *STEP_P and offset to *OFFSET_P.   

References const0_rtx, GET_CODE, ggc_alloc(), NULL, NULL_RTX, offset, simplify_gen_binary(), and XEXP.

Referenced by addr_for_mem_ref().

◆ get_address_description()

◆ gimplify_mem_ref_parts()

static void gimplify_mem_ref_parts ( gimple_stmt_iterator * gsi,
struct mem_address * parts )
static

◆ maybe_fold_tmr()

◆ mem_ref_valid_without_offset_p()

static bool mem_ref_valid_without_offset_p ( tree type,
mem_address parts )
static
Return true if the OFFSET in PARTS is the only thing that is making
it an invalid address for type TYPE.   

References ggc_alloc(), NULL_TREE, TYPE_ADDR_SPACE, TYPE_MODE, and valid_mem_ref_p().

Referenced by create_mem_ref().

◆ most_expensive_mult_to_index()

static void most_expensive_mult_to_index ( tree type,
struct mem_address * parts,
aff_tree * addr,
bool speed )
static

◆ move_fixed_address_to_symbol()

void move_fixed_address_to_symbol ( struct mem_address * parts,
aff_tree * addr )
If ADDR contains an address of object that is a link time constant,
move it to PARTS->symbol.   

References aff_combination_remove_elt(), aff_comb_elt::coef, aff_tree::elts, fixed_address_object_p(), ggc_alloc(), i, aff_tree::n, NULL_TREE, TREE_CODE, TREE_OPERAND, and aff_comb_elt::val.

Referenced by addr_to_parts(), and get_address_cost().

◆ move_hint_to_base()

static bool move_hint_to_base ( tree type,
struct mem_address * parts,
tree base_hint,
aff_tree * addr )
static

◆ move_pointer_to_base()

static void move_pointer_to_base ( struct mem_address * parts,
aff_tree * addr )
static
If ADDR contains an address of a dereferenced pointer, move it to
PARTS->base.   

References aff_combination_remove_elt(), aff_comb_elt::coef, aff_tree::elts, ggc_alloc(), i, aff_tree::n, NULL_TREE, POINTER_TYPE_P, TREE_TYPE, and aff_comb_elt::val.

Referenced by addr_to_parts().

◆ move_variant_to_index()

static void move_variant_to_index ( struct mem_address * parts,
aff_tree * addr,
tree v )
static
Moves the loop variant part V in linear address ADDR to be the index
of PARTS.   

References aff_combination_remove_elt(), aff_comb_elt::coef, aff_tree::elts, fold_convert, gcc_assert, ggc_alloc(), i, aff_tree::n, NULL_TREE, operand_equal_p(), sizetype, aff_comb_elt::val, and wide_int_to_tree().

Referenced by addr_to_parts().

◆ multiplier_allowed_in_address_p()

static bool multiplier_allowed_in_address_p ( HOST_WIDE_INT ratio,
machine_mode mode,
addr_space_t as )
static
Returns true if multiplying by RATIO is allowed in an address.  Test the
validity for a memory reference accessing memory of mode MODE in address
space AS.   

References bitmap_bit_p, bitmap_clear(), bitmap_set_bit, dump_file, dump_flags, gen_int_mode(), gen_raw_REG(), ggc_alloc(), i, LAST_VIRTUAL_REGISTER, MAX_RATIO, memory_address_addr_space_p(), NULL_RTX, sbitmap_alloc(), targetm, TDF_DETAILS, and XEXP.

Referenced by most_expensive_mult_to_index().

◆ preferred_mem_scale_factor()

unsigned int preferred_mem_scale_factor ( tree base,
machine_mode mem_mode,
bool speed )
Return the preferred index scale factor for accessing memory of mode
MEM_MODE in the address space of pointer BASE.  Assume that we're
optimizing for speed if SPEED is true and for size otherwise.   

References addr_for_mem_ref(), address_cost(), mem_address::base, GET_MODE_UNIT_SIZE, ggc_alloc(), integer_one_node, sizetype, TREE_TYPE, TYPE_ADDR_SPACE, and wide_int_to_tree().

Referenced by add_iv_candidate_for_use().

◆ tree_mem_ref_addr()

◆ valid_mem_ref_p()

bool valid_mem_ref_p ( machine_mode mode,
addr_space_t as,
struct mem_address * addr,
code_helper ch )
Returns true if a memory reference in MODE and with parameters given by
ADDR is valid on the current target.   

References addr_for_mem_ref(), and memory_address_addr_space_p().

Referenced by create_mem_ref_raw(), get_address_cost(), mem_ref_valid_without_offset_p(), and valid_mem_ref_cand_p().

Variable Documentation

◆ mem_addr_template_list

vec<mem_addr_template, va_gc>* mem_addr_template_list
static
The templates.  Each of the low five bits of the index corresponds to one
component of TARGET_MEM_REF being present, while the high bits identify
the address space.  See TEMPL_IDX.   

Referenced by addr_for_mem_ref().