[LLVMdev] Global register variables/custom calling conventions

Anton Korobeynikov anton at korobeynikov.info
Sun Sep 27 02:08:57 PDT 2009


> 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.

> As a hack-around (since posting the original
> message to the list) I'm injecting a couple of MOV instructions to move the
> pointer from %r14 (AREG0 - TCG's pointer to the CPU state struct on x86_64)
Use inline assembler to load the address of this struct, this is much
better than implementing a new calling convention.

> 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.

-- 
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University



More information about the llvm-dev mailing list