SPRAB89A September 2011 – March 2014
There are at least two cases that require a standardized layout for the local frame and ordering of callee-saved registers. They are exception handling and debugging.
This section describes conventions for managing the stack, the general layout of the frame, and the layout of the callee-saved area.
The stack grows toward zero. The SP points to the word above the topmost allocated word; that is, the word at *(SP+4) is allocated, but *SP is not.
Objects in the frame are accessed using SP-relative addressing with positive offsets.
A compiler is free to allocate one or more "frame pointer" registers to access the frame. The TI compiler uses A15 as a frame pointer (FP). If FP is allocated, its value is the value of SP before the function's frame is created. In other words, FP points to the bottom of the current frame, and the top of the caller's. Objects in the frame are accessed via FP with negative offsets. Incoming arguments are accessed via FP with positive offsets.
Insofar as a frame pointer is not part of the linkage between functions, the choice of whether to use a frame pointer, which register to use, and where it points is up to the discretion of the toolchain. However, some of the virtual instructions used for stack unwinding assume that A15 points to the frame as described in the preceding paragraph. If a function has no frame pointer, or uses a different convention as to which register is used or where it points, then these unwinding instructions cannot be used and a less efficient sequence may be required.
The stack frame of a function contains the following areas: