This section describes the macros that output function entry (prologue) and exit (epilogue) code.
void TARGET_ASM_FUNCTION_PROLOGUE (FILE *file, HOST_WIDE_INT size) | Target Hook |
If defined, a function that outputs the assembler code for entry to a
function. The prologue is responsible for setting up the stack frame,
initializing the frame pointer register, saving registers that must be
saved, and allocating size additional bytes of storage for the
local variables. size is an integer. file is a stdio
stream to which the assembler code should be output.
The label for the beginning of the function need not be output by this macro. That has already been done when the macro is run. To determine which registers to save, the macro can refer to the array
On machines that have "register windows", the function entry code does not save on the stack the registers that are in the windows, even if they are supposed to be preserved by function calls; instead it takes appropriate steps to "push" the register stack, if any non-call-used registers are used in the function. On machines where functions may or may not have frame-pointers, the
function entry code must vary accordingly; it must set up the frame
pointer if one is wanted, and not otherwise. To determine whether a
frame pointer is in wanted, the macro can refer to the variable
The function entry code is responsible for allocating any stack space
required for the function. This stack space consists of the regions
listed below. In most cases, these regions are allocated in the
order listed, with the last listed region closest to the top of the
stack (the lowest address if |
void TARGET_ASM_FUNCTION_END_PROLOGUE (FILE *file) | Target Hook |
If defined, a function that outputs assembler code at the end of a prologue. This should be used when the function prologue is being emitted as RTL, and you have some extra assembler that needs to be emitted. See prologue instruction pattern. |
void TARGET_ASM_FUNCTION_BEGIN_EPILOGUE (FILE *file) | Target Hook |
If defined, a function that outputs assembler code at the start of an epilogue. This should be used when the function epilogue is being emitted as RTL, and you have some extra assembler that needs to be emitted. See epilogue instruction pattern. |
void TARGET_ASM_FUNCTION_EPILOGUE (FILE *file, HOST_WIDE_INT size) | Target Hook |
If defined, a function that outputs the assembler code for exit from a
function. The epilogue is responsible for restoring the saved
registers and stack pointer to their values when the function was
called, and returning control to the caller. This macro takes the
same arguments as the macro TARGET_ASM_FUNCTION_PROLOGUE , and the
registers to restore are determined from regs_ever_live and
CALL_USED_REGISTERS in the same way.
On some machines, there is a single instruction that does all the work
of returning from the function. On these machines, give that
instruction the name Do not define a pattern named On machines where functions may or may not have frame-pointers, the
function exit code must vary accordingly. Sometimes the code for these
two cases is completely different. To determine whether a frame pointer
is wanted, the macro can refer to the variable
Normally, On some machines, some functions pop their arguments on exit while
others leave that for the caller to do. For example, the 68020 when
given Your definition of the macro |
current_function_pretend_args_size
bytes of
uninitialized space just underneath the first argument arriving on the
stack. (This may not be at the very start of the allocated stack region
if the calling sequence has pushed anything else since pushing the stack
arguments. But usually, on such machines, nothing else has been pushed
yet, because the function prologue itself does all the pushing.) This
region is used on machines where an argument may be passed partly in
registers and partly in memory, and, in some cases to support the
features in <varargs.h>
and <stdarg.h>
.
ACCUMULATE_OUTGOING_ARGS
is defined, a region of
current_function_outgoing_args_size
bytes to be used for outgoing
argument lists of the function. See Stack Arguments.
Normally, it is necessary for the macros
TARGET_ASM_FUNCTION_PROLOGUE
and
TARGET_ASM_FUNCTION_EPILOGUE
to treat leaf functions specially.
The C variable current_function_is_leaf
is nonzero for such a
function.
EXIT_IGNORE_STACK
Note that this macro's value is relevant only for functions for which
frame pointers are maintained. It is never safe to delete a final
stack adjustment in a function that has no frame pointer, and the
compiler knows this regardless of EXIT_IGNORE_STACK
.
EPILOGUE_USES (
regno)
return
pattern. The stack and frame
pointer registers are already be assumed to be used as needed.
EH_USES (
regno)
DELAY_SLOTS_FOR_EPILOGUE
ELIGIBLE_FOR_EPILOGUE_DELAY (
insn,
n)
The argument n is an integer which identifies the delay slot now
being considered (since different slots may have different rules of
eligibility). It is never negative and is always less than the number
of epilogue delay slots (what DELAY_SLOTS_FOR_EPILOGUE
returns).
If you reject a particular insn for a given delay slot, in principle, it
may be reconsidered for a subsequent delay slot. Also, other insns may
(at least in principle) be considered for the so far unfilled delay
slot.
The insns accepted to fill the epilogue delay slots are put in an RTL
list made with insn_list
objects, stored in the variable
current_function_epilogue_delay_list
. The insn for the first
delay slot comes first in the list. Your definition of the macro
TARGET_ASM_FUNCTION_EPILOGUE
should fill the delay slots by
outputting the insns in this list, usually by calling
final_scan_insn
.
You need not define this macro if you did not define
DELAY_SLOTS_FOR_EPILOGUE
.
ASM_OUTPUT_MI_THUNK (
file,
thunk_fndecl,
delta,
function)
First, emit code to add the integer delta to the location that
contains the incoming first argument. Assume that this argument
contains a pointer, and is the one used to pass the this
pointer
in C++. This is the incoming argument before the function prologue,
e.g. %o0
on a sparc. The addition must preserve the values of
all other incoming arguments.
After the addition, emit code to jump to function, which is a
FUNCTION_DECL
. This is a direct pure jump, not a call, and does
not touch the return address. Hence returning from FUNCTION will
return to whoever called the current thunk
.
The effect must be as if function had been called directly with
the adjusted first argument. This macro is responsible for emitting all
of the code for a thunk function; TARGET_ASM_FUNCTION_PROLOGUE
and TARGET_ASM_FUNCTION_EPILOGUE
are not invoked.
The thunk_fndecl is redundant. (delta and function have already been extracted from it.) It might possibly be useful on some targets, but probably not.
If you do not define this macro, the target-independent code in the C++ front end will generate a less efficient heavyweight thunk that calls function instead of jumping to it. The generic approach does not support varargs.