Movatterモバイル変換


[0]ホーム

URL:


Next:, Previous:, Up:Stack Layout and Calling Conventions   [Contents][Index]


17.9.5 Eliminating Frame Pointer and Arg Pointer

This is about eliminating the frame pointer and arg pointer.

Target Hook:boolTARGET_FRAME_POINTER_REQUIRED(void)

This target hook should returntrue if a function must have and usea frame pointer. This target hook is called in the reload pass. If its returnvalue istrue the function will have a frame pointer.

This target hook can in principle examine the current function and decideaccording to the facts, but on most machines the constantfalse or theconstanttrue suffices. Usefalse when the machine allows codeto be generated with no frame pointer, and doing so saves some time or space.Usetrue when there is no possible advantage to avoiding a framepointer.

In certain cases, the compiler does not know how to produce valid codewithout a frame pointer. The compiler recognizes those cases andautomatically gives the function a frame pointer regardless of whattargetm.frame_pointer_required returns. You don’t need to worry aboutthem.

In a function that does not require a frame pointer, the frame pointerregister can be allocated for ordinary usage, unless you mark it as afixed register. SeeFIXED_REGISTERS for more information.

Default return value isfalse.

Macro:ELIMINABLE_REGS

This macro specifies a table of register pairs used to eliminateunneeded registers that point into the stack frame.

The definition of this macro is a list of structure initializations, eachof which specifies an original and replacement register.

On some machines, the position of the argument pointer is not known untilthe compilation is completed. In such a case, a separate hard registermust be used for the argument pointer. This register can be eliminated byreplacing it with either the frame pointer or the argument pointer,depending on whether or not the frame pointer has been eliminated.

In this case, you might specify:

#define ELIMINABLE_REGS  \{{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \ {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}

Note that the elimination of the argument pointer with the stack pointer isspecified first since that is the preferred elimination.

Macro:RELOAD_ELIMINABLE_REGS

LikeELIMINABLE_REGS, but only used in the old reload framework whereit takes precedence overELIMINABLE_REGS. This macro can be usefulduring the transition to LRA because there are cases where reload and LRAdisagree on how eliminable registers should be represented. For an example,seeavr.h.

Target Hook:boolTARGET_CAN_ELIMINATE(const intfrom_reg, const intto_reg)

This target hook should returntrue if the compiler is allowed totry to replace register numberfrom_reg with register numberto_reg. This target hook will usually betrue, since most of thecases preventing register elimination are things that the compiler alreadyknows about.

Default return value istrue.

Macro:INITIAL_ELIMINATION_OFFSET(from-reg,to-reg,offset-var)

This macro returns the initial difference between the specified pairof registers. The value would be computed from informationsuch as the result ofget_frame_size () and the tables ofregistersdf_regs_ever_live_p andcall_used_regs.

Target Hook:voidTARGET_COMPUTE_FRAME_LAYOUT(void)

This target hook is called once each time the frame layout needs to berecalculated. The calculations can be cached by the target and can thenbe used byINITIAL_ELIMINATION_OFFSET instead of re-computing thelayout on every invocation of that hook. This is particularly usefulfor targets that have an expensive frame layout function. Implementingthis callback is optional.


Next:Passing Function Arguments on the Stack, Previous:Registers That Address the Stack Frame, Up:Stack Layout and Calling Conventions   [Contents][Index]


[8]ページ先頭

©2009-2026 Movatter.jp