GNU Info

Info Node: (gcc-295.info)Leaf Functions

(gcc-295.info)Leaf Functions


Next: Stack Registers Prev: Values in Registers Up: Registers
Enter node , (file) or (file)node

Handling Leaf Functions
-----------------------

   On some machines, a leaf function (i.e., one which makes no calls)
can run more efficiently if it does not make its own register window.
Often this means it is required to receive its arguments in the
registers where they are passed by the caller, instead of the registers
where they would normally arrive.

   The special treatment for leaf functions generally applies only when
other conditions are met; for example, often they may use only those
registers for its own variables and temporaries.  We use the term "leaf
function" to mean a function that is suitable for this special
handling, so that functions with no calls are not necessarily "leaf
functions".

   GNU CC assigns register numbers before it knows whether the function
is suitable for leaf function treatment.  So it needs to renumber the
registers in order to output a leaf function.  The following macros
accomplish this.

`LEAF_REGISTERS'
     A C initializer for a vector, indexed by hard register number,
     which contains 1 for a register that is allowable in a candidate
     for leaf function treatment.

     If leaf function treatment involves renumbering the registers,
     then the registers marked here should be the ones before
     renumbering--those that GNU CC would ordinarily allocate.  The
     registers which will actually be used in the assembler code, after
     renumbering, should not be marked with 1 in this vector.

     Define this macro only if the target machine offers a way to
     optimize the treatment of leaf functions.

`LEAF_REG_REMAP (REGNO)'
     A C expression whose value is the register number to which REGNO
     should be renumbered, when a function is treated as a leaf
     function.

     If REGNO is a register number which should not appear in a leaf
     function before renumbering, then the expression should yield -1,
     which will cause the compiler to abort.

     Define this macro only if the target machine offers a way to
     optimize the treatment of leaf functions, and registers need to be
     renumbered to do this.

   Normally, `FUNCTION_PROLOGUE' and `FUNCTION_EPILOGUE' must treat
leaf functions specially.  They can test the C variable
`current_function_is_leaf' which is nonzero for leaf functions.
`current_function_is_leaf' is set prior to local register allocation
and is valid for the remaining compiler passes.  They can also test the
C variable `current_function_uses_only_leaf_regs' which is nonzero for
leaf functions which only use leaf registers.
`current_function_uses_only_leaf_regs' is valid after reload and is
only useful if `LEAF_REGISTERS' is defined.


automatically generated by info2www version 1.2.2.9