[LLVMdev] PPC calling convention -- how to provide an environment pointer?
Jonas Maebe
jonas.maebe at elis.ugent.be
Sat Jan 31 16:18:21 PST 2009
On 28 Jan 2009, at 00:00, Jonathan S. Shapiro wrote:
> The part that is not clear to me is whether a call made by a C
> function
> in Darwin is required to avoid R11 and R12 in order to allow for the
> possibility that dynamic code generation may happen.
You cannot use R11 or R12 under Darwin, except
a) for calls to functions in the same object file (or calls to
functions in other object files of which you are certain that they
will be linked together with the current object file); and
b) if you are certain that the function will be within range of all
"bl" instructions that refer to it at link time
The reason is indeed that otherwise a stub is required. Such stubs are
normally generated for each and every call by the compiler, but
optimised away by the linker (also by the standard Mac OS X linker)
when the target of a "bl" is known at static link time and within
range of the "bl" instruction. Apple's gcc used R11 to pass the
caller's stack frame to nested functions.
So in general, you cannot use them. What you can use on Darwin
however, is R2 (unlike on SVR4, R2 is not reserved on Darwin; and it's
also not used by any call stubs).
Here are de ABI docs: http://developer.apple.com/documentation/DeveloperTools/Conceptual/LowLevelABI/100-32-bit_PowerPC_Function_Calling_Conventions/32bitPowerPC.html
Jonas
More information about the llvm-dev
mailing list