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

Data Structures

struct  mem_addr_template
struct  mem_address

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)
rtx addr_for_mem_ref ()
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.  
     Add ELT to base.  
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".  
         Reuse the templates for addresses, so that we do not waste memory.  
     Otherwise really expand the expressions.  
rtx addr_for_mem_ref ( )
   implement addr_for_mem_ref() directly from a tree, which avoids exporting
   the mem_address structure.  
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.  
     Try to find a symbol.  
     No need to do address parts reassociation if the number of parts
     is <= 2 -- in that case, no loop invariant code motion can be
     exposed.  
     First move the most expensive feasible multiplication
     to index.  
     Try to find a base of the reference.  Since at the moment
     there is no reliable way how to distinguish between pointer and its
     offset, this is just a guess.  
     Then try to process the remaining elements.  
void copy_ref_info ( )
   Copies the reference information from OLD_REF to NEW_REF, where
   NEW_REF should be either a MEM_REF or a TARGET_MEM_REF.  
     We can transfer points-to information from an old pointer
     or decl base to the new one.  
             We have to be careful about transferring alignment information.  
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.  
     The expression is too complicated.  Try making it simpler.  
         Move the multiplication to index.  
         Add the symbol to base, eventually forcing it to register.  
         Add index to base.  
         Try adding offset to base.  
     Verify that the address is in the simplest possible shape
     (only a register).  If we cannot create such a memory reference,
     something is really wrong.  

References mem_address::base, force_gimple_operand_gsi_1(), GSI_SAME_STMT, mem_address::index, is_gimple_mem_ref_addr(), and useless_type_conversion_p().

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.  
     If possible use a plain MEM_REF instead of a TARGET_MEM_REF.
     ???  As IVOPTs does not follow restrictions to where the base
     pointer may point to create a MEM_REF only if we know that
     base is valid.  

Referenced by gimplify_mem_ref_parts().

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

References aff_comb_elt::coef, affine_tree_combination::elts, double_int::is_one(), and aff_comb_elt::val.

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.  
void get_address_description ( )
static void gimplify_mem_ref_parts ( )
static
tree maybe_fold_tmr ( )
   Move constants in target_mem_ref REF to offset.  Returns the new target
   mem ref if anything changes, NULL_TREE otherwise.  
     If we have propagated something into this TARGET_MEM_REF and thus
     ended up folding it, always create a new TARGET_MEM_REF regardless
     if it is valid in this for on the target - the propagation result
     wouldn't be anyway.  

References fold_binary_to_constant(), and mem_address::step.

static void most_expensive_mult_to_index ( tree  type,
struct mem_address parts,
aff_tree addr,
bool  speed 
)
static
   Finds the most expensive multiplication in ADDR that can be
   expressed in an addressing mode and move the corresponding
   element(s) to PARTS.  
     Collect elements multiplied by best_mult.  

References aff_comb_elt::coef, and affine_tree_combination::elts.

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.  
static void move_hint_to_base ( tree  type,
struct mem_address parts,
tree  base_hint,
aff_tree addr 
)
static
   If ADDR contains an instance of BASE_HINT, move it to PARTS->base.  
     Cast value to appropriate pointer type.  We cannot use a pointer
     to TYPE directly, as the back-end will assume registers of pointer
     type are aligned, and just the base itself may not actually be.
     We use void pointer to the type's address space instead.  
static void move_pointer_to_base ( )
static
static void move_variant_to_index ( )
static
   Moves the loop variant part V in linear address ADDR to be the index
   of PARTS.  

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

tree tree_mem_ref_addr ( )
   Returns address of MEM_REF in TYPE.  
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 mem_address::base, integer_onep(), mem_address::offset, and mem_address::step.


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.