transform: update interface test to opaque pointers
Этот коммит содержится в:
родитель
f8a6e662d8
коммит
7fb23824e2
2 изменённых файлов: 57 добавлений и 57 удалений
56
transform/testdata/interface.ll
предоставленный
56
transform/testdata/interface.ll
предоставленный
|
@ -1,70 +1,70 @@
|
|||
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||
target triple = "armv7m-none-eabi"
|
||||
|
||||
@"reflect/types.type:basic:uint8" = linkonce_odr constant { i8, i8* } { i8 8, i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:pointer:basic:uint8", i32 0, i32 0) }, align 4
|
||||
@"reflect/types.type:pointer:basic:uint8" = linkonce_odr constant { i8, i8* } { i8 21, i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:basic:uint8", i32 0, i32 0) }, align 4
|
||||
@"reflect/types.type:basic:uint8" = linkonce_odr constant { i8, ptr } { i8 8, ptr @"reflect/types.type:pointer:basic:uint8" }, align 4
|
||||
@"reflect/types.type:pointer:basic:uint8" = linkonce_odr constant { i8, ptr } { i8 21, ptr @"reflect/types.type:basic:uint8" }, align 4
|
||||
@"reflect/types.typeid:basic:uint8" = external constant i8
|
||||
@"reflect/types.typeid:basic:int16" = external constant i8
|
||||
@"reflect/types.type:basic:int" = linkonce_odr constant { i8, i8* } { i8 2, i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:pointer:basic:int", i32 0, i32 0) }, align 4
|
||||
@"reflect/types.type:pointer:basic:int" = linkonce_odr constant { i8, i8* } { i8 21, i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:basic:int", i32 0, i32 0) }, align 4
|
||||
@"reflect/types.type:basic:int" = linkonce_odr constant { i8, ptr } { i8 2, ptr @"reflect/types.type:pointer:basic:int" }, align 4
|
||||
@"reflect/types.type:pointer:basic:int" = linkonce_odr constant { i8, ptr } { i8 21, ptr @"reflect/types.type:basic:int" }, align 4
|
||||
@"reflect/methods.NeverImplementedMethod()" = linkonce_odr constant i8 0
|
||||
@"reflect/methods.Double() int" = linkonce_odr constant i8 0
|
||||
@"Number$methodset" = linkonce_odr unnamed_addr constant { i32, [1 x i8*], { i32 (i8*, i8*)* } } { i32 1, [1 x i8*] [i8* @"reflect/methods.Double() int"], { i32 (i8*, i8*)* } { i32 (i8*, i8*)* @"(Number).Double$invoke" } }
|
||||
@"reflect/types.type:named:Number" = linkonce_odr constant { i8*, i8, i8*, i8* } { i8* bitcast ({ i32, [1 x i8*], { i32 (i8*, i8*)* } }* @"Number$methodset" to i8*), i8 34, i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:pointer:named:Number", i32 0, i32 0), i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:basic:int", i32 0, i32 0) }, align 4
|
||||
@"reflect/types.type:pointer:named:Number" = linkonce_odr constant { i8, i8* } { i8 21, i8* getelementptr inbounds ({ i8*, i8, i8*, i8* }, { i8*, i8, i8*, i8* }* @"reflect/types.type:named:Number", i32 0, i32 1) }, align 4
|
||||
@"Number$methodset" = linkonce_odr unnamed_addr constant { i32, [1 x ptr], { ptr } } { i32 1, [1 x ptr] [ptr @"reflect/methods.Double() int"], { ptr } { ptr @"(Number).Double$invoke" } }
|
||||
@"reflect/types.type:named:Number" = linkonce_odr constant { ptr, i8, ptr, ptr } { ptr @"Number$methodset", i8 34, ptr @"reflect/types.type:pointer:named:Number", ptr @"reflect/types.type:basic:int" }, align 4
|
||||
@"reflect/types.type:pointer:named:Number" = linkonce_odr constant { i8, ptr } { i8 21, ptr getelementptr inbounds ({ ptr, i8, ptr, ptr }, ptr @"reflect/types.type:named:Number", i32 0, i32 1) }, align 4
|
||||
|
||||
declare i1 @runtime.typeAssert(i8*, i8*)
|
||||
declare i1 @runtime.typeAssert(ptr, ptr)
|
||||
declare void @runtime.printuint8(i8)
|
||||
declare void @runtime.printint16(i16)
|
||||
declare void @runtime.printint32(i32)
|
||||
declare void @runtime.printptr(i32)
|
||||
declare void @runtime.printnl()
|
||||
declare void @runtime.nilPanic(i8*)
|
||||
declare void @runtime.nilPanic(ptr)
|
||||
|
||||
define void @printInterfaces() {
|
||||
call void @printInterface(i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:basic:int", i32 0, i32 0), i8* inttoptr (i32 5 to i8*))
|
||||
call void @printInterface(i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:basic:uint8", i32 0, i32 0), i8* inttoptr (i8 120 to i8*))
|
||||
call void @printInterface(i8* getelementptr inbounds ({ i8*, i8, i8*, i8* }, { i8*, i8, i8*, i8* }* @"reflect/types.type:named:Number", i32 0, i32 1), i8* inttoptr (i32 3 to i8*))
|
||||
call void @printInterface(ptr @"reflect/types.type:basic:int", ptr inttoptr (i32 5 to ptr))
|
||||
call void @printInterface(ptr @"reflect/types.type:basic:uint8", ptr inttoptr (i8 120 to ptr))
|
||||
call void @printInterface(ptr getelementptr inbounds ({ ptr, i8, ptr, ptr }, ptr @"reflect/types.type:named:Number", i32 0, i32 1), ptr inttoptr (i32 3 to ptr))
|
||||
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @printInterface(i8* %typecode, i8* %value) {
|
||||
%isUnmatched = call i1 @Unmatched$typeassert(i8* %typecode)
|
||||
define void @printInterface(ptr %typecode, ptr %value) {
|
||||
%isUnmatched = call i1 @Unmatched$typeassert(ptr %typecode)
|
||||
br i1 %isUnmatched, label %typeswitch.Unmatched, label %typeswitch.notUnmatched
|
||||
|
||||
typeswitch.Unmatched:
|
||||
%unmatched = ptrtoint i8* %value to i32
|
||||
%unmatched = ptrtoint ptr %value to i32
|
||||
call void @runtime.printptr(i32 %unmatched)
|
||||
call void @runtime.printnl()
|
||||
ret void
|
||||
|
||||
typeswitch.notUnmatched:
|
||||
%isDoubler = call i1 @Doubler$typeassert(i8* %typecode)
|
||||
%isDoubler = call i1 @Doubler$typeassert(ptr %typecode)
|
||||
br i1 %isDoubler, label %typeswitch.Doubler, label %typeswitch.notDoubler
|
||||
|
||||
typeswitch.Doubler:
|
||||
%doubler.result = call i32 @"Doubler.Double$invoke"(i8* %value, i8* %typecode, i8* undef)
|
||||
%doubler.result = call i32 @"Doubler.Double$invoke"(ptr %value, ptr %typecode, ptr undef)
|
||||
call void @runtime.printint32(i32 %doubler.result)
|
||||
ret void
|
||||
|
||||
typeswitch.notDoubler:
|
||||
%isByte = call i1 @runtime.typeAssert(i8* %typecode, i8* nonnull @"reflect/types.typeid:basic:uint8")
|
||||
%isByte = call i1 @runtime.typeAssert(ptr %typecode, ptr nonnull @"reflect/types.typeid:basic:uint8")
|
||||
br i1 %isByte, label %typeswitch.byte, label %typeswitch.notByte
|
||||
|
||||
typeswitch.byte:
|
||||
%byte = ptrtoint i8* %value to i8
|
||||
%byte = ptrtoint ptr %value to i8
|
||||
call void @runtime.printuint8(i8 %byte)
|
||||
call void @runtime.printnl()
|
||||
ret void
|
||||
|
||||
typeswitch.notByte:
|
||||
; this is a type assert that always fails
|
||||
%isInt16 = call i1 @runtime.typeAssert(i8* %typecode, i8* nonnull @"reflect/types.typeid:basic:int16")
|
||||
%isInt16 = call i1 @runtime.typeAssert(ptr %typecode, ptr nonnull @"reflect/types.typeid:basic:int16")
|
||||
br i1 %isInt16, label %typeswitch.int16, label %typeswitch.notInt16
|
||||
|
||||
typeswitch.int16:
|
||||
%int16 = ptrtoint i8* %value to i16
|
||||
%int16 = ptrtoint ptr %value to i16
|
||||
call void @runtime.printint16(i16 %int16)
|
||||
call void @runtime.printnl()
|
||||
ret void
|
||||
|
@ -73,22 +73,22 @@ typeswitch.notInt16:
|
|||
ret void
|
||||
}
|
||||
|
||||
define i32 @"(Number).Double"(i32 %receiver, i8* %context) {
|
||||
define i32 @"(Number).Double"(i32 %receiver, ptr %context) {
|
||||
%ret = mul i32 %receiver, 2
|
||||
ret i32 %ret
|
||||
}
|
||||
|
||||
define i32 @"(Number).Double$invoke"(i8* %receiverPtr, i8* %context) {
|
||||
%receiver = ptrtoint i8* %receiverPtr to i32
|
||||
%ret = call i32 @"(Number).Double"(i32 %receiver, i8* undef)
|
||||
define i32 @"(Number).Double$invoke"(ptr %receiverPtr, ptr %context) {
|
||||
%receiver = ptrtoint ptr %receiverPtr to i32
|
||||
%ret = call i32 @"(Number).Double"(i32 %receiver, ptr undef)
|
||||
ret i32 %ret
|
||||
}
|
||||
|
||||
declare i32 @"Doubler.Double$invoke"(i8* %receiver, i8* %typecode, i8* %context) #0
|
||||
declare i32 @"Doubler.Double$invoke"(ptr %receiver, ptr %typecode, ptr %context) #0
|
||||
|
||||
declare i1 @Doubler$typeassert(i8* %typecode) #1
|
||||
declare i1 @Doubler$typeassert(ptr %typecode) #1
|
||||
|
||||
declare i1 @Unmatched$typeassert(i8* %typecode) #2
|
||||
declare i1 @Unmatched$typeassert(ptr %typecode) #2
|
||||
|
||||
attributes #0 = { "tinygo-invoke"="reflect/methods.Double() int" "tinygo-methods"="reflect/methods.Double() int" }
|
||||
attributes #1 = { "tinygo-methods"="reflect/methods.Double() int" }
|
||||
|
|
58
transform/testdata/interface.out.ll
предоставленный
58
transform/testdata/interface.out.ll
предоставленный
|
@ -1,12 +1,12 @@
|
|||
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||
target triple = "armv7m-none-eabi"
|
||||
|
||||
@"reflect/types.type:basic:uint8" = linkonce_odr constant { i8, i8* } { i8 8, i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:pointer:basic:uint8", i32 0, i32 0) }, align 4
|
||||
@"reflect/types.type:pointer:basic:uint8" = linkonce_odr constant { i8, i8* } { i8 21, i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:basic:uint8", i32 0, i32 0) }, align 4
|
||||
@"reflect/types.type:basic:int" = linkonce_odr constant { i8, i8* } { i8 2, i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:pointer:basic:int", i32 0, i32 0) }, align 4
|
||||
@"reflect/types.type:pointer:basic:int" = linkonce_odr constant { i8, i8* } { i8 21, i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:basic:int", i32 0, i32 0) }, align 4
|
||||
@"reflect/types.type:pointer:named:Number" = linkonce_odr constant { i8, i8* } { i8 21, i8* getelementptr inbounds ({ i8, i8*, i8* }, { i8, i8*, i8* }* @"reflect/types.type:named:Number", i32 0, i32 0) }, align 4
|
||||
@"reflect/types.type:named:Number" = linkonce_odr constant { i8, i8*, i8* } { i8 34, i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:pointer:named:Number", i32 0, i32 0), i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:basic:int", i32 0, i32 0) }, align 4
|
||||
@"reflect/types.type:basic:uint8" = linkonce_odr constant { i8, ptr } { i8 8, ptr @"reflect/types.type:pointer:basic:uint8" }, align 4
|
||||
@"reflect/types.type:pointer:basic:uint8" = linkonce_odr constant { i8, ptr } { i8 21, ptr @"reflect/types.type:basic:uint8" }, align 4
|
||||
@"reflect/types.type:basic:int" = linkonce_odr constant { i8, ptr } { i8 2, ptr @"reflect/types.type:pointer:basic:int" }, align 4
|
||||
@"reflect/types.type:pointer:basic:int" = linkonce_odr constant { i8, ptr } { i8 21, ptr @"reflect/types.type:basic:int" }, align 4
|
||||
@"reflect/types.type:pointer:named:Number" = linkonce_odr constant { i8, ptr } { i8 21, ptr @"reflect/types.type:named:Number" }, align 4
|
||||
@"reflect/types.type:named:Number" = linkonce_odr constant { i8, ptr, ptr } { i8 34, ptr @"reflect/types.type:pointer:named:Number", ptr @"reflect/types.type:basic:int" }, align 4
|
||||
|
||||
declare void @runtime.printuint8(i8)
|
||||
|
||||
|
@ -18,40 +18,40 @@ declare void @runtime.printptr(i32)
|
|||
|
||||
declare void @runtime.printnl()
|
||||
|
||||
declare void @runtime.nilPanic(i8*)
|
||||
declare void @runtime.nilPanic(ptr)
|
||||
|
||||
define void @printInterfaces() {
|
||||
call void @printInterface(i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:basic:int", i32 0, i32 0), i8* inttoptr (i32 5 to i8*))
|
||||
call void @printInterface(i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:basic:uint8", i32 0, i32 0), i8* inttoptr (i8 120 to i8*))
|
||||
call void @printInterface(i8* getelementptr inbounds ({ i8, i8*, i8* }, { i8, i8*, i8* }* @"reflect/types.type:named:Number", i32 0, i32 0), i8* inttoptr (i32 3 to i8*))
|
||||
call void @printInterface(ptr @"reflect/types.type:basic:int", ptr inttoptr (i32 5 to ptr))
|
||||
call void @printInterface(ptr @"reflect/types.type:basic:uint8", ptr inttoptr (i8 120 to ptr))
|
||||
call void @printInterface(ptr @"reflect/types.type:named:Number", ptr inttoptr (i32 3 to ptr))
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @printInterface(i8* %typecode, i8* %value) {
|
||||
%isUnmatched = call i1 @"Unmatched$typeassert"(i8* %typecode)
|
||||
define void @printInterface(ptr %typecode, ptr %value) {
|
||||
%isUnmatched = call i1 @"Unmatched$typeassert"(ptr %typecode)
|
||||
br i1 %isUnmatched, label %typeswitch.Unmatched, label %typeswitch.notUnmatched
|
||||
|
||||
typeswitch.Unmatched: ; preds = %0
|
||||
%unmatched = ptrtoint i8* %value to i32
|
||||
%unmatched = ptrtoint ptr %value to i32
|
||||
call void @runtime.printptr(i32 %unmatched)
|
||||
call void @runtime.printnl()
|
||||
ret void
|
||||
|
||||
typeswitch.notUnmatched: ; preds = %0
|
||||
%isDoubler = call i1 @"Doubler$typeassert"(i8* %typecode)
|
||||
%isDoubler = call i1 @"Doubler$typeassert"(ptr %typecode)
|
||||
br i1 %isDoubler, label %typeswitch.Doubler, label %typeswitch.notDoubler
|
||||
|
||||
typeswitch.Doubler: ; preds = %typeswitch.notUnmatched
|
||||
%doubler.result = call i32 @"Doubler.Double$invoke"(i8* %value, i8* %typecode, i8* undef)
|
||||
%doubler.result = call i32 @"Doubler.Double$invoke"(ptr %value, ptr %typecode, ptr undef)
|
||||
call void @runtime.printint32(i32 %doubler.result)
|
||||
ret void
|
||||
|
||||
typeswitch.notDoubler: ; preds = %typeswitch.notUnmatched
|
||||
%typeassert.ok = icmp eq i8* getelementptr inbounds ({ i8, i8* }, { i8, i8* }* @"reflect/types.type:basic:uint8", i32 0, i32 0), %typecode
|
||||
%typeassert.ok = icmp eq ptr @"reflect/types.type:basic:uint8", %typecode
|
||||
br i1 %typeassert.ok, label %typeswitch.byte, label %typeswitch.notByte
|
||||
|
||||
typeswitch.byte: ; preds = %typeswitch.notDoubler
|
||||
%byte = ptrtoint i8* %value to i8
|
||||
%byte = ptrtoint ptr %value to i8
|
||||
call void @runtime.printuint8(i8 %byte)
|
||||
call void @runtime.printnl()
|
||||
ret void
|
||||
|
@ -60,7 +60,7 @@ typeswitch.notByte: ; preds = %typeswitch.notDoubl
|
|||
br i1 false, label %typeswitch.int16, label %typeswitch.notInt16
|
||||
|
||||
typeswitch.int16: ; preds = %typeswitch.notByte
|
||||
%int16 = ptrtoint i8* %value to i16
|
||||
%int16 = ptrtoint ptr %value to i16
|
||||
call void @runtime.printint16(i16 %int16)
|
||||
call void @runtime.printnl()
|
||||
ret void
|
||||
|
@ -69,34 +69,34 @@ typeswitch.notInt16: ; preds = %typeswitch.notByte
|
|||
ret void
|
||||
}
|
||||
|
||||
define i32 @"(Number).Double"(i32 %receiver, i8* %context) {
|
||||
define i32 @"(Number).Double"(i32 %receiver, ptr %context) {
|
||||
%ret = mul i32 %receiver, 2
|
||||
ret i32 %ret
|
||||
}
|
||||
|
||||
define i32 @"(Number).Double$invoke"(i8* %receiverPtr, i8* %context) {
|
||||
%receiver = ptrtoint i8* %receiverPtr to i32
|
||||
%ret = call i32 @"(Number).Double"(i32 %receiver, i8* undef)
|
||||
define i32 @"(Number).Double$invoke"(ptr %receiverPtr, ptr %context) {
|
||||
%receiver = ptrtoint ptr %receiverPtr to i32
|
||||
%ret = call i32 @"(Number).Double"(i32 %receiver, ptr undef)
|
||||
ret i32 %ret
|
||||
}
|
||||
|
||||
define internal i32 @"Doubler.Double$invoke"(i8* %receiver, i8* %actualType, i8* %context) unnamed_addr #0 {
|
||||
define internal i32 @"Doubler.Double$invoke"(ptr %receiver, ptr %actualType, ptr %context) unnamed_addr #0 {
|
||||
entry:
|
||||
%"named:Number.icmp" = icmp eq i8* %actualType, getelementptr inbounds ({ i8, i8*, i8* }, { i8, i8*, i8* }* @"reflect/types.type:named:Number", i32 0, i32 0)
|
||||
%"named:Number.icmp" = icmp eq ptr %actualType, @"reflect/types.type:named:Number"
|
||||
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)
|
||||
%0 = call i32 @"(Number).Double$invoke"(ptr %receiver, ptr undef)
|
||||
ret i32 %0
|
||||
|
||||
"named:Number.next": ; preds = %entry
|
||||
call void @runtime.nilPanic(i8* undef)
|
||||
call void @runtime.nilPanic(ptr undef)
|
||||
unreachable
|
||||
}
|
||||
|
||||
define internal i1 @"Doubler$typeassert"(i8* %actualType) unnamed_addr #1 {
|
||||
define internal i1 @"Doubler$typeassert"(ptr %actualType) unnamed_addr #1 {
|
||||
entry:
|
||||
%"named:Number.icmp" = icmp eq i8* %actualType, getelementptr inbounds ({ i8, i8*, i8* }, { i8, i8*, i8* }* @"reflect/types.type:named:Number", i32 0, i32 0)
|
||||
%"named:Number.icmp" = icmp eq ptr %actualType, @"reflect/types.type:named:Number"
|
||||
br i1 %"named:Number.icmp", label %then, label %"named:Number.next"
|
||||
|
||||
then: ; preds = %entry
|
||||
|
@ -106,7 +106,7 @@ then: ; preds = %entry
|
|||
ret i1 false
|
||||
}
|
||||
|
||||
define internal i1 @"Unmatched$typeassert"(i8* %actualType) unnamed_addr #2 {
|
||||
define internal i1 @"Unmatched$typeassert"(ptr %actualType) unnamed_addr #2 {
|
||||
entry:
|
||||
ret i1 false
|
||||
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче