ssa: update linkname go style
This commit is contained in:
Binary file not shown.
@@ -76,7 +76,7 @@ const (
|
|||||||
Done Errno = 101 // sqlite3_step() has finished executing
|
Done Errno = 101 // sqlite3_step() has finished executing
|
||||||
)
|
)
|
||||||
|
|
||||||
// llgo:link (Errno).Errstr C.sqlite3_errstr
|
// llgo:link Errno.Errstr C.sqlite3_errstr
|
||||||
func (err Errno) Errstr() *c.Char { return nil }
|
func (err Errno) Errstr() *c.Char { return nil }
|
||||||
|
|
||||||
// llgo:link (*Sqlite3).Errmsg C.sqlite3_errmsg
|
// llgo:link (*Sqlite3).Errmsg C.sqlite3_errmsg
|
||||||
|
|||||||
@@ -6,16 +6,16 @@ source_filename = "main"
|
|||||||
@__llgo_argc = global ptr null
|
@__llgo_argc = global ptr null
|
||||||
@__llgo_argv = global ptr null
|
@__llgo_argv = global ptr null
|
||||||
|
|
||||||
define i64 @"(main.T).Add"(i64 %0, i64 %1) {
|
define i64 @main.T.Add(i64 %0, i64 %1) {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
%2 = add i64 %0, %1
|
%2 = add i64 %0, %1
|
||||||
ret i64 %2
|
ret i64 %2
|
||||||
}
|
}
|
||||||
|
|
||||||
define i64 @"(*main.T).Add"(ptr %0, i64 %1) {
|
define i64 @"main.(*T).Add"(ptr %0, i64 %1) {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
%2 = load i64, ptr %0, align 4
|
%2 = load i64, ptr %0, align 4
|
||||||
%3 = call i64 @"(main.T).Add"(i64 %2, i64 %1)
|
%3 = call i64 @main.T.Add(i64 %2, i64 %1)
|
||||||
ret i64 %3
|
ret i64 %3
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ _llgo_0:
|
|||||||
store ptr %1, ptr @__llgo_argv, align 8
|
store ptr %1, ptr @__llgo_argv, align 8
|
||||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||||
call void @main.init()
|
call void @main.init()
|
||||||
%2 = call i64 @"(main.T).Add"(i64 1, i64 2)
|
%2 = call i64 @main.T.Add(i64 1, i64 2)
|
||||||
call void (ptr, ...) @printf(ptr @main.format, i64 %2)
|
call void (ptr, ...) @printf(ptr @main.format, i64 %2)
|
||||||
ret i32 0
|
ret i32 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ source_filename = "main"
|
|||||||
@__llgo_argc = global ptr null
|
@__llgo_argc = global ptr null
|
||||||
@__llgo_argv = global ptr null
|
@__llgo_argv = global ptr null
|
||||||
|
|
||||||
define void @"(*main.T).Print"(ptr %0, i64 %1) {
|
define void @"main.(*T).Print"(ptr %0, i64 %1) {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
call void (ptr, ...) @printf(ptr %0, i64 %1)
|
call void (ptr, ...) @printf(ptr %0, i64 %1)
|
||||||
ret void
|
ret void
|
||||||
@@ -41,7 +41,7 @@ _llgo_0:
|
|||||||
store ptr %1, ptr @__llgo_argv, align 8
|
store ptr %1, ptr @__llgo_argv, align 8
|
||||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||||
call void @main.init()
|
call void @main.init()
|
||||||
call void @"(*main.T).Print"(ptr @main.format, i64 100)
|
call void @"main.(*T).Print"(ptr @main.format, i64 100)
|
||||||
ret i32 0
|
ret i32 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ _llgo_0:
|
|||||||
define void @main.dumpTyp(ptr %0, %"github.com/goplus/llgo/internal/runtime.String" %1) {
|
define void @main.dumpTyp(ptr %0, %"github.com/goplus/llgo/internal/runtime.String" %1) {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %1)
|
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %1)
|
||||||
%2 = call i64 @"(*github.com/goplus/llgo/internal/abi.Type).Kind"(ptr %0)
|
%2 = call i64 @"github.com/goplus/llgo/internal/abi.(*Type).Kind"(ptr %0)
|
||||||
%3 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 0
|
%3 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 0
|
||||||
%4 = load i64, ptr %3, align 4
|
%4 = load i64, ptr %3, align 4
|
||||||
%5 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 1
|
%5 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 1
|
||||||
@@ -300,7 +300,7 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
|||||||
|
|
||||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String")
|
declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||||
|
|
||||||
declare i64 @"(*github.com/goplus/llgo/internal/abi.Type).Kind"(ptr)
|
declare i64 @"github.com/goplus/llgo/internal/abi.(*Type).Kind"(ptr)
|
||||||
|
|
||||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64)
|
declare void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64)
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ _llgo_0:
|
|||||||
ret %"github.com/goplus/llgo/internal/runtime.iface" %9
|
ret %"github.com/goplus/llgo/internal/runtime.iface" %9
|
||||||
}
|
}
|
||||||
|
|
||||||
define %"github.com/goplus/llgo/internal/runtime.String" @"(*main.errorString).Error"(ptr %0) {
|
define %"github.com/goplus/llgo/internal/runtime.String" @"main.(*errorString).Error"(ptr %0) {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
%1 = getelementptr inbounds %main.errorString, ptr %0, i32 0, i32 0
|
%1 = getelementptr inbounds %main.errorString, ptr %0, i32 0, i32 0
|
||||||
%2 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %1, align 8
|
%2 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %1, align 8
|
||||||
@@ -194,9 +194,9 @@ _llgo_4: ; preds = %_llgo_3, %_llgo_2
|
|||||||
%51 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %49, i32 0, i32 1
|
%51 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %49, i32 0, i32 1
|
||||||
store ptr %48, ptr %51, align 8
|
store ptr %48, ptr %51, align 8
|
||||||
%52 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %49, i32 0, i32 2
|
%52 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %49, i32 0, i32 2
|
||||||
store ptr @"(*main.errorString).Error", ptr %52, align 8
|
store ptr @"main.(*errorString).Error", ptr %52, align 8
|
||||||
%53 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %49, i32 0, i32 3
|
%53 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %49, i32 0, i32 3
|
||||||
store ptr @"(*main.errorString).Error", ptr %53, align 8
|
store ptr @"main.(*errorString).Error", ptr %53, align 8
|
||||||
%54 = load %"github.com/goplus/llgo/internal/abi.Method", ptr %49, align 8
|
%54 = load %"github.com/goplus/llgo/internal/abi.Method", ptr %49, align 8
|
||||||
%55 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
%55 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
||||||
%56 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %55, i64 0
|
%56 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %55, i64 0
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ _llgo_0:
|
|||||||
store %"github.com/goplus/llgo/cl/internal/foo.Foo" %26, ptr %18, align 8
|
store %"github.com/goplus/llgo/cl/internal/foo.Foo" %26, ptr %18, align 8
|
||||||
%27 = extractvalue { %"github.com/goplus/llgo/cl/internal/foo.Foo", i1 } %25, 1
|
%27 = extractvalue { %"github.com/goplus/llgo/cl/internal/foo.Foo", i1 } %25, 1
|
||||||
%28 = load %"github.com/goplus/llgo/cl/internal/foo.Foo", ptr %18, align 8
|
%28 = load %"github.com/goplus/llgo/cl/internal/foo.Foo", ptr %18, align 8
|
||||||
%29 = call ptr @"(github.com/goplus/llgo/cl/internal/foo.Foo).Pb"(%"github.com/goplus/llgo/cl/internal/foo.Foo" %28)
|
%29 = call ptr @"github.com/goplus/llgo/cl/internal/foo.Foo.Pb"(%"github.com/goplus/llgo/cl/internal/foo.Foo" %28)
|
||||||
%30 = getelementptr inbounds %"github.com/goplus/llgo/cl/internal/foo.Foo", ptr %18, i32 0, i32 1
|
%30 = getelementptr inbounds %"github.com/goplus/llgo/cl/internal/foo.Foo", ptr %18, i32 0, i32 1
|
||||||
%31 = load float, ptr %30, align 4
|
%31 = load float, ptr %30, align 4
|
||||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %29)
|
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %29)
|
||||||
@@ -393,9 +393,9 @@ _llgo_12: ; preds = %_llgo_11, %_llgo_9
|
|||||||
%114 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %112, i32 0, i32 1
|
%114 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %112, i32 0, i32 1
|
||||||
store ptr %111, ptr %114, align 8
|
store ptr %111, ptr %114, align 8
|
||||||
%115 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %112, i32 0, i32 2
|
%115 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %112, i32 0, i32 2
|
||||||
store ptr @"(*github.com/goplus/llgo/cl/internal/foo.Foo).Pb", ptr %115, align 8
|
store ptr @"github.com/goplus/llgo/cl/internal/foo.(*Foo).Pb", ptr %115, align 8
|
||||||
%116 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %112, i32 0, i32 3
|
%116 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %112, i32 0, i32 3
|
||||||
store ptr @"(*github.com/goplus/llgo/cl/internal/foo.Foo).Pb", ptr %116, align 8
|
store ptr @"github.com/goplus/llgo/cl/internal/foo.(*Foo).Pb", ptr %116, align 8
|
||||||
%117 = load %"github.com/goplus/llgo/internal/abi.Method", ptr %112, align 8
|
%117 = load %"github.com/goplus/llgo/internal/abi.Method", ptr %112, align 8
|
||||||
%118 = alloca %"github.com/goplus/llgo/internal/abi.Method", align 8
|
%118 = alloca %"github.com/goplus/llgo/internal/abi.Method", align 8
|
||||||
%119 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %118, i32 0, i32 0
|
%119 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %118, i32 0, i32 0
|
||||||
@@ -403,9 +403,9 @@ _llgo_12: ; preds = %_llgo_11, %_llgo_9
|
|||||||
%120 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %118, i32 0, i32 1
|
%120 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %118, i32 0, i32 1
|
||||||
store ptr %111, ptr %120, align 8
|
store ptr %111, ptr %120, align 8
|
||||||
%121 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %118, i32 0, i32 2
|
%121 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %118, i32 0, i32 2
|
||||||
store ptr @"(*github.com/goplus/llgo/cl/internal/foo.Foo).Pb", ptr %121, align 8
|
store ptr @"github.com/goplus/llgo/cl/internal/foo.(*Foo).Pb", ptr %121, align 8
|
||||||
%122 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %118, i32 0, i32 3
|
%122 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %118, i32 0, i32 3
|
||||||
store ptr @"(github.com/goplus/llgo/cl/internal/foo.Foo).Pb", ptr %122, align 8
|
store ptr @"github.com/goplus/llgo/cl/internal/foo.Foo.Pb", ptr %122, align 8
|
||||||
%123 = load %"github.com/goplus/llgo/internal/abi.Method", ptr %118, align 8
|
%123 = load %"github.com/goplus/llgo/internal/abi.Method", ptr %118, align 8
|
||||||
%124 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
%124 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
||||||
%125 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %124, i64 0
|
%125 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %124, i64 0
|
||||||
@@ -461,9 +461,9 @@ declare void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr, %"github.
|
|||||||
|
|
||||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice", i1)
|
declare ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice", i1)
|
||||||
|
|
||||||
declare ptr @"(*github.com/goplus/llgo/cl/internal/foo.Foo).Pb"(ptr)
|
declare ptr @"github.com/goplus/llgo/cl/internal/foo.(*Foo).Pb"(ptr)
|
||||||
|
|
||||||
declare ptr @"(github.com/goplus/llgo/cl/internal/foo.Foo).Pb"(%"github.com/goplus/llgo/cl/internal/foo.Foo")
|
declare ptr @"github.com/goplus/llgo/cl/internal/foo.Foo.Pb"(%"github.com/goplus/llgo/cl/internal/foo.Foo")
|
||||||
|
|
||||||
declare void @"github.com/goplus/llgo/cl/internal/foo.init"()
|
declare void @"github.com/goplus/llgo/cl/internal/foo.init"()
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ _llgo_3: ; preds = %_llgo_1
|
|||||||
ret %"github.com/goplus/llgo/internal/runtime.Slice" %8
|
ret %"github.com/goplus/llgo/internal/runtime.Slice" %8
|
||||||
}
|
}
|
||||||
|
|
||||||
define i32 @"(*main.generator).next"(ptr %0) {
|
define i32 @"main.(*generator).next"(ptr %0) {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
%1 = getelementptr inbounds %main.generator, ptr %0, i32 0, i32 0
|
%1 = getelementptr inbounds %main.generator, ptr %0, i32 0, i32 0
|
||||||
%2 = load i32, ptr %1, align 4
|
%2 = load i32, ptr %1, align 4
|
||||||
@@ -205,6 +205,6 @@ define i32 @"main.next$bound"(ptr %0) {
|
|||||||
_llgo_0:
|
_llgo_0:
|
||||||
%1 = load { ptr }, ptr %0, align 8
|
%1 = load { ptr }, ptr %0, align 8
|
||||||
%2 = extractvalue { ptr } %1, 0
|
%2 = extractvalue { ptr } %1, 0
|
||||||
%3 = call i32 @"(*main.generator).next"(ptr %2)
|
%3 = call i32 @"main.(*generator).next"(ptr %2)
|
||||||
ret i32 %3
|
ret i32 %3
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,27 @@ package main
|
|||||||
import (
|
import (
|
||||||
_ "unsafe"
|
_ "unsafe"
|
||||||
|
|
||||||
|
_ "github.com/goplus/llgo/cl/internal/linktarget"
|
||||||
"github.com/goplus/llgo/internal/runtime/c"
|
"github.com/goplus/llgo/internal/runtime/c"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:linkname print github.com/goplus/llgo/cl/internal/linktarget.F
|
//go:linkname print github.com/goplus/llgo/cl/internal/linktarget.F
|
||||||
func print(a, b, c, d *c.Char)
|
func print(a, b, c, d *c.Char)
|
||||||
|
|
||||||
|
type m struct {
|
||||||
|
s string
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:linkname setInfo github.com/goplus/llgo/cl/internal/linktarget.(*m).setInfo
|
||||||
|
func setInfo(*m, string)
|
||||||
|
|
||||||
|
//go:linkname info github.com/goplus/llgo/cl/internal/linktarget.m.info
|
||||||
|
func info(m) string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
print(c.Str("a"), c.Str("b"), c.Str("c"), c.Str("d"))
|
print(c.Str("a"), c.Str("b"), c.Str("c"), c.Str("d"))
|
||||||
print(c.Str("1"), c.Str("2"), c.Str("3"), c.Str("4"))
|
print(c.Str("1"), c.Str("2"), c.Str("3"), c.Str("4"))
|
||||||
|
var m m
|
||||||
|
setInfo(&m, "hello")
|
||||||
|
println(info(m))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
; ModuleID = 'main'
|
; ModuleID = 'main'
|
||||||
source_filename = "main"
|
source_filename = "main"
|
||||||
|
|
||||||
|
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||||
|
%main.m = type { %"github.com/goplus/llgo/internal/runtime.String" }
|
||||||
|
|
||||||
@"main.init$guard" = global ptr null
|
@"main.init$guard" = global ptr null
|
||||||
@__llgo_argc = global ptr null
|
@__llgo_argc = global ptr null
|
||||||
@__llgo_argv = global ptr null
|
@__llgo_argv = global ptr null
|
||||||
@@ -12,6 +15,9 @@ source_filename = "main"
|
|||||||
@5 = private unnamed_addr constant [2 x i8] c"2\00", align 1
|
@5 = private unnamed_addr constant [2 x i8] c"2\00", align 1
|
||||||
@6 = private unnamed_addr constant [2 x i8] c"3\00", align 1
|
@6 = private unnamed_addr constant [2 x i8] c"3\00", align 1
|
||||||
@7 = private unnamed_addr constant [2 x i8] c"4\00", align 1
|
@7 = private unnamed_addr constant [2 x i8] c"4\00", align 1
|
||||||
|
@8 = private unnamed_addr constant [6 x i8] c"hello\00", align 1
|
||||||
|
|
||||||
|
declare %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/cl/internal/linktarget.m.info"(%main.m)
|
||||||
|
|
||||||
define void @main.init() {
|
define void @main.init() {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
@@ -20,6 +26,7 @@ _llgo_0:
|
|||||||
|
|
||||||
_llgo_1: ; preds = %_llgo_0
|
_llgo_1: ; preds = %_llgo_0
|
||||||
store i1 true, ptr @"main.init$guard", align 1
|
store i1 true, ptr @"main.init$guard", align 1
|
||||||
|
call void @"github.com/goplus/llgo/cl/internal/linktarget.init"()
|
||||||
br label %_llgo_2
|
br label %_llgo_2
|
||||||
|
|
||||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||||
@@ -34,9 +41,31 @@ _llgo_0:
|
|||||||
call void @main.init()
|
call void @main.init()
|
||||||
call void @"github.com/goplus/llgo/cl/internal/linktarget.F"(ptr @0, ptr @1, ptr @2, ptr @3)
|
call void @"github.com/goplus/llgo/cl/internal/linktarget.F"(ptr @0, ptr @1, ptr @2, ptr @3)
|
||||||
call void @"github.com/goplus/llgo/cl/internal/linktarget.F"(ptr @4, ptr @5, ptr @6, ptr @7)
|
call void @"github.com/goplus/llgo/cl/internal/linktarget.F"(ptr @4, ptr @5, ptr @6, ptr @7)
|
||||||
|
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||||
|
%3 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||||
|
%4 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %3, i32 0, i32 0
|
||||||
|
store ptr @8, ptr %4, align 8
|
||||||
|
%5 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %3, i32 0, i32 1
|
||||||
|
store i64 5, ptr %5, align 4
|
||||||
|
%6 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %3, align 8
|
||||||
|
call void @"github.com/goplus/llgo/cl/internal/linktarget.(*m).setInfo"(ptr %2, %"github.com/goplus/llgo/internal/runtime.String" %6)
|
||||||
|
%7 = load %main.m, ptr %2, align 8
|
||||||
|
%8 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/cl/internal/linktarget.m.info"(%main.m %7)
|
||||||
|
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %8)
|
||||||
|
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||||
ret i32 0
|
ret i32 0
|
||||||
}
|
}
|
||||||
|
|
||||||
declare void @"github.com/goplus/llgo/cl/internal/linktarget.F"(ptr, ptr, ptr, ptr)
|
declare void @"github.com/goplus/llgo/cl/internal/linktarget.F"(ptr, ptr, ptr, ptr)
|
||||||
|
|
||||||
|
declare void @"github.com/goplus/llgo/cl/internal/linktarget.(*m).setInfo"(ptr, %"github.com/goplus/llgo/internal/runtime.String")
|
||||||
|
|
||||||
|
declare void @"github.com/goplus/llgo/cl/internal/linktarget.init"()
|
||||||
|
|
||||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||||
|
|
||||||
|
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||||
|
|
||||||
|
declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||||
|
|
||||||
|
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ source_filename = "main"
|
|||||||
@__llgo_argc = global ptr null
|
@__llgo_argc = global ptr null
|
||||||
@__llgo_argv = global ptr null
|
@__llgo_argv = global ptr null
|
||||||
|
|
||||||
define void @"(main.Foo).Print"(%main.Foo %0) {
|
define void @main.Foo.Print(%main.Foo %0) {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
%1 = alloca %main.Foo, align 8
|
%1 = alloca %main.Foo, align 8
|
||||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %1, i64 8)
|
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %1, i64 8)
|
||||||
@@ -27,10 +27,10 @@ _llgo_2: ; preds = %_llgo_1, %_llgo_0
|
|||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
define void @"(*main.Foo).Print"(ptr %0) {
|
define void @"main.(*Foo).Print"(ptr %0) {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
%1 = load %main.Foo, ptr %0, align 4
|
%1 = load %main.Foo, ptr %0, align 4
|
||||||
call void @"(main.Foo).Print"(%main.Foo %1)
|
call void @main.Foo.Print(%main.Foo %1)
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ _llgo_0:
|
|||||||
store i32 100, ptr %4, align 4
|
store i32 100, ptr %4, align 4
|
||||||
store i1 true, ptr %5, align 1
|
store i1 true, ptr %5, align 1
|
||||||
%6 = load %main.Foo, ptr %3, align 4
|
%6 = load %main.Foo, ptr %3, align 4
|
||||||
call void @"(main.Foo).Print"(%main.Foo %6)
|
call void @main.Foo.Print(%main.Foo %6)
|
||||||
ret i32 0
|
ret i32 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
24
cl/import.go
24
cl/import.go
@@ -241,20 +241,21 @@ func trecvTypeName(t ast.Expr, indices ...ast.Expr) string {
|
|||||||
|
|
||||||
// inPkgName:
|
// inPkgName:
|
||||||
// - func: name
|
// - func: name
|
||||||
// - method: (T).name, (*T).name
|
// - method: T.name, (*T).name
|
||||||
// fullName:
|
// fullName:
|
||||||
// - func: pkg.name
|
// - func: pkg.name
|
||||||
// - method: (pkg.T).name, (*pkg.T).name
|
// - method: pkg.(T).name, pkg.(*T).name
|
||||||
func astFuncName(pkgPath string, fn *ast.FuncDecl) (fullName, inPkgName string) {
|
func astFuncName(pkgPath string, fn *ast.FuncDecl) (fullName, inPkgName string) {
|
||||||
name := fn.Name.Name
|
name := fn.Name.Name
|
||||||
if recv := fn.Recv; recv != nil && len(recv.List) == 1 {
|
if recv := fn.Recv; recv != nil && len(recv.List) == 1 {
|
||||||
tPrefix := "("
|
var method string
|
||||||
t := recv.List[0].Type
|
t := recv.List[0].Type
|
||||||
if tp, ok := t.(*ast.StarExpr); ok {
|
if tp, ok := t.(*ast.StarExpr); ok {
|
||||||
t, tPrefix = tp.X, "(*"
|
method = "(*" + recvTypeName(tp.X) + ")." + name
|
||||||
|
} else {
|
||||||
|
method = recvTypeName(t) + "." + name
|
||||||
}
|
}
|
||||||
tSuffix := recvTypeName(t) + ")." + name
|
return pkgPath + "." + method, method
|
||||||
return tPrefix + pkgPath + "." + tSuffix, tPrefix + tSuffix
|
|
||||||
}
|
}
|
||||||
return pkgPath + "." + name, name
|
return pkgPath + "." + name, name
|
||||||
}
|
}
|
||||||
@@ -263,13 +264,14 @@ func typesFuncName(pkgPath string, fn *types.Func) (fullName, inPkgName string)
|
|||||||
sig := fn.Type().(*types.Signature)
|
sig := fn.Type().(*types.Signature)
|
||||||
name := fn.Name()
|
name := fn.Name()
|
||||||
if recv := sig.Recv(); recv != nil {
|
if recv := sig.Recv(); recv != nil {
|
||||||
tPrefix := "("
|
var method string
|
||||||
t := recv.Type()
|
t := recv.Type()
|
||||||
if tp, ok := t.(*types.Pointer); ok {
|
if tp, ok := t.(*types.Pointer); ok {
|
||||||
t, tPrefix = tp.Elem(), "(*"
|
method = "(*" + tp.Elem().(*types.Named).Obj().Name() + ")." + name
|
||||||
|
} else {
|
||||||
|
method = t.(*types.Named).Obj().Name() + "." + name
|
||||||
}
|
}
|
||||||
tSuffix := t.(*types.Named).Obj().Name() + ")." + name
|
return pkgPath + "." + method, method
|
||||||
return tPrefix + pkgPath + "." + tSuffix, tPrefix + tSuffix
|
|
||||||
}
|
}
|
||||||
return pkgPath + "." + name, name
|
return pkgPath + "." + name, name
|
||||||
}
|
}
|
||||||
@@ -277,7 +279,7 @@ func typesFuncName(pkgPath string, fn *types.Func) (fullName, inPkgName string)
|
|||||||
// TODO(xsw): may can use typesFuncName
|
// TODO(xsw): may can use typesFuncName
|
||||||
// fullName:
|
// fullName:
|
||||||
// - func: pkg.name
|
// - func: pkg.name
|
||||||
// - method: (pkg.T).name, (*pkg.T).name
|
// - method: pkg.(T).name, pkg.(*T).name
|
||||||
func funcName(pkg *types.Package, fn *ssa.Function) string {
|
func funcName(pkg *types.Package, fn *ssa.Function) string {
|
||||||
sig := fn.Signature
|
sig := fn.Signature
|
||||||
return llssa.FuncName(pkg, fn.Name(), sig.Recv())
|
return llssa.FuncName(pkg, fn.Name(), sig.Recv())
|
||||||
|
|||||||
@@ -7,3 +7,17 @@ import (
|
|||||||
func F(a, b *c.Char) {
|
func F(a, b *c.Char) {
|
||||||
c.Printf(c.Str("a: %s, b: %s\n"), a, b)
|
c.Printf(c.Str("a: %s, b: %s\n"), a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ m
|
||||||
|
|
||||||
|
type m struct {
|
||||||
|
s string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t m) info() string {
|
||||||
|
return t.s
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *m) setInfo(s string) {
|
||||||
|
t.s = s
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
; ModuleID = 'github.com/goplus/llgo/cl/internal/linktarget'
|
; ModuleID = 'github.com/goplus/llgo/cl/internal/linktarget'
|
||||||
source_filename = "github.com/goplus/llgo/cl/internal/linktarget"
|
source_filename = "github.com/goplus/llgo/cl/internal/linktarget"
|
||||||
|
|
||||||
|
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||||
|
%"github.com/goplus/llgo/cl/internal/linktarget.m" = type { %"github.com/goplus/llgo/internal/runtime.String" }
|
||||||
|
|
||||||
@"github.com/goplus/llgo/cl/internal/linktarget.init$guard" = global ptr null
|
@"github.com/goplus/llgo/cl/internal/linktarget.init$guard" = global ptr null
|
||||||
@0 = private unnamed_addr constant [14 x i8] c"a: %s, b: %s\0A\00", align 1
|
@0 = private unnamed_addr constant [14 x i8] c"a: %s, b: %s\0A\00", align 1
|
||||||
|
|
||||||
@@ -23,4 +26,30 @@ _llgo_2: ; preds = %_llgo_1, %_llgo_0
|
|||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/cl/internal/linktarget.m.info"(%"github.com/goplus/llgo/cl/internal/linktarget.m" %0) {
|
||||||
|
_llgo_0:
|
||||||
|
%1 = alloca %"github.com/goplus/llgo/cl/internal/linktarget.m", align 8
|
||||||
|
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %1, i64 16)
|
||||||
|
store %"github.com/goplus/llgo/cl/internal/linktarget.m" %0, ptr %2, align 8
|
||||||
|
%3 = getelementptr inbounds %"github.com/goplus/llgo/cl/internal/linktarget.m", ptr %2, i32 0, i32 0
|
||||||
|
%4 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %3, align 8
|
||||||
|
ret %"github.com/goplus/llgo/internal/runtime.String" %4
|
||||||
|
}
|
||||||
|
|
||||||
|
define %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/cl/internal/linktarget.(*m).info"(ptr %0) {
|
||||||
|
_llgo_0:
|
||||||
|
%1 = load %"github.com/goplus/llgo/cl/internal/linktarget.m", ptr %0, align 8
|
||||||
|
%2 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/cl/internal/linktarget.m.info"(%"github.com/goplus/llgo/cl/internal/linktarget.m" %1)
|
||||||
|
ret %"github.com/goplus/llgo/internal/runtime.String" %2
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @"github.com/goplus/llgo/cl/internal/linktarget.(*m).setInfo"(ptr %0, %"github.com/goplus/llgo/internal/runtime.String" %1) {
|
||||||
|
_llgo_0:
|
||||||
|
%2 = getelementptr inbounds %"github.com/goplus/llgo/cl/internal/linktarget.m", ptr %0, i32 0, i32 0
|
||||||
|
store %"github.com/goplus/llgo/internal/runtime.String" %1, ptr %2, align 8
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
declare i32 @printf(ptr, ...)
|
declare i32 @printf(ptr, ...)
|
||||||
|
|
||||||
|
declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64)
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -479,16 +479,17 @@ func PathOf(pkg *types.Package) string {
|
|||||||
|
|
||||||
// FuncName:
|
// FuncName:
|
||||||
// - func: pkg.name
|
// - func: pkg.name
|
||||||
// - method: (pkg.T).name, (*pkg.T).name
|
// - method: pkg.T.name, pkg.(*T).name
|
||||||
func FuncName(pkg *types.Package, name string, recv *types.Var) string {
|
func FuncName(pkg *types.Package, name string, recv *types.Var) string {
|
||||||
if recv != nil {
|
if recv != nil {
|
||||||
var tName string
|
var tName string
|
||||||
t := recv.Type()
|
t := recv.Type()
|
||||||
if tp, ok := t.(*types.Pointer); ok {
|
if tp, ok := t.(*types.Pointer); ok {
|
||||||
t, tName = tp.Elem(), "*"
|
tName = "(*" + tp.Elem().(*types.Named).Obj().Name() + ")"
|
||||||
|
} else {
|
||||||
|
tName = t.(*types.Named).Obj().Name()
|
||||||
}
|
}
|
||||||
tName += NameOf(t.(*types.Named))
|
return PathOf(pkg) + "." + tName + "." + name
|
||||||
return "(" + tName + ")." + name
|
|
||||||
}
|
}
|
||||||
ret := FullName(pkg, name)
|
ret := FullName(pkg, name)
|
||||||
if ret == "main.main" {
|
if ret == "main.main" {
|
||||||
|
|||||||
Reference in New Issue
Block a user