gccint: Stack Arguments
1
1 18.9.6 Passing Function Arguments on the Stack
1 ----------------------------------------------
1
1 The macros in this section control how arguments are passed on the
1 stack. See the following section for other macros that control passing
1 certain arguments in registers.
1
1 -- Target Hook: bool TARGET_PROMOTE_PROTOTYPES (const_tree FNTYPE)
1 This target hook returns 'true' if an argument declared in a
1 prototype as an integral type smaller than 'int' should actually be
1 passed as an 'int'. In addition to avoiding errors in certain
1 cases of mismatch, it also makes for better code on certain
1 machines. The default is to not promote prototypes.
1
1 -- Macro: PUSH_ARGS
1 A C expression. If nonzero, push insns will be used to pass
1 outgoing arguments. If the target machine does not have a push
1 instruction, set it to zero. That directs GCC to use an alternate
1 strategy: to allocate the entire argument block and then store the
1 arguments into it. When 'PUSH_ARGS' is nonzero, 'PUSH_ROUNDING'
1 must be defined too.
1
1 -- Macro: PUSH_ARGS_REVERSED
1 A C expression. If nonzero, function arguments will be evaluated
1 from last to first, rather than from first to last. If this macro
1 is not defined, it defaults to 'PUSH_ARGS' on targets where the
1 stack and args grow in opposite directions, and 0 otherwise.
1
1 -- Macro: PUSH_ROUNDING (NPUSHED)
1 A C expression that is the number of bytes actually pushed onto the
1 stack when an instruction attempts to push NPUSHED bytes.
1
1 On some machines, the definition
1
1 #define PUSH_ROUNDING(BYTES) (BYTES)
1
1 will suffice. But on other machines, instructions that appear to
1 push one byte actually push two bytes in an attempt to maintain
1 alignment. Then the definition should be
1
1 #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
1
1 If the value of this macro has a type, it should be an unsigned
1 type.
1
1 -- Macro: ACCUMULATE_OUTGOING_ARGS
1 A C expression. If nonzero, the maximum amount of space required
1 for outgoing arguments will be computed and placed into
1 'crtl->outgoing_args_size'. No space will be pushed onto the stack
1 for each call; instead, the function prologue should increase the
1 stack frame size by this amount.
1
1 Setting both 'PUSH_ARGS' and 'ACCUMULATE_OUTGOING_ARGS' is not
1 proper.
1
1 -- Macro: REG_PARM_STACK_SPACE (FNDECL)
1 Define this macro if functions should assume that stack space has
1 been allocated for arguments even when their values are passed in
1 registers.
1
1 The value of this macro is the size, in bytes, of the area reserved
1 for arguments passed in registers for the function represented by
1 FNDECL, which can be zero if GCC is calling a library function.
1 The argument FNDECL can be the FUNCTION_DECL, or the type itself of
1 the function.
1
1 This space can be allocated by the caller, or be a part of the
1 machine-dependent stack frame: 'OUTGOING_REG_PARM_STACK_SPACE' says
1 which.
1
1 -- Macro: INCOMING_REG_PARM_STACK_SPACE (FNDECL)
1 Like 'REG_PARM_STACK_SPACE', but for incoming register arguments.
1 Define this macro if space guaranteed when compiling a function
1 body is different to space required when making a call, a situation
1 that can arise with K&R style function definitions.
1
1 -- Macro: OUTGOING_REG_PARM_STACK_SPACE (FNTYPE)
1 Define this to a nonzero value if it is the responsibility of the
1 caller to allocate the area reserved for arguments passed in
1 registers when calling a function of FNTYPE. FNTYPE may be NULL if
1 the function called is a library function.
1
1 If 'ACCUMULATE_OUTGOING_ARGS' is defined, this macro controls
1 whether the space for these arguments counts in the value of
1 'crtl->outgoing_args_size'.
1
1 -- Macro: STACK_PARMS_IN_REG_PARM_AREA
1 Define this macro if 'REG_PARM_STACK_SPACE' is defined, but the
1 stack parameters don't skip the area specified by it.
1
1 Normally, when a parameter is not passed in registers, it is placed
1 on the stack beyond the 'REG_PARM_STACK_SPACE' area. Defining this
1 macro suppresses this behavior and causes the parameter to be
1 passed on the stack in its natural location.
1
1 -- Target Hook: poly_int64 TARGET_RETURN_POPS_ARGS (tree FUNDECL, tree
1 FUNTYPE, poly_int64 SIZE)
1 This target hook returns the number of bytes of its own arguments
1 that a function pops on returning, or 0 if the function pops no
1 arguments and the caller must therefore pop them all after the
1 function returns.
1
1 FUNDECL is a C variable whose value is a tree node that describes
1 the function in question. Normally it is a node of type
1 'FUNCTION_DECL' that describes the declaration of the function.
1 From this you can obtain the 'DECL_ATTRIBUTES' of the function.
1
1 FUNTYPE is a C variable whose value is a tree node that describes
1 the function in question. Normally it is a node of type
1 'FUNCTION_TYPE' that describes the data type of the function. From
1 this it is possible to obtain the data types of the value and
1 arguments (if known).
1
1 When a call to a library function is being considered, FUNDECL will
1 contain an identifier node for the library function. Thus, if you
1 need to distinguish among various library functions, you can do so
1 by their names. Note that "library function" in this context means
1 a function used to perform arithmetic, whose name is known
1 specially in the compiler and was not mentioned in the C code being
1 compiled.
1
1 SIZE is the number of bytes of arguments passed on the stack. If a
1 variable number of bytes is passed, it is zero, and argument
1 popping will always be the responsibility of the calling function.
1
1 On the VAX, all functions always pop their arguments, so the
1 definition of this macro is SIZE. On the 68000, using the standard
1 calling convention, no functions pop their arguments, so the value
1 of the macro is always 0 in this case. But an alternative calling
1 convention is available in which functions that take a fixed number
1 of arguments pop them but other functions (such as 'printf') pop
1 nothing (the caller pops all). When this convention is in use,
1 FUNTYPE is examined to determine whether a function takes a fixed
1 number of arguments.
1
1 -- Macro: CALL_POPS_ARGS (CUM)
1 A C expression that should indicate the number of bytes a call
1 sequence pops off the stack. It is added to the value of
1 'RETURN_POPS_ARGS' when compiling a function call.
1
1 CUM is the variable in which all arguments to the called function
1 have been accumulated.
1
1 On certain architectures, such as the SH5, a call trampoline is
1 used that pops certain registers off the stack, depending on the
1 arguments that have been passed to the function. Since this is a
1 property of the call site, not of the called function,
1 'RETURN_POPS_ARGS' is not appropriate.
1