On the safety of registers

Started by dcx2, July 31, 2010, 07:51:42 PM

Previous topic - Next topic

dcx2

#15
It's quite similar to integer regs but even simpler.  PowerPC EABI, on page 3.

f31-f14 are, like r31-r14, non-volatile registers.  They are not safe and their value must be preserved for the caller.  Functions may place non-volatile fregs onto the stack to make room for local variables.  Again, games prefers larger registers for this purpose.

f13, f2, and f1 are not dedicated registers like r13, r2, and r1.  In fact, f13-f9 are as safe as r12; they are not used to pass parameters in, or to return values, and their contents are volatile so the value does not need to be preserved for the caller.  f8-f2 are as safe as r10-r5, again in descending order (i.e. f8 is safer than f7, f7 is safer than f6, etc) - they are used for passing parameters into a function.  Again, games prefer smaller registers for parameter passing.  f1 is about as safe as r4/r3, because it is also used to pass values back to the caller.  f0's safety is unknown; it is given the ominous "language specific" description.  It's probably the kind of uneasy safe that r0 is.

While we're on that note, CR fields 2-4 are non-volatile and must be preserved for the caller.  CR0, CR1, CR5, CR6, and CR7 are volatile.  CR0 is implicitly used for integer compares, CR1 implicitly used for float compares.  So CR2-4 are as unsafe as r31-r14 and f31-f14.  CR5-7 are probably as safe as r12.  CR0-1 are about as safe as r4/r3.