github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/transform/testdata/interface.out.ll (about) 1 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" 2 target triple = "armv7m-none-eabi" 3 4 @"reflect/types.type:basic:uint8" = linkonce_odr constant { i8, ptr } { i8 8, ptr @"reflect/types.type:pointer:basic:uint8" }, align 4 5 @"reflect/types.type:pointer:basic:uint8" = linkonce_odr constant { i8, ptr } { i8 21, ptr @"reflect/types.type:basic:uint8" }, align 4 6 @"reflect/types.type:basic:int" = linkonce_odr constant { i8, ptr } { i8 2, ptr @"reflect/types.type:pointer:basic:int" }, align 4 7 @"reflect/types.type:pointer:basic:int" = linkonce_odr constant { i8, ptr } { i8 21, ptr @"reflect/types.type:basic:int" }, align 4 8 @"reflect/types.type:pointer:named:Number" = linkonce_odr constant { i8, ptr } { i8 21, ptr @"reflect/types.type:named:Number" }, align 4 9 @"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 10 11 declare void @runtime.printuint8(i8) 12 13 declare void @runtime.printint16(i16) 14 15 declare void @runtime.printint32(i32) 16 17 declare void @runtime.printptr(i32) 18 19 declare void @runtime.printnl() 20 21 declare void @runtime.nilPanic(ptr) 22 23 define void @printInterfaces() { 24 call void @printInterface(ptr @"reflect/types.type:basic:int", ptr inttoptr (i32 5 to ptr)) 25 call void @printInterface(ptr @"reflect/types.type:basic:uint8", ptr inttoptr (i8 120 to ptr)) 26 call void @printInterface(ptr @"reflect/types.type:named:Number", ptr inttoptr (i32 3 to ptr)) 27 ret void 28 } 29 30 define void @printInterface(ptr %typecode, ptr %value) { 31 %isUnmatched = call i1 @"Unmatched$typeassert"(ptr %typecode) 32 br i1 %isUnmatched, label %typeswitch.Unmatched, label %typeswitch.notUnmatched 33 34 typeswitch.Unmatched: ; preds = %0 35 %unmatched = ptrtoint ptr %value to i32 36 call void @runtime.printptr(i32 %unmatched) 37 call void @runtime.printnl() 38 ret void 39 40 typeswitch.notUnmatched: ; preds = %0 41 %isDoubler = call i1 @"Doubler$typeassert"(ptr %typecode) 42 br i1 %isDoubler, label %typeswitch.Doubler, label %typeswitch.notDoubler 43 44 typeswitch.Doubler: ; preds = %typeswitch.notUnmatched 45 %doubler.result = call i32 @"Doubler.Double$invoke"(ptr %value, ptr %typecode, ptr undef) 46 call void @runtime.printint32(i32 %doubler.result) 47 ret void 48 49 typeswitch.notDoubler: ; preds = %typeswitch.notUnmatched 50 %typeassert.ok = icmp eq ptr @"reflect/types.type:basic:uint8", %typecode 51 br i1 %typeassert.ok, label %typeswitch.byte, label %typeswitch.notByte 52 53 typeswitch.byte: ; preds = %typeswitch.notDoubler 54 %byte = ptrtoint ptr %value to i8 55 call void @runtime.printuint8(i8 %byte) 56 call void @runtime.printnl() 57 ret void 58 59 typeswitch.notByte: ; preds = %typeswitch.notDoubler 60 br i1 false, label %typeswitch.int16, label %typeswitch.notInt16 61 62 typeswitch.int16: ; preds = %typeswitch.notByte 63 %int16 = ptrtoint ptr %value to i16 64 call void @runtime.printint16(i16 %int16) 65 call void @runtime.printnl() 66 ret void 67 68 typeswitch.notInt16: ; preds = %typeswitch.notByte 69 ret void 70 } 71 72 define i32 @"(Number).Double"(i32 %receiver, ptr %context) { 73 %ret = mul i32 %receiver, 2 74 ret i32 %ret 75 } 76 77 define i32 @"(Number).Double$invoke"(ptr %receiverPtr, ptr %context) { 78 %receiver = ptrtoint ptr %receiverPtr to i32 79 %ret = call i32 @"(Number).Double"(i32 %receiver, ptr undef) 80 ret i32 %ret 81 } 82 83 define internal i32 @"Doubler.Double$invoke"(ptr %receiver, ptr %actualType, ptr %context) unnamed_addr #0 { 84 entry: 85 %"named:Number.icmp" = icmp eq ptr %actualType, @"reflect/types.type:named:Number" 86 br i1 %"named:Number.icmp", label %"named:Number", label %"named:Number.next" 87 88 "named:Number": ; preds = %entry 89 %0 = call i32 @"(Number).Double$invoke"(ptr %receiver, ptr undef) 90 ret i32 %0 91 92 "named:Number.next": ; preds = %entry 93 call void @runtime.nilPanic(ptr undef) 94 unreachable 95 } 96 97 define internal i1 @"Doubler$typeassert"(ptr %actualType) unnamed_addr #1 { 98 entry: 99 %"named:Number.icmp" = icmp eq ptr %actualType, @"reflect/types.type:named:Number" 100 br i1 %"named:Number.icmp", label %then, label %"named:Number.next" 101 102 then: ; preds = %entry 103 ret i1 true 104 105 "named:Number.next": ; preds = %entry 106 ret i1 false 107 } 108 109 define internal i1 @"Unmatched$typeassert"(ptr %actualType) unnamed_addr #2 { 110 entry: 111 ret i1 false 112 113 then: ; No predecessors! 114 ret i1 true 115 } 116 117 attributes #0 = { "tinygo-invoke"="reflect/methods.Double() int" "tinygo-methods"="reflect/methods.Double() int" } 118 attributes #1 = { "tinygo-methods"="reflect/methods.Double() int" } 119 attributes #2 = { "tinygo-methods"="reflect/methods.NeverImplementedMethod()" }