GCC Middle and Back End API Reference
|
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 |
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 |
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 |
Return true if there are any active insns between HEAD and TAIL.
Referenced by thread_prologue_and_epilogue_insns().
|
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 get_stack_local_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 current_function_decl, emit_move_insn(), gen_reg_rtx(), mark_reg_pointer(), reg_mentioned_p(), set_decl_incoming_rtl(), set_dst_reg_note(), function::static_chain_decl, and targetm.
|
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 change_address(), convert_to_mode(), copy_to_reg(), emit_move_insn(), gen_rtx_REG(), 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, and set_mem_attributes().
|
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 current_function_decl, gen_reg_rtx(), mark_user_reg(), assign_parm_data_one::nominal_mode, assign_parm_data_one::nominal_type, and promote_function_mode().
|
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.
Only assign_parm_setup_block knows how to deal with register arguments that are padded at the least significant end.
|
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 get_last_insn(), prev_nonnote_insn(), regno_reg_rtx, set_dst_reg_note(), set_unique_reg_note(), and assign_parm_data_one::stack_parm.
|
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.
|
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(), build_call_expr(), build_pointer_type(), builtin_decl_explicit(), compare_tree_int(), create_tmp_reg(), create_tmp_var(), 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(), and targetm.
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 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 targetm.
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 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 temp_slot::base_offset, cut_slot_from_list(), temp_slot::full_size, temp_slot::next, temp_slot::size, and temp_slot::slot.
Referenced by convert_tree_comp_to_rtx(), 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 default_rtl_profile(), 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 init_tree_optimization_optabs(), targetm, this_fn_optabs, and this_target_optabs.
void clear_block_marks | ( | ) |
Helper function for reorder_blocks. Reset TREE_ASM_WRITTEN.
void clobber_return_register | ( | void | ) |
In case we do use pseudo to return value, clobber it too.
|
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().
Referenced by update_temp_slot_address().
|
static |
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.
|
static |
LAST_BB is a block that exits, and empty of active instructions. Examine its predecessors for jumps that can be converted to (conditional) returns.
If we have an unconditional jump, we can replace that with a simple return instruction.
The use of the return register might be present in the exit fallthru block. Either: - removing the use is safe, and we should remove the use in the exit fallthru block, or - removing the use is not safe, and we should add it here. For now, we conservatively choose the latter. Either of the 2 helps in crossjumping.
If we have a conditional jump branching to the last block, we can try to replace that with a conditional return instruction.
See comment in simplejump_p case above.
If this block has only one successor, it both jumps and falls through to the fallthru block, so we can't delete the edge.
Fix up the CFG for the successful change we just made.
References edge_def::dest, dump_file, basic_block_def::index, and edge_def::src.
Referenced by thread_prologue_and_epilogue_insns().
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, and prologue_insn_hash.
Referenced by init_dummy_function_start().
|
static |
Referenced by init_dummy_function_start().
|
static |
|
static |
|
static |
void do_warn_unused_parameter | ( | ) |
Possibly warn about unused parameters.
|
static |
Create a copy of BB instructions and insert at BEFORE. Redirect preds of BB to COPY_BB if they don't appear in NEED_PROLOGUE.
We know BB has a single successor, so there is no need to copy a simple jump at the end of BB.
Redirect all the paths that need no prologue into copy_bb.
References bitmap_bit_p(), bitmap_set_bit(), can_duplicate_block_p(), edge_def::flags, basic_block_def::index, basic_block_def::preds, single_succ_p(), and edge_def::src.
unsigned int emit_initial_value_sets | ( | void | ) |
Called from gimple_expand_cfg.
References cfa_offset.
|
static |
Emit a return insn for the exit fallthru block.
Referenced by thread_prologue_and_epilogue_insns().
|
static |
Insert an appropriate return pattern at the end of block BB. This also means updating block_for_insn appropriately. SIMPLE_P is the same as in gen_return_pattern and passed to it.
References bitmap_set_bit(), edge_def::dest, and basic_block_def::index.
Referenced by requires_stack_frame_p().
|
static |
Insert use of return register before the end of BB.
References targetm.
Referenced by requires_stack_frame_p().
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.
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 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.
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 initial_value_struct::entries, 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.
|
static |
Create a return pattern, either simple_return or return, depending on simple_p.
void generate_setjmp_warnings | ( | void | ) |
Generate warning messages for variables live across setjmp.
References 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 error_at().
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.
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 frame_phase.
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.
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 current_function_decl, diddle_return_value(), and do_clobber_return_reg().
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, 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 max_slot_level(), temp_slot::next, and temp_slots_at_level().
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(), first_field(), get_callee_fndecl(), and gdbhooks::IDENTIFIER_NODE.
|
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.
If we have found a stack parm before we reach the end of the area reserved for registers, skip that area.
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.
Pad_below needs the pre-rounded size to know how much to pad below so this must be done before rounding up.
References current_function_decl, 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 |
Try to move INSN from BB to a successor. Return true on success. USES and DEFS are the set of registers that are used and defined after INSN in BB.
Look for a simple register copy.
Make sure that the source register isn't defined later in BB.
Make sure that the destination register isn't referenced later in BB.
See whether there is a successor block to which we could move INSN.
At this point we are committed to moving INSN, but let's try to move it as far as we can.
Check whether BB uses DEST or clobbers DEST. We need to add INSN to BB if so. Either way, DEST is no longer live on entry, except for any part that overlaps SRC (next loop).
Check whether BB clobbers SRC. We need to add INSN to BB if so. Either way, SRC is now live on entry.
DF_LR_BB_INFO (bb)->def does not comprise the DF_REF_PARTIAL and DF_REF_CONDITIONAL defs. So if DF_LIVE doesn't exist, i.e. at -O1, just give up searching NEXT_BLOCK.
If we don't need to add the move to BB, look for a single successor block.
BB now defines DEST. It only uses the parts of DEST that overlap SRC (next loop).
BB now uses SRC.
References bitmap_default_obstack, function::decl, df_analyze(), emit_insn(), emit_note(), emit_use(), end_sequence(), gen_blockage(), get_insns(), HAVE_prologue, inserted, lookup_attribute(), prologue_location, record_insns(), rtl_profile_for_bb(), set_insn_locations(), single_succ_edge(), single_succ_p(), start_sequence(), targetm, and vNULL.
|
static |
Moves temporary slot TEMP to LEVEL.
|
static |
See whether BB has a single successor that uses [REGNO, END_REGNO), and if BB is its only predecessor. Return that block if so, otherwise return null.
We can sometimes encounter dead code. Don't try to move it into the exit block.
Reject targets of abnormal edges. This is needed for correctness on ports like Alpha and MIPS, whose pic_offset_table_rtx can die on exception edges even though it is generally treated as call-saved for the majority of the compilation. Moving across abnormal edges isn't going to be interesting for shrink-wrap usage anyway.
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 |
Round the size up to multiple of PARM_BOUNDARY bits.
Add it in.
|
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.
??? The SPARC port may claim a STACK_BOUNDARY higher than the real alignment of %sp. However, when it does this, the alignment of %sp+STACK_POINTER_OFFSET is STACK_BOUNDARY.
ARGS_SIZE_TREE includes constant term.
bool pass_by_reference | ( | CUMULATIVE_ARGS * | ca, |
enum machine_mode | mode, | ||
tree | type, | ||
bool | named_arg | ||
) |
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.
|
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.
|
static |
Look for register copies in the first block of the function, and move them down into successor blocks if the register is used only on one path. This exposes more opportunities for shrink-wrapping. These kinds of sets often occur when incoming argument registers are moved to call-saved registers because their values are live across one or more calls during the function.
Add all defined registers to DEFs.
Add all used registers to USESs.
References bitmap_default_obstack, edge_def::dest, dump_file, live_on_edge(), note_stores(), note_uses(), record_hard_reg_sets(), and record_hard_reg_uses().
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 | ( | ) |
References find_edge().
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 current_function_decl, 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'.
Referenced by move_insn_for_shrink_wrap().
|
static |
Add a list of INSNS to the hash HASHP, possibly allocating HASHP for the first time.
References active_insn_p(), count, dump_file, duplicate_insn_chain(), end_sequence(), get_insns(), basic_block_def::index, 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.
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 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.
References current_function_decl.
void reposition_prologue_and_epilogue_notes | ( | void | ) |
Reposition the prologue-end and epilogue-begin notes after instruction scheduling.
Since the hash table is created on demand, the fact that it is non-null is a signal that it is non-empty.
Scan from the beginning until we reach the last prologue insn.
??? While we do have the CFG intact, there are two problems: (1) The prologue can contain loops (typically probing the stack), which means that the end of the prologue isn't in the first bb. (2) Sometimes the PROLOGUE_END note gets pushed into the next bb.
Scan forward looking for the PROLOGUE_END note. It should be right at the beginning of the block, possibly with other insn notes that got moved there.
Avoid placing note between CODE_LABEL and BASIC_BLOCK note.
Scan from the beginning until we reach the first epilogue insn.
If the function has a single basic block, and no real epilogue insns (e.g. sibcall with no cleanup), the epilogue note can get scheduled before the prologue note. If we have frame related prologue insns, having them scanned during the epilogue will result in a crash. In this case re-order the epilogue note to just before the last insn in the block.
bool requires_stack_frame_p | ( | rtx | insn, |
HARD_REG_SET | prologue_used, | ||
HARD_REG_SET | set_up_by_prologue | ||
) |
Return true if INSN requires the stack frame to be set up. PROLOGUE_USED contains the hard registers used in the function prologue. SET_UP_BY_PROLOGUE is the set of registers we expect the prologue to set up for the function.
We need a frame to get the unique CFA expected by the unwinder.
References delete_insn(), emit_return_into_block(), and emit_use_return_register_into_block().
|
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 recog_data_d::operand, and recog_data.
void set_cfun | ( | ) |
cfun should never be set directly; use this function.
References assemble_static_space(), int_size_in_bytes(), and function::returns_pcc_struct.
Referenced by push_function_context().
|
static |
Referenced by move_insn_for_shrink_wrap().
|
static |
Set the location of the insn chain starting at INSN to LOC.
References active_insn_p().
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.
|
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, 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.
Insert an explicit USE for the frame pointer if the profiling is on and the frame pointer is required.
Retain a map of the prologue insns.
Ensure that instructions are not moved into the prologue when profiling is on. The call to the profiling routine can be emitted within the live range of a call-clobbered register.
Try to perform a kind of shrink-wrapping, making sure the prologue/epilogue is emitted only around those parts of the function that require it.
Compute the registers set and used in the prologue.
Find the set of basic blocks that require a stack frame, and blocks that are too big to be duplicated.
We don't use a different max size depending on optimize_bb_for_speed_p because increasing shrink-wrapping opportunities by duplicating tail blocks can actually result in an overall decrease in code size.
Blocks that really need a prologue, or are too big for tails.
For every basic block that needs a prologue, mark all blocks reachable from it, so as to ensure they are also seen as requiring a prologue.
Find the set of basic blocks that need no prologue, have a single successor, can be duplicated, meet a max size requirement, and go to the exit via like blocks.
If there is predecessor of e->src which doesn't need prologue and the edge is complex, we might not be able to redirect the branch to a copy of e->src.
Now walk backwards from every block that is marked as needing a prologue to compute the bb_antic_flags bitmap. Exclude tail blocks; They can be duplicated to be used on paths not needing a prologue.
Find exactly one edge that leads to a block in ANTIC from a block that isn't.
Test whether the prologue is known to clobber any register (other than FP or SP) which are live on the edge.
Find tail blocks reachable from both blocks needing a prologue and blocks not needing a prologue.
Find the head of each tail.
Now duplicate the tails.
Create a copy of BB, instructions and all, for use on paths that don't need a prologue. Ideal placement of the copy is on a fall-thru edge or after a block that would jump to the copy.
Make sure we insert after any barriers.
Otherwise put the copy at the end of the function.
Quiet verify_flow_info by (ab)using EDGE_FAKE. We have yet to add a simple_return to the tails, as we'd like to first convert_jumps_to_returns in case the block is no longer used after that.
verify_flow_info doesn't like a note after a sibling call.
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.
convert_jumps_to_returns may add to EXIT_BLOCK_PTR->preds (but won't remove). Stop at end of current preds.
Emitting the return may add a basic block. Fix bb_flags for the added block.
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.
Find non-fallthru edges that end with EH_RETURN instructions. On some targets, these get split to a special version of the epilogue code. In order to be able to properly annotate these with unwind info, try to split them now. If we get a valid split, drop an EPILOGUE_BEG note and mark the insns as epilogue insns.
If nothing falls through into the exit block, we don't need an epilogue.
Retain a map of the epilogue insns.
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.
If there were branches to an empty LAST_BB which we tried to convert to conditional simple_returns, but couldn't for some reason, create a block to hold a simple_return insn and redirect those remaining edges.
See if we can reuse the last insn that was emitted for the epilogue.
Also check returns we might need to add to tail blocks.
Save a pointer to the exit's predecessor BB for use in inserting new BBs at the end of the function. Do this after the call to split_block above which may split the original exit pred.
Emit sibling epilogues before any sibling call sites.
Retain a map of the epilogue insns. Used in life analysis to avoid getting rid of sibcall epilogue insns. Do this before we actually emit the sequence.
Similarly, move any line notes that appear after the epilogue. There is no need, however, to be quite so anal about the existence of such a note. Also possibly move NOTE_INSN_FUNCTION_BEG notes, as those can be relevant for debug info generation.
Threading the prologue and epilogue changes the artificial refs in the entry and exit blocks.
References active_insn_between(), bitmap_bit_p(), convert_jumps_to_returns(), emit_return_for_exit(), basic_block_def::index, last, last_bb, 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(), 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 copy_node(), layout_decl(), and targetm.
|
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.
Referenced by add_partitioned_vars_to_ptset(), add_stmt_to_eh_lp(), add_ttypes_entry(), adjust_return_value(), ao_ref_from_mem(), calculate_bb_reg_pressure(), cgraph_release_function_body(), choose_inner_scope(), chrec_contains_undetermined(), cleanup_empty_eh_unsplit(), compute_hash_table(), compute_uninit_opnds_pos(), copy_decl_maybe_to_var(), copy_decl_no_change(), copy_ssa_name(), create_function_info_for(), debug_solution_for_var(), default_ctor_section_asm_out_constructor(), delete_prior_computation(), discard_pending_stack_adjust(), dump_live_info(), duplicate_computed_gotos(), dwarf2out_frame_debug_cfa_window_save(), ehspec_hasher::equal(), execute_function_todo(), execute_init_datastructures(), expand_omp_atomic_load(), expand_omp_sections(), finalize_ssa_defs(), finalize_ssa_uses(), find_case_label_for_value(), find_pbb_via_hash(), find_rtx_in_ldst(), find_switch_asserts(), find_uses_to_rename(), fixup_noreturn_call(), fold_gimple_cond(), get_eh_region_from_lp_number_fn(), get_fi_for_callee(), get_frame_arg(), gimple_call_arg_flags(), gimple_purge_dead_eh_edges(), gimple_redirect_edge_and_branch(), gimplify_omp_workshare(), gsi_split_seq_before(), init_ssa_operands(), initialize_parameter_reductions(), insert_phi_nodes(), instrument_memory_accesses(), is_too_expensive(), load_assign_lhs_subreplacements(), loop_canon_p(), lower_send_clauses(), lto_read_tree(), make_goto_expr_edges(), make_pass_tree_loop_init(), make_pass_vectorize(), make_ssa_name(), mark_ref_stored(), move_allocno_live_ranges(), move_stmt_r(), optimize_bb_for_speed_p(), optimize_function_for_speed_p(), output_eh_regions(), prepare_block_for_update(), print_graphite_statistics(), process_bb_node_lives(), profile_function(), record_stmt_eh_region(), release_defs(), release_ssa_name(), remove_eh_handler_splicer(), remove_unnecessary_allocnos(), remove_unreachable_eh_regions(), renumber_gimple_stmt_uids(), renumber_gimple_stmt_uids_in_blocks(), replace_ssa_name(), sanitize_hot_paths(), special_builtin_state(), split_live_ranges_for_shrink_wrap(), standard_iv_increment_position(), stmt_overflow_infinity(), store_killed_before(), stringop_block_profile(), suitable_for_tail_opt_p(), tree_could_trap_p(), tree_loop_vectorize(), update_alias_info_with_stack_vars(), update_complex_components_on_edge(), vectorize_loops(), verify_curr_properties(), and visit_hist().
|
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().