The calling sequence and stack frame

After the callee performs the save statement, the stack frame looks like:

[%fp] Caller's frame
variable size local scratch
(if needed) strg for wrd8
$\lbrack$%sp+92$\rbrack$ (if needed) strg for wrd7
[%sp+68] storage for words 1-6
[%sp+64] struct/union return ptr
[%sp] ireg window save
32 bit ABI
[%fp+2047] Caller's frame
variable size local scratch
(if needed) strg for wrd8
$\lbrack$%sp+176+2047$\rbrack$ (if needed) strg for wrd7
[%sp+128+2047] storage for words 1-6
[%sp+2047] ireg window save
64 bit ABI

The callee's arguments are stored in the caller's stack frame. Note that the address of %sp must be kept 8-byte aligned for the 32 bit ABI, and 16-byte aligned for 64 bit.

For the 64-bit frame, the 2047 offset is called the BIAS, and it allow system libs to know which ABI is in effect (if 1 in last binary digit, 64 bit). Integers are stored in 64 bit slots, with the last 4 bytes holding the good value. Therefore, to load an int stored at 176 you do a ldsw [%sp+2047+176+4], reg.

For the 32-bit ABIs, floating point args are passed in the integer regs (2 regs for double) and floating point functions return their value in %f0.

For the 64 bit v9 ABI, there is a complicated memory-slot/register mapping which determines how things are passed in registers, as shown in 2 (note that after the callee executes the save statement, the %o registers will of course be the %i registers). Note that v9a is just v9 with VIS extensions, and v9b also includes some UltraSPARC-III extensions, so all v9 ABIs are the same for the information discussed here.

Figure 2: Argument passing for 64-bit SPARC v9 ABI
\begin{figure}\begin{ttfamily}
\begin{center}
\begin{tabular}{\vert\vert l\vert ...
...f31& \%f30& \\ \hline
\hline
\end{tabular}\end{center}\end{ttfamily}\end{figure}

Clint Whaley 2012-07-10