GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "tm_p.h"
#include "basic-block.h"
#include "tree-pretty-print.h"
#include "gimple.h"
#include "tree-ssanames.h"
#include "tree-ssa-loop-ivopts.h"
#include "tree-dfa.h"
#include "dumpfile.h"
#include "flags.h"
#include "tree-inline.h"
#include "tree-affine.h"
#include "insn-config.h"
#include "rtl.h"
#include "recog.h"
#include "expr.h"
#include "ggc.h"
#include "target.h"
#include "expmed.h"
#include "tree-ssa-address.h"
#include "gt-tree-ssa-address.h"
Data Structures | |
struct | mem_addr_template |
struct | mem_address |
Macros | |
#define | TEMPL_IDX(AS, SYMBOL, BASE, INDEX, STEP, OFFSET) |
Typedefs | |
typedef struct mem_addr_template | mem_addr_template |
Variables | |
static vec< mem_addr_template, va_gc > * | mem_addr_template_list |
#define TEMPL_IDX | ( | AS, | |
SYMBOL, | |||
BASE, | |||
INDEX, | |||
STEP, | |||
OFFSET | |||
) |
typedef struct mem_addr_template mem_addr_template |
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.
|
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 |
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, fold_build_pointer_plus, force_gimple_operand_gsi_1(), gcc_assert, GSI_SAME_STMT, mem_address::index, is_gimple_mem_ref_addr(), NULL_TREE, sizetype, TREE_TYPE, and useless_type_conversion_p().
|
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 |
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(), TREE_CODE, TREE_OPERAND, and aff_comb_elt::val.
|
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 XEXP.
void get_address_description | ( | ) |
Copies components of the address from OP to ADDR.
References ptr_info_def::align, duplicate_ssa_name_ptr_info(), get_base_address(), get_ptr_info_alignment(), mem_ref_offset(), ptr_info_def::misalign, SSA_NAME_PTR_INFO, TMR_INDEX2, TMR_STEP, TREE_CODE, TREE_INT_CST_LOW, and TREE_OPERAND.
|
static |
Force the PARTS to register.
References create_mem_ref_raw(), fold_build2, force_gimple_operand_gsi(), gcc_assert, GSI_SAME_STMT, mem_address::index, NULL_TREE, sizetype, and mem_address::step.
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(), NULL_TREE, sizetype, and mem_address::step.
|
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 |
If ADDR contains an address of object that is a link time constant, move it to PARTS->symbol.
|
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 |
If ADDR contains an address of a dereferenced pointer, move it to PARTS->base.
References aff_combination_remove_elt(), aff_comb_elt::coef, double_int_to_tree(), affine_tree_combination::elts, fold_convert, gcc_assert, mem_address::index, affine_tree_combination::n, NULL_TREE, operand_equal_p(), sizetype, mem_address::step, and aff_comb_elt::val.
|
static |
Moves the loop variant part V in linear address ADDR to be the index of PARTS.
References mem_address::base, fold_build2, fold_build_pointer_plus, fold_convert, mem_address::index, POINTER_TYPE_P, sizetype, TREE_TYPE, and type().
tree tree_mem_ref_addr | ( | ) |
Returns address of MEM_REF in TYPE.
|
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, fold_convert, integer_onep(), NULL_TREE, mem_address::offset, mem_address::step, TYPE_ADDR_SPACE, and TYPE_MODE.
|
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.