[LLVMdev] Global register variables/custom calling conventions

Andrew Jeffery andrew at aj.id.au
Mon Sep 28 00:46:16 PDT 2009


Hi Anton

On 27/09/09 18:38, Anton Korobeynikov wrote:
>> At the moment I'm not explicitly specifying a calling convention for the
>> functions, but LLVM seems to consistently put the ARM CPU state struct
>> pointer (parameter) into %rdi.
> That's correct - please consider reading x86-64 ABI document.

Hmm - good idea :) I had a look at [1] and it clears up a lot.

> Use inline assembler to load the address of this struct, this is much
> better than implementing a new calling convention.

Ok - it certainly seems a lot less effort.
>
>> to %rdi before and back (from %rdi) to %r14 after the copied function block.
> You don't need this - I doubt you're changing the pointer to the struct.
>

Yes, I'm not changing the value. Before reading the ABI document it was 
just a bit of defensive programming to ensure that it got placed back in 
%r14, but clearly %r14 shouldn't be changing in value anyway.

Thanks for your help :)

Andrew

[1] http://www.x86-64.org/documentation/abi-0.99.pdf



More information about the llvm-dev mailing list