MIPS Leaf Routines

Compilers classify routines into one of two categories:

  • Non-leaf Routines, which contain calls to other routines.
  • Leaf Routines, which do no execute any procedure calls to other routines.

Leaf routines are further divided into routines that use stack space for local variables and those that do not. The category that a routine fits into determines what the stack frame will look like.

A leaf routine need not set up a stack frame for itself unless it needs to save permanent or system registers or allocate space for locals. Routines are not considered leaves if they perform alloca() operations.

If a leaf routine does require a stack frame, it need not allocate stack space for outgoing arguments. Outgoing arguments are only meaningful for non-leaf routines. Asynchronously invoked functions, such as signal and interrupt handlers, must make no assumption that all frames include four words of unused argument space because they can be invoked during the execution of a leaf routine that has no such argument space.

See Also

MIPS Stack Frame and Argument Registers | MIPS I, II Argument Registers | MIPS IV Argument Registers | MIPS Frame and Stack Pointers

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.