John Reagan via llvm-dev
2018-Mar-14 18:28 UTC
[llvm-dev] Capturing x86 %rax in prologue to use in body
As part of our OpenVMS-specific changes, we're adding an arg-count to all of our calls. We've done this as part of callLowering to put the # of slots used into %ah and leaving %al to hold the standard info about vector registers. That part is working. 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? 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. Anybody have suggestions on where we should be poking with our screwdriver? Do we have to write a new intrinsic to obtain that saved value? Thanks for any advice John -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: OpenPGP digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180314/27ec4015/attachment.sig>
Tim Northover via llvm-dev
2018-Mar-14 19:58 UTC
[llvm-dev] Capturing x86 %rax in prologue to use in body
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.
John Reagan via llvm-dev
2018-Mar-16 18:11 UTC
[llvm-dev] Capturing x86 %rax in prologue to use in body
Thanks. We did exactly that (add a new intrinsic call & put a piece of VMS-specific metadata on the routine to tell it to capture the %ah into a virtual register) and it all works as expected. On 3/14/18 3:58 PM, Tim Northover wrote:> 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.-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: OpenPGP digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180316/c50e4419/attachment.sig>
Seemingly Similar Threads
- Capturing x86 %rax in prologue to use in body
- x86-64 unwind additions
- [LLVMdev] Introduction for new consumer of LLVM
- [LLVMdev] Properly handling mem-loc arguments when prologue adjusts FP.
- [RFC] Coding Standards: "prefer `int` for, regular arithmetic, use `unsigned` only for bitmask and when you, intend to rely on wrapping behavior."