2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
6 .. index:: arguments on stack, stack arguments
10 Passing Function Arguments on the Stack
11 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13 The macros in this section control how arguments are passed
14 on the stack. See the following section for other macros that
15 control passing certain arguments in registers.
17 .. include:: ../tm.rst.in
18 :start-after: [TARGET_PROMOTE_PROTOTYPES]
19 :end-before: [TARGET_PROMOTE_PROTOTYPES]
22 .. include:: ../tm.rst.in
23 :start-after: [TARGET_PUSH_ARGUMENT]
24 :end-before: [TARGET_PUSH_ARGUMENT]
27 .. c:macro:: PUSH_ARGS_REVERSED
29 A C expression. If nonzero, function arguments will be evaluated from
30 last to first, rather than from first to last. If this macro is not
31 defined, it defaults to ``PUSH_ARGS`` on targets where the stack
32 and args grow in opposite directions, and 0 otherwise.
34 .. c:macro:: PUSH_ROUNDING (npushed)
36 A C expression that is the number of bytes actually pushed onto the
37 stack when an instruction attempts to push :samp:`{npushed}` bytes.
39 On some machines, the definition
43 #define PUSH_ROUNDING(BYTES) (BYTES)
45 will suffice. But on other machines, instructions that appear
46 to push one byte actually push two bytes in an attempt to maintain
47 alignment. Then the definition should be
51 #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
53 If the value of this macro has a type, it should be an unsigned type.
55 .. index:: outgoing_args_size, crtl->outgoing_args_size
57 .. c:macro:: ACCUMULATE_OUTGOING_ARGS
59 A C expression. If nonzero, the maximum amount of space required for outgoing arguments
60 will be computed and placed into
61 ``crtl->outgoing_args_size``. No space will be pushed
62 onto the stack for each call; instead, the function prologue should
63 increase the stack frame size by this amount.
65 Setting both ``PUSH_ARGS`` and ``ACCUMULATE_OUTGOING_ARGS``
68 .. c:macro:: REG_PARM_STACK_SPACE (fndecl)
70 Define this macro if functions should assume that stack space has been
71 allocated for arguments even when their values are passed in
74 The value of this macro is the size, in bytes, of the area reserved for
75 arguments passed in registers for the function represented by :samp:`{fndecl}`,
76 which can be zero if GCC is calling a library function.
77 The argument :samp:`{fndecl}` can be the FUNCTION_DECL, or the type itself
80 This space can be allocated by the caller, or be a part of the
81 machine-dependent stack frame: ``OUTGOING_REG_PARM_STACK_SPACE`` says
84 .. above is overfull. not sure what to do. -mew 5feb93 did
86 .. something, not sure if it looks good. -mew 10feb93
88 .. c:macro:: INCOMING_REG_PARM_STACK_SPACE (fndecl)
90 Like ``REG_PARM_STACK_SPACE``, but for incoming register arguments.
91 Define this macro if space guaranteed when compiling a function body
92 is different to space required when making a call, a situation that
93 can arise with K&R style function definitions.
95 .. c:macro:: OUTGOING_REG_PARM_STACK_SPACE (fntype)
97 Define this to a nonzero value if it is the responsibility of the
98 caller to allocate the area reserved for arguments passed in registers
99 when calling a function of :samp:`{fntype}`. :samp:`{fntype}` may be NULL
100 if the function called is a library function.
102 If ``ACCUMULATE_OUTGOING_ARGS`` is defined, this macro controls
103 whether the space for these arguments counts in the value of
104 ``crtl->outgoing_args_size``.
106 .. c:macro:: STACK_PARMS_IN_REG_PARM_AREA
108 Define this macro if ``REG_PARM_STACK_SPACE`` is defined, but the
109 stack parameters don't skip the area specified by it.
111 .. i changed this, makes more sens and it should have taken care of the
113 .. overfull.. not as specific, tho. -mew 5feb93
115 Normally, when a parameter is not passed in registers, it is placed on the
116 stack beyond the ``REG_PARM_STACK_SPACE`` area. Defining this macro
117 suppresses this behavior and causes the parameter to be passed on the
118 stack in its natural location.
120 .. include:: ../tm.rst.in
121 :start-after: [TARGET_RETURN_POPS_ARGS]
122 :end-before: [TARGET_RETURN_POPS_ARGS]
125 .. c:macro:: CALL_POPS_ARGS (cum)
127 A C expression that should indicate the number of bytes a call sequence
128 pops off the stack. It is added to the value of ``RETURN_POPS_ARGS``
129 when compiling a function call.
131 :samp:`{cum}` is the variable in which all arguments to the called function
132 have been accumulated.
134 On certain architectures, such as the SH5, a call trampoline is used
135 that pops certain registers off the stack, depending on the arguments
136 that have been passed to the function. Since this is a property of the
137 call site, not of the called function, ``RETURN_POPS_ARGS`` is not