Table 5 shows the registers available on the
sparc. For floating point registers, double precision only uses even
numbered registers, with the next odd numbered register holding the second
half of the 64-bit value. Single precision instructions can't use
%f32-%f62. However, one trick to keep in mind is anytime you need to load
two consecutive single precision values, these can be loaded to an even and
next odd register with one ldd, which is more efficient than two ld.
Table 5:
Sparc register summary
|
|
CALLEE |
REGISTER |
USAGE |
SAVE |
Global Registers |
%g0 (%r0) |
Always zero |
NO |
%g1-%g4 (%r1-%r4) |
global regs |
NO |
%g5-%g7 (%r5-%r7) |
system regs - no use |
NO USE |
Out Registers |
%o0 (%r8) |
Return value from callee |
NO |
|
outgoing arg 1 to caller |
|
%o1-%o5 (%r9-%r13) |
outgoing arg 2-6 to caller |
NO |
%o6/%sp (%r14) |
Stack pointer |
YES |
%o7 (%r15) |
scratch/@ of CALL inst. |
NO |
Local Registers |
%l0-%l7 (%r16-%r23) |
scratch registers |
YES |
In Registers |
%i0-%i5 (%r24-%r29) |
incoming arg 1-6 |
YES |
%i6/%fp (%r30) |
frame pointer |
YES |
%i7 (%r31) |
return address - 8 |
YES |
Floating Point Registers |
%f0-%f31 |
single prec regs |
NO |
|
even #'s double prec |
|
%f32-%f62 |
double prec regs |
NO |
|
The sparc has only eight globally visable integer registers, the Global
registers. Applications are not allowed to use the system registers
(%g5-%g7), not even if they are saved and restored.
Note that in the 64-bit variants of the ABI, %g5 can be
used, and need not be saved for v9, but must be saved for v8plus.
The other 24 registers (In, Out, Local)
are in a moving register window, which is moved by the save and
restore commands. Note that %g0 can be the target of
an operation, but it's value will not be effected (eg., its value will
remain 0, even if you were to subcc %i2, 8, %g0).
Note that as long as you use the save statement, all callee-saved
registers are implicitly saved by the register window.
The caller's Out registers are the callee's In registers.
Clint Whaley
2012-07-10