Here is the basic stack layout.
STACK_GROWS_DOWNWARD
When we say, "define this macro if ...," it means that the
compiler checks this macro only with #ifdef
so the precise
definition used does not matter.
STACK_PUSH_CODE
(set (mem (STACK_PUSH_CODE (reg sp))) ...)
The choices are PRE_DEC
, POST_DEC
, PRE_INC
,
and POST_INC
. Which of these is correct depends on
the stack direction and on whether the stack pointer points
to the last item on the stack or whether it points to the
space for the next item on the stack.
The default is PRE_DEC
when STACK_GROWS_DOWNWARD
is
defined, which is almost always right, and PRE_INC
otherwise,
which is often wrong.
FRAME_GROWS_DOWNWARD
ARGS_GROW_DOWNWARD
STARTING_FRAME_OFFSET
If FRAME_GROWS_DOWNWARD
, find the next slot's offset by
subtracting the first slot's length from STARTING_FRAME_OFFSET
.
Otherwise, it is found by adding the length of the first slot to the
value STARTING_FRAME_OFFSET
.
STACK_POINTER_OFFSET
If ARGS_GROW_DOWNWARD
, this is the offset to the location above
the first location at which outgoing arguments are placed.
FIRST_PARM_OFFSET (
fundecl)
If ARGS_GROW_DOWNWARD
, this is the offset to the location above
the first argument's address.
STACK_DYNAMIC_OFFSET (
fundecl)
alloca
.
The default value for this macro is STACK_POINTER_OFFSET
plus the
length of the outgoing arguments. The default is correct for most
machines. See function.c
for details.
DYNAMIC_CHAIN_ADDRESS (
frameaddr)
If you don't define this macro, the default is to return the value
of frameaddr--that is, the stack frame address is also the
address of the stack word that points to the previous frame.
SETUP_FRAME_ADDRESSES
BUILTIN_SETJMP_FRAME_VALUE
setjmp
buffer.
The default value, virtual_stack_vars_rtx
, is correct for most
machines. One reason you may need to define this macro is if
hard_frame_pointer_rtx
is the appropriate value on your machine.
RETURN_ADDR_RTX (
count,
frameaddr)
RETURN_ADDR_IN_PREVIOUS_FRAME
is defined.
The value of the expression must always be the correct address when
count is zero, but may be NULL_RTX
if there is not way to
determine the return address of other frames.
RETURN_ADDR_IN_PREVIOUS_FRAME
INCOMING_RETURN_ADDR_RTX
REG
, indicating that the return
value is saved in REG
, or a MEM
representing a location in
the stack.
You only need to define this macro if you want to support call frame debugging information like that provided by DWARF 2.
If this RTL is a REG
, you should also define
DWARF_FRAME_RETURN_COLUMN
to DWARF_FRAME_REGNUM (REGNO)
.
INCOMING_FRAME_SP_OFFSET
You only need to define this macro if you want to support call frame
debugging information like that provided by DWARF 2.
ARG_POINTER_CFA_OFFSET (
fundecl)
INCOMING_FRAME_SP_OFFSET
. Which is unfortunately not usable
during virtual register instantiation.
The default value for this macro is FIRST_PARM_OFFSET (fundecl)
,
which is correct for most machines; in general, the arguments are found
immediately before the stack frame. Note that this is not the case on
some targets that save registers into the caller's frame, such as SPARC
and rs6000, and so such targets need to define this macro.
You only need to define this macro if the default is incorrect, and you
want to support call frame debugging information like that provided by
DWARF 2.
SMALL_STACK
alloca
, though
__builtin_alloca
is not affected.