GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl-error.h"
#include "tree.h"
#include "flags.h"
#include "except.h"
#include "function.h"
#include "expr.h"
#include "optabs.h"
#include "libfuncs.h"
#include "regs.h"
#include "hard-reg-set.h"
#include "insn-config.h"
#include "recog.h"
#include "output.h"
#include "basic-block.h"
#include "hashtab.h"
#include "ggc.h"
#include "tm_p.h"
#include "langhooks.h"
#include "target.h"
#include "common/common-target.h"
#include "gimple.h"
#include "tree-pass.h"
#include "predict.h"
#include "df.h"
#include "params.h"
#include "bb-reorder.h"
#include "gt-function.h"
Data Structures | |
struct | temp_slot |
struct | temp_slot_address_entry |
struct | initial_value_pair |
struct | initial_value_struct |
struct | assign_parm_data_all |
struct | assign_parm_data_one |
Macros | |
#define | STACK_ALIGNMENT_NEEDED 1 |
#define | STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT) |
#define | NAME__MAIN "__main" |
#define | FLOOR_ROUND(VALUE, ALIGN) ((VALUE) & ~((ALIGN) - 1)) |
#define | CEIL_ROUND(VALUE, ALIGN) (((VALUE) + (ALIGN) - 1) & ~((ALIGN)- 1)) |
#define | STACK_POINTER_OFFSET 0 |
#define | STACK_DYNAMIC_OFFSET(FNDECL) |
#define | HAVE_stack_protect_set 0 |
#define | gen_stack_protect_set(x, y) (gcc_unreachable (), NULL_RTX) |
#define | HAVE_stack_protect_test 0 |
#define | gen_stack_protect_test(x, y, z) (gcc_unreachable (), NULL_RTX) |
Typedefs | |
typedef struct function * | function_p |
typedef struct initial_value_pair | initial_value_pair |
typedef struct initial_value_struct | initial_value_struct |
Variables | |
int | virtuals_instantiated |
static int | funcdef_no |
struct machine_function *(* | init_machine_status )(void) |
struct function * | cfun = 0 |
static htab_t | prologue_insn_hash |
static htab_t | epilogue_insn_hash |
htab_t | types_used_by_vars_hash = NULL |
vec< tree, va_gc > * | types_used_by_cur_var_decl |
static vec< function_p > | function_context_stack |
static htab_t | temp_slot_address_table |
static size_t | n_temp_slots_in_use |
static int | in_arg_offset |
static int | var_offset |
static int | dynamic_offset |
static int | out_arg_offset |
static int | cfa_offset |
static int | next_block_index = 2 |
static bool | in_dummy_function |
static vec< function_p > | cfun_stack |
#define CEIL_ROUND | ( | VALUE, | |
ALIGN | |||
) | (((VALUE) + (ALIGN) - 1) & ~((ALIGN)- 1)) |
Similar, but round to the next highest integer that meets the alignment.
Referenced by add_frame_space().
#define FLOOR_ROUND | ( | VALUE, | |
ALIGN | |||
) | ((VALUE) & ~((ALIGN) - 1)) |
Round a value to the lowest integer less than it that is a multiple of the required alignment. Avoid using division in case the value is negative. Assume the alignment is a power of two.
Referenced by get_stack_local_alignment().
#define gen_stack_protect_set | ( | x, | |
y | |||
) | (gcc_unreachable (), NULL_RTX) |
#define gen_stack_protect_test | ( | x, | |
y, | |||
z | |||
) | (gcc_unreachable (), NULL_RTX) |
#define HAVE_stack_protect_set 0 |
Expand code to initialize the stack_protect_guard. This is invoked at the beginning of a function to be protected.
#define HAVE_stack_protect_test 0 |
Expand code to verify the stack_protect_guard. This is invoked at the end of a function to be protected.
#define NAME__MAIN "__main" |
Some systems use main in a way incompatible with its use in gcc, in these cases use the macros NAMEMAIN to give a quoted symbol and SYMBOL__MAIN to give the same symbol without quotes for an alternative entry point. You must define both, or neither.
#define STACK_ALIGNMENT_NEEDED 1 |
Expands front end tree to back end RTL for GCC. Copyright (C) 1987-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/. This file handles the generation of rtl code from tree structure at the level of the function as a whole. It creates the rtl expressions for parameters and auto variables and has full responsibility for allocating stack slots.
`expand_function_start' is called at the beginning of a function, before the function body is parsed, and `expand_function_end' is called after parsing the body.
Call `assign_stack_local' to allocate a stack slot for a local variable. This is usually done during the RTL generation for the function body, but it can also be done in the reload pass when a pseudo-register does not get a hard register. So we can assign to cfun in this file.
#define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT) |
#define STACK_DYNAMIC_OFFSET | ( | FNDECL | ) |
If not defined, pick an appropriate default for the offset of dynamically allocated memory depending on the value of ACCUMULATE_OUTGOING_ARGS, REG_PARM_STACK_SPACE, and OUTGOING_REG_PARM_STACK_SPACE. The bottom of the stack points to the actual arguments. If REG_PARM_STACK_SPACE is defined, this includes the space for the register parameters. However, if OUTGOING_REG_PARM_STACK space is not defined, stack space for register parameters is not pushed by the caller, but rather part of the fixed stack areas and hence not included in `crtl->outgoing_args_size'. Nevertheless, we must allow for it when allocating stack dynamic objects.
#define STACK_POINTER_OFFSET 0 |
In most machines, the stack pointer register is equivalent to the bottom of the stack.
typedef struct function* function_p |
Stack of nested functions. Keep track of the cfun stack.
typedef struct initial_value_pair initial_value_pair |
Functions and data structures to keep track of the values hard regs had at the start of the function. Private type used by get_hard_reg_initial_reg, get_hard_reg_initial_val, and has_hard_reg_initial_val..
typedef struct initial_value_struct initial_value_struct |
??? This could be a VEC but there is currently no way to define an opaque VEC type. This could be worked around by defining struct initial_value_pair in function.h.
|
static |
Create a new frame_space structure describing free space in the stack frame beginning at START and ending at END, and chain it into the function's frame_space_list.
References BITS_PER_UNIT, CEIL_ROUND, get_stack_local_alignment(), and MAX_SUPPORTED_STACK_ALIGNMENT.
int aggregate_value_p | ( | ) |
Return 1 if EXP is an aggregate type (or a value with aggregate type). This means a type for which function calls must pass an address to the function or get an address back from the function. EXP may be a type node or an expression (whose type is tested).
We don't expect other tree types here.
If a record should be passed the same as its first (and only) member don't pass it as an aggregate. If the front end has decided that this needs to be passed by reference, do so.
Function types that are TREE_ADDRESSABLE force return in memory.
Types that are TREE_ADDRESSABLE must be constructed in memory, and thus can't be returned in registers.
Make sure we have suitable call-clobbered regs to return the value in; if not, we must return it in memory.
If we have something other than a REG (e.g. a PARALLEL), then assume it is OK.
Referenced by dest_safe_for_nrv_p(), instantiate_decls(), and reverse_op().
|
static |
Count the subblocks of the list starting with BLOCK. If VECTOR is non-NULL, list them all into VECTOR, in a depth-first preorder traversal of the block tree. Also clear TREE_ASM_WRITTEN in all blocks.
Record this block.
Record the subblocks, and their subblocks...
void allocate_struct_function | ( | ) |
Allocate a function structure for FNDECL and set its contents to the defaults. Set cfun to the newly-allocated object. Some of the helper functions invoked during initialization assume that cfun has already been set. Therefore, assign the new object directly into cfun and invoke the back end hook explicitly at the very end, rather than initializing a temporary and calling set_cfun on it.
ABSTRACT_P is true if this is a function that will never be seen by the middle-end. Such functions are front-end concepts (like C++ function templates) that do not correspond directly to functions placed in object files.
Assume all registers in stdarg functions need to be saved.
??? This could be set on a per-function basis by the front-end but is this worth the hassle?
References arg_pointer_rtx, emit_move_insn(), gen_reg_rtx(), mark_reg_pointer(), MEM_P, reg_mentioned_p(), set_decl_incoming_rtl(), SET_DECL_RTL, set_dst_reg_note(), function::static_chain_decl, targetm, TYPE_ALIGN, and XEXP.
|
static |
A subroutine of assign_parms. Adjust DATA->ENTRY_RTL such that it's always valid and contiguous.
If this parm was passed part in regs and part in memory, pretend it arrived entirely in memory by pushing the register-part onto the stack. In the special case of a DImode or DFmode that is split, we could put it together in a pseudoreg directly, but for now that's not worth bothering with.
Handle calls that pass values in multiple non-contiguous locations. The Irix 6 ABI has examples of this.
If we didn't decide this parm came in a register, by default it came on the stack.
When an argument is passed in multiple locations, we can't make use of this information, but we can save some copying if the whole argument is passed in a single register.
References BITS_PER_WORD, change_address(), convert_to_mode(), copy_to_reg(), emit_move_insn(), gen_rtx_REG(), REGNO, and word_mode.
|
static |
A subroutine of assign_parms. Adjust DATA->STACK_RTL such that it's always valid and properly aligned.
If we can't trust the parm stack slot to be aligned enough for its ultimate type, don't use that slot after entry. We'll make another stack slot, if we need one.
If parm was passed in memory, and we need to convert it on entry, don't store it back in that same slot.
If stack protection is in effect for this function, don't leave any pointers in their passed stack slots.
References gen_rtx_MEM(), assign_parm_data_one::passed_type, SET_DECL_RTL, set_mem_attributes(), TREE_TYPE, and TYPE_MODE.
|
static |
A subroutine of assign_parms. Examine PARM and pull out type and mode data for the parameter. Incorporate ABI specifics such as pass-by- reference and type promotion.
NAMED_ARG is a misnomer. We really mean 'non-variadic'.
Look out for errors propagating this far. Also, if the parameter's type is void then its value doesn't matter.
This can happen after weird syntax errors or if an enum type is defined among the parms.
Find mode of arg as it is passed, and mode of arg as it should be during execution of this function.
If the parm is to be passed as a transparent union or record, use the type of the first field for the tests below. We have already verified that the modes are the same.
See if this arg was passed by invisible reference.
Find mode as it is passed by the ABI.
Referenced by assign_parms().
|
static |
A subroutine of assign_parms. Set DATA->ENTRY_PARM corresponding to the incoming location of the current parameter.
Determine parm's home in the stack, in case it arrives in the stack or we should pretend it did. Compute the stack position and rtx where the argument arrives and its size. There is one complexity here: If this was a parameter that would have been passed in registers, but wasn't only because it is __builtin_va_alist, we want locate_and_pad_parm to treat it as if it came in a register so that REG_PARM_STACK_SPACE isn't skipped. In this case, we call FUNCTION_ARG with NAMED set to 1 instead of 0 as it was the previous time.
If this parameter was passed both in registers and in the stack, use the copy on the stack.
The caller might already have allocated stack space for the register parameters.
Part of this argument is passed in registers and part is passed on the stack. Ask the prologue code to extend the stack part so that we can recreate the full value. PRETEND_BYTES is the size of the registers we need to store. CURRENT_FUNCTION_PRETEND_ARGS_SIZE is the amount of extra stack space that the prologue should allocate. Internally, gcc assumes that the argument pointer is aligned to STACK_BOUNDARY bits. This is used both for alignment optimizations (see init_emit) and to locate arguments that are aligned to more than PARM_BOUNDARY bits. We must preserve this invariant by rounding CURRENT_FUNCTION_PRETEND_ARGS_SIZE up to a stack boundary.
We assume at most one partial arg, and it must be the first argument on the stack.
We want to align relative to the actual stack pointer, so don't include this in the stack size until later.
Update parm_stack_boundary if this parameter is passed in the stack.
Adjust offsets to include the pretend args.
|
static |
A subroutine of assign_parms. Given that this parameter is allocated stack space by the ABI, find it.
If we're passing this arg using a reg, make its stack home the aligned stack slot.
set_mem_attributes could set MEM_SIZE to the passed mode's size, while promoted mode's size is needed.
If we're padding upward, we know that the alignment of the slot is TARGET_FUNCTION_ARG_BOUNDARY. If we're using slot_offset, we're intentionally forcing upward padding. Otherwise we have to come up with a guess at the alignment based on OFFSET_RTX.
|
static |
A subroutine of assign_parms. If there is actually space on the stack for this parm, count it in stack_args_size and return true.
Trivially true if we've no incoming register.
Also true if we're partially in registers and partially not, since we've arranged to drop the entire argument on the stack.
Also true if the target says that it's passed in both registers and on the stack.
Also true if the target says that there's stack allocated for all register parameters.
Otherwise, no, this parameter has no ABI defined stack slot.
|
static |
A subroutine of assign_parms. Reconstitute any values which were passed in multiple registers and would fit in a single register.
Convert the PARALLEL to a REG of the same mode as the parallel. This can be done with register operations rather than on the stack, even if we will store the reconstituted parameter on the stack later.
References DECL_ARTIFICIAL, gen_reg_rtx(), mark_user_reg(), assign_parm_data_one::nominal_mode, assign_parm_data_one::nominal_type, promote_function_mode(), TREE_TYPE, and TYPE_UNSIGNED.
|
static |
A subroutine of assign_parms. Arrange for the parameter to be present and valid in DATA->STACK_RTL.
If a BLKmode arrives in registers, copy it to a stack slot. Handle calls that pass values in multiple non-contiguous locations.
Note that we will be storing an integral number of words. So we have to be careful to ensure that we allocate an integral number of words. We do this above when we call assign_stack_local if space was not allocated in the argument list. If it was, this will not work if PARM_BOUNDARY is not a multiple of BITS_PER_WORD. It isn't clear how to fix this if it becomes a problem. Exception is when BLKmode arrives with arguments not conforming to word_mode.
Handle values in multiple non-contiguous locations.
If SIZE is that of a mode no bigger than a word, just use that mode's store operation.
We are really truncating a word_mode value containing SIZE bytes into a value of mode MODE. If such an operation requires no actual instructions, we can refer to the value directly in mode MODE, otherwise we must start with the register in word_mode and explicitly convert it.
Blocks smaller than a word on a BYTES_BIG_ENDIAN machine must be aligned to the left before storing to memory. Note that the previous test doesn't handle all cases (e.g. SIZE == 3).
References targetm.
|
static |
A subroutine of assign_parms. Return true if the current parameter should be stored as a BLKmode in the current frame.
|
static |
A subroutine of assign_parms. Allocate a pseudo to hold the current parameter. Get it there. Perform all ABI specified conversions.
Store the parm in a pseudoregister during the function, but we may need to do it in a wider mode. Using 2 here makes the result consistent with promote_decl_mode and thus expand_expr_real_1.
If this was an item that we received a pointer to, set DECL_RTL appropriately.
Copy the value into the register, thus bridging between assign_parm_find_data_types and expand_expr_real_1.
ENTRY_PARM has been converted to PROMOTED_MODE, its mode, by the caller. We now have to convert it to NOMINAL_MODE, if different. However, PARMREG may be in a different mode than NOMINAL_MODE if it is being stored promoted. If ENTRY_PARM is a hard register, it might be in a register not valid for operating in its mode (e.g., an odd-numbered register for a DFmode). In that case, moves are the only thing valid, so we can't do a convert from there. This occurs when the calling sequence allow such misaligned usages. In addition, the conversion may involve a call, which could clobber parameters which haven't been copied to pseudo registers yet. First, we try to emit an insn which performs the necessary conversion. We verify that this insn does not clobber any hard registers.
If op1 is a hard register that is likely spilled, first force it into a pseudo, otherwise combiner might extend its lifetime too much.
Nothing to do.
We did not have an insn to convert directly, or the sequence generated appeared unsafe. We must first copy the parm to a pseudo reg, and save the conversion until after all parameters have been moved.
The argument is already sign/zero extended, so note it into the subreg.
TREE_USED gets set erroneously during expand_assignment.
If we were passed a pointer but the actual value can safely live in a register, retrieve it and use it directly.
We can't use nominal_mode, because it will have been set to Pmode above. We must use the actual mode of the parm.
STACK_PARM is the pointer, not the parm, and PARMREG is now the parm.
Mark the register as eliminable if we did no conversion and it was copied from memory at a fixed offset, and the arg pointer was not copied to a pseudo-reg. If the arg pointer is a pseudo reg or the offset formed an invalid address, such memory-equivalences as we make here would screw up life analysis for it.
Mark complex types separately.
Scan backwards for the set of the real and imaginary parts.
For pointer data type, suggest pointer register.
References adjust_address_nv, GET_CODE, get_last_insn(), GET_MODE, GET_MODE_INNER, GET_MODE_SIZE, prev_nonnote_insn(), REGNO, regno_reg_rtx, SET_DEST, set_dst_reg_note(), set_unique_reg_note(), single_set, assign_parm_data_one::stack_parm, and XEXP.
|
static |
A subroutine of assign_parms. Allocate stack space to hold the current parameter. Get it there. Perform all ABI specified conversions.
Value must be stored in the stack slot STACK_PARM during function execution.
Conversion is required.
??? This may need a big-endian conversion on sparc64.
Use a block move to handle potentially misaligned entry_parm.
References crtl, gcc_assert, and GET_MODE_ALIGNMENT.
|
static |
Assign RTL expressions to the function's parameters. This may involve copying them into registers and using those registers as the DECL_RTL.
Extract the type of PARM; adjust it according to ABI.
Early out for errors and void parameters.
Estimate stack alignment from parameter alignment.
Find out where the parameter arrives in this function.
Find out where stack space for this parameter might be.
Record permanently how this parm was passed.
Update info on where next arg arrives in registers.
Output all parameter conversion instructions (possibly including calls) now that all parameters have been copied out of hard registers.
Estimate reload stack alignment from scalar return mode.
If we are receiving a struct value address as the first argument, set up the RTL for the function result. As this might require code to convert the transmitted address to Pmode, we do this here to ensure that possible preliminary conversions of the address have been emitted already.
We have aligned all the args, so add space for the pretend args.
Adjust function incoming argument size for alignment and minimum length.
See how many bytes, if any, of its args a function should try to pop on return.
For stdarg.h function, save info about regs and stack space used by the named args.
Set the rtx used for the function return value. Put this in its own variable so any optimizers that need this information don't have to include tree.h. Do this here so it gets done when an inlined function gets output.
If scalar return value was computed in a pseudo-reg, or was a named return value that got dumped to the stack, copy that to the hard return register.
The delay slot scheduler assumes that crtl->return_rtx holds the hard register containing the return value, not a temporary pseudo.
References assign_parm_data_all::args_so_far, assign_parm_data_all::args_so_far_v, assign_parm_find_data_types(), build2, build_call_expr(), build_fold_indirect_ref, build_pointer_type(), builtin_decl_explicit(), CALL_ALLOCA_FOR_VAR_P, compare_tree_int(), create_tmp_reg(), create_tmp_var, DECL_ALIGN, DECL_GIMPLE_REG_P, DECL_HAS_VALUE_EXPR_P, DECL_IGNORED_P, DECL_SIZE, DECL_SIZE_UNIT, fold_convert, GENERIC_STACK_CHECK, get_name(), gimplify_and_add(), gimplify_assign(), gimplify_one_sizepos(), gimplify_parm_type(), assign_parm_data_one::named_arg, assign_parm_data_one::passed_mode, assign_parm_data_one::passed_pointer, assign_parm_data_one::passed_type, assign_parm_data_one::promoted_mode, reference_callee_copied(), SET_DECL_VALUE_EXPR, size_int, targetm, TREE_ADDRESSABLE, TREE_CODE, TREE_TYPE, TYPE_MODE, and walk_tree_without_duplicates.
A subroutine of assign_parms. Adjust the parameter list to incorporate the hidden struct return argument, and (abi willing) complex args. Return the new parameter list.
If struct value address is treated as the first argument, make it so.
If the target wants to split complex arguments into scalars, do so.
|
static |
A subroutine of assign_parms. Initialize ALL.
|
static |
A subroutine of assign_parms. Invoke setup_incoming_varargs.
If the back-end has requested extra stack space, record how much is needed. Do not change pretend_args_size otherwise since it may be nonzero from an earlier partial argument.
References DECL_MODE, GET_MODE_SIZE, MEM_EXPR, MEM_OFFSET, MEM_OFFSET_KNOWN_P, assign_parm_data_one::promoted_mode, set_mem_offset(), set_mem_size(), and subreg_lowpart_offset().
|
static |
A subroutine of assign_parms. If the ABI splits complex arguments, then undo the frobbing that we did in assign_parms_augmented_arg_list.
split_complex_arg put the real and imag parts in pseudos. Move them to memory.
References crtl, DECL_REGISTER, DECL_RESULT, DECL_RTL, REG_FUNCTION_VALUE_P, REG_P, REGNO, targetm, and TREE_TYPE.
rtx assign_stack_local | ( | ) |
Wrap up assign_stack_local_1 with last parameter as false.
Referenced by assign_mem_slot(), and delete_caller_save_insns().
rtx assign_stack_local_1 | ( | enum machine_mode | mode, |
HOST_WIDE_INT | size, | ||
int | align, | ||
int | kind | ||
) |
Allocate a stack slot of SIZE bytes and return a MEM rtx for it with machine mode MODE.
ALIGN controls the amount of alignment for the address of the slot: 0 means according to MODE, -1 means use BIGGEST_ALIGNMENT and round size to multiple of that, -2 means use BITS_PER_UNIT, positive specifies alignment boundary in bits.
KIND has ASLK_REDUCE_ALIGN bit set if it is OK to reduce alignment and ASLK_RECORD_PAD bit set if we should remember extra space we allocated for alignment purposes. When we are called from assign_stack_temp_for_type, it is not set so we don't track the same stack slot in two independent lists.
We do not round to stack_boundary here.
Ignore alignment if it exceeds MAX_SUPPORTED_STACK_ALIGNMENT.
If stack is realigned and stack alignment value hasn't been finalized, it is OK not to increase stack_alignment_estimated. The bigger alignment requirement is recorded in stack_alignment_needed below.
It is OK to reduce the alignment as long as the requested size is 0 or the estimated stack alignment >= mode alignment.
On a big-endian machine, if we are allocating more space than we will use, use the least significant bytes of those that are allocated.
If we have already instantiated virtual registers, return the actual address relative to the frame pointer.
rtx assign_stack_temp | ( | ) |
Allocate a temporary stack slot and record it for possible later reuse. First two arguments are same as in preceding function.
References avail_temp_slots, and temp_slot::next.
rtx assign_stack_temp_for_type | ( | enum machine_mode | mode, |
HOST_WIDE_INT | size, | ||
tree | type | ||
) |
Allocate a temporary stack slot and record it for possible later reuse.
MODE is the machine mode to be given to the returned rtx.
SIZE is the size in units of the space required. We do no rounding here since assign_stack_local will do any required rounding.
TYPE is the type that will be used for the stack slot.
If SIZE is -1 it means that somebody tried to allocate a temporary of a variable size.
Try to find an available, already-allocated temporary of the proper mode which meets the size and alignment requirements. Choose the smallest one with the closest alignment. If assign_stack_temp is called outside of the tree->rtl expansion, we cannot reuse the stack slots (that may still refer to VIRTUAL_STACK_VARS_REGNUM).
Make our best, if any, the one to use.
If there are enough aligned bytes left over, make them into a new temp_slot so that the extra bytes don't get wasted. Do this only for BLKmode slots, so that we can be sure of the alignment.
If we still didn't find one, make a new temporary.
We are passing an explicit alignment request to assign_stack_local. One side effect of that is assign_stack_local will not round SIZE to ensure the frame offset remains suitably aligned. So for requests which depended on the rounding of SIZE, we go ahead and round it now. We also make sure ALIGNMENT is at least BIGGEST_ALIGNMENT.
The following slot size computation is necessary because we don't know the actual size of the temporary slot until assign_stack_local has performed all the frame alignment and size rounding for the requested temporary. Note that extra space added for alignment can be either above or below this stack slot depending on which way the frame grows. We include the extra space if and only if it is above this slot.
Now define the fields used by combine_temp_slots.
Create a new MEM rtx to avoid clobbering MEM flags of old slots.
If we know the alias set for the memory that will be used, use it. If there's no TYPE, then we don't know anything about the alias set for the memory.
If a type is specified, set the relevant flags.
Assign a temporary. If TYPE_OR_DECL is a decl, then we are doing it on behalf of the decl and so that should be used in error messages. In either case, we allocate of the given type. MEMORY_REQUIRED is 1 if the result must be addressable stack memory; it is 0 if a register is OK. DONT_PROMOTE is 1 if we should not promote values in register to wider modes.
Zero sized arrays are GNU C extension. Set size to 1 to avoid problems with allocating the stack space.
Unfortunately, we don't yet know how to allocate variable-sized temporaries. However, sometimes we can find a fixed upper limit on the size, so try that instead.
The size of the temporary may be too large to fit into an integer.
??? Not sure this should happen except for user silliness, so limit this to things that aren't compiler-generated temporaries. The rest of the time we'll die in assign_stack_temp_for_type.
References avail_temp_slots, temp_slot::base_offset, cut_slot_from_list(), temp_slot::full_size, GET_MODE, temp_slot::next, temp_slot::size, and temp_slot::slot.
Referenced by expand_value_return(), and initialize_argument_information().
tree block_chainon | ( | ) |
Concatenate two chains of blocks (chained through BLOCK_CHAIN) by modifying the last node in chain 1 to point to chain 2.
|
static |
Reverse the order of elements in the fragment chain T of blocks, and return the new head of the chain (old last element). In addition to that clear BLOCK_SAME_RANGE flags when needed and adjust BLOCK_SUPERCONTEXT from the super fragment to its super fragment origin.
tree blocks_nreverse | ( | ) |
Reverse the order of elements in the chain T of blocks, and return the new head of the chain (old last element).
References crtl, default_rtl_profile(), gcc_assert, init_emit(), init_expr(), init_temp_slots(), init_varasm_status(), and function::su.
|
static |
Reverse the order of elements in the chain T of blocks, and return the new head of the chain (old last element). Also do the same on subblocks and reverse the order of elements in BLOCK_FRAGMENT_CHAIN as well.
References DECL_FUNCTION_SPECIFIC_OPTIMIZATION, init_tree_optimization_optabs(), optimization_current_node, optimization_default_node, targetm, this_fn_optabs, this_target_optabs, TREE_OPTIMIZATION, and TREE_OPTIMIZATION_OPTABS.
void clear_block_marks | ( | ) |
Helper function for reorder_blocks. Reset TREE_ASM_WRITTEN.
void clobber_return_register | ( | ) |
In case we do use pseudo to return value, clobber it too.
References GET_CODE, NONJUMP_INSN_P, PATTERN, XVECEXP, and XVECLEN.
|
static |
Combine temporary stack slots which are adjacent on the stack.
This allows for better use of already allocated stack space. This is only done for BLKmode slots because we can be sure that we won't have alignment problems in this case.
We can't combine slots, because the information about which slot is in which alias set will be lost.
If there are a lot of temp slots, don't do anything unless high levels of optimization.
Q comes after P; combine Q into P.
P comes after Q; combine P into Q.
Either delete P or advance past it.
References update_temp_slot_address(), and XEXP.
Referenced by update_temp_slot_address().
Referenced by use_return_register().
|
static |
Determine if any INSNs in HASH are, or are part of, INSN. Because we can be running after reorg, SEQUENCE rtl is possible.
const char* current_function_name | ( | void | ) |
Returns the name of the current function.
Referenced by find_taken_edge_computed_goto(), and pre_insert_copies().
|
static |
Removes temporary slot TEMP from LIST.
References insert_slot_to_list(), temp_slot::level, and temp_slots_at_level().
Referenced by assign_temp().
DEBUG_FUNCTION tree debug_find_var_in_block_tree | ( | ) |
If VAR is present in a subblock of BLOCK, return the subblock.
void diddle_return_value | ( | void(*)(rtx, void *) | doit, |
void * | arg | ||
) |
Call DOIT for each hard register used as a return value from the current function.
References copy(), epilogue_insn_hash, gcc_assert, and prologue_insn_hash.
Referenced by init_dummy_function_start().
|
static |
Referenced by init_dummy_function_start().
|
static |
References INSN_LOCATION, INSN_P, and NEXT_INSN.
|
static |
|
static |
void do_warn_unused_parameter | ( | ) |
Possibly warn about unused parameters.
References CALL_P, HARD_REG_SET, and SIBLING_CALL_P.
unsigned int emit_initial_value_sets | ( | void | ) |
Called from gimple_expand_cfg.
References arg_pointer_rtx, cfa_offset, and frame_pointer_rtx.
void expand_dummy_function_end | ( | void | ) |
Undo the effects of init_dummy_function_start.
End any sequences that failed to be closed due to syntax errors.
Outside function body, can't compute type's actual size until next function's body starts.
References gcc_assert, htab_create_ggc, and NEXT_INSN.
void expand_function_end | ( | void | ) |
Generate RTL for the end of the current function.
If arg_pointer_save_area was referenced only from a nested function, we will not have initialized it yet. Do that now.
If we are doing generic stack checking and this function makes calls, do a stack probe at the start of the function to ensure we have enough space for another stack frame.
End any sequences that failed to be closed due to syntax errors.
Output a linenumber for the end of the function. SDB depends on this.
Before the return label (if any), clobber the return registers so that they are not propagated live to the rest of the function. This can only happen with functions that drop through; if there had been a return statement, there would have either been a return rtx, or a jump to the return label. We delay actual code generation after the current_function_value_rtx is computed.
Output the label for the actual return from the function.
Let except.c know where it should emit the call to unregister the function context for sjlj exceptions.
We want to ensure that instructions that may trap are not moved into the epilogue by scheduling, because we don't always emit unwind information for the epilogue.
If this is an implementation of throw, do what's necessary to communicate between __builtin_eh_return and the epilogue.
If scalar return value was computed in a pseudo-reg, or was a named return value that got dumped to the stack, copy that to the hard return register.
This should be set in assign_parms.
If this is a BLKmode structure being returned in registers, then use the mode computed in expand_return. Note that if decl_rtl is memory, then its mode may have been changed, but that crtl->return_rtx has not.
If a non-BLKmode return value should be padded at the least significant end of the register, shift it left by the appropriate amount. BLKmode results are handled using the group load/store machinery.
If a named return value dumped decl_return to memory, then we may need to re-do the PROMOTE_MODE signed/unsigned extension.
If expand_function_start has created a PARALLEL for decl_rtl, move the result to the real return registers. Otherwise, do a group load from decl_rtl for a named return.
In the case of complex integer modes smaller than a word, we'll need to generate some non-trivial bitfield insertions. Do that on a pseudo and not the hard register.
If returning a structure, arrange to return the address of the value in a place where debuggers expect to find it. If returning a structure PCC style, the caller also depends on this value. And cfun->returns_pcc_struct is not necessarily set.
Mark this as a function return value so integrate will delete the assignment and USE below when inlining this function.
The address may be ptr_mode and OUTGOING may be Pmode.
Show return register used to hold result (in this case the address of the result.
Emit the actual code to clobber return register.
Output the label for the naked return from the function.
@@@ This is a kludge. We want to ensure that instructions that may trap are not moved into the epilogue by scheduling, because we don't always emit unwind information for the epilogue.
If stack protection is enabled for this function, check the guard.
If we had calls to alloca, and this machine needs an accurate stack pointer to exit the function, insert some code to save and restore the stack pointer.
??? This should no longer be necessary since stupid is no longer with us, but there are some parts of the compiler (eg reload_combine, and sh mach_dep_reorg) that still try and compute their own lifetime info instead of using the general framework.
void expand_function_start | ( | ) |
Start the RTL for a new function, and set variables used for emitting RTL. SUBR is the FUNCTION_DECL node. PARMS_HAVE_CLEANUPS is nonzero if there are cleanups associated with the function's parameters, which must be run at any return statement.
Make sure volatile mem refs aren't considered valid operands of arithmetic insns.
Make the label for return statements to jump to. Do not special case machines with special return instructions – they will be handled later during jump, ifcvt, or epilogue creation.
Initialize rtx used to return the value.
Do this before assign_parms so that we copy the struct value address before any library calls that assign parms might generate.
Decide whether to return the value in memory or in a register.
Returning something that won't go in a register.
Expect to be passed the address of a place to store the value. If it is passed as an argument, assign_parms will take care of it.
If return mode is void, this decl rtl should not be used.
Compute the return values into a pseudo reg, which we will copy into the true return register after the cleanups are done.
expand_function_end will insert the appropriate padding in this case. Use the return value's natural (unpadded) mode within the function proper.
In order to figure out what mode to use for the pseudo, we figure out what the mode of the eventual return register will actually be, and use that.
Structures that are returned in registers are not aggregate_value_p, so we may see a PARALLEL or a REG.
Set DECL_REGISTER flag so that expand_function_end will copy the result to the real return register(s).
Initialize rtx for parameters and local variables. In some cases this requires emitting insns.
If function gets a static chain arg, store it.
Mark the register as eliminable, similar to parameters.
If the function receives a non-local goto, then store the bits we need to restore the frame pointer.
The following was moved from init_function_start. The move is supposed to make sdb output more accurate.
Indicate the beginning of the function body, as opposed to parm setup.
If we are doing generic stack checking, the probe should go here.
References targetm.
void expand_main_function | ( | void | ) |
In function.c
|
staticread |
Find the temp slot corresponding to the object at address X.
First try the easy way: See if X exists in the address -> temp slot mapping.
If we have a sum involving a register, see if it points to a temp slot.
Last resort: Address is a virtual stack var address.
const char* fndecl_name | ( | ) |
Returns the name of function declared by FNDECL.
bool frame_offset_overflow | ( | ) |
Issue an error message and return TRUE if frame OFFSET overflows in the signed target pointer arithmetics for function FUNC. Otherwise return FALSE.
Leave room for the fixed part of the frame.
References GET_MODE_ALIGNMENT, STACK_SLOT_ALIGNMENT, lang_hooks_for_types::type_for_mode, and lang_hooks::types.
void free_after_compilation | ( | ) |
Clear out all parts of the state in F that can safely be discarded after the function has been compiled, to let garbage collection reclaim the memory.
References FRAME_GROWS_DOWNWARD, and frame_offset.
void free_after_parsing | ( | ) |
Clear out all parts of the state in F that can safely be discarded after the function has been parsed, but not compiled, to let garbage collection reclaim the memory.
void free_temp_slots | ( | void | ) |
Free all temporaries used so far. This is normally called at the end of generating code for a statement.
References crtl, initial_value_struct::entries, GGC_RESIZEVEC, has_hard_reg_initial_val(), initial_value_struct::max_entries, and initial_value_struct::num_entries.
Referenced by expand_asm_stmt().
const char* function_name | ( | ) |
Returns the name of function FN.
void generate_setjmp_warnings | ( | void | ) |
Generate warning messages for variables live across setjmp.
References BLOCK_NUMBER, DECL_INITIAL, get_block_vector(), SDB_DEBUG, and XCOFF_DEBUG.
Referenced by split_live_ranges_for_shrink_wrap().
rtx get_arg_pointer_save_area | ( | void | ) |
Save the arg pointer at the beginning of the function. The generated stack slot may not be a valid memory address, so we have to check it and fix it if necessary.
Referenced by generate_setjmp_warnings().
|
static |
Return a vector containing all the blocks rooted at BLOCK. The number of elements in the vector is stored in N_BLOCKS_P. The vector is dynamically allocated; it is the caller's responsibility to call `free' on the pointer returned.
HOST_WIDE_INT get_frame_size | ( | void | ) |
Return size needed for stack frame based on slots so far allocated. This size counts from zero. It is not rounded to PREFERRED_STACK_BOUNDARY; the caller may have to do that.
References DECL_SOURCE_LOCATION, error_at(), and TRUE.
rtx get_hard_reg_initial_reg | ( | ) |
If a pseudo represents an initial hard reg (or expression), return it, else return NULL_RTX.
rtx get_hard_reg_initial_val | ( | ) |
Make sure that there's a pseudo register of mode MODE that stores the initial value of hard register REGNO. Return an rtx for such a pseudo.
References offset, and virtual_incoming_args_rtx.
int get_last_funcdef_no | ( | void | ) |
Return value of funcdef.
int get_next_funcdef_no | ( | void | ) |
Return value of funcdef and increase it.
References hard_function_value().
|
static |
Return stack slot alignment in bits for TYPE and MODE.
Allow the frond-end to (possibly) increase the alignment of this stack slot.
References BITS_PER_UNIT, FLOOR_ROUND, FRAME_GROWS_DOWNWARD, frame_phase, and PREFERRED_STACK_BOUNDARY.
Referenced by add_frame_space().
gimple_seq gimplify_parameters | ( | void | ) |
Gimplify the parameter list for current_function_decl. This involves evaluating SAVE_EXPRs of variable sized parameters and generating code to implement callee-copies reference parameters. Returns a sequence of statements to add to the beginning of the function.
Extract the type of PARM; adjust it according to ABI.
Early out for errors and void parameters.
Update info on where next arg arrives in registers.
??? Once upon a time variable_size stuffed parameter list SAVE_EXPRs (amongst others) onto a pending sizes list. This turned out to be less than manageable in the gimple world. Now we have to hunt them down ourselves.
For constant-sized objects, this is trivial; for variable-sized objects, we have to play games.
If PARM was addressable, move that flag over to the local copy, as its address will be taken, not the PARMs. Keep the parms address taken as we'll query that flag during gimplification.
The call has been built for a variable-sized object.
|
static |
A subroutine of gimplify_parameters, invoked via walk_tree. For all seen types, gimplify their sizes.
Referenced by assign_parms().
rtx has_hard_reg_initial_val | ( | ) |
See if get_hard_reg_initial_val has been used to create a pseudo for the initial value of hard register REGNO in mode MODE. Return the associated pseudo if so, otherwise return NULL.
References crtl.
Referenced by free_temp_slots().
|
static |
Helper to Hash a struct types_used_by_vars_entry.
void init_dummy_function_start | ( | void | ) |
Initialize the rtl expansion mechanism so that we can do simple things like generate sequences. This is used to provide a context during global initialization of some passes. You must call expand_dummy_function_end to exit this context.
References DECL_RESULT, DECL_RTL, DECL_RTL_SET_P, diddle_return_value(), do_clobber_return_reg(), REG_P, and REGNO.
void init_function_start | ( | ) |
Generate RTL for the start of the function SUBR (a FUNCTION_DECL tree node) and initialize static variables for generating RTL for the statements of the function.
Warn if this value is an aggregate type, regardless of which calling convention we are using for it.
void init_temp_slots | ( | void | ) |
Initialize temporary slots.
We have not allocated any temporaries yet.
Set up the table to map addresses to temp slots.
Referenced by blocks_nreverse().
bool initial_value_entry | ( | ) |
Return the hardreg-pseudoreg initial values pair entry I and TRUE if I is a valid entry, or FALSE if I is not a valid entry.
References changed, GET_CODE, instantiate_new_reg(), and offset.
|
static |
Inserts temporary slot TEMP to LIST.
Referenced by cut_slot_from_list().
|
static |
Add ADDRESS as an alias of TEMP_SLOT to the addess -> temp slot mapping.
References INTVAL, max_slot_level(), temp_slot::next, temp_slots_at_level(), and XEXP.
void instantiate_decl_rtl | ( | ) |
Subroutine of instantiate_decls. Given RTL representing a decl, do any instantiation required.
If this is a CONCAT, recurse for the pieces.
If this is not a MEM, no need to do anything. Similarly if the address is a constant or a register that is not a virtual register.
|
static |
Scan all decls in FNDECL (both variables and parameters) and instantiate all virtual registers in their DECL_RTL's.
Process all parameters of the function.
Now process all variables defined in the function or its subblocks.
References aggregate_value_p(), CALL_EXPR_FN, DECL_BY_REFERENCE, first_field(), gcc_unreachable, get_callee_fndecl(), gdbhooks::IDENTIFIER_NODE, NULL_TREE, TREE_CODE, TREE_TYPE, TYPE_P, TYPE_TRANSPARENT_AGGR, and VOID_TYPE_P.
|
static |
Subroutine of instantiate_decls: Process all decls in the given BLOCK node and all its subblocks.
Process all subblocks.
References execute(), and instantiate_virtual_regs().
|
static |
Helper for instantiate_decls called via walk_tree: Process all decls in the given DECL_VALUE_EXPR.
References targetm.
|
static |
Given a piece of RTX and a pointer to a HOST_WIDE_INT, if the RTX is a virtual register, return the equivalent hard register and set the offset indirectly through the pointer. Otherwise, return 0.
Replace virtual_incoming_args_rtx with internal arg pointer if DRAP is used to realign stack.
Referenced by initial_value_entry().
|
static |
Pass through the INSNS of function FNDECL and convert virtual register references to hard register references.
Compute the offsets to use for this function.
Initialize recognition, indicating that volatile is OK.
Scan through all the insns, instantiating every virtual register still present.
These patterns in the instruction stream can never be recognized. Fortunately, they shouldn't contain virtual registers either.
Instantiate any virtual registers in CALL_INSN_FUNCTION_USAGE.
Instantiate the virtual registers in the DECLs for debugging purposes.
Indicate that, from now on, assign_stack_local should use frame_pointer_rtx.
References targetm.
Referenced by instantiate_decls_1().
|
static |
A subroutine of instantiate_virtual_regs. Instantiate any virtual registers present inside of insn. The result will be a valid insn.
There are some special cases to be handled first.
We're allowed to assign to a virtual register. This is interpreted to mean that the underlying register gets assigned the inverse transformation. This is used, for example, in the handling of non-local gotos.
Handle a straight copy from a virtual register by generating a new add insn. The difference between this and falling through to the generic case is avoiding a new pseudo and eliminating a move insn in the initial rtl stream.
Handle a plus involving a virtual register by determining if the operands remain valid if they're modified in place.
If the sum is zero, then replace with a plain move.
Using validate_change and apply_change_group here leaves recog_data in an invalid state. Since we know exactly what we want to check, do those two by hand.
Fall through into the regular operand fixup loop in order to take care of operands other than 1 and 2.
In the general case, we expect virtual registers to appear only in operands, and then only as either bare registers or inside memories.
It may happen that the address with the virtual reg was valid (e.g. based on the virtual stack reg, which might be acceptable to the predicates with all offsets), whereas the address now isn't anymore, for instance when the address is still offsetted, but the base reg isn't virtual-stack-reg anymore. Below we would do a force_reg on the whole operand, but this insn might actually only accept memory. Hence, before doing that last resort, try to reload the address into a register, so this operand stays a MEM.
Careful, special mode predicates may have stuff in insn_data[insn_code].operand[i].mode that isn't useful to us for computing a new value.
??? Recognize address_operand and/or "p" constraints to see if (plus new offset) is a valid before we put this through expand_simple_binop.
At this point, X contains the new value for the operand. Validate the new value vs the insn predicate. Note that asm insns will have insn_code -1 here.
Propagate operand changes into the duplicates.
Force re-recognition of the instruction for validation.
For asm goto, instead of fixing up all the edges just clear the template and clear input operands (asm goto doesn't have any output operands).
|
static |
A subroutine of instantiate_virtual_regs, called via for_each_rtx. Instantiate any virtual registers present inside of *LOC. The expression is simplified, as much as possible, but is not to be considered "valid" in any sense implied by the target. If any change is made, set CHANGED to true.
FIXME – from old code
If we have (plus (subreg (virtual-reg)) (const_int)), we know we can commute the PLUS and SUBREG because pointers into the frame are well-behaved.
|
static |
Invoke the target hook when setting cfun. Update the optimization options if the function uses different options than the default.
Change optimization options if needed.
References targetm.
void locate_and_pad_parm | ( | enum machine_mode | passed_mode, |
tree | type, | ||
int | in_regs, | ||
int | partial, | ||
tree | fndecl, | ||
struct args_size * | initial_offset_ptr, | ||
struct locate_and_pad_arg_data * | locate | ||
) |
Compute the size and offset from the start of the stacked arguments for a parm passed in mode PASSED_MODE and with type TYPE.
INITIAL_OFFSET_PTR points to the current offset into the stacked arguments.
The starting offset and size for this parm are returned in LOCATE->OFFSET and LOCATE->SIZE, respectively. When IN_REGS is nonzero, the offset is that of stack slot, which is returned in LOCATE->SLOT_OFFSET. LOCATE->ALIGNMENT_PAD is the amount of padding required from the initial offset ptr to the stack slot.
IN_REGS is nonzero if the argument will be passed in registers. It will never be set if REG_PARM_STACK_SPACE is not defined.
FNDECL is the function in which the argument was defined.
There are two types of rounding that are done. The first, controlled by TARGET_FUNCTION_ARG_BOUNDARY, forces the offset from the start of the argument list to be aligned to the specific boundary (in bits). This rounding affects the initial and starting offsets, but not the argument size.
The second, controlled by FUNCTION_ARG_PADDING and PARM_BOUNDARY, optionally rounds the size of the parm to PARM_BOUNDARY. The initial offset is not affected by this rounding, while the size always is and the starting offset may be. LOCATE->OFFSET will be negative for ARGS_GROW_DOWNWARD case; INITIAL_OFFSET_PTR is positive because locate_and_pad_parm's callers pass in the total size of args so far as INITIAL_OFFSET_PTR. LOCATE->SIZE is always positive.
Alignment can't exceed MAX_SUPPORTED_STACK_ALIGNMENT.
stack_alignment_estimated can't change after stack has been realigned.
If stack is realigned and stack alignment value hasn't been finalized, it is OK not to increase stack_alignment_estimated. The bigger alignment requirement is recorded in stack_alignment_needed below.
Remember if the outgoing parameter requires extra alignment on the calling function side.
Pad_below needs the pre-rounded size to know how much to pad below so this must be done before rounding up.
References DECL_ARGUMENTS, DECL_CHAIN, DECL_RTL, REG_P, REGNO, regno_clobbered_at_setjmp(), and warning().
Referenced by initialize_argument_information(), and split_complex_types().
rtl_opt_pass* make_pass_instantiate_virtual_regs | ( | ) |
rtl_opt_pass* make_pass_leaf_regs | ( | ) |
rtl_opt_pass* make_pass_match_asm_constraints | ( | ) |
rtl_opt_pass* make_pass_thread_prologue_and_epilogue | ( | ) |
|
static |
Make temporary slot TEMP available.
References temp_slot::in_use, temp_slot_address_entry::temp_slot, and temp_slot_address_table.
Referenced by update_temp_slot_address().
|
static |
This mini-pass fixes fall-out from SSA in asm statements that have in-out constraints. Say you start with
orig = inout; asm ("": "+mr" (inout)); use (orig);
which is transformed very early to use explicit output and match operands:
orig = inout; asm ("": "=mr" (inout) : "0" (inout)); use (orig);
Or, after SSA and copyprop,
asm ("": "=mr" (inout_2) : "0" (inout_1)); use (inout_1);
Clearly inout_2 and inout_1 can't be coalesced easily anymore, as they represent two separate values, so they will get different pseudo registers during expansion. Then, since the two operands need to match per the constraints, but use different pseudo registers, reload can only register a reload for these operands. But reloads can only be satisfied by hardregs, not by memory, so we need a register for this reload, just because we are presented with non-matching operands. So, even though we allow memory for this operand, no memory can be used for it, just because the two operands don't match. This can cause reload failures on register-starved targets.
So it's a symptom of reload not being able to use memory for reloads or, alternatively it's also a symptom of both operands not coming into reload as matching (in which case the pseudo could go to memory just fine, as the alternative allows it, and no reload would be necessary). We fix the latter problem here, by transforming
asm ("": "=mr" (inout_2) : "0" (inout_1));
back to
inout_2 = inout_1; asm ("": "=mr" (inout_2) : "0" (inout_2));
Only do the transformation for pseudos.
We can't do anything if the output is also used as input, as we're going to overwrite it.
Avoid changing the same input several times. For asm ("" : "=mr" (out1), "=mr" (out2) : "0" (in), "1" (in)); only change in once (to out1), rather than changing it first to out1 and afterwards to out2.
Now replace all mentions of the input with output. We can't just replace the occurrence in inputs[i], as the register might also be used in some other input (or even in an address of an output), which would mean possibly increasing the number of inputs by one (namely 'output' in addition), which might pose a too complicated problem for reload to solve. E.g. this situation: asm ("" : "=r" (output), "=m" (input) : "0" (input)) Here 'input' is used in two occurrences as input (once for the input operand, once for the address in the second output operand). If we would replace only the occurrence of the input operand (to make the matching) we would be left with this: output = input asm ("" : "=r" (output), "=m" (input) : "0" (output)) Now we suddenly have two different input values (containing the same value, but different pseudos) where we formerly had only one. With more complicated asms this might lead to reload failures which wouldn't have happen without this pass. So, iterate over all operands and replace all occurrences of the register used.
|
static |
Returns the maximal temporary slot level.
Referenced by insert_temp_slot_address().
void maybe_copy_prologue_epilogue_insn | ( | ) |
INSN has been duplicated or replaced by as COPY, perhaps by duplicating a basic block, splitting or peepholes. If INSN is a prologue or epilogue insn, then record COPY as well.
|
static |
Moves temporary slot TEMP to LEVEL.
void number_blocks | ( | ) |
Set BLOCK_NUMBER for all the blocks in FN.
For SDB and XCOFF debugging output, we start numbering the blocks from 1 within each function, rather than keeping a running count.
The top-level BLOCK isn't numbered at all.
We number the blocks from two.
|
static |
|
static |
Round the stack offset in *OFFSET_PTR up to a multiple of BOUNDARY. BOUNDARY is measured in bits, but must be a multiple of a storage unit.
ARGS_SIZE_TREE includes constant term.
Return true if TYPE should be passed by invisible reference.
If this type contains non-trivial constructors, then it is forbidden for the middle-end to create any new copies.
GCC post 3.4 passes *all* variable sized types by reference.
If a record type should be passed the same as its first (and only) member, use the type and mode of that member.
Referenced by initialize_argument_information().
void pop_cfun | ( | void | ) |
Pop cfun from the stack. Also set current_function_decl accordingly.
When in_dummy_function, we do have a cfun but current_function_decl is NULL. We also allow pushing NULL cfun and subsequently changing current_function_decl to something else and have both restored by pop_cfun.
Referenced by cgraph_process_new_functions(), and gcc::pass_manager::pass_manager().
void pop_function_context | ( | void | ) |
Restore the last saved context, at the end of a nested function. This function is called from language-specific code.
Reset variables that have known state during rtx generation.
void pop_temp_slots | ( | void | ) |
Pop a temporary nesting level. All slots in use in the current level are freed.
References crtl.
|
static |
Reset crtl and other non-struct-function variables to defaults as appropriate for emitting rtl at the start of a function.
Caller save not needed yet.
We haven't done register allocation yet.
Indicate that we have not instantiated virtual registers yet.
Indicate that we want CONCATs now.
Indicate we have no need of a frame pointer yet.
void preserve_temp_slots | ( | ) |
If X could be a reference to a temporary slot, mark that slot as belonging to the to one level higher than the current level. If X matched one of our slots, just mark that one. Otherwise, we can't easily predict which it is, so upgrade all of them.
This is called when an ({...}) construct occurs and a statement returns a value in memory.
If X is a register that is being used as a pointer, see if we have a temporary slot we know it points to.
If X is not in memory or is at a constant address, it cannot be in a temporary slot.
First see if we can find a match.
Otherwise, preserve all non-kept slots at this level.
int prologue_epilogue_contains | ( | ) |
void push_cfun | ( | ) |
Push the current cfun onto the stack, and set cfun to new_cfun. Also set current_function_decl accordingly.
References emit_move_insn(), and gen_reg_rtx().
Referenced by cgraph_process_new_functions(), init_alias_vars(), lower_emutls_phi_arg(), and gcc::pass_manager::pass_manager().
void push_function_context | ( | void | ) |
Save the current context for compilation of a nested function. This is called from language-specific code.
References function::decl, generating_concat_p, set_cfun(), and virtuals_instantiated.
void push_struct_function | ( | ) |
This is like allocate_struct_function, but pushes a new cfun for FNDECL instead of just setting it.
When in_dummy_function we might be in the middle of a pop_cfun and current_function_decl and cfun may not match.
void push_temp_slots | ( | void | ) |
Push deeper into the nesting level for stack temporaries.
We always define `record_insns' even if it's not used so that we can always export `prologue_epilogue_contains'.
|
static |
Add a list of INSNS to the hash HASHP, possibly allocating HASHP for the first time.
References active_insn_p(), BB_END, BB_HEAD, count, dump_file, duplicate_insn_chain(), end_sequence(), get_insns(), basic_block_def::index, NEXT_INSN, PREV_INSN, simplejump_p(), and start_sequence().
bool reference_callee_copied | ( | CUMULATIVE_ARGS * | ca, |
enum machine_mode | mode, | ||
tree | type, | ||
bool | named_arg | ||
) |
Return true if TYPE, which is passed by reference, should be callee copied instead of caller copied.
References targetm.
Referenced by assign_parms(), and initialize_argument_information().
|
static |
True if register REGNO was alive at a place where `setjmp' was called and was set more than once or is an argument. Such regs may be clobbered by `longjmp'.
There appear to be cases where some local vars never reach the backend but have bogus regnos.
References BLOCK_CHAIN, and gcc_assert.
Referenced by locate_and_pad_parm().
|
static |
Remove all mappings of addresses to unused temp slots.
Use quicker clearing if there aren't any active temp slots.
References gcc_assert, NULL, and temp_slot::slot.
Referenced by update_temp_slot_address().
|
static |
Remove an address -> temp slot mapping entry if the temp slot is not in use anymore. Callback for remove_unused_temp_slot_addresses.
void reorder_blocks | ( | void | ) |
Identify BLOCKs referenced by more than one NOTE_INSN_BLOCK_{BEG,END}, and create duplicate blocks. ??? Need an option to either create block fragments or to create abstract origin duplicates of a source block. It really depends on what optimization has been performed.
Reset the TREE_ASM_WRITTEN bit for all blocks.
Prune the old trees away, so that they don't get in the way.
Recreate the block tree from the note nesting.
|
static |
If we have seen this block before, that means it now spans multiple address regions. Create a new fragment.
When there's only one block for the entire function, current_block == block and we mustn't do this, it will cause infinite recursion.
void reposition_prologue_and_epilogue_notes | ( | void | ) |
Reposition the prologue-end and epilogue-begin notes after instruction scheduling.
|
static |
|
static |
On some machines, the prologue and epilogue code, or parts thereof, can be represented as RTL. Doing so lets us schedule insns between it and the rest of the code and also allows delayed branch scheduling to operate in the epilogue.
The stack usage info is finalized during prologue expansion.
|
static |
|
static |
A subroutine of instantiate_virtual_regs_in_insn. Return true if X matches the predicate for insn CODE operand OPERAND.
References GET_CODE, recog_data_d::operand, and recog_data.
void set_cfun | ( | ) |
cfun should never be set directly; use this function.
References assemble_static_space(), DECL_RESULT, int_size_in_bytes(), and function::returns_pcc_struct.
Referenced by push_function_context().
|
static |
|
static |
Set the location of the insn chain starting at INSN to LOC.
References active_insn_p(), and PREV_INSN.
void set_return_jump_label | ( | ) |
Set JUMP_LABEL for a return insn.
|
static |
Do the appropriate part of setjmp_vars_warning but for arguments instead of local variables.
References all_blocks.
|
static |
Walk the tree of blocks describing the binding levels within a function and warn about variables the might be killed by setjmp or vfork. This is done after calling flow_analysis before register allocation since that will clobber the pseudo-regs to hard regs.
References all_blocks, BLOCK_CHAIN, BLOCK_SUBBLOCKS, and TREE_ASM_WRITTEN.
|
static |
If ARGS contains entries with complex types, split the entry into two entries of the component type. Return a new list of substitutions are needed, else the old list.
Rewrite the PARM_DECL's type with its component.
If this arg must go in memory, put it in a pseudo here. We can't allow it to go in memory as per normal parms, because the usual place might not have the imag part adjacent to the real part.
Build a second synthetic decl.
void stack_protect_epilogue | ( | void | ) |
Allow the target to compare Y with X without leaking either into a register.
FALLTHRU
The noreturn predictor has been moved to the tree level. The rtl-level predictors estimate this branch about 20%, which isn't enough to get things moved out of line. Since this is the only extant case of adding a noreturn function at the rtl level, it doesn't seem worth doing ought except adding the prediction by hand.
void stack_protect_prologue | ( | void | ) |
Allow the target to copy from Y to X without leaking Y into a register.
Otherwise do a straight move.
|
static |
Compute the hash value for an address -> temp slot mapping. The value is cached on the mapping entry.
|
static |
Compare two address -> temp slot mapping entries.
|
static |
Return the hash value for an address -> temp slot mapping.
References temp_slot_address_entry::address, NULL, and temp_slot_address_entry::temp_slot.
|
staticread |
Returns the list of used temp slots at LEVEL.
References temp_slot_address_entry::hash.
Referenced by cut_slot_from_list(), insert_temp_slot_address(), and update_temp_slot_address().
|
static |
Generate the prologue and epilogue RTL if the machine supports it. Thread this into place with notes indicating where the prologue ends and where the epilogue begins. Update the basic block information when possible.
Notes on epilogue placement: There are several kinds of edges to the exit block: a single fallthru edge from LAST_BB possibly, edges from blocks containing sibcalls possibly, fake edges from infinite loops
The epilogue is always emitted on the fallthru edge from the last basic block in the function, LAST_BB, into the exit block.
If LAST_BB is empty except for a label, it is the target of every other basic block in the function that ends in a return. If a target has a return or simple_return pattern (possibly with conditional variants), these basic blocks can be changed so that a return insn is emitted into them, and their target is adjusted to the real exit block.
Notes on shrink wrapping: We implement a fairly conservative version of shrink-wrapping rather than the textbook one. We only generate a single prologue and a single epilogue. This is sufficient to catch a number of interesting cases involving early exits.
First, we identify the blocks that require the prologue to occur before them. These are the ones that modify a call-saved register, or reference any of the stack or frame pointer registers. To simplify things, we then mark everything reachable from these blocks as also requiring a prologue. This takes care of loops automatically, and avoids the need to examine whether MEMs reference the frame, since it is sufficient to check for occurrences of the stack or frame pointer.
We then compute the set of blocks for which the need for a prologue is anticipatable (borrowing terminology from the shrink-wrapping description in Muchnick's book). These are the blocks which either require a prologue themselves, or those that have only successors where the prologue is anticipatable. The prologue needs to be inserted on all edges from BB1->BB2 where BB2 is in ANTIC and BB1 is not. For the moment, we ensure that only one such edge exists.
The epilogue is placed as described above, but we make a distinction between inserting return and simple_return patterns when modifying other blocks that end in a return. Blocks that end in a sibcall omit the sibcall_epilogue if the block is not in ANTIC.
Can't deal with multiple successors of the entry block at the moment. Function should always have at least one entry point.
If the exit block has no non-fake predecessors, we don't need an epilogue.
If we're allowed to generate a simple return instruction, then by definition we don't need a full epilogue. If the last basic block before the exit block does not contain active instructions, examine its predecessors and try to emit (conditional) return instructions.
A small fib – epilogue is not yet completed, but we wish to re-use this marker for the splits of EH_RETURN patterns, and nothing else uses the flag in the meantime.
If nothing falls through into the exit block, we don't need an epilogue.
We have a fall-through edge to the exit block, the source is not at the end of the function, and there will be an assembler epilogue at the end of the function. We can't use force_nonfallthru here, because that would try to use return. Inserting a jump 'by hand' is extremely messy, so we take advantage of cfg_layout_finalize using fixup_fallthru_exit_predecessor.
Look for basic blocks within the prologue insns.
The epilogue insns we inserted may cause the exit edge to no longer be fallthru.
Threading the prologue and epilogue changes the artificial refs in the entry and exit blocks.
References BB_END, BB_HEAD, bitmap_bit_p, EDGE_COUNT, EDGE_I, basic_block_def::index, LABEL_P, last, NULL, basic_block_def::preds, and edge_def::src.
|
static |
Determine whether it is possible to fit a stack slot of size SIZE and alignment ALIGNMENT into an area in the stack frame that starts at frame offset START and has a length of LENGTH. If so, store the frame offset to be used for the stack slot in *POFFSET and return true; return false otherwise. This function will extend the frame size when given a start/length pair that lies at the end of the frame.
Calculate how many bytes the start of local variables is off from stack alignment.
Round the frame offset to the specified alignment.
We must be careful here, since FRAME_OFFSET might be negative and division with a negative dividend isn't as well defined as we might like. So we instead assume that ALIGNMENT is a power of two and use logical operations which are unambiguous.
See if it fits. If this space is at the edge of the frame, consider extending the frame to make it fit. Our caller relies on this when allocating a new slot.
void types_used_by_var_decl_insert | ( | ) |
Inserts an entry into the types_used_by_vars_hash hash table.
hashval_t types_used_by_vars_do_hash | ( | ) |
Hash function of the types_used_by_vars_entry hash table.
int types_used_by_vars_eq | ( | ) |
void update_temp_slot_address | ( | ) |
Indicate that NEW_RTX is an alternate way of referring to the temp slot that previously was known by OLD_RTX.
If we didn't find one, see if both OLD_RTX is a PLUS. If so, and NEW_RTX is a register, see if one operand of the PLUS is a temporary location. If so, NEW_RTX points into it. Otherwise, if both OLD_RTX and NEW_RTX are a PLUS and if there is a register in common between them. If so, try a recursive call on those values.
Otherwise add an alias for the temp's address.
References combine_temp_slots(), make_slot_available(), temp_slot::next, remove_unused_temp_slot_addresses(), temp_slot_level, and temp_slots_at_level().
Referenced by combine_temp_slots().
bool use_register_for_decl | ( | ) |
Return true if we should assign DECL a pseudo register; false if it should live on the local stack.
Honor volatile.
Honor addressability.
Only register-like things go in registers.
If -ffloat-store specified, don't put explicit float variables into registers.
??? This should be checked after DECL_ARTIFICIAL, but tree-ssa propagates values across these stores, and it probably shouldn't.
If we're not interested in tracking debugging information for this decl, then we can certainly put it in a register.
When not optimizing, disregard register keyword for variables with types containing methods, otherwise the methods won't be callable from the debugger.
References build_decl, copy_node, DECL_ARG_TYPE, DECL_ARTIFICIAL, DECL_IGNORED_P, DECL_MODE, DECL_SIZE, DECL_SIZE_UNIT, EXPR_LOCATION, layout_decl(), NULL, NULL_TREE, targetm, TREE_ADDRESSABLE, TREE_CODE, and TREE_TYPE.
|
static |
References contains().
void used_types_insert | ( | ) |
Given a type, insert it into the used hash table in cfun.
So this might be a type referenced by a global variable. Record that type so that we can later decide to emit its debug information.
|
static |
Insert a TYPE into the used types hash table of CFUN.
|
static |
Referenced by emit_initial_value_sets().
struct function* cfun = 0 |
The currently compiled function.
|
static |
Initialized with NOGC, making this poisonous to the garbage collector.
|
static |
|
static |
Referenced by diddle_return_value().
|
static |
Assign unique numbers to labels generated for profiling, debugging, etc.
|
static |
|
static |
These routines are responsible for converting virtual register references to the actual hard register references once RTL generation is complete.
The following four variables are used for communication between the routines. They contain the offsets of the virtual registers from their respective hard registers.
|
static |
Keep track of whether we're in a dummy function context. If we are, we don't want to invoke the set_current_function hook, because we'll get into trouble if the hook calls target_reinit () recursively or when the initial initialization is not yet complete.
struct machine_function*(* init_machine_status)(void) |
These variables hold pointers to functions to create and destroy target specific, per-function data structures.
|
static |
|
static |
|
static |
|
static |
These hashes record the prologue and epilogue insns.
Referenced by diddle_return_value().
|
static |
A table of addresses that represent a stack slot. The table is a mapping from address RTXen to a temp slot.
Referenced by make_slot_available().
During parsing of a global variable, this vector contains the types referenced by the global variable.
htab_t types_used_by_vars_hash = NULL |
Hash table making the relationship between a global variable and the types it references in its initializer. The key of the entry is a referenced type, and the value is the DECL of the global variable. types_use_by_vars_do_hash and types_used_by_vars_eq below are the hash and equality functions to use for this hash table.
|
static |
int virtuals_instantiated |
Nonzero once virtual register instantiation has been done. assign_stack_local uses frame_pointer_rtx when this is nonzero. calls.c:emit_library_call_value_1 uses it to set up post-instantiation libcalls.
Referenced by emit_library_call_value_1(), and push_function_context().