Next: Stack Arguments, Previous: Frame Registers, Up: Stack and Calling
这些是关于消除帧指针和参数指针的。
This target hook should return
true
if a function must have and use a frame pointer. This target hook is called in the reload pass. If its return value istrue
the function will have a frame pointer.This target hook can in principle examine the current function and decide according to the facts, but on most machines the constant
false
or the constanttrue
suffices. Usefalse
when the machine allows code to be generated with no frame pointer, and doing so saves some time or space. Usetrue
when there is no possible advantage to avoiding a frame pointer.In certain cases, the compiler does not know how to produce valid code without a frame pointer. The compiler recognizes those cases and automatically gives the function a frame pointer regardless of what
TARGET_FRAME_POINTER_REQUIRED
returns. You don't need to worry about them.In a function that does not require a frame pointer, the frame pointer register can be allocated for ordinary usage, unless you mark it as a fixed register. See
FIXED_REGISTERS
for more information.Default return value is
false
.
一条C语句,用来紧接着函数序言之后, 将帧指针和栈指针值的差存储在depth-var中。 该值应该通过像
get_frame_size ()
这样的结果信息以及寄存器表regs_ever_live
和call_used_regs
中被计算。如果
ELIMINABLE_REGS
被定义,则该宏将不被使用并不需要被定义。 否则,其必须被定义,即使FRAME_POINTER_REQUIRED
被定义为总是为真; 这这种情况下,你可以设置depth-var为任何值。
如果被定义,则该宏指定了一个寄存器双对的表,用于消除不需要的指向栈帧的寄存器。 如果没有被定义,则编译器唯一尝试去做的消除是将对帧指针的引用替换为对栈指针的引用。
该宏的定义为一个结构体初始化列表,每个指定了最初的和替换后的寄存器。
在一些机器上,参数指针的位置直到编译结束时才知道。这种情况下, 一个单独的硬件寄存器必须用于参数指针。 该寄存器可以通过替换为帧指针或者参数指针来消除,这取决于帧指针是否已经被消除。
这种情况下,你可能会指定:
#define ELIMINABLE_REGS \ {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \ {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}注意首先指定的是使用栈指针来消除参数指针,因为这是首选的消除方式。
This target hook should returns
true
if the compiler is allowed to try to replace register number from_reg with register number to_reg. This target hook need only be defined ifELIMINABLE_REGS
is defined, and will usually betrue
, since most of the cases preventing register elimination are things that the compiler already knows about.Default return value is
true
.