Displaying 5 results from an estimated 5 matches for "retpt".
Did you mean:
rept
2017 Apr 17
9
[RFC] Adding CPS call support
...t is here when we run into a problem in LLVM.
Consider the following CPS call to @bar and how it will return:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
define void @foo (i8** %sp, ...) {
someBlk:
; ...
; finish stack frame by writing return address
%retAddr = blockaddress(@foo, %retpt)
store i8* %retAddr, i8** %sp
; jump to @bar
tail call void @bar(i8** %sp, ...)
retpt: ; <- how can @bar "call" %retpt?
%sp2 = ???
%val = ???
; ...
}
define void @bar (i8** %sp, ...) {
; perform a return
%retAddr0 = load i8*, i8** %sp
%retAddr1 = bitc...
2017 Apr 17
2
[RFC] Adding CPS call support
...nsider the following CPS call to @bar and how it will return:
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>> define void @foo (i8** %sp, ...) {
>> someBlk:
>> ; ...
>> ; finish stack frame by writing return address
>> %retAddr = blockaddress(@foo, %retpt)
>> store i8* %retAddr, i8** %sp
>> ; jump to @bar
>> tail call void @bar(i8** %sp, ...)
>> retpt: ; <- how can @bar "call" %retpt?
>> %sp2 = ???
>> %val = ???
>> ; ...
>> }
>> define void @bar (i8** %sp, ...) {
>&...
2017 Apr 19
3
[RFC] Adding CPS call support
...serious hesitation.
There are nicer ways to embed CPS call/return into LLVM; I just figured that there would not be much support for adding a new terminator because it would change a lot of code. Ideally we would have a block terminator like:
cps call ghccc @bar (.. args ..) returnsto label %retpt
Where the "returnsto" is optional to cover both CPS calls and returns. Another alternative would be to emulate this terminator using an intrinsic.
So, my question is: would there be more support for a version of this terminator (whether as an intrinsic or not) instead of what I was prop...
2017 Apr 17
2
[RFC] Adding CPS call support
...eturn address, which looks no different than a function call.
Thus, we have no callee-saved registers to worry about since the tail calls never come back. In addition, there are no live values in the LLVM stack frame, since they are all passed in the CPS call (which uses a different stack). Thus, retpt receives all of its values from the struct it extracts from. While the 'cps' marked call appears to be non-tail, it will be lowered to a tail call.
It's also worth noting that this proposal is based on something that already works in LLVM, using a special assembly routine. We currently...
2017 Apr 18
2
[RFC] Adding CPS call support
...LR. On other architectures, you can emulate this (for example, you could lower an IR "call" to LEA+JMP on x86-64).
This is similar to what I was originally thinking, since the end goal of all of this is the following machine code for a call (I'll use an x86-64 example):
leaq _retpt(%rip), %scratchReg
movq %scratchReg, (%ghcSPReg)
jmp _bar
But, if we want to end up with the above machine code using a custom lowering of just the following IR instruction,
%retVals = cps call ghccc @bar (... args ...)
_without_ explicitly taking the block address and writing it...