GCC Middle and Back End API Reference
tree-ssa-address.c File Reference

Data Structures

struct  mem_addr_template

Typedefs

typedef struct mem_addr_template mem_addr_template

Functions

static void gen_addr_rtx (enum 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)
tree tree_mem_ref_addr ()
static bool valid_mem_ref_p (enum machine_mode mode, addr_space_t as, struct mem_address *addr)
static tree create_mem_ref_raw (tree type, tree alias_ptr_type, struct mem_address *addr, bool verify)
static bool fixed_address_object_p ()
static void move_fixed_address_to_symbol ()
static void move_hint_to_base (tree type, struct mem_address *parts, tree base_hint, aff_tree *addr)
static void move_pointer_to_base ()
static void move_variant_to_index ()
static void add_to_parts ()
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 speed)
static void gimplify_mem_ref_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 ()
void copy_ref_info ()
tree maybe_fold_tmr ()
void dump_mem_address (FILE *, struct mem_address *)
void dump_mem_address ()

Variables

static vec< mem_addr_template,
va_gc > * 
mem_addr_template_list

Typedef Documentation

@verbatim Memory address lowering and addressing mode selection.

Copyright (C) 2004-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/.

Utility functions for manipulation with TARGET_MEM_REFs -- tree expressions
   that directly map to addressing modes of the target.   
FIXME: We compute address costs using RTL.   
TODO -- handling of symbols (according to Richard Hendersons
   comments, http://gcc.gnu.org/ml/gcc-patches/2005-04/msg00949.html):

   There are at least 5 different kinds of symbols that we can run up against:

     (1) binds_local_p, small data area.
     (2) binds_local_p, eg local statics
     (3) !binds_local_p, eg global variables
     (4) thread local, local_exec
     (5) thread local, !local_exec

   Now, (1) won't appear often in an array context, but it certainly can.
   All you have to do is set -GN high enough, or explicitly mark any
   random object __attribute__((section (".sdata"))).

   All of these affect whether or not a symbol is in fact a valid address.
   The only one tested here is (3).  And that result may very well
   be incorrect for (4) or (5).

   An incorrect result here does not cause incorrect results out the
   back end, because the expander in expr.c validizes the address.  However
   it would be nice to improve the handling here in order to produce more
   precise results.   
A "template" for memory address, used to determine whether the address is
   valid for mode.   

Function Documentation

static void add_to_parts ( )
static
Adds ELT to PARTS.   

References mem_address::base, mem_address::index, and type().

Referenced by addr_to_parts().

rtx addr_for_mem_ref ( struct mem_address addr,
addr_space_t  as,
bool  really_expand 
)
Returns address for TARGET_MEM_REF with parameters given by ADDR
   in address space AS.
   If REALLY_EXPAND is false, just make fake registers instead
   of really expanding the operands, and perform the expansion in-place
   by using one of the "templates".   

References mem_address::base, expand_expr(), EXPAND_NORMAL, gen_addr_rtx(), gen_raw_REG(), immed_double_int_const(), mem_address::index, integer_onep(), integer_zerop(), mem_addr_template::off_p, mem_address::offset, mem_addr_template::ref, double_int::sext(), mem_address::step, mem_addr_template::step_p, mem_address::symbol, targetm, tree_to_double_int(), vec_safe_grow_cleared(), and vec_safe_length().

Referenced by expand_expr_real_1(), and valid_mem_ref_p().

static void addr_to_parts ( tree  type,
aff_tree addr,
tree  iv_cand,
tree  base_hint,
struct mem_address parts,
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.

   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(), mem_address::base, aff_comb_elt::coef, double_int_to_tree(), affine_tree_combination::elts, mem_address::index, double_int::is_one(), double_int::is_zero(), most_expensive_mult_to_index(), move_fixed_address_to_symbol(), move_hint_to_base(), move_pointer_to_base(), move_variant_to_index(), affine_tree_combination::n, affine_tree_combination::offset, mem_address::offset, affine_tree_combination::rest, mem_address::step, mem_address::symbol, and aff_comb_elt::val.

Referenced by create_mem_ref().

void copy_ref_info ( )
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 addr_to_parts(), mem_address::base, create_mem_ref_raw(), force_gimple_operand_gsi(), force_gimple_operand_gsi_1(), gimplify_mem_ref_parts(), GSI_SAME_STMT, mem_address::index, integer_onep(), integer_zerop(), is_gimple_mem_ref_addr(), is_gimple_val(), mem_address::offset, mem_address::step, mem_address::symbol, and useless_type_conversion_p().

Referenced by rewrite_use_address().

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, build_int_cst(), mem_address::index, integer_onep(), integer_zerop(), mem_address::offset, mem_address::step, mem_address::symbol, and valid_mem_ref_p().

Referenced by create_mem_ref(), and maybe_fold_tmr().

void dump_mem_address ( FILE *  ,
struct mem_address  
)
Dump PARTS to FILE.   
static bool fixed_address_object_p ( )
static
Returns true if OBJ is an object whose address is a link time constant.   

Referenced by move_fixed_address_to_symbol().

static void gen_addr_rtx ( enum 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 offset, and simplify_gen_binary().

Referenced by addr_for_mem_ref().

void get_address_description ( )
Copies components of the address from OP to ADDR.   

References mem_address::base, mem_address::index, integer_zerop(), mem_address::offset, mem_address::step, and mem_address::symbol.

static void gimplify_mem_ref_parts ( )
static
tree maybe_fold_tmr ( )
static void most_expensive_mult_to_index ( tree  type,
struct mem_address parts,
aff_tree addr,
bool  speed 
)
static
static void move_fixed_address_to_symbol ( )
static
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, affine_tree_combination::elts, fixed_address_object_p(), double_int::is_one(), affine_tree_combination::n, mem_address::symbol, and aff_comb_elt::val.

Referenced by addr_to_parts().

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

References aff_combination_remove_elt(), mem_address::base, aff_comb_elt::coef, affine_tree_combination::elts, double_int::is_one(), affine_tree_combination::n, and aff_comb_elt::val.

Referenced by addr_to_parts().

static void move_variant_to_index ( )
static
tree tree_mem_ref_addr ( )
Returns address of MEM_REF in TYPE.   

References integer_zerop(), and offset.

Referenced by expand_debug_expr(), find_interesting_uses_address(), gimplify_addr(), and mf_xform_derefs_1().

static bool valid_mem_ref_p ( enum machine_mode  mode,
addr_space_t  as,
struct mem_address addr 
)
static
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().


Variable Documentation

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.