Next: Register Arguments, Previous: Elimination, Up: Stack and Calling
该节的宏控制如何在栈上传递参数。关于控制在寄存器中传递特定参数的其它宏, 参见后续的章节。
该target钩子返回
true
,如果在函数原型中声明的一个参数, 为整型的并且比int
小,应该作为int
来传递。 除了能够避免一些不匹配的错误以外,其还能在特定机器上生成更好的代码。 缺省为不提升原型。
一个C表达式。如果非0,则将使用push insn来传递输出参数。 如果target机器不具有push指令,则设置其为0。这将指示GCC使用替代的策略: 分配整个参数块然后将参数存进去。当
PUSH_ARGS
为非0时,PUSH_ROUNDING
也必须被定义。
一个C表达式。如果非0,则函数参数将按照从最后一个到第一个的顺序来求值, 而不是从第一个到最后一个。如果该宏没被定义,其缺省为
PUSH_ARGS
, 在栈和args按照相反的顺序进行增长的target上,否则为0。
一个C表达式,其为当一个指令试图压入npushed个字节时,实际压入栈中的字节数。
在一些机器上,定义
#define PUSH_ROUNDING(BYTES) (BYTES)便可以满足。但是在其它机器上,指令压入一个字节时, 而为了保持对齐实际压入了两个字节。则定义应该为
#define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
一个C表达式。如果非0,则为输出参数中将被计算并放进变量
current_function_outgoing_args_size
所需要的空间最大数目。 对于每个调用,将不会有空间被压入栈中;替代的,函数序言应该增加栈帧的大小。同时设置
PUSH_ARGS
和ACCUMULATE_OUTGOING_ARGS
是不合适的。
定义该宏,如果函数应该假设参数的栈空间已经被分配, 即使它们的值是在寄存器中被传递的。
该宏的值是一个fndecl表示的函数在寄存器中传递的参数的保留空间的大小, 字节为单位,其可以为0如果GCC在调用一个库函数。
该空间可以被调用者分配,或者为机器相关的栈帧的一部分: 这由
OUTGOING_REG_PARM_STACK_SPACE
决定。
定义该宏为一个非0值,如果分配在寄存器中传递的参数的保留空间,是由调用者负责。
如果
ACCUMULATE_OUTGOING_ARGS
被定义, 则该宏控制这些参数的空间是否算在current_function_outgoing_args_size
中。
定义该宏,如果
REG_PARM_STACK_SPACE
被定义, 但是栈参数不跳过其所指定的区域。通常,当一个参数没有在寄存器中传递时, 其被放在
REG_PARM_STACK_SPACE
区域之外的栈上。 定义该宏来抑制这种行为并使得在栈上传递的参数按照它的自然位置。
This target hook returns the number of bytes of its own arguments that a function pops on returning, or 0 if the function pops no arguments and the caller must therefore pop them all after the function returns.
fundecl is a C variable whose value is a tree node that describes the function in question. Normally it is a node of type
FUNCTION_DECL
that describes the declaration of the function. From this you can obtain theDECL_ATTRIBUTES
of the function.funtype is a C variable whose value is a tree node that describes the function in question. Normally it is a node of type
FUNCTION_TYPE
that describes the data type of the function. From this it is possible to obtain the data types of the value and arguments (if known).When a call to a library function is being considered, fundecl will contain an identifier node for the library function. Thus, if you need to distinguish among various library functions, you can do so by their names. Note that “library function” in this context means a function used to perform arithmetic, whose name is known specially in the compiler and was not mentioned in the C code being compiled.
size is the number of bytes of arguments passed on the stack. If a variable number of bytes is passed, it is zero, and argument popping will always be the responsibility of the calling function.
On the VAX, all functions always pop their arguments, so the definition of this macro is size. On the 68000, using the standard calling convention, no functions pop their arguments, so the value of the macro is always 0 in this case. But an alternative calling convention is available in which functions that take a fixed number of arguments pop them but other functions (such as
printf
) pop nothing (the caller pops all). When this convention is in use, funtype is examined to determine whether a function takes a fixed number of arguments.