Skip to content

Commit

Permalink
Merge pull request #916 from visualfc/runtime.interface
Browse files Browse the repository at this point in the history
abi: fix named interface init
  • Loading branch information
xushiwei authored Dec 17, 2024
2 parents 424670d + e55a5d7 commit b4af70a
Show file tree
Hide file tree
Showing 8 changed files with 1,217 additions and 1,061 deletions.
213 changes: 119 additions & 94 deletions cl/_testgo/ifaceconv/out.ll

Large diffs are not rendered by default.

45 changes: 28 additions & 17 deletions cl/_testgo/ifaceprom/out.ll
Original file line number Diff line number Diff line change
Expand Up @@ -566,28 +566,35 @@ _llgo_10: ; preds = %_llgo_9, %_llgo_8
%78 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %77, i64 2, 2
%79 = call ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, %"github.com/goplus/llgo/internal/runtime.Slice" %78)
store ptr %79, ptr @"main.iface$zZ89tENb5h_KNjvpxf1TXPfaWFYn0IZrZwyVf42lRtA", align 8
%80 = load ptr, ptr @"_llgo_func$ETeB8WwW04JEq0ztcm-XPTJtuYvtpkjIsAc0-2NT9zA", align 8
%81 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
%82 = load ptr, ptr @_llgo_main.I, align 8
%83 = icmp eq ptr %82, null
br i1 %83, label %_llgo_11, label %_llgo_12
%80 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 6 })
%81 = load ptr, ptr @_llgo_main.I, align 8
%82 = icmp eq ptr %81, null
br i1 %82, label %_llgo_11, label %_llgo_12

_llgo_11: ; preds = %_llgo_10
%84 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 8 }, ptr undef }, ptr %80, 1
%85 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 8 }, ptr undef }, ptr %81, 1
%86 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
%87 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %86, i64 0
store %"github.com/goplus/llgo/internal/abi.Imethod" %84, ptr %87, align 8
%88 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %86, i64 1
store %"github.com/goplus/llgo/internal/abi.Imethod" %85, ptr %88, align 8
%89 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %86, 0
%90 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %89, i64 2, 1
%91 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %90, i64 2, 2
%92 = call ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 6 }, %"github.com/goplus/llgo/internal/runtime.Slice" %91)
store ptr %92, ptr @_llgo_main.I, align 8
store ptr %80, ptr @_llgo_main.I, align 8
br label %_llgo_12

_llgo_12: ; preds = %_llgo_11, %_llgo_10
%83 = load ptr, ptr @"_llgo_func$ETeB8WwW04JEq0ztcm-XPTJtuYvtpkjIsAc0-2NT9zA", align 8
%84 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
br i1 %82, label %_llgo_13, label %_llgo_14

_llgo_13: ; preds = %_llgo_12
%85 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 8 }, ptr undef }, ptr %83, 1
%86 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 8 }, ptr undef }, ptr %84, 1
%87 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
%88 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %87, i64 0
store %"github.com/goplus/llgo/internal/abi.Imethod" %85, ptr %88, align 8
%89 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %87, i64 1
store %"github.com/goplus/llgo/internal/abi.Imethod" %86, ptr %89, align 8
%90 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %87, 0
%91 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %90, i64 2, 1
%92 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %91, i64 2, 2
call void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr %80, %"github.com/goplus/llgo/internal/runtime.Slice" %92)
br label %_llgo_14

_llgo_14: ; preds = %_llgo_13, %_llgo_12
ret void
}

Expand Down Expand Up @@ -615,6 +622,10 @@ declare void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplu

declare ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface")

declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String")

declare void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr, %"github.com/goplus/llgo/internal/runtime.Slice")

declare i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr, ptr)

define i64 @"main.one$bound"(ptr %0) {
Expand Down
47 changes: 29 additions & 18 deletions cl/_testgo/interface/out.ll
Original file line number Diff line number Diff line change
Expand Up @@ -403,28 +403,35 @@ _llgo_23: ; preds = %_llgo_22
br label %_llgo_24

_llgo_24: ; preds = %_llgo_23, %_llgo_22
%100 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
%101 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
%102 = load ptr, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Gamer", align 8
%103 = icmp eq ptr %102, null
br i1 %103, label %_llgo_25, label %_llgo_26
%100 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 38 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @12, i64 44 })
%101 = load ptr, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Gamer", align 8
%102 = icmp eq ptr %101, null
br i1 %102, label %_llgo_25, label %_llgo_26

_llgo_25: ; preds = %_llgo_24
%104 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 4 }, ptr undef }, ptr %100, 1
%105 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 47 }, ptr undef }, ptr %101, 1
%106 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
%107 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %106, i64 0
store %"github.com/goplus/llgo/internal/abi.Imethod" %104, ptr %107, align 8
%108 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %106, i64 1
store %"github.com/goplus/llgo/internal/abi.Imethod" %105, ptr %108, align 8
%109 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %106, 0
%110 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %109, i64 2, 1
%111 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %110, i64 2, 2
%112 = call ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 38 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @12, i64 44 }, %"github.com/goplus/llgo/internal/runtime.Slice" %111)
store ptr %112, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Gamer", align 8
store ptr %100, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Gamer", align 8
br label %_llgo_26

_llgo_26: ; preds = %_llgo_25, %_llgo_24
%103 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
%104 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
br i1 %102, label %_llgo_27, label %_llgo_28

_llgo_27: ; preds = %_llgo_26
%105 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 4 }, ptr undef }, ptr %103, 1
%106 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 47 }, ptr undef }, ptr %104, 1
%107 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
%108 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %107, i64 0
store %"github.com/goplus/llgo/internal/abi.Imethod" %105, ptr %108, align 8
%109 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %107, i64 1
store %"github.com/goplus/llgo/internal/abi.Imethod" %106, ptr %109, align 8
%110 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %107, 0
%111 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %110, i64 2, 1
%112 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %111, i64 2, 2
call void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr %100, %"github.com/goplus/llgo/internal/runtime.Slice" %112)
br label %_llgo_28

_llgo_28: ; preds = %_llgo_27, %_llgo_26
%113 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
%114 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
%115 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 4 }, ptr undef }, ptr %113, 1
Expand Down Expand Up @@ -458,10 +465,14 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/

declare ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr)

declare ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.Slice")
declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String")

declare void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr, %"github.com/goplus/llgo/internal/runtime.Slice")

declare i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr, ptr)

declare ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.Slice")

declare ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr, ptr)

declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String")
Expand Down
39 changes: 25 additions & 14 deletions cl/_testgo/invoke/out.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1016,38 +1016,45 @@ _llgo_61: ; preds = %_llgo_60
br label %_llgo_62

_llgo_62: ; preds = %_llgo_61, %_llgo_60
%279 = load ptr, ptr @"_llgo_func$ETeB8WwW04JEq0ztcm-XPTJtuYvtpkjIsAc0-2NT9zA", align 8
%279 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @10, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @30, i64 6 })
%280 = load ptr, ptr @_llgo_main.I, align 8
%281 = icmp eq ptr %280, null
br i1 %281, label %_llgo_63, label %_llgo_64

_llgo_63: ; preds = %_llgo_62
%282 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @11, i64 6 }, ptr undef }, ptr %279, 1
%283 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
%284 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %283, i64 0
store %"github.com/goplus/llgo/internal/abi.Imethod" %282, ptr %284, align 8
%285 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %283, 0
%286 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %285, i64 1, 1
%287 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %286, i64 1, 2
%288 = call ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @10, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @30, i64 6 }, %"github.com/goplus/llgo/internal/runtime.Slice" %287)
store ptr %288, ptr @_llgo_main.I, align 8
store ptr %279, ptr @_llgo_main.I, align 8
br label %_llgo_64

_llgo_64: ; preds = %_llgo_63, %_llgo_62
%282 = load ptr, ptr @"_llgo_func$ETeB8WwW04JEq0ztcm-XPTJtuYvtpkjIsAc0-2NT9zA", align 8
br i1 %281, label %_llgo_65, label %_llgo_66

_llgo_65: ; preds = %_llgo_64
%283 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @11, i64 6 }, ptr undef }, ptr %282, 1
%284 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
%285 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %284, i64 0
store %"github.com/goplus/llgo/internal/abi.Imethod" %283, ptr %285, align 8
%286 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %284, 0
%287 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %286, i64 1, 1
%288 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %287, i64 1, 2
call void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr %279, %"github.com/goplus/llgo/internal/runtime.Slice" %288)
br label %_llgo_66

_llgo_66: ; preds = %_llgo_65, %_llgo_64
%289 = load ptr, ptr @_llgo_any, align 8
%290 = icmp eq ptr %289, null
br i1 %290, label %_llgo_65, label %_llgo_66
br i1 %290, label %_llgo_67, label %_llgo_68

_llgo_65: ; preds = %_llgo_64
_llgo_67: ; preds = %_llgo_66
%291 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
%292 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %291, 0
%293 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %292, i64 0, 1
%294 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %293, i64 0, 2
%295 = call ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @10, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, %"github.com/goplus/llgo/internal/runtime.Slice" %294)
store ptr %295, ptr @_llgo_any, align 8
br label %_llgo_66
br label %_llgo_68

_llgo_66: ; preds = %_llgo_65, %_llgo_64
_llgo_68: ; preds = %_llgo_67, %_llgo_66
ret void
}

Expand Down Expand Up @@ -1081,6 +1088,10 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/go

declare void @"github.com/goplus/llgo/internal/runtime.PrintIface"(%"github.com/goplus/llgo/internal/runtime.iface")

declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String")

declare void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr, %"github.com/goplus/llgo/internal/runtime.Slice")

declare i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr, ptr)

declare void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface")
Expand Down
Loading

0 comments on commit b4af70a

Please sign in to comment.