diff --git a/compiler/cl/internal/foo/foo.go b/compiler/cl/_testdata/foo/foo.go similarity index 100% rename from compiler/cl/internal/foo/foo.go rename to compiler/cl/_testdata/foo/foo.go diff --git a/compiler/cl/_testdata/foo/out.ll b/compiler/cl/_testdata/foo/out.ll new file mode 100644 index 00000000..a71b56e3 --- /dev/null +++ b/compiler/cl/_testdata/foo/out.ll @@ -0,0 +1,151 @@ +; ModuleID = 'github.com/goplus/llgo/compiler/cl/_testdata/foo' +source_filename = "github.com/goplus/llgo/compiler/cl/_testdata/foo" + +%"github.com/goplus/llgo/runtime/internal/runtime.eface" = type { ptr, ptr } +%"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo" = type { ptr, float } +%"github.com/goplus/llgo/runtime/internal/runtime.String" = type { ptr, i64 } +%"github.com/goplus/llgo/runtime/abi.StructField" = type { %"github.com/goplus/llgo/runtime/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/runtime/internal/runtime.String", i1 } +%"github.com/goplus/llgo/runtime/internal/runtime.Slice" = type { ptr, i64, i64 } + +@"github.com/goplus/llgo/compiler/cl/_testdata/foo.init$guard" = global i1 false, align 1 +@_llgo_int = linkonce global ptr null, align 8 +@"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk" = linkonce global ptr null, align 8 +@0 = private unnamed_addr constant [1 x i8] c"V", align 1 +@1 = private unnamed_addr constant [48 x i8] c"github.com/goplus/llgo/compiler/cl/_testdata/foo", align 1 +@"github.com/goplus/llgo/compiler/cl/_testdata/foo.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88" = linkonce global ptr null, align 8 +@2 = private unnamed_addr constant [1 x i8] c"v", align 1 +@3 = private unnamed_addr constant [4 x i8] c"load", align 1 + +define %"github.com/goplus/llgo/runtime/internal/runtime.eface" @"github.com/goplus/llgo/compiler/cl/_testdata/foo.Bar"() { +_llgo_0: + %0 = alloca { i64 }, align 8 + call void @llvm.memset(ptr %0, i8 0, i64 8, i1 false) + %1 = getelementptr inbounds { i64 }, ptr %0, i32 0, i32 0 + store i64 1, ptr %1, align 4 + %2 = load { i64 }, ptr %0, align 4 + %3 = load ptr, ptr @_llgo_int, align 8 + %4 = load ptr, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 + %5 = extractvalue { i64 } %2, 0 + %6 = inttoptr i64 %5 to ptr + %7 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %4, 0 + %8 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %7, ptr %6, 1 + ret %"github.com/goplus/llgo/runtime/internal/runtime.eface" %8 +} + +define %"github.com/goplus/llgo/runtime/internal/runtime.eface" @"github.com/goplus/llgo/compiler/cl/_testdata/foo.F"() { +_llgo_0: + %0 = alloca { i64 }, align 8 + call void @llvm.memset(ptr %0, i8 0, i64 8, i1 false) + %1 = getelementptr inbounds { i64 }, ptr %0, i32 0, i32 0 + store i64 1, ptr %1, align 4 + %2 = load { i64 }, ptr %0, align 4 + %3 = load ptr, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8 + %4 = extractvalue { i64 } %2, 0 + %5 = inttoptr i64 %4 to ptr + %6 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %3, 0 + %7 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %6, ptr %5, 1 + ret %"github.com/goplus/llgo/runtime/internal/runtime.eface" %7 +} + +define ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo.Pb"(%"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo" %0) { +_llgo_0: + %1 = alloca %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", align 8 + call void @llvm.memset(ptr %1, i8 0, i64 16, i1 false) + store %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo" %0, ptr %1, align 8 + %2 = getelementptr inbounds %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", ptr %1, i32 0, i32 0 + %3 = load ptr, ptr %2, align 8 + ret ptr %3 +} + +define ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Foo).Pb"(ptr %0) { +_llgo_0: + %1 = load %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", ptr %0, align 8 + %2 = call ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo.Pb"(%"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo" %1) + ret ptr %2 +} + +define void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).Load"(ptr %0) { +_llgo_0: + call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintString"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @3, i64 4 }) + call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 10) + ret void +} + +define void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).initGame"(ptr %0) { +_llgo_0: + ret void +} + +define void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.init"() { +_llgo_0: + %0 = load i1, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.init$guard", align 1 + br i1 %0, label %_llgo_2, label %_llgo_1 + +_llgo_1: ; preds = %_llgo_0 + store i1 true, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.init$guard", align 1 + call void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.init$after"() + br label %_llgo_2 + +_llgo_2: ; preds = %_llgo_1, %_llgo_0 + ret void +} + +; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write) +declare void @llvm.memset(ptr nocapture writeonly, i8, i64, i1 immarg) #0 + +define void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.init$after"() { +_llgo_0: + %0 = load ptr, ptr @_llgo_int, align 8 + %1 = icmp eq ptr %0, null + br i1 %1, label %_llgo_1, label %_llgo_2 + +_llgo_1: ; preds = %_llgo_0 + %2 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64 34) + store ptr %2, ptr @_llgo_int, align 8 + br label %_llgo_2 + +_llgo_2: ; preds = %_llgo_1, %_llgo_0 + %3 = load ptr, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 + %4 = icmp eq ptr %3, null + br i1 %4, label %_llgo_3, label %_llgo_4 + +_llgo_3: ; preds = %_llgo_2 + %5 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64 34) + %6 = call %"github.com/goplus/llgo/runtime/abi.StructField" @"github.com/goplus/llgo/runtime/internal/runtime.StructField"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 1 }, ptr %5, i64 0, %"github.com/goplus/llgo/runtime/internal/runtime.String" zeroinitializer, i1 false) + %7 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 56) + %8 = getelementptr %"github.com/goplus/llgo/runtime/abi.StructField", ptr %7, i64 0 + store %"github.com/goplus/llgo/runtime/abi.StructField" %6, ptr %8, align 8 + %9 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %7, 0 + %10 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %9, i64 1, 1 + %11 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %10, i64 1, 2 + %12 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Struct"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @1, i64 48 }, i64 8, %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %11) + store ptr %12, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 + br label %_llgo_4 + +_llgo_4: ; preds = %_llgo_3, %_llgo_2 + %13 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64 34) + %14 = call %"github.com/goplus/llgo/runtime/abi.StructField" @"github.com/goplus/llgo/runtime/internal/runtime.StructField"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @2, i64 1 }, ptr %13, i64 0, %"github.com/goplus/llgo/runtime/internal/runtime.String" zeroinitializer, i1 false) + %15 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 56) + %16 = getelementptr %"github.com/goplus/llgo/runtime/abi.StructField", ptr %15, i64 0 + store %"github.com/goplus/llgo/runtime/abi.StructField" %14, ptr %16, align 8 + %17 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %15, 0 + %18 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %17, i64 1, 1 + %19 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %18, i64 1, 2 + %20 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Struct"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @1, i64 48 }, i64 8, %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %19) + store ptr %20, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8 + ret void +} + +declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64) + +declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.Struct"(%"github.com/goplus/llgo/runtime/internal/runtime.String", i64, %"github.com/goplus/llgo/runtime/internal/runtime.Slice") + +declare %"github.com/goplus/llgo/runtime/abi.StructField" @"github.com/goplus/llgo/runtime/internal/runtime.StructField"(%"github.com/goplus/llgo/runtime/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/runtime/internal/runtime.String", i1) + +declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64) + +declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintString"(%"github.com/goplus/llgo/runtime/internal/runtime.String") + +declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8) + +attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) } diff --git a/compiler/cl/_testdata/importpkg/in.go b/compiler/cl/_testdata/importpkg/in.go index c57effda..60d4ad62 100644 --- a/compiler/cl/_testdata/importpkg/in.go +++ b/compiler/cl/_testdata/importpkg/in.go @@ -1,6 +1,6 @@ package main -import "github.com/goplus/llgo/compiler/cl/internal/stdio" +import "github.com/goplus/llgo/compiler/cl/_testdata/importpkg/stdio" var hello = [...]int8{'H', 'e', 'l', 'l', 'o', '\n', 0} diff --git a/compiler/cl/_testdata/importpkg/out.ll b/compiler/cl/_testdata/importpkg/out.ll index 04124b67..8142bfc9 100644 --- a/compiler/cl/_testdata/importpkg/out.ll +++ b/compiler/cl/_testdata/importpkg/out.ll @@ -13,7 +13,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 - call void @"github.com/goplus/llgo/compiler/cl/internal/stdio.init"() + call void @"github.com/goplus/llgo/compiler/cl/_testdata/importpkg/stdio.init"() store i8 72, ptr @main.hello, align 1 store i8 101, ptr getelementptr inbounds (i8, ptr @main.hello, i64 1), align 1 store i8 108, ptr getelementptr inbounds (i8, ptr @main.hello, i64 2), align 1 @@ -33,15 +33,15 @@ _llgo_0: store ptr %1, ptr @__llgo_argv, align 8 call void @"github.com/goplus/llgo/runtime/internal/runtime.init"() call void @main.init() - %2 = call i64 @"github.com/goplus/llgo/compiler/cl/internal/stdio.Max"(i64 2, i64 100) + %2 = call i64 @"github.com/goplus/llgo/compiler/cl/_testdata/importpkg/stdio.Max"(i64 2, i64 100) call void (ptr, ...) @printf(ptr @main.hello) ret i32 0 } -declare void @"github.com/goplus/llgo/compiler/cl/internal/stdio.init"() +declare void @"github.com/goplus/llgo/compiler/cl/_testdata/importpkg/stdio.init"() declare void @"github.com/goplus/llgo/runtime/internal/runtime.init"() -declare i64 @"github.com/goplus/llgo/compiler/cl/internal/stdio.Max"(i64, i64) +declare i64 @"github.com/goplus/llgo/compiler/cl/_testdata/importpkg/stdio.Max"(i64, i64) declare void @printf(ptr, ...) diff --git a/compiler/cl/internal/stdio/printf.go b/compiler/cl/_testdata/importpkg/stdio/printf.go similarity index 100% rename from compiler/cl/internal/stdio/printf.go rename to compiler/cl/_testdata/importpkg/stdio/printf.go diff --git a/compiler/cl/_testgo/interface/in.go b/compiler/cl/_testgo/interface/in.go index 76948815..600008ce 100644 --- a/compiler/cl/_testgo/interface/in.go +++ b/compiler/cl/_testgo/interface/in.go @@ -1,7 +1,7 @@ package main import ( - "github.com/goplus/llgo/compiler/cl/internal/foo" + "github.com/goplus/llgo/compiler/cl/_testdata/foo" ) type Game1 struct { diff --git a/compiler/cl/_testgo/interface/out.ll b/compiler/cl/_testgo/interface/out.ll index bac4f49d..0b7780d8 100644 --- a/compiler/cl/_testgo/interface/out.ll +++ b/compiler/cl/_testgo/interface/out.ll @@ -16,22 +16,22 @@ source_filename = "main" @_llgo_main.Game1 = linkonce global ptr null, align 8 @0 = private unnamed_addr constant [4 x i8] c"main", align 1 @1 = private unnamed_addr constant [5 x i8] c"Game1", align 1 -@"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Game" = linkonce global ptr null, align 8 -@2 = private unnamed_addr constant [47 x i8] c"github.com/goplus/llgo/compiler/cl/internal/foo", align 1 +@"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Game" = linkonce global ptr null, align 8 +@2 = private unnamed_addr constant [48 x i8] c"github.com/goplus/llgo/compiler/cl/_testdata/foo", align 1 @3 = private unnamed_addr constant [4 x i8] c"Game", align 1 @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw" = linkonce global ptr null, align 8 @4 = private unnamed_addr constant [4 x i8] c"Load", align 1 @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac" = linkonce global ptr null, align 8 @5 = private unnamed_addr constant [8 x i8] c"initGame", align 1 -@6 = private unnamed_addr constant [56 x i8] c"github.com/goplus/llgo/compiler/cl/internal/foo.initGame", align 1 -@"*_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Game" = linkonce global ptr null, align 8 -@"_llgo_struct$qa3Pttfm1GQvokHektasLRsX-bwAs-LsF1bLMI_aThw" = linkonce global ptr null, align 8 +@6 = private unnamed_addr constant [57 x i8] c"github.com/goplus/llgo/compiler/cl/_testdata/foo.initGame", align 1 +@"*_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Game" = linkonce global ptr null, align 8 +@"_llgo_struct$8pZiNl4ZxK-lZr-eyXOGJ2lgSsNDx-SmrHiChs0Nc-o" = linkonce global ptr null, align 8 @"*_llgo_main.Game1" = linkonce global ptr null, align 8 @_llgo_main.Game2 = linkonce global ptr null, align 8 @7 = private unnamed_addr constant [5 x i8] c"Game2", align 1 @8 = private unnamed_addr constant [13 x i8] c"main.initGame", align 1 @"*_llgo_main.Game2" = linkonce global ptr null, align 8 -@"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Gamer" = linkonce global ptr null, align 8 +@"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Gamer" = linkonce global ptr null, align 8 @9 = private unnamed_addr constant [5 x i8] c"Gamer", align 1 @"main.iface$sO8a1LvuUsjXwiwaC6sR9-L4DiYgiOnZi7iosyShJXg" = linkonce global ptr null, align 8 @10 = private unnamed_addr constant [2 x i8] c"OK", align 1 @@ -44,7 +44,7 @@ _llgo_0: store %main.Game1 %0, ptr %1, align 8 %2 = getelementptr inbounds %main.Game1, ptr %1, i32 0, i32 0 %3 = load ptr, ptr %2, align 8 - call void @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Game).Load"(ptr %3) + call void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).Load"(ptr %3) ret void } @@ -55,7 +55,7 @@ _llgo_0: store %main.Game1 %0, ptr %1, align 8 %2 = getelementptr inbounds %main.Game1, ptr %1, i32 0, i32 0 %3 = load ptr, ptr %2, align 8 - call void @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Game).initGame"(ptr %3) + call void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).initGame"(ptr %3) ret void } @@ -63,7 +63,7 @@ define void @"main.(*Game1).Load"(ptr %0) { _llgo_0: %1 = getelementptr inbounds %main.Game1, ptr %0, i32 0, i32 0 %2 = load ptr, ptr %1, align 8 - call void @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Game).Load"(ptr %2) + call void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).Load"(ptr %2) ret void } @@ -71,7 +71,7 @@ define void @"main.(*Game1).initGame"(ptr %0) { _llgo_0: %1 = getelementptr inbounds %main.Game1, ptr %0, i32 0, i32 0 %2 = load ptr, ptr %1, align 8 - call void @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Game).initGame"(ptr %2) + call void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).initGame"(ptr %2) ret void } @@ -87,7 +87,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 - call void @"github.com/goplus/llgo/compiler/cl/internal/foo.init"() + call void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.init"() call void @"main.init$after"() br label %_llgo_2 @@ -115,7 +115,7 @@ _llgo_0: %12 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %11, 0 %13 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %12, ptr %9, 1 %14 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %8, 0 - %15 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Gamer", align 8 + %15 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Gamer", align 8 %16 = call i1 @"github.com/goplus/llgo/runtime/internal/runtime.Implements"(ptr %15, ptr %14) br i1 %16, label %_llgo_3, label %_llgo_4 @@ -133,7 +133,7 @@ _llgo_1: ; preds = %_llgo_5 _llgo_2: ; preds = %_llgo_1, %_llgo_5 %25 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %13, 0 - %26 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Gamer", align 8 + %26 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Gamer", align 8 %27 = call i1 @"github.com/goplus/llgo/runtime/internal/runtime.Implements"(ptr %26, ptr %25) br i1 %27, label %_llgo_6, label %_llgo_7 @@ -191,11 +191,11 @@ _llgo_8: ; preds = %_llgo_7, %_llgo_6 ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write) declare void @llvm.memset(ptr nocapture writeonly, i8, i64, i1 immarg) #0 -declare void @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Game).Load"(ptr) +declare void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).Load"(ptr) -declare void @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Game).initGame"(ptr) +declare void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).initGame"(ptr) -declare void @"github.com/goplus/llgo/compiler/cl/internal/foo.init"() +declare void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.init"() declare void @"github.com/goplus/llgo/runtime/internal/runtime.init"() @@ -214,13 +214,13 @@ _llgo_1: ; preds = %_llgo_0 br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 - %3 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.NewNamed"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @2, i64 47 }, %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @3, i64 4 }, i64 25, i64 0, i64 0, i64 2) - %4 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Game", align 8 + %3 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.NewNamed"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @2, i64 48 }, %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @3, i64 4 }, i64 25, i64 0, i64 0, i64 2) + %4 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Game", align 8 %5 = icmp eq ptr %4, null br i1 %5, label %_llgo_3, label %_llgo_4 _llgo_3: ; preds = %_llgo_2 - store ptr %3, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Game", align 8 + store ptr %3, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Game", align 8 br label %_llgo_4 _llgo_4: ; preds = %_llgo_3, %_llgo_2 @@ -247,9 +247,9 @@ _llgo_7: ; preds = %_llgo_6 br i1 %15, label %_llgo_9, label %_llgo_10 _llgo_8: ; preds = %_llgo_10, %_llgo_6 - %16 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Game", align 8 - %17 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.NewNamed"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @2, i64 47 }, %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @3, i64 4 }, i64 25, i64 0, i64 0, i64 2) - %18 = load ptr, ptr @"*_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Game", align 8 + %16 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Game", align 8 + %17 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.NewNamed"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @2, i64 48 }, %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @3, i64 4 }, i64 25, i64 0, i64 0, i64 2) + %18 = load ptr, ptr @"*_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Game", align 8 %19 = icmp eq ptr %18, null br i1 %19, label %_llgo_11, label %_llgo_12 @@ -270,12 +270,12 @@ _llgo_9: ; preds = %_llgo_7 _llgo_10: ; preds = %_llgo_9, %_llgo_7 %29 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8 %30 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" { %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @4, i64 4 }, ptr undef, ptr undef, ptr undef }, ptr %29, 1 - %31 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %30, ptr @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Game).Load", 2 - %32 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %31, ptr @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Game).Load", 3 + %31 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %30, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).Load", 2 + %32 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %31, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).Load", 3 %33 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8 - %34 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" { %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @6, i64 56 }, ptr undef, ptr undef, ptr undef }, ptr %33, 1 - %35 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %34, ptr @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Game).initGame", 2 - %36 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %35, ptr @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Game).initGame", 3 + %34 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" { %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @6, i64 57 }, ptr undef, ptr undef, ptr undef }, ptr %33, 1 + %35 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %34, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).initGame", 2 + %36 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %35, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).initGame", 3 %37 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 80) %38 = getelementptr %"github.com/goplus/llgo/runtime/abi.Method", ptr %37, i64 0 store %"github.com/goplus/llgo/runtime/abi.Method" %32, ptr %38, align 8 @@ -290,13 +290,13 @@ _llgo_10: ; preds = %_llgo_9, %_llgo_7 _llgo_11: ; preds = %_llgo_8 %43 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.PointerTo"(ptr %17) call void @"github.com/goplus/llgo/runtime/internal/runtime.SetDirectIface"(ptr %43) - store ptr %43, ptr @"*_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Game", align 8 + store ptr %43, ptr @"*_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Game", align 8 br label %_llgo_12 _llgo_12: ; preds = %_llgo_11, %_llgo_8 - %44 = load ptr, ptr @"*_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Game", align 8 - %45 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.NewNamed"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @2, i64 47 }, %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @3, i64 4 }, i64 25, i64 0, i64 0, i64 2) - %46 = load ptr, ptr @"_llgo_struct$qa3Pttfm1GQvokHektasLRsX-bwAs-LsF1bLMI_aThw", align 8 + %44 = load ptr, ptr @"*_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Game", align 8 + %45 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.NewNamed"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @2, i64 48 }, %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @3, i64 4 }, i64 25, i64 0, i64 0, i64 2) + %46 = load ptr, ptr @"_llgo_struct$8pZiNl4ZxK-lZr-eyXOGJ2lgSsNDx-SmrHiChs0Nc-o", align 8 %47 = icmp eq ptr %46, null br i1 %47, label %_llgo_13, label %_llgo_14 @@ -311,11 +311,11 @@ _llgo_13: ; preds = %_llgo_12 %54 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %53, i64 1, 2 %55 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Struct"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 4 }, i64 8, %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %54) call void @"github.com/goplus/llgo/runtime/internal/runtime.SetDirectIface"(ptr %55) - store ptr %55, ptr @"_llgo_struct$qa3Pttfm1GQvokHektasLRsX-bwAs-LsF1bLMI_aThw", align 8 + store ptr %55, ptr @"_llgo_struct$8pZiNl4ZxK-lZr-eyXOGJ2lgSsNDx-SmrHiChs0Nc-o", align 8 br label %_llgo_14 _llgo_14: ; preds = %_llgo_13, %_llgo_12 - %56 = load ptr, ptr @"_llgo_struct$qa3Pttfm1GQvokHektasLRsX-bwAs-LsF1bLMI_aThw", align 8 + %56 = load ptr, ptr @"_llgo_struct$8pZiNl4ZxK-lZr-eyXOGJ2lgSsNDx-SmrHiChs0Nc-o", align 8 br i1 %2, label %_llgo_15, label %_llgo_16 _llgo_15: ; preds = %_llgo_14 @@ -327,9 +327,9 @@ _llgo_15: ; preds = %_llgo_14 %62 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %61, ptr @"main.(*Game1).Load", 2 %63 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %62, ptr @main.Game1.Load, 3 %64 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8 - %65 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" { %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @6, i64 56 }, ptr undef, ptr undef, ptr undef }, ptr %64, 1 - %66 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %65, ptr @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Game).initGame", 2 - %67 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %66, ptr @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Game).initGame", 3 + %65 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" { %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @6, i64 57 }, ptr undef, ptr undef, ptr undef }, ptr %64, 1 + %66 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %65, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).initGame", 2 + %67 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %66, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Game).initGame", 3 %68 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 40) %69 = getelementptr %"github.com/goplus/llgo/runtime/abi.Method", ptr %68, i64 0 store %"github.com/goplus/llgo/runtime/abi.Method" %63, ptr %69, align 8 @@ -400,13 +400,13 @@ _llgo_23: ; preds = %_llgo_22 br label %_llgo_24 _llgo_24: ; preds = %_llgo_23, %_llgo_22 - %100 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @2, i64 47 }, %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @9, i64 5 }) - %101 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Gamer", align 8 + %100 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @2, i64 48 }, %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @9, i64 5 }) + %101 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Gamer", align 8 %102 = icmp eq ptr %101, null br i1 %102, label %_llgo_25, label %_llgo_26 _llgo_25: ; preds = %_llgo_24 - store ptr %100, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Gamer", align 8 + store ptr %100, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Gamer", align 8 br label %_llgo_26 _llgo_26: ; preds = %_llgo_25, %_llgo_24 @@ -416,7 +416,7 @@ _llgo_26: ; preds = %_llgo_25, %_llgo_24 _llgo_27: ; preds = %_llgo_26 %105 = insertvalue %"github.com/goplus/llgo/runtime/abi.Imethod" { %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @4, i64 4 }, ptr undef }, ptr %103, 1 - %106 = insertvalue %"github.com/goplus/llgo/runtime/abi.Imethod" { %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @6, i64 56 }, ptr undef }, ptr %104, 1 + %106 = insertvalue %"github.com/goplus/llgo/runtime/abi.Imethod" { %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @6, i64 57 }, ptr undef }, ptr %104, 1 %107 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 48) %108 = getelementptr %"github.com/goplus/llgo/runtime/abi.Imethod", ptr %107, i64 0 store %"github.com/goplus/llgo/runtime/abi.Imethod" %105, ptr %108, align 8 @@ -432,7 +432,7 @@ _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/runtime/abi.Imethod" { %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @4, i64 4 }, ptr undef }, ptr %113, 1 - %116 = insertvalue %"github.com/goplus/llgo/runtime/abi.Imethod" { %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @6, i64 56 }, ptr undef }, ptr %114, 1 + %116 = insertvalue %"github.com/goplus/llgo/runtime/abi.Imethod" { %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @6, i64 57 }, ptr undef }, ptr %114, 1 %117 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 48) %118 = getelementptr %"github.com/goplus/llgo/runtime/abi.Imethod", ptr %117, i64 0 store %"github.com/goplus/llgo/runtime/abi.Imethod" %115, ptr %118, align 8 diff --git a/compiler/cl/_testgo/strucintf/in.go b/compiler/cl/_testgo/strucintf/in.go index 6e7517c4..4fb44d9a 100644 --- a/compiler/cl/_testgo/strucintf/in.go +++ b/compiler/cl/_testgo/strucintf/in.go @@ -1,6 +1,6 @@ package main -import "github.com/goplus/llgo/compiler/cl/internal/foo" +import "github.com/goplus/llgo/compiler/cl/_testdata/foo" func Foo() any { return struct{ v int }{1} diff --git a/compiler/cl/_testgo/strucintf/out.ll b/compiler/cl/_testgo/strucintf/out.ll index 70bdc94d..79c20677 100644 --- a/compiler/cl/_testgo/strucintf/out.ll +++ b/compiler/cl/_testgo/strucintf/out.ll @@ -42,7 +42,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 - call void @"github.com/goplus/llgo/compiler/cl/internal/foo.init"() + call void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.init"() call void @"main.init$after"() br label %_llgo_2 @@ -72,7 +72,7 @@ _llgo_1: ; preds = %_llgo_12 br label %_llgo_2 _llgo_2: ; preds = %_llgo_3, %_llgo_1 - %9 = call %"github.com/goplus/llgo/runtime/internal/runtime.eface" @"github.com/goplus/llgo/compiler/cl/internal/foo.Bar"() + %9 = call %"github.com/goplus/llgo/runtime/internal/runtime.eface" @"github.com/goplus/llgo/compiler/cl/_testdata/foo.Bar"() %10 = alloca { i64 }, align 8 call void @llvm.memset(ptr %10, i8 0, i64 8, i1 false) %11 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %9, 0 @@ -95,7 +95,7 @@ _llgo_4: ; preds = %_llgo_15 _llgo_5: ; preds = %_llgo_6, %_llgo_4 %16 = alloca { i64 }, align 8 call void @llvm.memset(ptr %16, i8 0, i64 8, i1 false) - %17 = call %"github.com/goplus/llgo/runtime/internal/runtime.eface" @"github.com/goplus/llgo/compiler/cl/internal/foo.F"() + %17 = call %"github.com/goplus/llgo/runtime/internal/runtime.eface" @"github.com/goplus/llgo/compiler/cl/_testdata/foo.F"() %18 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %17, 0 %19 = load ptr, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8 %20 = icmp eq ptr %18, %19 @@ -230,7 +230,7 @@ declare %"github.com/goplus/llgo/runtime/abi.StructField" @"github.com/goplus/ll declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64) -declare void @"github.com/goplus/llgo/compiler/cl/internal/foo.init"() +declare void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.init"() declare void @"github.com/goplus/llgo/runtime/internal/runtime.init"() @@ -240,8 +240,8 @@ declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8) declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintString"(%"github.com/goplus/llgo/runtime/internal/runtime.String") -declare %"github.com/goplus/llgo/runtime/internal/runtime.eface" @"github.com/goplus/llgo/compiler/cl/internal/foo.Bar"() +declare %"github.com/goplus/llgo/runtime/internal/runtime.eface" @"github.com/goplus/llgo/compiler/cl/_testdata/foo.Bar"() -declare %"github.com/goplus/llgo/runtime/internal/runtime.eface" @"github.com/goplus/llgo/compiler/cl/internal/foo.F"() +declare %"github.com/goplus/llgo/runtime/internal/runtime.eface" @"github.com/goplus/llgo/compiler/cl/_testdata/foo.F"() attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) } diff --git a/compiler/cl/_testgo/struczero/in.go b/compiler/cl/_testgo/struczero/in.go index 64a80949..9bb44d4e 100644 --- a/compiler/cl/_testgo/struczero/in.go +++ b/compiler/cl/_testgo/struczero/in.go @@ -1,6 +1,6 @@ package main -import "github.com/goplus/llgo/compiler/cl/internal/foo" +import "github.com/goplus/llgo/compiler/cl/_testdata/foo" type bar struct { pb *byte diff --git a/compiler/cl/_testgo/struczero/out.ll b/compiler/cl/_testgo/struczero/out.ll index 41df8c35..c4217937 100644 --- a/compiler/cl/_testgo/struczero/out.ll +++ b/compiler/cl/_testgo/struczero/out.ll @@ -1,7 +1,7 @@ ; ModuleID = 'main' source_filename = "main" -%"github.com/goplus/llgo/compiler/cl/internal/foo.Foo" = type { ptr, float } +%"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo" = type { ptr, float } %"github.com/goplus/llgo/runtime/internal/runtime.eface" = type { ptr, ptr } %main.bar = type { ptr, float } %"github.com/goplus/llgo/runtime/internal/runtime.String" = type { ptr, i64 } @@ -10,8 +10,8 @@ source_filename = "main" %"github.com/goplus/llgo/runtime/abi.Method" = type { %"github.com/goplus/llgo/runtime/internal/runtime.String", ptr, ptr, ptr } @"main.init$guard" = global i1 false, align 1 -@"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Foo" = linkonce global ptr null, align 8 -@0 = private unnamed_addr constant [47 x i8] c"github.com/goplus/llgo/compiler/cl/internal/foo", align 1 +@"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo" = linkonce global ptr null, align 8 +@0 = private unnamed_addr constant [48 x i8] c"github.com/goplus/llgo/compiler/cl/_testdata/foo", align 1 @1 = private unnamed_addr constant [3 x i8] c"Foo", align 1 @_llgo_byte = linkonce global ptr null, align 8 @"*_llgo_byte" = linkonce global ptr null, align 8 @@ -30,30 +30,30 @@ source_filename = "main" @__llgo_argv = global ptr null, align 8 @8 = private unnamed_addr constant [6 x i8] c"notOk:", align 1 -define { %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", i1 } @main.Bar(%"github.com/goplus/llgo/runtime/internal/runtime.eface" %0) { +define { %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", i1 } @main.Bar(%"github.com/goplus/llgo/runtime/internal/runtime.eface" %0) { _llgo_0: %1 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %0, 0 - %2 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Foo", align 8 + %2 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", align 8 %3 = icmp eq ptr %1, %2 br i1 %3, label %_llgo_1, label %_llgo_2 _llgo_1: ; preds = %_llgo_0 %4 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %0, 1 - %5 = load %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", ptr %4, align 8 - %6 = insertvalue { %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", i1 } undef, %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo" %5, 0 - %7 = insertvalue { %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", i1 } %6, i1 true, 1 + %5 = load %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", ptr %4, align 8 + %6 = insertvalue { %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", i1 } undef, %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo" %5, 0 + %7 = insertvalue { %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", i1 } %6, i1 true, 1 br label %_llgo_3 _llgo_2: ; preds = %_llgo_0 br label %_llgo_3 _llgo_3: ; preds = %_llgo_2, %_llgo_1 - %8 = phi { %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", i1 } [ %7, %_llgo_1 ], [ zeroinitializer, %_llgo_2 ] - %9 = extractvalue { %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", i1 } %8, 0 - %10 = extractvalue { %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", i1 } %8, 1 - %11 = insertvalue { %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", i1 } undef, %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo" %9, 0 - %12 = insertvalue { %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", i1 } %11, i1 %10, 1 - ret { %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", i1 } %12 + %8 = phi { %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", i1 } [ %7, %_llgo_1 ], [ zeroinitializer, %_llgo_2 ] + %9 = extractvalue { %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", i1 } %8, 0 + %10 = extractvalue { %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", i1 } %8, 1 + %11 = insertvalue { %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", i1 } undef, %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo" %9, 0 + %12 = insertvalue { %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", i1 } %11, i1 %10, 1 + ret { %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", i1 } %12 } define { %main.bar, i1 } @main.Foo(%"github.com/goplus/llgo/runtime/internal/runtime.eface" %0) { @@ -89,7 +89,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 - call void @"github.com/goplus/llgo/compiler/cl/internal/foo.init"() + call void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.init"() call void @"main.init$after"() br label %_llgo_2 @@ -123,20 +123,20 @@ _llgo_0: call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintBool"(i1 %10) call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 10) - %12 = alloca %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", align 8 + %12 = alloca %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", align 8 call void @llvm.memset(ptr %12, i8 0, i64 16, i1 false) - %13 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Foo", align 8 + %13 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", align 8 %14 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16) - store %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo" zeroinitializer, ptr %14, align 8 + store %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo" zeroinitializer, ptr %14, align 8 %15 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %13, 0 %16 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %15, ptr %14, 1 - %17 = call { %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", i1 } @main.Bar(%"github.com/goplus/llgo/runtime/internal/runtime.eface" %16) - %18 = extractvalue { %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", i1 } %17, 0 - store %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo" %18, ptr %12, align 8 - %19 = extractvalue { %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", i1 } %17, 1 - %20 = load %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", ptr %12, align 8 - %21 = call ptr @"github.com/goplus/llgo/compiler/cl/internal/foo.Foo.Pb"(%"github.com/goplus/llgo/compiler/cl/internal/foo.Foo" %20) - %22 = getelementptr inbounds %"github.com/goplus/llgo/compiler/cl/internal/foo.Foo", ptr %12, i32 0, i32 1 + %17 = call { %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", i1 } @main.Bar(%"github.com/goplus/llgo/runtime/internal/runtime.eface" %16) + %18 = extractvalue { %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", i1 } %17, 0 + store %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo" %18, ptr %12, align 8 + %19 = extractvalue { %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", i1 } %17, 1 + %20 = load %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", ptr %12, align 8 + %21 = call ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo.Pb"(%"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo" %20) + %22 = getelementptr inbounds %"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", ptr %12, i32 0, i32 1 %23 = load float, ptr %22, align 4 call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintPointer"(ptr %21) call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 32) @@ -150,13 +150,13 @@ _llgo_0: define void @"main.init$after"() { _llgo_0: - %0 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.NewNamed"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 47 }, %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @1, i64 3 }, i64 25, i64 16, i64 1, i64 1) - %1 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Foo", align 8 + %0 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.NewNamed"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 48 }, %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @1, i64 3 }, i64 25, i64 16, i64 1, i64 1) + %1 = load ptr, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", align 8 %2 = icmp eq ptr %1, null br i1 %2, label %_llgo_1, label %_llgo_2 _llgo_1: ; preds = %_llgo_0 - store ptr %0, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/internal/foo.Foo", align 8 + store ptr %0, ptr @"_llgo_github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo", align 8 br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 @@ -262,11 +262,11 @@ _llgo_11: ; preds = %_llgo_9 _llgo_12: ; preds = %_llgo_11, %_llgo_9 %58 = load ptr, ptr @"_llgo_func$NfGSLZ1QiKRoFkKeqYSXE5hUU5bpeteSJKrbMNUzYRE", align 8 %59 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" { %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @5, i64 2 }, ptr undef, ptr undef, ptr undef }, ptr %58, 1 - %60 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %59, ptr @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Foo).Pb", 2 - %61 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %60, ptr @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Foo).Pb", 3 + %60 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %59, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Foo).Pb", 2 + %61 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %60, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Foo).Pb", 3 %62 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" { %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @5, i64 2 }, ptr undef, ptr undef, ptr undef }, ptr %58, 1 - %63 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %62, ptr @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Foo).Pb", 2 - %64 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %63, ptr @"github.com/goplus/llgo/compiler/cl/internal/foo.Foo.Pb", 3 + %63 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %62, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Foo).Pb", 2 + %64 = insertvalue %"github.com/goplus/llgo/runtime/abi.Method" %63, ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo.Pb", 3 %65 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 40) %66 = getelementptr %"github.com/goplus/llgo/runtime/abi.Method", ptr %65, i64 0 store %"github.com/goplus/llgo/runtime/abi.Method" %64, ptr %66, align 8 @@ -301,11 +301,11 @@ declare void @"github.com/goplus/llgo/runtime/internal/runtime.InitNamed"(ptr, p declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.Func"(%"github.com/goplus/llgo/runtime/internal/runtime.Slice", %"github.com/goplus/llgo/runtime/internal/runtime.Slice", i1) -declare ptr @"github.com/goplus/llgo/compiler/cl/internal/foo.(*Foo).Pb"(ptr) +declare ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.(*Foo).Pb"(ptr) -declare ptr @"github.com/goplus/llgo/compiler/cl/internal/foo.Foo.Pb"(%"github.com/goplus/llgo/compiler/cl/internal/foo.Foo") +declare ptr @"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo.Pb"(%"github.com/goplus/llgo/compiler/cl/_testdata/foo.Foo") -declare void @"github.com/goplus/llgo/compiler/cl/internal/foo.init"() +declare void @"github.com/goplus/llgo/compiler/cl/_testdata/foo.init"() declare void @"github.com/goplus/llgo/runtime/internal/runtime.init"() diff --git a/compiler/cl/_testrt/hello/in.go b/compiler/cl/_testrt/hello/in.go index 5e809089..216feded 100644 --- a/compiler/cl/_testrt/hello/in.go +++ b/compiler/cl/_testrt/hello/in.go @@ -1,6 +1,6 @@ package main -import "github.com/goplus/llgo/compiler/cl/internal/libc" +import "github.com/goplus/llgo/compiler/cl/_testrt/hello/libc" var format = [...]int8{'H', 'e', 'l', 'l', 'o', ' ', '%', 'd', '\n', 0} diff --git a/compiler/cl/internal/libc/libc.go b/compiler/cl/_testrt/hello/libc/libc.go similarity index 100% rename from compiler/cl/internal/libc/libc.go rename to compiler/cl/_testrt/hello/libc/libc.go diff --git a/compiler/cl/_testrt/linkname/in.go b/compiler/cl/_testrt/linkname/in.go index a6687718..406e7ee9 100644 --- a/compiler/cl/_testrt/linkname/in.go +++ b/compiler/cl/_testrt/linkname/in.go @@ -4,20 +4,20 @@ import ( _ "unsafe" "github.com/goplus/llgo/c" - _ "github.com/goplus/llgo/compiler/cl/internal/linktarget" + _ "github.com/goplus/llgo/compiler/cl/_testrt/linkname/linktarget" ) -//go:linkname print github.com/goplus/llgo/compiler/cl/internal/linktarget.F +//go:linkname print github.com/goplus/llgo/compiler/cl/_testrt/linkname/linktarget.F func print(a, b, c, d *c.Char) type m struct { s string } -//go:linkname setInfo github.com/goplus/llgo/compiler/cl/internal/linktarget.(*m).setInfo +//go:linkname setInfo github.com/goplus/llgo/compiler/cl/_testrt/linkname/linktarget.(*m).setInfo func setInfo(*m, string) -//go:linkname info github.com/goplus/llgo/compiler/cl/internal/linktarget.m.info +//go:linkname info github.com/goplus/llgo/compiler/cl/_testrt/linkname/linktarget.m.info func info(m) string func main() { diff --git a/compiler/cl/internal/linktarget/foo.go b/compiler/cl/_testrt/linkname/linktarget/foo.go similarity index 100% rename from compiler/cl/internal/linktarget/foo.go rename to compiler/cl/_testrt/linkname/linktarget/foo.go diff --git a/compiler/cl/internal/linktarget/out.ll b/compiler/cl/_testrt/linkname/linktarget/out.ll similarity index 100% rename from compiler/cl/internal/linktarget/out.ll rename to compiler/cl/_testrt/linkname/linktarget/out.ll diff --git a/compiler/cl/_testrt/linkname/out.ll b/compiler/cl/_testrt/linkname/out.ll index 86f3a482..9f3855ee 100644 --- a/compiler/cl/_testrt/linkname/out.ll +++ b/compiler/cl/_testrt/linkname/out.ll @@ -17,7 +17,7 @@ source_filename = "main" @7 = private unnamed_addr constant [2 x i8] c"4\00", align 1 @8 = private unnamed_addr constant [5 x i8] c"hello", align 1 -declare %"github.com/goplus/llgo/runtime/internal/runtime.String" @"github.com/goplus/llgo/compiler/cl/internal/linktarget.m.info"(%main.m) +declare %"github.com/goplus/llgo/runtime/internal/runtime.String" @"github.com/goplus/llgo/compiler/cl/_testrt/linkname/linktarget.m.info"(%main.m) define void @main.init() { _llgo_0: @@ -26,7 +26,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 - call void @"github.com/goplus/llgo/compiler/cl/internal/linktarget.init"() + call void @"github.com/goplus/llgo/compiler/cl/_testrt/linkname/linktarget.init"() br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 @@ -39,22 +39,22 @@ _llgo_0: store ptr %1, ptr @__llgo_argv, align 8 call void @"github.com/goplus/llgo/runtime/internal/runtime.init"() call void @main.init() - call void @"github.com/goplus/llgo/compiler/cl/internal/linktarget.F"(ptr @0, ptr @1, ptr @2, ptr @3) - call void @"github.com/goplus/llgo/compiler/cl/internal/linktarget.F"(ptr @4, ptr @5, ptr @6, ptr @7) + call void @"github.com/goplus/llgo/compiler/cl/_testrt/linkname/linktarget.F"(ptr @0, ptr @1, ptr @2, ptr @3) + call void @"github.com/goplus/llgo/compiler/cl/_testrt/linkname/linktarget.F"(ptr @4, ptr @5, ptr @6, ptr @7) %2 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64 16) - call void @"github.com/goplus/llgo/compiler/cl/internal/linktarget.(*m).setInfo"(ptr %2, %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @8, i64 5 }) + call void @"github.com/goplus/llgo/compiler/cl/_testrt/linkname/linktarget.(*m).setInfo"(ptr %2, %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @8, i64 5 }) %3 = load %main.m, ptr %2, align 8 - %4 = call %"github.com/goplus/llgo/runtime/internal/runtime.String" @"github.com/goplus/llgo/compiler/cl/internal/linktarget.m.info"(%main.m %3) + %4 = call %"github.com/goplus/llgo/runtime/internal/runtime.String" @"github.com/goplus/llgo/compiler/cl/_testrt/linkname/linktarget.m.info"(%main.m %3) call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintString"(%"github.com/goplus/llgo/runtime/internal/runtime.String" %4) call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 10) ret i32 0 } -declare void @"github.com/goplus/llgo/compiler/cl/internal/linktarget.F"(ptr, ptr, ptr, ptr) +declare void @"github.com/goplus/llgo/compiler/cl/_testrt/linkname/linktarget.F"(ptr, ptr, ptr, ptr) -declare void @"github.com/goplus/llgo/compiler/cl/internal/linktarget.(*m).setInfo"(ptr, %"github.com/goplus/llgo/runtime/internal/runtime.String") +declare void @"github.com/goplus/llgo/compiler/cl/_testrt/linkname/linktarget.(*m).setInfo"(ptr, %"github.com/goplus/llgo/runtime/internal/runtime.String") -declare void @"github.com/goplus/llgo/compiler/cl/internal/linktarget.init"() +declare void @"github.com/goplus/llgo/compiler/cl/_testrt/linkname/linktarget.init"() declare void @"github.com/goplus/llgo/runtime/internal/runtime.init"() diff --git a/compiler/cl/_testrt/qsortfn/in.go b/compiler/cl/_testrt/qsortfn/in.go index 57a1e423..58072352 100644 --- a/compiler/cl/_testrt/qsortfn/in.go +++ b/compiler/cl/_testrt/qsortfn/in.go @@ -4,7 +4,7 @@ import ( "unsafe" "github.com/goplus/llgo/c" - q "github.com/goplus/llgo/compiler/cl/internal/qsort" + q "github.com/goplus/llgo/compiler/cl/_testrt/qsortfn/qsort" ) //llgo:type C diff --git a/compiler/cl/internal/qsort/qsort.go b/compiler/cl/_testrt/qsortfn/qsort/qsort.go similarity index 100% rename from compiler/cl/internal/qsort/qsort.go rename to compiler/cl/_testrt/qsortfn/qsort/qsort.go