[llvm-dev] Capturing x86 %rax in prologue to use in body

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 14 12:58:34 PDT 2018


Hi John,

On 14 March 2018 at 18:28, John Reagan via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> However, we're struggling somewhat on the code in the prologue to
> capture the %ah value to then be obtained by our "arg_count" compiler
> builtin.  We found where the 1st parameter is put into a virtual
> register in the event that it has to be passed back in %rax for
> functions returning large structures. We certainly could do the same
> with %ah, but what IR would we generate to fetch that value in the body
> of a routine?

It would almost certainly be an @llvm.whatever intrinsic call at the
IR level with custom SDAG lowering that uses getCopyFromReg to copy
the value back out of the stashed VReg you found before.

> We haven't created our own private OpenVMS calling convention but just
> riding along on the standard convention.  Another thought would be to
> create a new CC but that seems overkill just for this.

That sounds pretty sensible. Unless you need to support multiple
calling conventions simultaneously the default "C" makes sense at the
IR level. You may or may not want a special OpenVMS CallingConv in the
.td files.

Cheers.

Tim.


More information about the llvm-dev mailing list