compiler: remove parentHandle from calling convention

This removes the parentHandle argument from the internal calling convention.
It was formerly used to implment coroutines.
Now that coroutines have been removed, it is no longer necessary.
This commit is contained in:
Nia Waldvogel
2021-12-31 14:53:19 -05:00
committed by Nia
parent 0c2fefa09b
commit c6ae1c58fc
38 changed files with 443 additions and 487 deletions
+7 -7
View File
@@ -10,7 +10,7 @@ target triple = "armv7m-none-eabi"
@"reflect/types.type:basic:int" = private constant %runtime.typecodeID zeroinitializer
@"reflect/methods.NeverImplementedMethod()" = linkonce_odr constant i8 0
@"reflect/methods.Double() int" = linkonce_odr constant i8 0
@"Number$methodset" = private constant [1 x %runtime.interfaceMethodInfo] [%runtime.interfaceMethodInfo { i8* @"reflect/methods.Double() int", i32 ptrtoint (i32 (i8*, i8*, i8*)* @"(Number).Double$invoke" to i32) }]
@"Number$methodset" = private constant [1 x %runtime.interfaceMethodInfo] [%runtime.interfaceMethodInfo { i8* @"reflect/methods.Double() int", i32 ptrtoint (i32 (i8*, i8*)* @"(Number).Double$invoke" to i32) }]
@"reflect/types.type:named:Number" = private constant %runtime.typecodeID { %runtime.typecodeID* @"reflect/types.type:basic:int", i32 0, %runtime.interfaceMethodInfo* getelementptr inbounds ([1 x %runtime.interfaceMethodInfo], [1 x %runtime.interfaceMethodInfo]* @"Number$methodset", i32 0, i32 0), %runtime.typecodeID* null, i32 0 }
declare i1 @runtime.typeAssert(i32, i8*)
@@ -19,7 +19,7 @@ declare void @runtime.printint16(i16)
declare void @runtime.printint32(i32)
declare void @runtime.printptr(i32)
declare void @runtime.printnl()
declare void @runtime.nilPanic(i8*, i8*)
declare void @runtime.nilPanic(i8*)
define void @printInterfaces() {
call void @printInterface(i32 ptrtoint (%runtime.typecodeID* @"reflect/types.type:basic:int" to i32), i8* inttoptr (i32 5 to i8*))
@@ -44,7 +44,7 @@ typeswitch.notUnmatched:
br i1 %isDoubler, label %typeswitch.Doubler, label %typeswitch.notDoubler
typeswitch.Doubler:
%doubler.result = call i32 @"Doubler.Double$invoke"(i8* %value, i32 %typecode, i8* undef, i8* undef)
%doubler.result = call i32 @"Doubler.Double$invoke"(i8* %value, i32 %typecode, i8* undef)
call void @runtime.printint32(i32 %doubler.result)
ret void
@@ -73,18 +73,18 @@ typeswitch.notInt16:
ret void
}
define i32 @"(Number).Double"(i32 %receiver, i8* %context, i8* %parentHandle) {
define i32 @"(Number).Double"(i32 %receiver, i8* %context) {
%ret = mul i32 %receiver, 2
ret i32 %ret
}
define i32 @"(Number).Double$invoke"(i8* %receiverPtr, i8* %context, i8* %parentHandle) {
define i32 @"(Number).Double$invoke"(i8* %receiverPtr, i8* %context) {
%receiver = ptrtoint i8* %receiverPtr to i32
%ret = call i32 @"(Number).Double"(i32 %receiver, i8* undef, i8* null)
%ret = call i32 @"(Number).Double"(i32 %receiver, i8* undef)
ret i32 %ret
}
declare i32 @"Doubler.Double$invoke"(i8* %receiver, i32 %typecode, i8* %context, i8* %parentHandle) #0
declare i32 @"Doubler.Double$invoke"(i8* %receiver, i32 %typecode, i8* %context) #0
declare i1 @Doubler$typeassert(i32 %typecode) #1
+8 -8
View File
@@ -18,7 +18,7 @@ declare void @runtime.printptr(i32)
declare void @runtime.printnl()
declare void @runtime.nilPanic(i8*, i8*)
declare void @runtime.nilPanic(i8*)
define void @printInterfaces() {
call void @printInterface(i32 ptrtoint (%runtime.typecodeID* @"reflect/types.type:basic:int" to i32), i8* inttoptr (i32 5 to i8*))
@@ -42,7 +42,7 @@ typeswitch.notUnmatched: ; preds = %0
br i1 %isDoubler, label %typeswitch.Doubler, label %typeswitch.notDoubler
typeswitch.Doubler: ; preds = %typeswitch.notUnmatched
%doubler.result = call i32 @"Doubler.Double$invoke"(i8* %value, i32 %typecode, i8* undef, i8* undef)
%doubler.result = call i32 @"Doubler.Double$invoke"(i8* %value, i32 %typecode, i8* undef)
call void @runtime.printint32(i32 %doubler.result)
ret void
@@ -69,28 +69,28 @@ typeswitch.notInt16: ; preds = %typeswitch.notByte
ret void
}
define i32 @"(Number).Double"(i32 %receiver, i8* %context, i8* %parentHandle) {
define i32 @"(Number).Double"(i32 %receiver, i8* %context) {
%ret = mul i32 %receiver, 2
ret i32 %ret
}
define i32 @"(Number).Double$invoke"(i8* %receiverPtr, i8* %context, i8* %parentHandle) {
define i32 @"(Number).Double$invoke"(i8* %receiverPtr, i8* %context) {
%receiver = ptrtoint i8* %receiverPtr to i32
%ret = call i32 @"(Number).Double"(i32 %receiver, i8* undef, i8* null)
%ret = call i32 @"(Number).Double"(i32 %receiver, i8* undef)
ret i32 %ret
}
define internal i32 @"Doubler.Double$invoke"(i8* %receiver, i32 %actualType, i8* %context, i8* %parentHandle) unnamed_addr #0 {
define internal i32 @"Doubler.Double$invoke"(i8* %receiver, i32 %actualType, i8* %context) unnamed_addr #0 {
entry:
%"named:Number.icmp" = icmp eq i32 %actualType, ptrtoint (%runtime.typecodeID* @"reflect/types.type:named:Number" to i32)
br i1 %"named:Number.icmp", label %"named:Number", label %"named:Number.next"
"named:Number": ; preds = %entry
%0 = call i32 @"(Number).Double$invoke"(i8* %receiver, i8* undef, i8* undef)
%0 = call i32 @"(Number).Double$invoke"(i8* %receiver, i8* undef)
ret i32 %0
"named:Number.next": ; preds = %entry
call void @runtime.nilPanic(i8* undef, i8* undef)
call void @runtime.nilPanic(i8* undef)
unreachable
}
+14 -14
View File
@@ -7,33 +7,33 @@ target triple = "armv7em-none-eabi"
%"runtime/interrupt.handle" = type { i8*, i32, %"runtime/interrupt.Interrupt" }
%"runtime/interrupt.Interrupt" = type { i32 }
@"runtime/interrupt.$interrupt2" = private unnamed_addr constant %"runtime/interrupt.handle" { i8* bitcast (%machine.UART* @machine.UART0 to i8*), i32 ptrtoint (void (i32, i8*, i8*)* @"(*machine.UART).handleInterrupt$bound" to i32), %"runtime/interrupt.Interrupt" { i32 2 } }
@"runtime/interrupt.$interrupt2" = private unnamed_addr constant %"runtime/interrupt.handle" { i8* bitcast (%machine.UART* @machine.UART0 to i8*), i32 ptrtoint (void (i32, i8*)* @"(*machine.UART).handleInterrupt$bound" to i32), %"runtime/interrupt.Interrupt" { i32 2 } }
@machine.UART0 = internal global %machine.UART { %machine.RingBuffer* @"machine$alloc.335" }
@"machine$alloc.335" = internal global %machine.RingBuffer zeroinitializer
declare void @"runtime/interrupt.callHandlers"(i32, i8*, i8*) local_unnamed_addr
declare void @"runtime/interrupt.callHandlers"(i32, i8*) local_unnamed_addr
declare void @"device/arm.EnableIRQ"(i32, i8* nocapture readnone, i8* nocapture readnone)
declare void @"device/arm.EnableIRQ"(i32, i8* nocapture readnone)
declare void @"device/arm.SetPriority"(i32, i32, i8* nocapture readnone, i8* nocapture readnone)
declare void @"device/arm.SetPriority"(i32, i32, i8* nocapture readnone)
declare void @"runtime/interrupt.use"(%"runtime/interrupt.Interrupt")
define void @runtime.initAll(i8* nocapture readnone, i8* nocapture readnone) unnamed_addr {
define void @runtime.initAll(i8* nocapture readnone) unnamed_addr {
entry:
call void @"device/arm.SetPriority"(i32 ptrtoint (%"runtime/interrupt.handle"* @"runtime/interrupt.$interrupt2" to i32), i32 192, i8* undef, i8* undef)
call void @"device/arm.EnableIRQ"(i32 ptrtoint (%"runtime/interrupt.handle"* @"runtime/interrupt.$interrupt2" to i32), i8* undef, i8* undef)
call void @"device/arm.SetPriority"(i32 ptrtoint (%"runtime/interrupt.handle"* @"runtime/interrupt.$interrupt2" to i32), i32 192, i8* undef)
call void @"device/arm.EnableIRQ"(i32 ptrtoint (%"runtime/interrupt.handle"* @"runtime/interrupt.$interrupt2" to i32), i8* undef)
call void @"runtime/interrupt.use"(%"runtime/interrupt.Interrupt" { i32 ptrtoint (%"runtime/interrupt.handle"* @"runtime/interrupt.$interrupt2" to i32) })
ret void
}
define void @UARTE0_UART0_IRQHandler() {
call void @"runtime/interrupt.callHandlers"(i32 2, i8* undef, i8* undef)
call void @"runtime/interrupt.callHandlers"(i32 2, i8* undef)
ret void
}
define void @NFCT_IRQHandler() {
call void @"runtime/interrupt.callHandlers"(i32 5, i8* undef, i8* undef)
call void @"runtime/interrupt.callHandlers"(i32 5, i8* undef)
ret void
}
@@ -45,22 +45,22 @@ entry:
]
switch.body2:
call void @"runtime/interrupt.callHandlers"(i32 2, i8* undef, i8* undef)
call void @"runtime/interrupt.callHandlers"(i32 2, i8* undef)
ret void
switch.body5:
call void @"runtime/interrupt.callHandlers"(i32 5, i8* undef, i8* undef)
call void @"runtime/interrupt.callHandlers"(i32 5, i8* undef)
ret void
switch.done:
ret void
}
define internal void @"(*machine.UART).handleInterrupt$bound"(i32, i8* nocapture %context, i8* nocapture readnone %parentHandle) {
define internal void @"(*machine.UART).handleInterrupt$bound"(i32, i8* nocapture %context) {
entry:
%unpack.ptr = bitcast i8* %context to %machine.UART*
call void @"(*machine.UART).handleInterrupt"(%machine.UART* %unpack.ptr, i32 %0, i8* undef, i8* undef)
call void @"(*machine.UART).handleInterrupt"(%machine.UART* %unpack.ptr, i32 %0, i8* undef)
ret void
}
declare void @"(*machine.UART).handleInterrupt"(%machine.UART* nocapture, i32, i8* nocapture readnone, i8* nocapture readnone)
declare void @"(*machine.UART).handleInterrupt"(%machine.UART* nocapture, i32, i8* nocapture readnone)
+11 -11
View File
@@ -9,23 +9,23 @@ target triple = "armv7em-none-eabi"
@machine.UART0 = internal global %machine.UART { %machine.RingBuffer* @"machine$alloc.335" }
@"machine$alloc.335" = internal global %machine.RingBuffer zeroinitializer
declare void @"runtime/interrupt.callHandlers"(i32, i8*, i8*) local_unnamed_addr
declare void @"runtime/interrupt.callHandlers"(i32, i8*) local_unnamed_addr
declare void @"device/arm.EnableIRQ"(i32, i8* nocapture readnone, i8* nocapture readnone)
declare void @"device/arm.EnableIRQ"(i32, i8* nocapture readnone)
declare void @"device/arm.SetPriority"(i32, i32, i8* nocapture readnone, i8* nocapture readnone)
declare void @"device/arm.SetPriority"(i32, i32, i8* nocapture readnone)
declare void @"runtime/interrupt.use"(%"runtime/interrupt.Interrupt")
define void @runtime.initAll(i8* nocapture readnone %0, i8* nocapture readnone %1) unnamed_addr {
define void @runtime.initAll(i8* nocapture readnone %0) unnamed_addr {
entry:
call void @"device/arm.SetPriority"(i32 2, i32 192, i8* undef, i8* undef)
call void @"device/arm.EnableIRQ"(i32 2, i8* undef, i8* undef)
call void @"device/arm.SetPriority"(i32 2, i32 192, i8* undef)
call void @"device/arm.EnableIRQ"(i32 2, i8* undef)
ret void
}
define void @UARTE0_UART0_IRQHandler() {
call void @"(*machine.UART).handleInterrupt$bound"(i32 2, i8* bitcast (%machine.UART* @machine.UART0 to i8*), i8* undef)
call void @"(*machine.UART).handleInterrupt$bound"(i32 2, i8* bitcast (%machine.UART* @machine.UART0 to i8*))
ret void
}
@@ -37,7 +37,7 @@ entry:
]
switch.body2: ; preds = %entry
call void @"(*machine.UART).handleInterrupt$bound"(i32 2, i8* bitcast (%machine.UART* @machine.UART0 to i8*), i8* undef)
call void @"(*machine.UART).handleInterrupt$bound"(i32 2, i8* bitcast (%machine.UART* @machine.UART0 to i8*))
ret void
switch.body5: ; preds = %entry
@@ -47,11 +47,11 @@ switch.done: ; preds = %entry
ret void
}
define internal void @"(*machine.UART).handleInterrupt$bound"(i32 %0, i8* nocapture %context, i8* nocapture readnone %parentHandle) {
define internal void @"(*machine.UART).handleInterrupt$bound"(i32 %0, i8* nocapture %context) {
entry:
%unpack.ptr = bitcast i8* %context to %machine.UART*
call void @"(*machine.UART).handleInterrupt"(%machine.UART* %unpack.ptr, i32 %0, i8* undef, i8* undef)
call void @"(*machine.UART).handleInterrupt"(%machine.UART* %unpack.ptr, i32 %0, i8* undef)
ret void
}
declare void @"(*machine.UART).handleInterrupt"(%machine.UART* nocapture, i32, i8* nocapture readnone, i8* nocapture readnone)
declare void @"(*machine.UART).handleInterrupt"(%machine.UART* nocapture, i32, i8* nocapture readnone)
+5 -5
View File
@@ -22,9 +22,9 @@ target triple = "i686--linux"
; The type itself is stored in %typ.value, %typ.typecode just refers to the
; type of reflect.Type. This function can be optimized because errorType is
; known at compile time (after the interp pass has run).
define i1 @main.isError(i32 %typ.typecode, i8* %typ.value, i8* %context, i8* %parentHandle) {
define i1 @main.isError(i32 %typ.typecode, i8* %typ.value, i8* %context) {
entry:
%result = call i1 @"reflect.Type.Implements$invoke"(i8* %typ.value, i32 ptrtoint (%runtime.typecodeID* @"reflect/types.type:named:reflect.rawType" to i32), i8* bitcast (%runtime.typecodeID* @"reflect/types.type:named:error" to i8*), i32 %typ.typecode, i8* undef, i8* undef)
%result = call i1 @"reflect.Type.Implements$invoke"(i8* %typ.value, i32 ptrtoint (%runtime.typecodeID* @"reflect/types.type:named:reflect.rawType" to i32), i8* bitcast (%runtime.typecodeID* @"reflect/types.type:named:error" to i8*), i32 %typ.typecode, i8* undef)
ret i1 %result
}
@@ -33,13 +33,13 @@ entry:
; func isUnknown(typ, itf reflect.Type) bool {
; return typ.Implements(itf)
; }
define i1 @main.isUnknown(i32 %typ.typecode, i8* %typ.value, i32 %itf.typecode, i8* %itf.value, i8* %context, i8* %parentHandle) {
define i1 @main.isUnknown(i32 %typ.typecode, i8* %typ.value, i32 %itf.typecode, i8* %itf.value, i8* %context) {
entry:
%result = call i1 @"reflect.Type.Implements$invoke"(i8* %typ.value, i32 %itf.typecode, i8* %itf.value, i32 %typ.typecode, i8* undef, i8* undef)
%result = call i1 @"reflect.Type.Implements$invoke"(i8* %typ.value, i32 %itf.typecode, i8* %itf.value, i32 %typ.typecode, i8* undef)
ret i1 %result
}
declare i1 @"reflect.Type.Implements$invoke"(i8*, i32, i8*, i32, i8*, i8*) #0
declare i1 @"reflect.Type.Implements$invoke"(i8*, i32, i8*, i32, i8*) #0
declare i1 @"error.$typeassert"(i32) #1
attributes #0 = { "tinygo-invoke"="reflect/methods.Implements(reflect.Type) bool" "tinygo-methods"="reflect/methods.Align() int; reflect/methods.Implements(reflect.Type) bool" }
+4 -4
View File
@@ -15,20 +15,20 @@ target triple = "i686--linux"
@"reflect.rawType$methodset" = linkonce_odr constant [20 x %runtime.interfaceMethodInfo] zeroinitializer
@"reflect/types.type:basic:uintptr" = linkonce_odr constant %runtime.typecodeID zeroinitializer
define i1 @main.isError(i32 %typ.typecode, i8* %typ.value, i8* %context, i8* %parentHandle) {
define i1 @main.isError(i32 %typ.typecode, i8* %typ.value, i8* %context) {
entry:
%0 = ptrtoint i8* %typ.value to i32
%1 = call i1 @"error.$typeassert"(i32 %0)
ret i1 %1
}
define i1 @main.isUnknown(i32 %typ.typecode, i8* %typ.value, i32 %itf.typecode, i8* %itf.value, i8* %context, i8* %parentHandle) {
define i1 @main.isUnknown(i32 %typ.typecode, i8* %typ.value, i32 %itf.typecode, i8* %itf.value, i8* %context) {
entry:
%result = call i1 @"reflect.Type.Implements$invoke"(i8* %typ.value, i32 %itf.typecode, i8* %itf.value, i32 %typ.typecode, i8* undef, i8* undef)
%result = call i1 @"reflect.Type.Implements$invoke"(i8* %typ.value, i32 %itf.typecode, i8* %itf.value, i32 %typ.typecode, i8* undef)
ret i1 %result
}
declare i1 @"reflect.Type.Implements$invoke"(i8*, i32, i8*, i32, i8*, i8*) #0
declare i1 @"reflect.Type.Implements$invoke"(i8*, i32, i8*, i32, i8*) #0
declare i1 @"error.$typeassert"(i32) #1
+5 -5
View File
@@ -3,17 +3,17 @@ target triple = "armv7m-none-eabi"
@zeroString = constant [0 x i8] zeroinitializer
declare i1 @runtime.stringEqual(i8*, i32, i8*, i32, i8*, i8*)
declare i1 @runtime.stringEqual(i8*, i32, i8*, i32, i8*)
define i1 @main.stringCompareEqualConstantZero(i8* %s1.data, i32 %s1.len, i8* %context, i8* %parentHandle) {
define i1 @main.stringCompareEqualConstantZero(i8* %s1.data, i32 %s1.len, i8* %context) {
entry:
%0 = call i1 @runtime.stringEqual(i8* %s1.data, i32 %s1.len, i8* getelementptr inbounds ([0 x i8], [0 x i8]* @zeroString, i32 0, i32 0), i32 0, i8* undef, i8* null)
%0 = call i1 @runtime.stringEqual(i8* %s1.data, i32 %s1.len, i8* getelementptr inbounds ([0 x i8], [0 x i8]* @zeroString, i32 0, i32 0), i32 0, i8* undef)
ret i1 %0
}
define i1 @main.stringCompareUnequalConstantZero(i8* %s1.data, i32 %s1.len, i8* %context, i8* %parentHandle) {
define i1 @main.stringCompareUnequalConstantZero(i8* %s1.data, i32 %s1.len, i8* %context) {
entry:
%0 = call i1 @runtime.stringEqual(i8* %s1.data, i32 %s1.len, i8* getelementptr inbounds ([0 x i8], [0 x i8]* @zeroString, i32 0, i32 0), i32 0, i8* undef, i8* null)
%0 = call i1 @runtime.stringEqual(i8* %s1.data, i32 %s1.len, i8* getelementptr inbounds ([0 x i8], [0 x i8]* @zeroString, i32 0, i32 0), i32 0, i8* undef)
%1 = xor i1 %0, true
ret i1 %1
}
+3 -3
View File
@@ -3,15 +3,15 @@ target triple = "armv7m-none-eabi"
@zeroString = constant [0 x i8] zeroinitializer
declare i1 @runtime.stringEqual(i8*, i32, i8*, i32, i8*, i8*)
declare i1 @runtime.stringEqual(i8*, i32, i8*, i32, i8*)
define i1 @main.stringCompareEqualConstantZero(i8* %s1.data, i32 %s1.len, i8* %context, i8* %parentHandle) {
define i1 @main.stringCompareEqualConstantZero(i8* %s1.data, i32 %s1.len, i8* %context) {
entry:
%0 = icmp eq i32 %s1.len, 0
ret i1 %0
}
define i1 @main.stringCompareUnequalConstantZero(i8* %s1.data, i32 %s1.len, i8* %context, i8* %parentHandle) {
define i1 @main.stringCompareUnequalConstantZero(i8* %s1.data, i32 %s1.len, i8* %context) {
entry:
%0 = icmp eq i32 %s1.len, 0
%1 = xor i1 %0, true