build: separate compiler and libs
This commit is contained in:
56
compiler/cl/_testrt/abinamed/in.go
Normal file
56
compiler/cl/_testrt/abinamed/in.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/compiler/internal/abi"
|
||||
)
|
||||
|
||||
type T struct {
|
||||
p *T
|
||||
t *abi.Type
|
||||
n uintptr
|
||||
a []T
|
||||
}
|
||||
|
||||
type eface struct {
|
||||
typ *abi.Type
|
||||
data unsafe.Pointer
|
||||
}
|
||||
|
||||
func toEface(i any) *eface {
|
||||
return (*eface)(unsafe.Pointer(&i))
|
||||
}
|
||||
|
||||
func main() {
|
||||
e := toEface(T{})
|
||||
e2 := toEface(abi.Type{})
|
||||
|
||||
println(e.typ)
|
||||
println(e.typ.PtrToThis_)
|
||||
println(e2.typ)
|
||||
println(e2.typ.PtrToThis_)
|
||||
|
||||
f0 := e.typ.StructType().Fields[0]
|
||||
if f0.Typ != e.typ.PtrToThis_ {
|
||||
panic("error field 0")
|
||||
}
|
||||
if f0.Typ.Elem() != e.typ {
|
||||
panic("error field 0 elem")
|
||||
}
|
||||
f1 := e.typ.StructType().Fields[1]
|
||||
if f1.Typ != e2.typ.PtrToThis_ {
|
||||
panic("error field 1")
|
||||
}
|
||||
if f1.Typ.Elem() != e2.typ {
|
||||
panic("error field 1 elem")
|
||||
}
|
||||
f2 := e.typ.StructType().Fields[2]
|
||||
if f2.Typ != e2.typ.StructType().Fields[0].Typ {
|
||||
panic("error field 2")
|
||||
}
|
||||
f3 := e.typ.StructType().Fields[3]
|
||||
if f3.Typ.Elem() != e.typ {
|
||||
panic("error field 3")
|
||||
}
|
||||
}
|
||||
3174
compiler/cl/_testrt/abinamed/out.ll
Normal file
3174
compiler/cl/_testrt/abinamed/out.ll
Normal file
File diff suppressed because it is too large
Load Diff
12
compiler/cl/_testrt/alloca/in.go
Normal file
12
compiler/cl/_testrt/alloca/in.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := c.Str("Hi\n")
|
||||
s2 := c.Alloca(4)
|
||||
c.Memcpy(s2, c.Pointer(s), 4)
|
||||
c.Printf(c.Str("%s"), s2)
|
||||
}
|
||||
39
compiler/cl/_testrt/alloca/out.ll
Normal file
39
compiler/cl/_testrt/alloca/out.ll
Normal file
@@ -0,0 +1,39 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [4 x i8] c"Hi\0A\00", align 1
|
||||
@1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = alloca i8, i64 4, align 1
|
||||
%3 = call ptr @memcpy(ptr %2, ptr @0, i64 4)
|
||||
%4 = call i32 (ptr, ...) @printf(ptr @1, ptr %2)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare ptr @memcpy(ptr, ptr, i64)
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
13
compiler/cl/_testrt/allocstr/in.go
Normal file
13
compiler/cl/_testrt/allocstr/in.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
func hello() string {
|
||||
return "Hello world\n"
|
||||
}
|
||||
|
||||
func main() {
|
||||
c.Printf(c.AllocaCStr(hello()))
|
||||
}
|
||||
48
compiler/cl/_testrt/allocstr/out.ll
Normal file
48
compiler/cl/_testrt/allocstr/out.ll
Normal file
@@ -0,0 +1,48 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@0 = private unnamed_addr constant [12 x i8] c"Hello world\0A", align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.String" @main.hello() {
|
||||
_llgo_0:
|
||||
ret %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 12 }
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call %"github.com/goplus/llgo/internal/runtime.String" @main.hello()
|
||||
%3 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %2, 1
|
||||
%4 = add i64 %3, 1
|
||||
%5 = alloca i8, i64 %4, align 1
|
||||
%6 = call ptr @"github.com/goplus/llgo/internal/runtime.CStrCopy"(ptr %5, %"github.com/goplus/llgo/internal/runtime.String" %2)
|
||||
%7 = call i32 (ptr, ...) @printf(ptr %6)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.CStrCopy"(ptr, %"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
17
compiler/cl/_testrt/any/in.go
Normal file
17
compiler/cl/_testrt/any/in.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
func hi(a any) *c.Char {
|
||||
return a.(*c.Char)
|
||||
}
|
||||
|
||||
func incVal(a any) int {
|
||||
return a.(int) + 1
|
||||
}
|
||||
|
||||
func main() {
|
||||
c.Printf(c.Str("%s %d\n"), hi(c.Str("Hello")), incVal(100))
|
||||
}
|
||||
154
compiler/cl/_testrt/any/out.ll
Normal file
154
compiler/cl/_testrt/any/out.ll
Normal file
@@ -0,0 +1,154 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@_llgo_int8 = linkonce global ptr null, align 8
|
||||
@"*_llgo_int8" = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [21 x i8] c"type assertion failed", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@_llgo_int = linkonce global ptr null, align 8
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@1 = private unnamed_addr constant [7 x i8] c"%s %d\0A\00", align 1
|
||||
@2 = private unnamed_addr constant [6 x i8] c"Hello\00", align 1
|
||||
|
||||
define ptr @main.hi(%"github.com/goplus/llgo/internal/runtime.eface" %0) {
|
||||
_llgo_0:
|
||||
%1 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0
|
||||
%2 = load ptr, ptr @_llgo_int8, align 8
|
||||
%3 = load ptr, ptr @"*_llgo_int8", align 8
|
||||
%4 = icmp eq ptr %1, %3
|
||||
br i1 %4, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%5 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1
|
||||
ret ptr %5
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
%6 = load ptr, ptr @_llgo_string, align 8
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 21 }, ptr %7, align 8
|
||||
%8 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %6, 0
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %8, ptr %7, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %9)
|
||||
unreachable
|
||||
}
|
||||
|
||||
define i64 @main.incVal(%"github.com/goplus/llgo/internal/runtime.eface" %0) {
|
||||
_llgo_0:
|
||||
%1 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0
|
||||
%2 = load ptr, ptr @_llgo_int, 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/internal/runtime.eface" %0, 1
|
||||
%5 = ptrtoint ptr %4 to i64
|
||||
%6 = add i64 %5, 1
|
||||
ret i64 %6
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
%7 = load ptr, ptr @_llgo_string, align 8
|
||||
%8 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 21 }, ptr %8, align 8
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %7, 0
|
||||
%10 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %9, ptr %8, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %10)
|
||||
unreachable
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"main.init$after"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = load ptr, ptr @"*_llgo_int8", align 8
|
||||
%3 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %2, 0
|
||||
%4 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %3, ptr @2, 1
|
||||
%5 = call ptr @main.hi(%"github.com/goplus/llgo/internal/runtime.eface" %4)
|
||||
%6 = load ptr, ptr @_llgo_int, align 8
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %6, 0
|
||||
%8 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %7, ptr inttoptr (i64 100 to ptr), 1
|
||||
%9 = call i64 @main.incVal(%"github.com/goplus/llgo/internal/runtime.eface" %8)
|
||||
%10 = call i32 (ptr, ...) @printf(ptr @1, ptr %5, i64 %9)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @"main.init$after"() {
|
||||
_llgo_0:
|
||||
%0 = load ptr, ptr @_llgo_int8, 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/internal/runtime.Basic"(i64 35)
|
||||
store ptr %2, ptr @_llgo_int8, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%3 = load ptr, ptr @"*_llgo_int8", 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/internal/runtime.Basic"(i64 35)
|
||||
%6 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %5)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %6)
|
||||
store ptr %6, ptr @"*_llgo_int8", align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%7 = load ptr, ptr @_llgo_string, align 8
|
||||
%8 = icmp eq ptr %7, null
|
||||
br i1 %8, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4
|
||||
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
store ptr %9, ptr @_llgo_string, align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
%10 = load ptr, ptr @_llgo_int, align 8
|
||||
%11 = icmp eq ptr %10, null
|
||||
br i1 %11, label %_llgo_7, label %_llgo_8
|
||||
|
||||
_llgo_7: ; preds = %_llgo_6
|
||||
%12 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
store ptr %12, ptr @_llgo_int, align 8
|
||||
br label %_llgo_8
|
||||
|
||||
_llgo_8: ; preds = %_llgo_7, %_llgo_6
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
92
compiler/cl/_testrt/builtin/in.go
Normal file
92
compiler/cl/_testrt/builtin/in.go
Normal file
@@ -0,0 +1,92 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var a int64 = 1<<63 - 1
|
||||
var b int64 = -1 << 63
|
||||
var n uint64 = 1<<64 - 1
|
||||
|
||||
func main() {
|
||||
var s = []int{1, 2, 3, 4}
|
||||
var a = [...]int{1, 2, 3, 4}
|
||||
d := make([]byte, 4, 10)
|
||||
println(s, len(s), cap(s))
|
||||
println(d, len(d), cap(d))
|
||||
println(len(a), cap(a), cap(&a), len(&a))
|
||||
println(len([]int{1, 2, 3, 4}), len([4]int{1, 2, 3, 4}))
|
||||
println(len(s[1:]), cap(s[1:]), len(s[1:2]), cap(s[1:2]), len(s[1:2:2]), cap(s[1:2:2]))
|
||||
println(len(a[1:]), cap(a[1:]), len(a[1:2]), cap(a[1:2]), len(a[1:2:2]), cap(a[1:2:2]))
|
||||
|
||||
println("hello", "hello"[1:], "hello"[1:2], len("hello"[5:]))
|
||||
println(append(s, 5, 6, 7, 8))
|
||||
data := []byte{'a', 'b', 'c'}
|
||||
data = append(data, "def"...)
|
||||
println(data)
|
||||
var i any = 100
|
||||
println(true, 0, 100, -100, uint(255), int32(-100), 0.0, 100.5, i, &i, uintptr(unsafe.Pointer(&i)))
|
||||
var dst [3]byte
|
||||
n := copy(dst[:], data)
|
||||
println(n, dst[0], dst[1], dst[2])
|
||||
n = copy(dst[1:], "ABCD")
|
||||
println(n, dst[0], dst[1], dst[2])
|
||||
|
||||
fn1 := demo
|
||||
fn2 := func() {
|
||||
println("fn")
|
||||
}
|
||||
fn3 := func() {
|
||||
println(n)
|
||||
}
|
||||
println(demo, fn1, fn2, fn3)
|
||||
|
||||
for i, v := range "中abcd" {
|
||||
println(i, v)
|
||||
}
|
||||
|
||||
println(Inf(1), Inf(-1), NaN(), IsNaN(NaN()), IsNaN(1.0))
|
||||
|
||||
data1 := []byte("中abcd")
|
||||
data2 := []rune("中abcd")
|
||||
println(data1, data2)
|
||||
println(string(data1), string(data2), string(data1[3]), string(data2[0]))
|
||||
s1 := "abc"
|
||||
s2 := "abd"
|
||||
println(s1 == "abc", s1 == s2, s1 != s2, s1 < s2, s1 <= s2, s1 > s2, s1 >= s2)
|
||||
}
|
||||
|
||||
func demo() {
|
||||
}
|
||||
|
||||
const (
|
||||
uvnan = 0x7FF8000000000001
|
||||
uvinf = 0x7FF0000000000000
|
||||
uvneginf = 0xFFF0000000000000
|
||||
uvone = 0x3FF0000000000000
|
||||
mask = 0x7FF
|
||||
shift = 64 - 11 - 1
|
||||
bias = 1023
|
||||
signMask = 1 << 63
|
||||
fracMask = 1<<shift - 1
|
||||
)
|
||||
|
||||
// Inf returns positive infinity if sign >= 0, negative infinity if sign < 0.
|
||||
func Inf(sign int) float64 {
|
||||
var v uint64
|
||||
if sign >= 0 {
|
||||
v = uvinf
|
||||
} else {
|
||||
v = uvneginf
|
||||
}
|
||||
return Float64frombits(v)
|
||||
}
|
||||
|
||||
// NaN returns an IEEE 754 “not-a-number” value.
|
||||
func NaN() float64 { return Float64frombits(uvnan) }
|
||||
|
||||
func IsNaN(f float64) (is bool) {
|
||||
return f != f
|
||||
}
|
||||
|
||||
func Float64frombits(b uint64) float64 { return *(*float64)(unsafe.Pointer(&b)) }
|
||||
523
compiler/cl/_testrt/builtin/out.ll
Normal file
523
compiler/cl/_testrt/builtin/out.ll
Normal file
@@ -0,0 +1,523 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
|
||||
@main.a = global i64 0, align 8
|
||||
@main.b = global i64 0, align 8
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@main.n = global i64 0, align 8
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [5 x i8] c"hello", align 1
|
||||
@1 = private unnamed_addr constant [3 x i8] c"def", align 1
|
||||
@_llgo_int = linkonce global ptr null, align 8
|
||||
@2 = private unnamed_addr constant [4 x i8] c"ABCD", align 1
|
||||
@3 = private unnamed_addr constant [7 x i8] c"\E4\B8\ADabcd", align 1
|
||||
@4 = private unnamed_addr constant [3 x i8] c"abc", align 1
|
||||
@5 = private unnamed_addr constant [3 x i8] c"abd", align 1
|
||||
@6 = private unnamed_addr constant [2 x i8] c"fn", align 1
|
||||
|
||||
define double @main.Float64frombits(i64 %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
store i64 %0, ptr %1, align 4
|
||||
%2 = load double, ptr %1, align 8
|
||||
ret double %2
|
||||
}
|
||||
|
||||
define double @main.Inf(i64 %0) {
|
||||
_llgo_0:
|
||||
%1 = icmp sge i64 %0, 0
|
||||
br i1 %1, label %_llgo_1, label %_llgo_3
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_3, %_llgo_1
|
||||
%2 = phi i64 [ 9218868437227405312, %_llgo_1 ], [ -4503599627370496, %_llgo_3 ]
|
||||
%3 = call double @main.Float64frombits(i64 %2)
|
||||
ret double %3
|
||||
|
||||
_llgo_3: ; preds = %_llgo_0
|
||||
br label %_llgo_2
|
||||
}
|
||||
|
||||
define i1 @main.IsNaN(double %0) {
|
||||
_llgo_0:
|
||||
%1 = fcmp une double %0, %0
|
||||
ret i1 %1
|
||||
}
|
||||
|
||||
define double @main.NaN() {
|
||||
_llgo_0:
|
||||
%0 = call double @main.Float64frombits(i64 9221120237041090561)
|
||||
ret double %0
|
||||
}
|
||||
|
||||
define void @main.demo() {
|
||||
_llgo_0:
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"main.init$after"()
|
||||
store i64 9223372036854775807, ptr @main.a, align 4
|
||||
store i64 -9223372036854775808, ptr @main.b, align 4
|
||||
store i64 -1, ptr @main.n, align 4
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32)
|
||||
%3 = getelementptr inbounds i64, ptr %2, i64 0
|
||||
store i64 1, ptr %3, align 4
|
||||
%4 = getelementptr inbounds i64, ptr %2, i64 1
|
||||
store i64 2, ptr %4, align 4
|
||||
%5 = getelementptr inbounds i64, ptr %2, i64 2
|
||||
store i64 3, ptr %5, align 4
|
||||
%6 = getelementptr inbounds i64, ptr %2, i64 3
|
||||
store i64 4, ptr %6, align 4
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %2, 0
|
||||
%8 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, i64 4, 1
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %8, i64 4, 2
|
||||
%10 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32)
|
||||
%11 = getelementptr inbounds i64, ptr %10, i64 0
|
||||
%12 = getelementptr inbounds i64, ptr %10, i64 1
|
||||
%13 = getelementptr inbounds i64, ptr %10, i64 2
|
||||
%14 = getelementptr inbounds i64, ptr %10, i64 3
|
||||
store i64 1, ptr %11, align 4
|
||||
store i64 2, ptr %12, align 4
|
||||
store i64 3, ptr %13, align 4
|
||||
store i64 4, ptr %14, align 4
|
||||
%15 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 10)
|
||||
%16 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %15, i64 1, i64 10, i64 0, i64 4, i64 10)
|
||||
%17 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 1
|
||||
%18 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %9)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %17)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %18)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%19 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %16, 1
|
||||
%20 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %16, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %16)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %19)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %20)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%21 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32)
|
||||
%22 = getelementptr inbounds i64, ptr %21, i64 0
|
||||
store i64 1, ptr %22, align 4
|
||||
%23 = getelementptr inbounds i64, ptr %21, i64 1
|
||||
store i64 2, ptr %23, align 4
|
||||
%24 = getelementptr inbounds i64, ptr %21, i64 2
|
||||
store i64 3, ptr %24, align 4
|
||||
%25 = getelementptr inbounds i64, ptr %21, i64 3
|
||||
store i64 4, ptr %25, align 4
|
||||
%26 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %21, 0
|
||||
%27 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %26, i64 4, 1
|
||||
%28 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %27, i64 4, 2
|
||||
%29 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %28, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %29)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%30 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 2
|
||||
%31 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 1
|
||||
%32 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 0
|
||||
%33 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %32, i64 8, i64 %30, i64 1, i64 %31, i64 %30)
|
||||
%34 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %33, 1
|
||||
%35 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 2
|
||||
%36 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 1
|
||||
%37 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 0
|
||||
%38 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %37, i64 8, i64 %35, i64 1, i64 %36, i64 %35)
|
||||
%39 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %38, 2
|
||||
%40 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 2
|
||||
%41 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 0
|
||||
%42 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %41, i64 8, i64 %40, i64 1, i64 2, i64 %40)
|
||||
%43 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %42, 1
|
||||
%44 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 2
|
||||
%45 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 0
|
||||
%46 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %45, i64 8, i64 %44, i64 1, i64 2, i64 %44)
|
||||
%47 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %46, 2
|
||||
%48 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 2
|
||||
%49 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 0
|
||||
%50 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %49, i64 8, i64 %48, i64 1, i64 2, i64 2)
|
||||
%51 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %50, 1
|
||||
%52 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 2
|
||||
%53 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 0
|
||||
%54 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %53, i64 8, i64 %52, i64 1, i64 2, i64 2)
|
||||
%55 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %54, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %34)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %39)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %43)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %47)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %51)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %55)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%56 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %10, i64 8, i64 4, i64 1, i64 4, i64 4)
|
||||
%57 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %56, 1
|
||||
%58 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %10, i64 8, i64 4, i64 1, i64 4, i64 4)
|
||||
%59 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %58, 2
|
||||
%60 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %10, i64 8, i64 4, i64 1, i64 2, i64 4)
|
||||
%61 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %60, 1
|
||||
%62 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %10, i64 8, i64 4, i64 1, i64 2, i64 4)
|
||||
%63 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %62, 2
|
||||
%64 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %10, i64 8, i64 4, i64 1, i64 2, i64 2)
|
||||
%65 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %64, 1
|
||||
%66 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %10, i64 8, i64 4, i64 1, i64 2, i64 2)
|
||||
%67 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %66, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %57)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %59)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %61)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %63)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %65)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %67)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%68 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringSlice"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, i64 1, i64 5)
|
||||
%69 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringSlice"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, i64 1, i64 2)
|
||||
%70 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringSlice"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, i64 5, i64 5)
|
||||
%71 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %70, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %68)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %69)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %71)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%72 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32)
|
||||
%73 = getelementptr inbounds i64, ptr %72, i64 0
|
||||
store i64 5, ptr %73, align 4
|
||||
%74 = getelementptr inbounds i64, ptr %72, i64 1
|
||||
store i64 6, ptr %74, align 4
|
||||
%75 = getelementptr inbounds i64, ptr %72, i64 2
|
||||
store i64 7, ptr %75, align 4
|
||||
%76 = getelementptr inbounds i64, ptr %72, i64 3
|
||||
store i64 8, ptr %76, align 4
|
||||
%77 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %72, 0
|
||||
%78 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %77, i64 4, 1
|
||||
%79 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %78, i64 4, 2
|
||||
%80 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %79, 0
|
||||
%81 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %79, 1
|
||||
%82 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.SliceAppend"(%"github.com/goplus/llgo/internal/runtime.Slice" %9, ptr %80, i64 %81, i64 8)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %82)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%83 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 3)
|
||||
%84 = getelementptr inbounds i8, ptr %83, i64 0
|
||||
store i8 97, ptr %84, align 1
|
||||
%85 = getelementptr inbounds i8, ptr %83, i64 1
|
||||
store i8 98, ptr %85, align 1
|
||||
%86 = getelementptr inbounds i8, ptr %83, i64 2
|
||||
store i8 99, ptr %86, align 1
|
||||
%87 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %83, 0
|
||||
%88 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %87, i64 3, 1
|
||||
%89 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %88, i64 3, 2
|
||||
%90 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.SliceAppend"(%"github.com/goplus/llgo/internal/runtime.Slice" %89, ptr @1, i64 3, i64 1)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %90)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%91 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
%92 = load ptr, ptr @_llgo_int, align 8
|
||||
%93 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %92, 0
|
||||
%94 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %93, ptr inttoptr (i64 100 to ptr), 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %94, ptr %91, align 8
|
||||
%95 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %91, align 8
|
||||
%96 = ptrtoint ptr %91 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 true)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 0)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 100)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 -100)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 255)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 -100)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double 0.000000e+00)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double 1.005000e+02)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintEface"(%"github.com/goplus/llgo/internal/runtime.eface" %95)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %91)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %96)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%97 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 3)
|
||||
%98 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%99 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %97, 0
|
||||
%100 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %99, i64 3, 1
|
||||
%101 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %100, i64 3, 2
|
||||
%102 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %90, 0
|
||||
%103 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %90, 1
|
||||
%104 = call i64 @"github.com/goplus/llgo/internal/runtime.SliceCopy"(%"github.com/goplus/llgo/internal/runtime.Slice" %101, ptr %102, i64 %103, i64 1)
|
||||
store i64 %104, ptr %98, align 4
|
||||
%105 = load i64, ptr %98, align 4
|
||||
%106 = getelementptr inbounds i8, ptr %97, i64 0
|
||||
%107 = load i8, ptr %106, align 1
|
||||
%108 = getelementptr inbounds i8, ptr %97, i64 1
|
||||
%109 = load i8, ptr %108, align 1
|
||||
%110 = getelementptr inbounds i8, ptr %97, i64 2
|
||||
%111 = load i8, ptr %110, align 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %105)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%112 = zext i8 %107 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %112)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%113 = zext i8 %109 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %113)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%114 = zext i8 %111 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %114)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%115 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %97, i64 1, i64 3, i64 1, i64 3, i64 3)
|
||||
%116 = call i64 @"github.com/goplus/llgo/internal/runtime.SliceCopy"(%"github.com/goplus/llgo/internal/runtime.Slice" %115, ptr @2, i64 4, i64 1)
|
||||
store i64 %116, ptr %98, align 4
|
||||
%117 = load i64, ptr %98, align 4
|
||||
%118 = getelementptr inbounds i8, ptr %97, i64 0
|
||||
%119 = load i8, ptr %118, align 1
|
||||
%120 = getelementptr inbounds i8, ptr %97, i64 1
|
||||
%121 = load i8, ptr %120, align 1
|
||||
%122 = getelementptr inbounds i8, ptr %97, i64 2
|
||||
%123 = load i8, ptr %122, align 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %117)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%124 = zext i8 %119 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %124)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%125 = zext i8 %121 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %125)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%126 = zext i8 %123 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %126)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%127 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%128 = getelementptr inbounds { ptr }, ptr %127, i32 0, i32 0
|
||||
store ptr %98, ptr %128, align 8
|
||||
%129 = insertvalue { ptr, ptr } { ptr @"main.main$2", ptr undef }, ptr %127, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr @main.demo)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr @main.demo)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr @"main.main$1")
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%130 = extractvalue { ptr, ptr } %129, 0
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %130)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%131 = call ptr @"github.com/goplus/llgo/internal/runtime.NewStringIter"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 7 })
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%132 = call { i1, i64, i32 } @"github.com/goplus/llgo/internal/runtime.StringIterNext"(ptr %131)
|
||||
%133 = extractvalue { i1, i64, i32 } %132, 0
|
||||
br i1 %133, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%134 = extractvalue { i1, i64, i32 } %132, 1
|
||||
%135 = extractvalue { i1, i64, i32 } %132, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %134)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%136 = sext i32 %135 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %136)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
%137 = call double @main.Inf(i64 1)
|
||||
%138 = call double @main.Inf(i64 -1)
|
||||
%139 = call double @main.NaN()
|
||||
%140 = call double @main.NaN()
|
||||
%141 = call i1 @main.IsNaN(double %140)
|
||||
%142 = call i1 @main.IsNaN(double 1.000000e+00)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double %137)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double %138)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double %139)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %141)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %142)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%143 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.StringToBytes"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 7 })
|
||||
%144 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.StringToRunes"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 7 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %143)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %144)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%145 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringFromBytes"(%"github.com/goplus/llgo/internal/runtime.Slice" %143)
|
||||
%146 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringFromRunes"(%"github.com/goplus/llgo/internal/runtime.Slice" %144)
|
||||
%147 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %143, 0
|
||||
%148 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %143, 1
|
||||
%149 = icmp sge i64 3, %148
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %149)
|
||||
%150 = getelementptr inbounds i8, ptr %147, i64 3
|
||||
%151 = load i8, ptr %150, align 1
|
||||
%152 = sext i8 %151 to i32
|
||||
%153 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringFromRune"(i32 %152)
|
||||
%154 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %144, 0
|
||||
%155 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %144, 1
|
||||
%156 = icmp sge i64 0, %155
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %156)
|
||||
%157 = getelementptr inbounds i32, ptr %154, i64 0
|
||||
%158 = load i32, ptr %157, align 4
|
||||
%159 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringFromRune"(i32 %158)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %145)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %146)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %153)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %159)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%160 = call i1 @"github.com/goplus/llgo/internal/runtime.StringEqual"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 3 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 3 })
|
||||
%161 = call i1 @"github.com/goplus/llgo/internal/runtime.StringEqual"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 3 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 3 })
|
||||
%162 = call i1 @"github.com/goplus/llgo/internal/runtime.StringEqual"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 3 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 3 })
|
||||
%163 = xor i1 %162, true
|
||||
%164 = call i1 @"github.com/goplus/llgo/internal/runtime.StringLess"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 3 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 3 })
|
||||
%165 = call i1 @"github.com/goplus/llgo/internal/runtime.StringLess"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 3 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 3 })
|
||||
%166 = xor i1 %165, true
|
||||
%167 = call i1 @"github.com/goplus/llgo/internal/runtime.StringLess"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 3 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 3 })
|
||||
%168 = call i1 @"github.com/goplus/llgo/internal/runtime.StringLess"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 3 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 3 })
|
||||
%169 = xor i1 %168, true
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %160)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %161)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %163)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %164)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %166)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %167)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %169)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @"main.main$1"() {
|
||||
_llgo_0:
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 2 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.main$2"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { ptr }, ptr %0, align 8
|
||||
%2 = extractvalue { ptr } %1, 0
|
||||
%3 = load i64, ptr %2, align 4
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %3)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr, i64, i64, i64, i64, i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64)
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringSlice"(%"github.com/goplus/llgo/internal/runtime.String", i64, i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.SliceAppend"(%"github.com/goplus/llgo/internal/runtime.Slice", ptr, i64, i64)
|
||||
|
||||
define void @"main.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/internal/runtime.Basic"(i64 34)
|
||||
store ptr %2, ptr @_llgo_int, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintEface"(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr)
|
||||
|
||||
declare i64 @"github.com/goplus/llgo/internal/runtime.SliceCopy"(%"github.com/goplus/llgo/internal/runtime.Slice", ptr, i64, i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.NewStringIter"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare { i1, i64, i32 } @"github.com/goplus/llgo/internal/runtime.StringIterNext"(ptr)
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.StringToBytes"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.StringToRunes"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringFromBytes"(%"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringFromRunes"(%"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1)
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringFromRune"(i32)
|
||||
|
||||
declare i1 @"github.com/goplus/llgo/internal/runtime.StringEqual"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare i1 @"github.com/goplus/llgo/internal/runtime.StringLess"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String")
|
||||
18
compiler/cl/_testrt/callback/in.go
Normal file
18
compiler/cl/_testrt/callback/in.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
func callback(msg *c.Char, f func(*c.Char)) {
|
||||
f(msg)
|
||||
}
|
||||
|
||||
func print(msg *c.Char) {
|
||||
c.Printf(msg)
|
||||
}
|
||||
|
||||
func main() {
|
||||
callback(c.Str("Hello\n"), print)
|
||||
callback(c.Str("callback\n"), print)
|
||||
}
|
||||
56
compiler/cl/_testrt/callback/out.ll
Normal file
56
compiler/cl/_testrt/callback/out.ll
Normal file
@@ -0,0 +1,56 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [7 x i8] c"Hello\0A\00", align 1
|
||||
@1 = private unnamed_addr constant [10 x i8] c"callback\0A\00", align 1
|
||||
|
||||
define void @main.callback(ptr %0, { ptr, ptr } %1) {
|
||||
_llgo_0:
|
||||
%2 = extractvalue { ptr, ptr } %1, 1
|
||||
%3 = extractvalue { ptr, ptr } %1, 0
|
||||
call void %3(ptr %2, ptr %0)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
call void @main.callback(ptr @0, { ptr, ptr } { ptr @__llgo_stub.main.print, ptr null })
|
||||
call void @main.callback(ptr @1, { ptr, ptr } { ptr @__llgo_stub.main.print, ptr null })
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @main.print(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = call i32 (ptr, ...) @printf(ptr %0)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
define linkonce void @__llgo_stub.main.print(ptr %0, ptr %1) {
|
||||
_llgo_0:
|
||||
tail call void @main.print(ptr %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
155
compiler/cl/_testrt/cast/in.go
Normal file
155
compiler/cl/_testrt/cast/in.go
Normal file
@@ -0,0 +1,155 @@
|
||||
package main
|
||||
|
||||
//"github.com/goplus/llgo/c"
|
||||
|
||||
func main() {
|
||||
cvt64to8(0, 0)
|
||||
cvt64to8(127, 127)
|
||||
cvt64to8(128, -128)
|
||||
cvt64to8(-128, -128)
|
||||
cvt64to8(-129, 127)
|
||||
cvt64to8(256, 0)
|
||||
|
||||
cvt64to8U(0, 0)
|
||||
cvt64to8U(255, 255)
|
||||
cvt64to8U(256, 0)
|
||||
cvt64to8U(257, 1)
|
||||
cvt64to8U(-1, 255)
|
||||
|
||||
cvt32Fto8(0.1, 0)
|
||||
cvt32Fto8(127.1, 127)
|
||||
cvt32Fto8(128.1, -128)
|
||||
cvt32Fto8(-128.1, -128)
|
||||
cvt32Fto8(-129.1, 127)
|
||||
cvt32Fto8(256.1, 0)
|
||||
|
||||
cvt32Fto8U(0, 0)
|
||||
cvt32Fto8U(255, 255)
|
||||
cvt32Fto8U(256, 0)
|
||||
cvt32Fto8U(257, 1)
|
||||
cvt32Fto8U(-1, 255)
|
||||
|
||||
// MaxInt32 = 1<<31 - 1 // 2147483647
|
||||
// MinInt32 = -1 << 31 // -2147483648
|
||||
cvt32Fto32(0, 0)
|
||||
cvt32Fto32(1.5, 1)
|
||||
cvt32Fto32(1147483647.1, 1147483648)
|
||||
cvt32Fto32(-2147483648.1, -2147483648)
|
||||
|
||||
// MaxUint32 = 1<<32 - 1 // 4294967295
|
||||
cvt32Fto32U(0, 0)
|
||||
cvt32Fto32U(1.5, 1)
|
||||
cvt32Fto32U(4294967295.1, 0)
|
||||
cvt32Fto32U(5294967295.1, 1000000000)
|
||||
cvt32Fto32U(-4294967295.1, 0)
|
||||
cvt32Fto32U(-1294967295.1, 3000000000)
|
||||
cvt32Fto32U(-1.1, 4294967295)
|
||||
|
||||
// MaxFloat32 = 0x1p127 * (1 + (1 - 0x1p-23)) // 3.40282346638528859811704183484516925440e+38
|
||||
// SmallestNonzeroFloat32 = 0x1p-126 * 0x1p-23 // 1.401298464324817070923729583289916131280e-45
|
||||
// MaxFloat64 = 0x1p1023 * (1 + (1 - 0x1p-52)) // 1.79769313486231570814527423731704356798070e+308
|
||||
// SmallestNonzeroFloat64 = 0x1p-1022 * 0x1p-52 // 4.9406564584124654417656879286822137236505980e-324
|
||||
|
||||
cvt32Fto64F(0, 0)
|
||||
cvt32Fto64F(1.5, 1.5)
|
||||
cvt32Fto64F(1e10, 1e10)
|
||||
cvt32Fto64F(-1e10, -1e10)
|
||||
|
||||
cvt64Fto32F(0, 0)
|
||||
cvt64Fto32F(1.5, 1.5)
|
||||
cvt64Fto32F(1e10, 1e10)
|
||||
cvt64Fto32F(-1e10, -1e10)
|
||||
|
||||
// MaxInt64 = 1<<63 - 1 // 9223372036854775807
|
||||
// MinInt64 = -1 << 63 // -9223372036854775808
|
||||
cvt64to64F(0, 0)
|
||||
cvt64to64F(1e10, 1e10)
|
||||
cvt64to64F(9223372036854775807, 9223372036854775807)
|
||||
cvt64to64F(-9223372036854775807, -9223372036854775807)
|
||||
|
||||
// MaxUint64 = 1<<64 - 1 // 18446744073709551615
|
||||
cvt64Uto64F(0, 0)
|
||||
cvt64Uto64F(1e10, 1e10)
|
||||
cvt64Uto64F(9223372036854775807, 9223372036854775807)
|
||||
cvt64Uto64F(18446744073709551615, 18446744073709551615)
|
||||
|
||||
cvt32to64(0, 0)
|
||||
cvt32to64(2147483647, 2147483647)
|
||||
|
||||
cvtUinptr(1024, 1024)
|
||||
}
|
||||
|
||||
func cvtUinptr(a int32, b uintptr) {
|
||||
if uintptr(a) != b {
|
||||
panic("error")
|
||||
}
|
||||
if int32(b) != a {
|
||||
panic("error")
|
||||
}
|
||||
}
|
||||
|
||||
func cvt32to64(a int32, b int64) {
|
||||
if int64(a) != b {
|
||||
panic("error")
|
||||
}
|
||||
}
|
||||
|
||||
func cvt64to64F(a int64, b float64) {
|
||||
if float64(a) != b {
|
||||
panic("error")
|
||||
}
|
||||
}
|
||||
|
||||
func cvt64Uto64F(a uint64, b float64) {
|
||||
if float64(a) != b {
|
||||
panic("error")
|
||||
}
|
||||
}
|
||||
|
||||
func cvt64Fto32F(a float64, b float32) {
|
||||
if float32(a) != b {
|
||||
panic("error")
|
||||
}
|
||||
}
|
||||
|
||||
func cvt32Fto64F(a float32, b float64) {
|
||||
if float64(a) != b {
|
||||
panic("error")
|
||||
}
|
||||
}
|
||||
|
||||
func cvt32Fto32(a float32, b int32) {
|
||||
if int32(a) != b {
|
||||
panic("error")
|
||||
}
|
||||
}
|
||||
|
||||
func cvt32Fto32U(a float32, b uint32) {
|
||||
if uint32(a) != b {
|
||||
panic("error")
|
||||
}
|
||||
}
|
||||
|
||||
func cvt32Fto8(a float32, b int8) {
|
||||
if int8(a) != b {
|
||||
panic("error")
|
||||
}
|
||||
}
|
||||
|
||||
func cvt32Fto8U(a float32, b uint8) {
|
||||
if uint8(a) != b {
|
||||
panic("error")
|
||||
}
|
||||
}
|
||||
|
||||
func cvt64to8(a int64, b int8) {
|
||||
if int8(a) != b {
|
||||
panic("error")
|
||||
}
|
||||
}
|
||||
|
||||
func cvt64to8U(a int, b uint8) {
|
||||
if uint8(a) != b {
|
||||
panic("error")
|
||||
}
|
||||
}
|
||||
351
compiler/cl/_testrt/cast/out.ll
Normal file
351
compiler/cl/_testrt/cast/out.ll
Normal file
@@ -0,0 +1,351 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@0 = private unnamed_addr constant [5 x i8] c"error", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.cvt32Fto32(float %0, i32 %1) {
|
||||
_llgo_0:
|
||||
%2 = fptosi float %0 to i32
|
||||
%3 = icmp ne i32 %2, %1
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.cvt32Fto32U(float %0, i32 %1) {
|
||||
_llgo_0:
|
||||
%2 = fptoui float %0 to i32
|
||||
%3 = icmp ne i32 %2, %1
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.cvt32Fto64F(float %0, double %1) {
|
||||
_llgo_0:
|
||||
%2 = fpext float %0 to double
|
||||
%3 = fcmp une double %2, %1
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.cvt32Fto8(float %0, i8 %1) {
|
||||
_llgo_0:
|
||||
%2 = fptosi float %0 to i8
|
||||
%3 = icmp ne i8 %2, %1
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.cvt32Fto8U(float %0, i8 %1) {
|
||||
_llgo_0:
|
||||
%2 = fptoui float %0 to i8
|
||||
%3 = icmp ne i8 %2, %1
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.cvt32to64(i32 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = sext i32 %0 to i64
|
||||
%3 = icmp ne i64 %2, %1
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.cvt64Fto32F(double %0, float %1) {
|
||||
_llgo_0:
|
||||
%2 = fptrunc double %0 to float
|
||||
%3 = fcmp une float %2, %1
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.cvt64Uto64F(i64 %0, double %1) {
|
||||
_llgo_0:
|
||||
%2 = uitofp i64 %0 to double
|
||||
%3 = fcmp une double %2, %1
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.cvt64to64F(i64 %0, double %1) {
|
||||
_llgo_0:
|
||||
%2 = sitofp i64 %0 to double
|
||||
%3 = fcmp une double %2, %1
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.cvt64to8(i64 %0, i8 %1) {
|
||||
_llgo_0:
|
||||
%2 = trunc i64 %0 to i8
|
||||
%3 = icmp ne i8 %2, %1
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.cvt64to8U(i64 %0, i8 %1) {
|
||||
_llgo_0:
|
||||
%2 = trunc i64 %0 to i8
|
||||
%3 = icmp ne i8 %2, %1
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.cvtUinptr(i32 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = zext i32 %0 to i64
|
||||
%3 = icmp ne i64 %2, %1
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
%8 = trunc i64 %1 to i32
|
||||
%9 = icmp ne i32 %8, %0
|
||||
br i1 %9, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_3: ; preds = %_llgo_2
|
||||
%10 = load ptr, ptr @_llgo_string, align 8
|
||||
%11 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %11, align 8
|
||||
%12 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %10, 0
|
||||
%13 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %12, ptr %11, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %13)
|
||||
unreachable
|
||||
|
||||
_llgo_4: ; preds = %_llgo_2
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"main.init$after"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
call void @main.cvt64to8(i64 0, i8 0)
|
||||
call void @main.cvt64to8(i64 127, i8 127)
|
||||
call void @main.cvt64to8(i64 128, i8 -128)
|
||||
call void @main.cvt64to8(i64 -128, i8 -128)
|
||||
call void @main.cvt64to8(i64 -129, i8 127)
|
||||
call void @main.cvt64to8(i64 256, i8 0)
|
||||
call void @main.cvt64to8U(i64 0, i8 0)
|
||||
call void @main.cvt64to8U(i64 255, i8 -1)
|
||||
call void @main.cvt64to8U(i64 256, i8 0)
|
||||
call void @main.cvt64to8U(i64 257, i8 1)
|
||||
call void @main.cvt64to8U(i64 -1, i8 -1)
|
||||
call void @main.cvt32Fto8(float 0x3FB99999A0000000, i8 0)
|
||||
call void @main.cvt32Fto8(float 0x405FC66660000000, i8 127)
|
||||
call void @main.cvt32Fto8(float 0x4060033340000000, i8 -128)
|
||||
call void @main.cvt32Fto8(float 0xC060033340000000, i8 -128)
|
||||
call void @main.cvt32Fto8(float 0xC060233340000000, i8 127)
|
||||
call void @main.cvt32Fto8(float 0x40700199A0000000, i8 0)
|
||||
call void @main.cvt32Fto8U(float 0.000000e+00, i8 0)
|
||||
call void @main.cvt32Fto8U(float 2.550000e+02, i8 -1)
|
||||
call void @main.cvt32Fto8U(float 2.560000e+02, i8 0)
|
||||
call void @main.cvt32Fto8U(float 2.570000e+02, i8 1)
|
||||
call void @main.cvt32Fto8U(float -1.000000e+00, i8 -1)
|
||||
call void @main.cvt32Fto32(float 0.000000e+00, i32 0)
|
||||
call void @main.cvt32Fto32(float 1.500000e+00, i32 1)
|
||||
call void @main.cvt32Fto32(float 0x41D1194D80000000, i32 1147483648)
|
||||
call void @main.cvt32Fto32(float 0xC1E0000000000000, i32 -2147483648)
|
||||
call void @main.cvt32Fto32U(float 0.000000e+00, i32 0)
|
||||
call void @main.cvt32Fto32U(float 1.500000e+00, i32 1)
|
||||
call void @main.cvt32Fto32U(float 0x41F0000000000000, i32 0)
|
||||
call void @main.cvt32Fto32U(float 0x41F3B9ACA0000000, i32 1000000000)
|
||||
call void @main.cvt32Fto32U(float 0xC1F0000000000000, i32 0)
|
||||
call void @main.cvt32Fto32U(float 0xC1D34BE880000000, i32 -1294967296)
|
||||
call void @main.cvt32Fto32U(float 0xBFF19999A0000000, i32 -1)
|
||||
call void @main.cvt32Fto64F(float 0.000000e+00, double 0.000000e+00)
|
||||
call void @main.cvt32Fto64F(float 1.500000e+00, double 1.500000e+00)
|
||||
call void @main.cvt32Fto64F(float 1.000000e+10, double 1.000000e+10)
|
||||
call void @main.cvt32Fto64F(float -1.000000e+10, double -1.000000e+10)
|
||||
call void @main.cvt64Fto32F(double 0.000000e+00, float 0.000000e+00)
|
||||
call void @main.cvt64Fto32F(double 1.500000e+00, float 1.500000e+00)
|
||||
call void @main.cvt64Fto32F(double 1.000000e+10, float 1.000000e+10)
|
||||
call void @main.cvt64Fto32F(double -1.000000e+10, float -1.000000e+10)
|
||||
call void @main.cvt64to64F(i64 0, double 0.000000e+00)
|
||||
call void @main.cvt64to64F(i64 10000000000, double 1.000000e+10)
|
||||
call void @main.cvt64to64F(i64 9223372036854775807, double 0x43E0000000000000)
|
||||
call void @main.cvt64to64F(i64 -9223372036854775807, double 0xC3E0000000000000)
|
||||
call void @main.cvt64Uto64F(i64 0, double 0.000000e+00)
|
||||
call void @main.cvt64Uto64F(i64 10000000000, double 1.000000e+10)
|
||||
call void @main.cvt64Uto64F(i64 9223372036854775807, double 0x43E0000000000000)
|
||||
call void @main.cvt64Uto64F(i64 -1, double 0x43F0000000000000)
|
||||
call void @main.cvt32to64(i32 0, i64 0)
|
||||
call void @main.cvt32to64(i32 2147483647, i64 2147483647)
|
||||
call void @main.cvtUinptr(i32 1024, i64 1024)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @"main.init$after"() {
|
||||
_llgo_0:
|
||||
%0 = load ptr, ptr @_llgo_string, 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/internal/runtime.Basic"(i64 24)
|
||||
store ptr %2, ptr @_llgo_string, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
50
compiler/cl/_testrt/cchan/in.go
Normal file
50
compiler/cl/_testrt/cchan/in.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/compiler/internal/runtime"
|
||||
)
|
||||
|
||||
const (
|
||||
eltSize = int(unsafe.Sizeof(0))
|
||||
)
|
||||
|
||||
func doChan(cap int) {
|
||||
c := runtime.NewChan(eltSize, cap)
|
||||
go func() {
|
||||
v := 100
|
||||
runtime.ChanSend(c, unsafe.Pointer(&v), eltSize)
|
||||
}()
|
||||
var ret int
|
||||
runtime.ChanRecv(c, unsafe.Pointer(&ret), eltSize)
|
||||
println(ret)
|
||||
}
|
||||
|
||||
func main() {
|
||||
doChan(10)
|
||||
doChan(0)
|
||||
|
||||
c := runtime.NewChan(eltSize, 3)
|
||||
|
||||
v := 1
|
||||
runtime.ChanSend(c, unsafe.Pointer(&v), eltSize)
|
||||
v = 2
|
||||
runtime.ChanSend(c, unsafe.Pointer(&v), eltSize)
|
||||
v = 3
|
||||
runtime.ChanSend(c, unsafe.Pointer(&v), eltSize)
|
||||
runtime.ChanClose(c)
|
||||
|
||||
v = 10
|
||||
|
||||
if runtime.ChanTrySend(c, unsafe.Pointer(&v), eltSize) {
|
||||
println("error: chan send to closed chan")
|
||||
}
|
||||
|
||||
for {
|
||||
if ok := runtime.ChanRecv(c, unsafe.Pointer(&v), eltSize); !ok {
|
||||
break
|
||||
}
|
||||
println(v)
|
||||
}
|
||||
}
|
||||
41
compiler/cl/_testrt/cchansel/in.go
Normal file
41
compiler/cl/_testrt/cchansel/in.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/compiler/internal/runtime"
|
||||
)
|
||||
|
||||
const (
|
||||
eltSize = int(unsafe.Sizeof(0))
|
||||
)
|
||||
|
||||
func fibonacci(c, quit *runtime.Chan) {
|
||||
x, y := 0, 1
|
||||
for {
|
||||
isel, _ := runtime.Select(
|
||||
runtime.ChanOp{C: c, Send: true, Val: unsafe.Pointer(&x), Size: int32(eltSize)},
|
||||
runtime.ChanOp{C: quit},
|
||||
)
|
||||
if isel == 0 {
|
||||
x, y = y, x+y
|
||||
} else {
|
||||
println("quit")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
c := runtime.NewChan(eltSize, 0)
|
||||
quit := runtime.NewChan(eltSize, 0)
|
||||
go func() {
|
||||
for i := 0; i < 10; i++ {
|
||||
val := 0
|
||||
runtime.ChanRecv(c, unsafe.Pointer(&val), eltSize)
|
||||
println(val)
|
||||
}
|
||||
runtime.ChanClose(quit)
|
||||
}()
|
||||
fibonacci(c, quit)
|
||||
}
|
||||
11
compiler/cl/_testrt/clear/in.go
Normal file
11
compiler/cl/_testrt/clear/in.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package clear
|
||||
|
||||
func Clear() {
|
||||
a := []int{1, 2, 3, 4}
|
||||
clear(a)
|
||||
println(a)
|
||||
|
||||
b := map[int]int{1: 1, 2: 2, 3: 3, 4: 4}
|
||||
clear(b)
|
||||
println(b)
|
||||
}
|
||||
173
compiler/cl/_testrt/clear/out.ll
Normal file
173
compiler/cl/_testrt/clear/out.ll
Normal file
@@ -0,0 +1,173 @@
|
||||
; ModuleID = 'github.com/goplus/llgo/cl/_testrt/clear'
|
||||
source_filename = "github.com/goplus/llgo/cl/_testrt/clear"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
%"github.com/goplus/llgo/internal/abi.StructField" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1 }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
|
||||
@"github.com/goplus/llgo/cl/_testrt/clear.init$guard" = global i1 false, align 1
|
||||
@_llgo_int = linkonce global ptr null, align 8
|
||||
@"[]_llgo_int" = linkonce global ptr null, align 8
|
||||
@"map[_llgo_int]_llgo_int" = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [7 x i8] c"topbits", align 1
|
||||
@1 = private unnamed_addr constant [4 x i8] c"keys", align 1
|
||||
@2 = private unnamed_addr constant [5 x i8] c"elems", align 1
|
||||
@3 = private unnamed_addr constant [8 x i8] c"overflow", align 1
|
||||
@4 = private unnamed_addr constant [39 x i8] c"github.com/goplus/llgo/cl/_testrt/clear", align 1
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testrt/clear.Clear"() {
|
||||
_llgo_0:
|
||||
%0 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32)
|
||||
%1 = getelementptr inbounds i64, ptr %0, i64 0
|
||||
store i64 1, ptr %1, align 4
|
||||
%2 = getelementptr inbounds i64, ptr %0, i64 1
|
||||
store i64 2, ptr %2, align 4
|
||||
%3 = getelementptr inbounds i64, ptr %0, i64 2
|
||||
store i64 3, ptr %3, align 4
|
||||
%4 = getelementptr inbounds i64, ptr %0, i64 3
|
||||
store i64 4, ptr %4, align 4
|
||||
%5 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %0, 0
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %5, i64 4, 1
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %6, i64 4, 2
|
||||
%8 = load ptr, ptr @_llgo_int, align 8
|
||||
%9 = load ptr, ptr @"[]_llgo_int", align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SliceClear"(ptr %9, %"github.com/goplus/llgo/internal/runtime.Slice" %7)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %7)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%10 = load ptr, ptr @"map[_llgo_int]_llgo_int", align 8
|
||||
%11 = call ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr %10, i64 4)
|
||||
%12 = load ptr, ptr @"map[_llgo_int]_llgo_int", align 8
|
||||
%13 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
store i64 1, ptr %13, align 4
|
||||
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %12, ptr %11, ptr %13)
|
||||
store i64 1, ptr %14, align 4
|
||||
%15 = load ptr, ptr @"map[_llgo_int]_llgo_int", align 8
|
||||
%16 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
store i64 2, ptr %16, align 4
|
||||
%17 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %15, ptr %11, ptr %16)
|
||||
store i64 2, ptr %17, align 4
|
||||
%18 = load ptr, ptr @"map[_llgo_int]_llgo_int", align 8
|
||||
%19 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
store i64 3, ptr %19, align 4
|
||||
%20 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %18, ptr %11, ptr %19)
|
||||
store i64 3, ptr %20, align 4
|
||||
%21 = load ptr, ptr @"map[_llgo_int]_llgo_int", align 8
|
||||
%22 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
store i64 4, ptr %22, align 4
|
||||
%23 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %21, ptr %11, ptr %22)
|
||||
store i64 4, ptr %23, align 4
|
||||
%24 = load ptr, ptr @"map[_llgo_int]_llgo_int", align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.MapClear"(ptr %24, ptr %11)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %11)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testrt/clear.init"() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"github.com/goplus/llgo/cl/_testrt/clear.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/cl/_testrt/clear.init$guard", align 1
|
||||
call void @"github.com/goplus/llgo/cl/_testrt/clear.init$after"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testrt/clear.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/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_int", 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/internal/runtime.Basic"(i64 34)
|
||||
%6 = call ptr @"github.com/goplus/llgo/internal/runtime.SliceOf"(ptr %5)
|
||||
store ptr %6, ptr @"[]_llgo_int", align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%7 = load ptr, ptr @"map[_llgo_int]_llgo_int", align 8
|
||||
%8 = icmp eq ptr %7, null
|
||||
br i1 %8, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4
|
||||
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%10 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%11 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 40)
|
||||
%12 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %11)
|
||||
%13 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 7 }, ptr %12, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%15 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %14)
|
||||
%16 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, ptr %15, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%17 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%18 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %17)
|
||||
%19 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 5 }, ptr %18, i64 72, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%20 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 44)
|
||||
%21 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 8 }, ptr %20, i64 136, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%22 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 224)
|
||||
%23 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %22, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %13, ptr %23, align 8
|
||||
%24 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %22, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %16, ptr %24, align 8
|
||||
%25 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %22, i64 2
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %19, ptr %25, align 8
|
||||
%26 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %22, i64 3
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %21, ptr %26, align 8
|
||||
%27 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %22, 0
|
||||
%28 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %27, i64 4, 1
|
||||
%29 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %28, i64 4, 2
|
||||
%30 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 39 }, i64 144, %"github.com/goplus/llgo/internal/runtime.Slice" %29)
|
||||
%31 = call ptr @"github.com/goplus/llgo/internal/runtime.MapOf"(ptr %9, ptr %10, ptr %30, i64 4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %31)
|
||||
store ptr %31, ptr @"map[_llgo_int]_llgo_int", align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.SliceOf"(ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.SliceClear"(ptr, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MapOf"(ptr, ptr, ptr, i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64, ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr, i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr, ptr, ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.MapClear"(ptr, ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr)
|
||||
18
compiler/cl/_testrt/closure/in.go
Normal file
18
compiler/cl/_testrt/closure/in.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
func main() {
|
||||
func(n1, n2 int) {
|
||||
c.Printf(c.Str("%d %d\n"), n1, n2)
|
||||
}(100, 200)
|
||||
fn1 := func(n1, n2 int) {
|
||||
c.Printf(c.Str("%d %d\n"), n1, n2)
|
||||
}
|
||||
fn2 := func() {
|
||||
fn1(100, 200)
|
||||
}
|
||||
fn2()
|
||||
}
|
||||
77
compiler/cl/_testrt/closure/out.ll
Normal file
77
compiler/cl/_testrt/closure/out.ll
Normal file
@@ -0,0 +1,77 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
|
||||
@1 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
call void @"main.main$1"(i64 100, i64 200)
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
store { ptr, ptr } { ptr @"__llgo_stub.main.main$2", ptr null }, ptr %2, align 8
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%4 = getelementptr inbounds { ptr }, ptr %3, i32 0, i32 0
|
||||
store ptr %2, ptr %4, align 8
|
||||
%5 = insertvalue { ptr, ptr } { ptr @"main.main$3", ptr undef }, ptr %3, 1
|
||||
%6 = extractvalue { ptr, ptr } %5, 1
|
||||
%7 = extractvalue { ptr, ptr } %5, 0
|
||||
call void %7(ptr %6)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @"main.main$1"(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = call i32 (ptr, ...) @printf(ptr @0, i64 %0, i64 %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.main$2"(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = call i32 (ptr, ...) @printf(ptr @1, i64 %0, i64 %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.main$3"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { ptr }, ptr %0, align 8
|
||||
%2 = extractvalue { ptr } %1, 0
|
||||
%3 = load { ptr, ptr }, ptr %2, align 8
|
||||
%4 = extractvalue { ptr, ptr } %3, 1
|
||||
%5 = extractvalue { ptr, ptr } %3, 0
|
||||
call void %5(ptr %4, i64 100, i64 200)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
define linkonce void @"__llgo_stub.main.main$2"(ptr %0, i64 %1, i64 %2) {
|
||||
_llgo_0:
|
||||
tail call void @"main.main$2"(i64 %1, i64 %2)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
63
compiler/cl/_testrt/closureconv/in.go
Normal file
63
compiler/cl/_testrt/closureconv/in.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
type Func func(a int, b int) int
|
||||
type Func2 func(a int, b int) int
|
||||
|
||||
type Call struct {
|
||||
fn Func
|
||||
n int
|
||||
}
|
||||
|
||||
func (c *Call) add(a int, b int) int {
|
||||
return a + b + c.n
|
||||
}
|
||||
|
||||
func add(a int, b int) int {
|
||||
return a + b
|
||||
}
|
||||
|
||||
func demo1(n int) Func {
|
||||
m := &Call{n: n}
|
||||
m.fn = m.add
|
||||
return m.fn
|
||||
}
|
||||
|
||||
func demo2() Func {
|
||||
m := &Call{}
|
||||
return m.add
|
||||
}
|
||||
|
||||
func demo3() Func {
|
||||
return add
|
||||
}
|
||||
|
||||
func demo4() Func {
|
||||
return func(a, b int) int { return a + b }
|
||||
}
|
||||
|
||||
func demo5(n int) Func {
|
||||
return func(a, b int) int { return a + b + n }
|
||||
}
|
||||
|
||||
func main() {
|
||||
n1 := demo1(1)(99, 200)
|
||||
println(n1)
|
||||
|
||||
n2 := demo2()(100, 200)
|
||||
println(n2)
|
||||
|
||||
n3 := demo3()(100, 200)
|
||||
println(n3)
|
||||
|
||||
n4 := demo4()(100, 200)
|
||||
println(n4)
|
||||
|
||||
n5 := demo5(1)(99, 200)
|
||||
println(n5)
|
||||
|
||||
var fn func(a int, b int) int = demo5(1)
|
||||
println(fn(99, 200))
|
||||
|
||||
var fn2 Func2 = (Func2)(demo5(1))
|
||||
println(fn2(99, 200))
|
||||
}
|
||||
193
compiler/cl/_testrt/closureconv/out.ll
Normal file
193
compiler/cl/_testrt/closureconv/out.ll
Normal file
@@ -0,0 +1,193 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%main.Call = type { %main.Func, i64 }
|
||||
%main.Func = type { ptr, ptr }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define i64 @"main.(*Call).add"(ptr %0, i64 %1, i64 %2) {
|
||||
_llgo_0:
|
||||
%3 = add i64 %1, %2
|
||||
%4 = getelementptr inbounds %main.Call, ptr %0, i32 0, i32 1
|
||||
%5 = load i64, ptr %4, align 4
|
||||
%6 = add i64 %3, %5
|
||||
ret i64 %6
|
||||
}
|
||||
|
||||
define i64 @main.add(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = add i64 %0, %1
|
||||
ret i64 %2
|
||||
}
|
||||
|
||||
define %main.Func @main.demo1(i64 %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 24)
|
||||
%2 = getelementptr inbounds %main.Call, ptr %1, i32 0, i32 1
|
||||
store i64 %0, ptr %2, align 4
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%4 = getelementptr inbounds { ptr }, ptr %3, i32 0, i32 0
|
||||
store ptr %1, ptr %4, align 8
|
||||
%5 = insertvalue { ptr, ptr } { ptr @"main.add$bound", ptr undef }, ptr %3, 1
|
||||
%6 = getelementptr inbounds %main.Call, ptr %1, i32 0, i32 0
|
||||
%7 = alloca %main.Func, align 8
|
||||
store { ptr, ptr } %5, ptr %7, align 8
|
||||
%8 = load %main.Func, ptr %7, align 8
|
||||
store %main.Func %8, ptr %6, align 8
|
||||
%9 = getelementptr inbounds %main.Call, ptr %1, i32 0, i32 0
|
||||
%10 = load %main.Func, ptr %9, align 8
|
||||
ret %main.Func %10
|
||||
}
|
||||
|
||||
define %main.Func @main.demo2() {
|
||||
_llgo_0:
|
||||
%0 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 24)
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%2 = getelementptr inbounds { ptr }, ptr %1, i32 0, i32 0
|
||||
store ptr %0, ptr %2, align 8
|
||||
%3 = insertvalue { ptr, ptr } { ptr @"main.add$bound", ptr undef }, ptr %1, 1
|
||||
%4 = alloca %main.Func, align 8
|
||||
store { ptr, ptr } %3, ptr %4, align 8
|
||||
%5 = load %main.Func, ptr %4, align 8
|
||||
ret %main.Func %5
|
||||
}
|
||||
|
||||
define %main.Func @main.demo3() {
|
||||
_llgo_0:
|
||||
ret %main.Func { ptr @__llgo_stub.main.add, ptr null }
|
||||
}
|
||||
|
||||
define %main.Func @main.demo4() {
|
||||
_llgo_0:
|
||||
ret %main.Func { ptr @"__llgo_stub.main.demo4$1", ptr null }
|
||||
}
|
||||
|
||||
define i64 @"main.demo4$1"(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = add i64 %0, %1
|
||||
ret i64 %2
|
||||
}
|
||||
|
||||
define %main.Func @main.demo5(i64 %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
store i64 %0, ptr %1, align 4
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%3 = getelementptr inbounds { ptr }, ptr %2, i32 0, i32 0
|
||||
store ptr %1, ptr %3, align 8
|
||||
%4 = insertvalue { ptr, ptr } { ptr @"main.demo5$1", ptr undef }, ptr %2, 1
|
||||
%5 = alloca %main.Func, align 8
|
||||
store { ptr, ptr } %4, ptr %5, align 8
|
||||
%6 = load %main.Func, ptr %5, align 8
|
||||
ret %main.Func %6
|
||||
}
|
||||
|
||||
define i64 @"main.demo5$1"(ptr %0, i64 %1, i64 %2) {
|
||||
_llgo_0:
|
||||
%3 = add i64 %1, %2
|
||||
%4 = load { ptr }, ptr %0, align 8
|
||||
%5 = extractvalue { ptr } %4, 0
|
||||
%6 = load i64, ptr %5, align 4
|
||||
%7 = add i64 %3, %6
|
||||
ret i64 %7
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call %main.Func @main.demo1(i64 1)
|
||||
%3 = extractvalue %main.Func %2, 1
|
||||
%4 = extractvalue %main.Func %2, 0
|
||||
%5 = call i64 %4(ptr %3, i64 99, i64 200)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %5)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%6 = call %main.Func @main.demo2()
|
||||
%7 = extractvalue %main.Func %6, 1
|
||||
%8 = extractvalue %main.Func %6, 0
|
||||
%9 = call i64 %8(ptr %7, i64 100, i64 200)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %9)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%10 = call %main.Func @main.demo3()
|
||||
%11 = extractvalue %main.Func %10, 1
|
||||
%12 = extractvalue %main.Func %10, 0
|
||||
%13 = call i64 %12(ptr %11, i64 100, i64 200)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %13)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%14 = call %main.Func @main.demo4()
|
||||
%15 = extractvalue %main.Func %14, 1
|
||||
%16 = extractvalue %main.Func %14, 0
|
||||
%17 = call i64 %16(ptr %15, i64 100, i64 200)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %17)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%18 = call %main.Func @main.demo5(i64 1)
|
||||
%19 = extractvalue %main.Func %18, 1
|
||||
%20 = extractvalue %main.Func %18, 0
|
||||
%21 = call i64 %20(ptr %19, i64 99, i64 200)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %21)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%22 = call %main.Func @main.demo5(i64 1)
|
||||
%23 = alloca { ptr, ptr }, align 8
|
||||
store %main.Func %22, ptr %23, align 8
|
||||
%24 = load { ptr, ptr }, ptr %23, align 8
|
||||
%25 = extractvalue { ptr, ptr } %24, 1
|
||||
%26 = extractvalue { ptr, ptr } %24, 0
|
||||
%27 = call i64 %26(ptr %25, i64 99, i64 200)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %27)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%28 = call %main.Func @main.demo5(i64 1)
|
||||
%29 = extractvalue %main.Func %28, 1
|
||||
%30 = extractvalue %main.Func %28, 0
|
||||
%31 = call i64 %30(ptr %29, i64 99, i64 200)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %31)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
define i64 @"main.add$bound"(ptr %0, i64 %1, i64 %2) {
|
||||
_llgo_0:
|
||||
%3 = load { ptr }, ptr %0, align 8
|
||||
%4 = extractvalue { ptr } %3, 0
|
||||
%5 = call i64 @"main.(*Call).add"(ptr %4, i64 %1, i64 %2)
|
||||
ret i64 %5
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
define linkonce i64 @__llgo_stub.main.add(ptr %0, i64 %1, i64 %2) {
|
||||
_llgo_0:
|
||||
%3 = tail call i64 @main.add(i64 %1, i64 %2)
|
||||
ret i64 %3
|
||||
}
|
||||
|
||||
define linkonce i64 @"__llgo_stub.main.demo4$1"(ptr %0, i64 %1, i64 %2) {
|
||||
_llgo_0:
|
||||
%3 = tail call i64 @"main.demo4$1"(i64 %1, i64 %2)
|
||||
ret i64 %3
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
14
compiler/cl/_testrt/closureiface/in.go
Normal file
14
compiler/cl/_testrt/closureiface/in.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
var m int = 200
|
||||
fn := func(n int) int {
|
||||
return m + n
|
||||
}
|
||||
var i any = fn
|
||||
f, ok := i.(func(int) int)
|
||||
if !ok {
|
||||
panic("error")
|
||||
}
|
||||
println(f(100))
|
||||
}
|
||||
213
compiler/cl/_testrt/closureiface/out.ll
Normal file
213
compiler/cl/_testrt/closureiface/out.ll
Normal file
@@ -0,0 +1,213 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
%"github.com/goplus/llgo/internal/abi.StructField" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@_llgo_int = linkonce global ptr null, align 8
|
||||
@"_llgo_func$ekGNsrYBSzltfAjxbl6T8H6Yq8j16wzqS3nDj2xxGMU" = linkonce global ptr null, align 8
|
||||
@_llgo_Pointer = linkonce global ptr null, align 8
|
||||
@"main.struct$QIHBTaw1IFobr8yvWpq-2AJFm3xBNhdW_aNBicqUBGk" = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [2 x i8] c"$f", align 1
|
||||
@1 = private unnamed_addr constant [5 x i8] c"$data", align 1
|
||||
@2 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@3 = private unnamed_addr constant [5 x i8] c"error", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"main.init$after"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
store i64 200, ptr %2, align 4
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%4 = getelementptr inbounds { ptr }, ptr %3, i32 0, i32 0
|
||||
store ptr %2, ptr %4, align 8
|
||||
%5 = insertvalue { ptr, ptr } { ptr @"main.main$1", ptr undef }, ptr %3, 1
|
||||
%6 = load ptr, ptr @_llgo_int, align 8
|
||||
%7 = load ptr, ptr @"_llgo_func$ekGNsrYBSzltfAjxbl6T8H6Yq8j16wzqS3nDj2xxGMU", align 8
|
||||
%8 = load ptr, ptr @_llgo_Pointer, align 8
|
||||
%9 = load ptr, ptr @"main.struct$QIHBTaw1IFobr8yvWpq-2AJFm3xBNhdW_aNBicqUBGk", align 8
|
||||
%10 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store { ptr, ptr } %5, ptr %10, align 8
|
||||
%11 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %9, 0
|
||||
%12 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %11, ptr %10, 1
|
||||
%13 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %12, 0
|
||||
%14 = load ptr, ptr @"main.struct$QIHBTaw1IFobr8yvWpq-2AJFm3xBNhdW_aNBicqUBGk", align 8
|
||||
%15 = icmp eq ptr %13, %14
|
||||
br i1 %15, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_1: ; preds = %_llgo_5
|
||||
%16 = load ptr, ptr @_llgo_string, align 8
|
||||
%17 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 5 }, ptr %17, align 8
|
||||
%18 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %16, 0
|
||||
%19 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %18, ptr %17, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %19)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_5
|
||||
%20 = extractvalue { ptr, ptr } %28, 1
|
||||
%21 = extractvalue { ptr, ptr } %28, 0
|
||||
%22 = call i64 %21(ptr %20, i64 100)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %22)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
|
||||
_llgo_3: ; preds = %_llgo_0
|
||||
%23 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %12, 1
|
||||
%24 = load { ptr, ptr }, ptr %23, align 8
|
||||
%25 = insertvalue { { ptr, ptr }, i1 } undef, { ptr, ptr } %24, 0
|
||||
%26 = insertvalue { { ptr, ptr }, i1 } %25, i1 true, 1
|
||||
br label %_llgo_5
|
||||
|
||||
_llgo_4: ; preds = %_llgo_0
|
||||
br label %_llgo_5
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4, %_llgo_3
|
||||
%27 = phi { { ptr, ptr }, i1 } [ %26, %_llgo_3 ], [ zeroinitializer, %_llgo_4 ]
|
||||
%28 = extractvalue { { ptr, ptr }, i1 } %27, 0
|
||||
%29 = extractvalue { { ptr, ptr }, i1 } %27, 1
|
||||
br i1 %29, label %_llgo_2, label %_llgo_1
|
||||
}
|
||||
|
||||
define i64 @"main.main$1"(ptr %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = load { ptr }, ptr %0, align 8
|
||||
%3 = extractvalue { ptr } %2, 0
|
||||
%4 = load i64, ptr %3, align 4
|
||||
%5 = add i64 %4, %1
|
||||
ret i64 %5
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
define void @"main.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/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_int, align 8
|
||||
%4 = load ptr, ptr @_llgo_int, align 8
|
||||
%5 = load ptr, ptr @"_llgo_func$ekGNsrYBSzltfAjxbl6T8H6Yq8j16wzqS3nDj2xxGMU", align 8
|
||||
%6 = icmp eq ptr %5, null
|
||||
br i1 %6, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_3: ; preds = %_llgo_2
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%8 = getelementptr ptr, ptr %7, i64 0
|
||||
store ptr %3, ptr %8, align 8
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %7, 0
|
||||
%10 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, i64 1, 1
|
||||
%11 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %10, i64 1, 2
|
||||
%12 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%13 = getelementptr ptr, ptr %12, i64 0
|
||||
store ptr %4, ptr %13, align 8
|
||||
%14 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %12, 0
|
||||
%15 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %14, i64 1, 1
|
||||
%16 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %15, i64 1, 2
|
||||
%17 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %11, %"github.com/goplus/llgo/internal/runtime.Slice" %16, i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %17)
|
||||
store ptr %17, ptr @"_llgo_func$ekGNsrYBSzltfAjxbl6T8H6Yq8j16wzqS3nDj2xxGMU", align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%18 = load ptr, ptr @_llgo_Pointer, align 8
|
||||
%19 = icmp eq ptr %18, null
|
||||
br i1 %19, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4
|
||||
%20 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 58)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %20)
|
||||
store ptr %20, ptr @_llgo_Pointer, align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
%21 = load ptr, ptr @_llgo_int, align 8
|
||||
%22 = load ptr, ptr @_llgo_int, align 8
|
||||
%23 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%24 = getelementptr ptr, ptr %23, i64 0
|
||||
store ptr %21, ptr %24, align 8
|
||||
%25 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %23, 0
|
||||
%26 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %25, i64 1, 1
|
||||
%27 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %26, i64 1, 2
|
||||
%28 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%29 = getelementptr ptr, ptr %28, i64 0
|
||||
store ptr %22, ptr %29, align 8
|
||||
%30 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %28, 0
|
||||
%31 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %30, i64 1, 1
|
||||
%32 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %31, i64 1, 2
|
||||
%33 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %27, %"github.com/goplus/llgo/internal/runtime.Slice" %32, i1 false)
|
||||
%34 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 2 }, ptr %33, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%35 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 58)
|
||||
%36 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 5 }, ptr %35, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%37 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 112)
|
||||
%38 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %37, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %34, ptr %38, align 8
|
||||
%39 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %37, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %36, ptr %39, align 8
|
||||
%40 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %37, 0
|
||||
%41 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %40, i64 2, 1
|
||||
%42 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %41, i64 2, 2
|
||||
%43 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 4 }, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %42)
|
||||
store ptr %43, ptr @"main.struct$QIHBTaw1IFobr8yvWpq-2AJFm3xBNhdW_aNBicqUBGk", align 8
|
||||
%44 = load ptr, ptr @_llgo_string, align 8
|
||||
%45 = icmp eq ptr %44, null
|
||||
br i1 %45, label %_llgo_7, label %_llgo_8
|
||||
|
||||
_llgo_7: ; preds = %_llgo_6
|
||||
%46 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
store ptr %46, ptr @_llgo_string, align 8
|
||||
br label %_llgo_8
|
||||
|
||||
_llgo_8: ; preds = %_llgo_7, %_llgo_6
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
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 void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
20
compiler/cl/_testrt/complex/in.go
Normal file
20
compiler/cl/_testrt/complex/in.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
type T complex64
|
||||
|
||||
func main() {
|
||||
a := 1 + 2i
|
||||
b := 3 + 4i
|
||||
c := 0 + 0i
|
||||
println(real(a), imag(a))
|
||||
println(-a)
|
||||
println(a + b)
|
||||
println(a - b)
|
||||
println(a * b)
|
||||
println(a / b)
|
||||
println(a / c)
|
||||
println(c / c)
|
||||
println(a == a, a != a)
|
||||
println(a == b, a != b)
|
||||
println(complex128(T(a)) == a)
|
||||
}
|
||||
66
compiler/cl/_testrt/complex/out.ll
Normal file
66
compiler/cl/_testrt/complex/out.ll
Normal file
@@ -0,0 +1,66 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double 1.000000e+00)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double 2.000000e+00)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintComplex"({ double, double } { double -1.000000e+00, double -2.000000e+00 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintComplex"({ double, double } { double 4.000000e+00, double 6.000000e+00 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintComplex"({ double, double } { double -2.000000e+00, double -2.000000e+00 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintComplex"({ double, double } { double -5.000000e+00, double 1.000000e+01 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintComplex"({ double, double } { double 4.400000e-01, double -8.000000e-02 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintComplex"({ double, double } { double 0x7FF0000000000000, double 0x7FF0000000000000 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintComplex"({ double, double } { double 0x7FF8000000000000, double 0x7FF8000000000000 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 true)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 true)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 true)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintComplex"({ double, double })
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1)
|
||||
17
compiler/cl/_testrt/concat/in.go
Normal file
17
compiler/cl/_testrt/concat/in.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
func concat(args ...string) (ret string) {
|
||||
for _, v := range args {
|
||||
ret += v
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func info(s string) string {
|
||||
return "" + s + "..."
|
||||
}
|
||||
|
||||
func main() {
|
||||
result := concat("Hello", " ", "World")
|
||||
println(result)
|
||||
}
|
||||
95
compiler/cl/_testrt/concat/out.ll
Normal file
95
compiler/cl/_testrt/concat/out.ll
Normal file
@@ -0,0 +1,95 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@0 = private unnamed_addr constant [3 x i8] c"...", align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@1 = private unnamed_addr constant [5 x i8] c"Hello", align 1
|
||||
@2 = private unnamed_addr constant [1 x i8] c" ", align 1
|
||||
@3 = private unnamed_addr constant [5 x i8] c"World", align 1
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.String" @main.concat(%"github.com/goplus/llgo/internal/runtime.Slice" %0) {
|
||||
_llgo_0:
|
||||
%1 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 1
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%2 = phi %"github.com/goplus/llgo/internal/runtime.String" [ zeroinitializer, %_llgo_0 ], [ %13, %_llgo_2 ]
|
||||
%3 = phi i64 [ -1, %_llgo_0 ], [ %4, %_llgo_2 ]
|
||||
%4 = add i64 %3, 1
|
||||
%5 = icmp slt i64 %4, %1
|
||||
br i1 %5, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%6 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 0
|
||||
%7 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 1
|
||||
%8 = icmp slt i64 %4, 0
|
||||
%9 = icmp sge i64 %4, %7
|
||||
%10 = or i1 %9, %8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %10)
|
||||
%11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %6, i64 %4
|
||||
%12 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %11, align 8
|
||||
%13 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String" %2, %"github.com/goplus/llgo/internal/runtime.String" %12)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret %"github.com/goplus/llgo/internal/runtime.String" %2
|
||||
}
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.String" @main.info(%"github.com/goplus/llgo/internal/runtime.String" %0) {
|
||||
_llgo_0:
|
||||
%1 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, %"github.com/goplus/llgo/internal/runtime.String" %0)
|
||||
%2 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String" %1, %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 3 })
|
||||
ret %"github.com/goplus/llgo/internal/runtime.String" %2
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 48)
|
||||
%3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i64 0
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 5 }, ptr %3, align 8
|
||||
%4 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i64 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 1 }, ptr %4, align 8
|
||||
%5 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i64 2
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 5 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %2, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %6, i64 3, 1
|
||||
%8 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, i64 3, 2
|
||||
%9 = call %"github.com/goplus/llgo/internal/runtime.String" @main.concat(%"github.com/goplus/llgo/internal/runtime.Slice" %8)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %9)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1)
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
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)
|
||||
10
compiler/cl/_testrt/constuptr/in.go
Normal file
10
compiler/cl/_testrt/constuptr/in.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func main() {
|
||||
a := unsafe.Pointer(uintptr(100))
|
||||
println(a)
|
||||
}
|
||||
36
compiler/cl/_testrt/constuptr/out.ll
Normal file
36
compiler/cl/_testrt/constuptr/out.ll
Normal file
@@ -0,0 +1,36 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr inttoptr (i64 100 to ptr))
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
13
compiler/cl/_testrt/cstr/in.go
Normal file
13
compiler/cl/_testrt/cstr/in.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import _ "unsafe"
|
||||
|
||||
//go:linkname cstr llgo.cstr
|
||||
func cstr(string) *int8
|
||||
|
||||
//go:linkname printf C.printf
|
||||
func printf(format *int8, __llgo_va_list ...any)
|
||||
|
||||
func main() {
|
||||
printf(cstr("Hello, world\n"))
|
||||
}
|
||||
34
compiler/cl/_testrt/cstr/out.ll
Normal file
34
compiler/cl/_testrt/cstr/out.ll
Normal file
@@ -0,0 +1,34 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [14 x i8] c"Hello, world\0A\00", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
call void (ptr, ...) @printf(ptr @0)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare void @printf(ptr, ...)
|
||||
19
compiler/cl/_testrt/cvar/in.go
Normal file
19
compiler/cl/_testrt/cvar/in.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import _ "unsafe"
|
||||
|
||||
//go:linkname barX _bar_x
|
||||
var barX struct {
|
||||
Arr [16]int8
|
||||
Callbacks [2]func()
|
||||
}
|
||||
|
||||
//go:linkname barY _bar_y
|
||||
var barY struct {
|
||||
Arr [16]int8
|
||||
}
|
||||
|
||||
func main() {
|
||||
_ = barX
|
||||
_ = barY
|
||||
}
|
||||
34
compiler/cl/_testrt/cvar/out.ll
Normal file
34
compiler/cl/_testrt/cvar/out.ll
Normal file
@@ -0,0 +1,34 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@_bar_x = external global { [16 x i8], [2 x ptr] }, align 8
|
||||
@_bar_y = external global { [16 x i8] }, align 1
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = load { [16 x i8], [2 x ptr] }, ptr @_bar_x, align 8
|
||||
%3 = load { [16 x i8] }, ptr @_bar_y, align 1
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
71
compiler/cl/_testrt/eface/in.go
Normal file
71
compiler/cl/_testrt/eface/in.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/compiler/internal/abi"
|
||||
)
|
||||
|
||||
type T string
|
||||
|
||||
func (t *T) Invoke() {
|
||||
println("invoke")
|
||||
}
|
||||
|
||||
type eface struct {
|
||||
_type *abi.Type
|
||||
data unsafe.Pointer
|
||||
}
|
||||
|
||||
func main() {
|
||||
dump(true)
|
||||
dump(0)
|
||||
dump(int8(0))
|
||||
dump(int16(0))
|
||||
dump(int32(0))
|
||||
dump(int64(0))
|
||||
dump(uint(0))
|
||||
dump(uint8(0))
|
||||
dump(uint16(0))
|
||||
dump(uint32(0))
|
||||
dump(uint64(0))
|
||||
dump(uintptr(0))
|
||||
dump(float32(0))
|
||||
dump(float64(0))
|
||||
dump([10]int{})
|
||||
dump(func() {})
|
||||
dump((*int)(nil))
|
||||
dump([]int{})
|
||||
dump("hello")
|
||||
dump(struct {
|
||||
x int8
|
||||
y int
|
||||
z int
|
||||
}{})
|
||||
var t T
|
||||
dump(t)
|
||||
}
|
||||
|
||||
func dump(v any) {
|
||||
e := (*eface)(unsafe.Pointer(&v))
|
||||
dumpTyp(e._type, "")
|
||||
}
|
||||
|
||||
func dumpTyp(t *abi.Type, sep string) {
|
||||
print(sep)
|
||||
println(t.String(), t.Kind(), t.Size_, t.PtrBytes, t.Hash, t.TFlag, t.Align_, t.PtrToThis_, t.Uncommon())
|
||||
if t.Elem() != nil {
|
||||
dumpTyp(t.Elem(), sep+"\telem: ")
|
||||
}
|
||||
if t.Uncommon() != nil {
|
||||
dumpUncommon(t.Uncommon(), sep+"\tuncomm: ")
|
||||
if t.PtrToThis_ != nil {
|
||||
dumpUncommon(t.PtrToThis_.Uncommon(), sep+"\tuncomm: ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func dumpUncommon(u *abi.UncommonType, sep string) {
|
||||
print(sep)
|
||||
println(u.PkgPath_, u.Mcount, u.Xcount)
|
||||
}
|
||||
632
compiler/cl/_testrt/eface/out.ll
Normal file
632
compiler/cl/_testrt/eface/out.ll
Normal file
@@ -0,0 +1,632 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
%main.eface = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/abi.Type" = type { i64, i64, i32, i8, i8, i8, i8, { ptr, ptr }, ptr, %"github.com/goplus/llgo/internal/runtime.String", ptr }
|
||||
%"github.com/goplus/llgo/internal/abi.UncommonType" = type { %"github.com/goplus/llgo/internal/runtime.String", i16, i16, i32 }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
%"github.com/goplus/llgo/internal/abi.StructField" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1 }
|
||||
%"github.com/goplus/llgo/internal/abi.Method" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, ptr, ptr }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@0 = private unnamed_addr constant [6 x i8] c"invoke", align 1
|
||||
@1 = private unnamed_addr constant [7 x i8] c"\09elem: ", align 1
|
||||
@2 = private unnamed_addr constant [9 x i8] c"\09uncomm: ", align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@_llgo_bool = linkonce global ptr null, align 8
|
||||
@_llgo_int = linkonce global ptr null, align 8
|
||||
@_llgo_int8 = linkonce global ptr null, align 8
|
||||
@_llgo_int16 = linkonce global ptr null, align 8
|
||||
@_llgo_int32 = linkonce global ptr null, align 8
|
||||
@_llgo_int64 = linkonce global ptr null, align 8
|
||||
@_llgo_uint = linkonce global ptr null, align 8
|
||||
@_llgo_uint8 = linkonce global ptr null, align 8
|
||||
@_llgo_uint16 = linkonce global ptr null, align 8
|
||||
@_llgo_uint32 = linkonce global ptr null, align 8
|
||||
@_llgo_uint64 = linkonce global ptr null, align 8
|
||||
@_llgo_uintptr = linkonce global ptr null, align 8
|
||||
@_llgo_float32 = linkonce global ptr null, align 8
|
||||
@_llgo_float64 = linkonce global ptr null, align 8
|
||||
@"[10]_llgo_int" = linkonce global ptr null, align 8
|
||||
@"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac" = linkonce global ptr null, align 8
|
||||
@_llgo_Pointer = linkonce global ptr null, align 8
|
||||
@"main.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8" = linkonce global ptr null, align 8
|
||||
@3 = private unnamed_addr constant [2 x i8] c"$f", align 1
|
||||
@4 = private unnamed_addr constant [5 x i8] c"$data", align 1
|
||||
@5 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@"*_llgo_int" = linkonce global ptr null, align 8
|
||||
@"[]_llgo_int" = linkonce global ptr null, align 8
|
||||
@6 = private unnamed_addr constant [5 x i8] c"hello", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@"main.struct$RKbUG45GE4henGMAdmt0Rju0JptyR8NsX7IZLsOI0OM" = linkonce global ptr null, align 8
|
||||
@7 = private unnamed_addr constant [1 x i8] c"x", align 1
|
||||
@8 = private unnamed_addr constant [1 x i8] c"y", align 1
|
||||
@9 = private unnamed_addr constant [1 x i8] c"z", align 1
|
||||
@_llgo_main.T = linkonce global ptr null, align 8
|
||||
@10 = private unnamed_addr constant [1 x i8] c"T", align 1
|
||||
@11 = private unnamed_addr constant [6 x i8] c"Invoke", align 1
|
||||
|
||||
define void @"main.(*T).Invoke"(ptr %0) {
|
||||
_llgo_0:
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 6 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %0, ptr %1, align 8
|
||||
%2 = getelementptr inbounds %main.eface, ptr %1, i32 0, i32 0
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
call void @main.dumpTyp(ptr %3, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.dumpTyp(ptr %0, %"github.com/goplus/llgo/internal/runtime.String" %1) {
|
||||
_llgo_0:
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %1)
|
||||
%2 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/abi.(*Type).String"(ptr %0)
|
||||
%3 = call i64 @"github.com/goplus/llgo/internal/abi.(*Type).Kind"(ptr %0)
|
||||
%4 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 0
|
||||
%5 = load i64, ptr %4, align 4
|
||||
%6 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 1
|
||||
%7 = load i64, ptr %6, align 4
|
||||
%8 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 2
|
||||
%9 = load i32, ptr %8, align 4
|
||||
%10 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 3
|
||||
%11 = load i8, ptr %10, align 1
|
||||
%12 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 4
|
||||
%13 = load i8, ptr %12, align 1
|
||||
%14 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 10
|
||||
%15 = load ptr, ptr %14, align 8
|
||||
%16 = call ptr @"github.com/goplus/llgo/internal/abi.(*Type).Uncommon"(ptr %0)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %2)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %3)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %5)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %7)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%17 = zext i32 %9 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %17)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%18 = zext i8 %11 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %18)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%19 = zext i8 %13 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %19)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %15)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %16)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%20 = call ptr @"github.com/goplus/llgo/internal/abi.(*Type).Elem"(ptr %0)
|
||||
%21 = icmp ne ptr %20, null
|
||||
br i1 %21, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%22 = call ptr @"github.com/goplus/llgo/internal/abi.(*Type).Elem"(ptr %0)
|
||||
%23 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String" %1, %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 7 })
|
||||
call void @main.dumpTyp(ptr %22, %"github.com/goplus/llgo/internal/runtime.String" %23)
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%24 = call ptr @"github.com/goplus/llgo/internal/abi.(*Type).Uncommon"(ptr %0)
|
||||
%25 = icmp ne ptr %24, null
|
||||
br i1 %25, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_3: ; preds = %_llgo_2
|
||||
%26 = call ptr @"github.com/goplus/llgo/internal/abi.(*Type).Uncommon"(ptr %0)
|
||||
%27 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String" %1, %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 9 })
|
||||
call void @main.dumpUncommon(ptr %26, %"github.com/goplus/llgo/internal/runtime.String" %27)
|
||||
%28 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 10
|
||||
%29 = load ptr, ptr %28, align 8
|
||||
%30 = icmp ne ptr %29, null
|
||||
br i1 %30, label %_llgo_5, label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_5, %_llgo_3, %_llgo_2
|
||||
ret void
|
||||
|
||||
_llgo_5: ; preds = %_llgo_3
|
||||
%31 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 10
|
||||
%32 = load ptr, ptr %31, align 8
|
||||
%33 = call ptr @"github.com/goplus/llgo/internal/abi.(*Type).Uncommon"(ptr %32)
|
||||
%34 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String" %1, %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 9 })
|
||||
call void @main.dumpUncommon(ptr %33, %"github.com/goplus/llgo/internal/runtime.String" %34)
|
||||
br label %_llgo_4
|
||||
}
|
||||
|
||||
define void @main.dumpUncommon(ptr %0, %"github.com/goplus/llgo/internal/runtime.String" %1) {
|
||||
_llgo_0:
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %1)
|
||||
%2 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.UncommonType", ptr %0, i32 0, i32 0
|
||||
%3 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %2, align 8
|
||||
%4 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.UncommonType", ptr %0, i32 0, i32 1
|
||||
%5 = load i16, ptr %4, align 2
|
||||
%6 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.UncommonType", ptr %0, i32 0, i32 2
|
||||
%7 = load i16, ptr %6, align 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %3)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%8 = zext i16 %5 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %8)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%9 = zext i16 %7 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %9)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"github.com/goplus/llgo/internal/abi.init"()
|
||||
call void @"main.init$after"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = load ptr, ptr @_llgo_bool, align 8
|
||||
%3 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %2, 0
|
||||
%4 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %3, ptr inttoptr (i64 -1 to ptr), 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %4)
|
||||
%5 = load ptr, ptr @_llgo_int, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %5, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
%8 = load ptr, ptr @_llgo_int8, align 8
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %8, 0
|
||||
%10 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %9, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %10)
|
||||
%11 = load ptr, ptr @_llgo_int16, align 8
|
||||
%12 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %11, 0
|
||||
%13 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %12, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %13)
|
||||
%14 = load ptr, ptr @_llgo_int32, align 8
|
||||
%15 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %14, 0
|
||||
%16 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %15, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %16)
|
||||
%17 = load ptr, ptr @_llgo_int64, align 8
|
||||
%18 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %17, 0
|
||||
%19 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %18, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %19)
|
||||
%20 = load ptr, ptr @_llgo_uint, align 8
|
||||
%21 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %20, 0
|
||||
%22 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %21, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %22)
|
||||
%23 = load ptr, ptr @_llgo_uint8, align 8
|
||||
%24 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %23, 0
|
||||
%25 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %24, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %25)
|
||||
%26 = load ptr, ptr @_llgo_uint16, align 8
|
||||
%27 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %26, 0
|
||||
%28 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %27, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %28)
|
||||
%29 = load ptr, ptr @_llgo_uint32, align 8
|
||||
%30 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %29, 0
|
||||
%31 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %30, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %31)
|
||||
%32 = load ptr, ptr @_llgo_uint64, align 8
|
||||
%33 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %32, 0
|
||||
%34 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %33, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %34)
|
||||
%35 = load ptr, ptr @_llgo_uintptr, align 8
|
||||
%36 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %35, 0
|
||||
%37 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %36, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %37)
|
||||
%38 = load ptr, ptr @_llgo_float32, align 8
|
||||
%39 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %38, 0
|
||||
%40 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %39, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %40)
|
||||
%41 = load ptr, ptr @_llgo_float64, align 8
|
||||
%42 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %41, 0
|
||||
%43 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %42, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %43)
|
||||
%44 = load ptr, ptr @"[10]_llgo_int", align 8
|
||||
%45 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 80)
|
||||
store [10 x i64] zeroinitializer, ptr %45, align 4
|
||||
%46 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %44, 0
|
||||
%47 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %46, ptr %45, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %47)
|
||||
%48 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%49 = load ptr, ptr @_llgo_Pointer, align 8
|
||||
%50 = load ptr, ptr @"main.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||
%51 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store { ptr, ptr } { ptr @"__llgo_stub.main.main$1", ptr null }, ptr %51, align 8
|
||||
%52 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %50, 0
|
||||
%53 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %52, ptr %51, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %53)
|
||||
%54 = load ptr, ptr @"*_llgo_int", align 8
|
||||
%55 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %54, 0
|
||||
%56 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %55, ptr null, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %56)
|
||||
%57 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 0)
|
||||
%58 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %57, 0
|
||||
%59 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %58, i64 0, 1
|
||||
%60 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %59, i64 0, 2
|
||||
%61 = load ptr, ptr @"[]_llgo_int", align 8
|
||||
%62 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
|
||||
store %"github.com/goplus/llgo/internal/runtime.Slice" %60, ptr %62, align 8
|
||||
%63 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %61, 0
|
||||
%64 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %63, ptr %62, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %64)
|
||||
%65 = load ptr, ptr @_llgo_string, align 8
|
||||
%66 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 5 }, ptr %66, align 8
|
||||
%67 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %65, 0
|
||||
%68 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %67, ptr %66, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %68)
|
||||
%69 = load ptr, ptr @"main.struct$RKbUG45GE4henGMAdmt0Rju0JptyR8NsX7IZLsOI0OM", align 8
|
||||
%70 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
|
||||
store { i8, i64, i64 } zeroinitializer, ptr %70, align 4
|
||||
%71 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %69, 0
|
||||
%72 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %71, ptr %70, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %72)
|
||||
%73 = load ptr, ptr @_llgo_main.T, align 8
|
||||
%74 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, ptr %74, align 8
|
||||
%75 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %73, 0
|
||||
%76 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %75, ptr %74, 1
|
||||
call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %76)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @"main.main$1"() {
|
||||
_llgo_0:
|
||||
ret void
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/abi.(*Type).String"(ptr)
|
||||
|
||||
declare i64 @"github.com/goplus/llgo/internal/abi.(*Type).Kind"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/abi.(*Type).Uncommon"(ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/abi.(*Type).Elem"(ptr)
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/abi.init"()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
define void @"main.init$after"() {
|
||||
_llgo_0:
|
||||
%0 = load ptr, ptr @_llgo_bool, 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/internal/runtime.Basic"(i64 33)
|
||||
store ptr %2, ptr @_llgo_bool, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%3 = load ptr, ptr @_llgo_int, 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/internal/runtime.Basic"(i64 34)
|
||||
store ptr %5, ptr @_llgo_int, align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%6 = load ptr, ptr @_llgo_int8, align 8
|
||||
%7 = icmp eq ptr %6, null
|
||||
br i1 %7, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4
|
||||
%8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 35)
|
||||
store ptr %8, ptr @_llgo_int8, align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
%9 = load ptr, ptr @_llgo_int16, align 8
|
||||
%10 = icmp eq ptr %9, null
|
||||
br i1 %10, label %_llgo_7, label %_llgo_8
|
||||
|
||||
_llgo_7: ; preds = %_llgo_6
|
||||
%11 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 36)
|
||||
store ptr %11, ptr @_llgo_int16, align 8
|
||||
br label %_llgo_8
|
||||
|
||||
_llgo_8: ; preds = %_llgo_7, %_llgo_6
|
||||
%12 = load ptr, ptr @_llgo_int32, align 8
|
||||
%13 = icmp eq ptr %12, null
|
||||
br i1 %13, label %_llgo_9, label %_llgo_10
|
||||
|
||||
_llgo_9: ; preds = %_llgo_8
|
||||
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 37)
|
||||
store ptr %14, ptr @_llgo_int32, align 8
|
||||
br label %_llgo_10
|
||||
|
||||
_llgo_10: ; preds = %_llgo_9, %_llgo_8
|
||||
%15 = load ptr, ptr @_llgo_int64, align 8
|
||||
%16 = icmp eq ptr %15, null
|
||||
br i1 %16, label %_llgo_11, label %_llgo_12
|
||||
|
||||
_llgo_11: ; preds = %_llgo_10
|
||||
%17 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 38)
|
||||
store ptr %17, ptr @_llgo_int64, align 8
|
||||
br label %_llgo_12
|
||||
|
||||
_llgo_12: ; preds = %_llgo_11, %_llgo_10
|
||||
%18 = load ptr, ptr @_llgo_uint, align 8
|
||||
%19 = icmp eq ptr %18, null
|
||||
br i1 %19, label %_llgo_13, label %_llgo_14
|
||||
|
||||
_llgo_13: ; preds = %_llgo_12
|
||||
%20 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 39)
|
||||
store ptr %20, ptr @_llgo_uint, align 8
|
||||
br label %_llgo_14
|
||||
|
||||
_llgo_14: ; preds = %_llgo_13, %_llgo_12
|
||||
%21 = load ptr, ptr @_llgo_uint8, align 8
|
||||
%22 = icmp eq ptr %21, null
|
||||
br i1 %22, label %_llgo_15, label %_llgo_16
|
||||
|
||||
_llgo_15: ; preds = %_llgo_14
|
||||
%23 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 40)
|
||||
store ptr %23, ptr @_llgo_uint8, align 8
|
||||
br label %_llgo_16
|
||||
|
||||
_llgo_16: ; preds = %_llgo_15, %_llgo_14
|
||||
%24 = load ptr, ptr @_llgo_uint16, align 8
|
||||
%25 = icmp eq ptr %24, null
|
||||
br i1 %25, label %_llgo_17, label %_llgo_18
|
||||
|
||||
_llgo_17: ; preds = %_llgo_16
|
||||
%26 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 41)
|
||||
store ptr %26, ptr @_llgo_uint16, align 8
|
||||
br label %_llgo_18
|
||||
|
||||
_llgo_18: ; preds = %_llgo_17, %_llgo_16
|
||||
%27 = load ptr, ptr @_llgo_uint32, align 8
|
||||
%28 = icmp eq ptr %27, null
|
||||
br i1 %28, label %_llgo_19, label %_llgo_20
|
||||
|
||||
_llgo_19: ; preds = %_llgo_18
|
||||
%29 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 42)
|
||||
store ptr %29, ptr @_llgo_uint32, align 8
|
||||
br label %_llgo_20
|
||||
|
||||
_llgo_20: ; preds = %_llgo_19, %_llgo_18
|
||||
%30 = load ptr, ptr @_llgo_uint64, align 8
|
||||
%31 = icmp eq ptr %30, null
|
||||
br i1 %31, label %_llgo_21, label %_llgo_22
|
||||
|
||||
_llgo_21: ; preds = %_llgo_20
|
||||
%32 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 43)
|
||||
store ptr %32, ptr @_llgo_uint64, align 8
|
||||
br label %_llgo_22
|
||||
|
||||
_llgo_22: ; preds = %_llgo_21, %_llgo_20
|
||||
%33 = load ptr, ptr @_llgo_uintptr, align 8
|
||||
%34 = icmp eq ptr %33, null
|
||||
br i1 %34, label %_llgo_23, label %_llgo_24
|
||||
|
||||
_llgo_23: ; preds = %_llgo_22
|
||||
%35 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 44)
|
||||
store ptr %35, ptr @_llgo_uintptr, align 8
|
||||
br label %_llgo_24
|
||||
|
||||
_llgo_24: ; preds = %_llgo_23, %_llgo_22
|
||||
%36 = load ptr, ptr @_llgo_float32, align 8
|
||||
%37 = icmp eq ptr %36, null
|
||||
br i1 %37, label %_llgo_25, label %_llgo_26
|
||||
|
||||
_llgo_25: ; preds = %_llgo_24
|
||||
%38 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 45)
|
||||
store ptr %38, ptr @_llgo_float32, align 8
|
||||
br label %_llgo_26
|
||||
|
||||
_llgo_26: ; preds = %_llgo_25, %_llgo_24
|
||||
%39 = load ptr, ptr @_llgo_float64, align 8
|
||||
%40 = icmp eq ptr %39, null
|
||||
br i1 %40, label %_llgo_27, label %_llgo_28
|
||||
|
||||
_llgo_27: ; preds = %_llgo_26
|
||||
%41 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 46)
|
||||
store ptr %41, ptr @_llgo_float64, align 8
|
||||
br label %_llgo_28
|
||||
|
||||
_llgo_28: ; preds = %_llgo_27, %_llgo_26
|
||||
%42 = load ptr, ptr @"[10]_llgo_int", align 8
|
||||
%43 = icmp eq ptr %42, null
|
||||
br i1 %43, label %_llgo_29, label %_llgo_30
|
||||
|
||||
_llgo_29: ; preds = %_llgo_28
|
||||
%44 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%45 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 10, ptr %44)
|
||||
store ptr %45, ptr @"[10]_llgo_int", align 8
|
||||
br label %_llgo_30
|
||||
|
||||
_llgo_30: ; preds = %_llgo_29, %_llgo_28
|
||||
%46 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%47 = icmp eq ptr %46, null
|
||||
br i1 %47, label %_llgo_31, label %_llgo_32
|
||||
|
||||
_llgo_31: ; preds = %_llgo_30
|
||||
%48 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%49 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %48, 0
|
||||
%50 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %49, i64 0, 1
|
||||
%51 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %50, i64 0, 2
|
||||
%52 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%53 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %52, 0
|
||||
%54 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %53, i64 0, 1
|
||||
%55 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %54, i64 0, 2
|
||||
%56 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %51, %"github.com/goplus/llgo/internal/runtime.Slice" %55, i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %56)
|
||||
store ptr %56, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
br label %_llgo_32
|
||||
|
||||
_llgo_32: ; preds = %_llgo_31, %_llgo_30
|
||||
%57 = load ptr, ptr @_llgo_Pointer, align 8
|
||||
%58 = icmp eq ptr %57, null
|
||||
br i1 %58, label %_llgo_33, label %_llgo_34
|
||||
|
||||
_llgo_33: ; preds = %_llgo_32
|
||||
%59 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 58)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %59)
|
||||
store ptr %59, ptr @_llgo_Pointer, align 8
|
||||
br label %_llgo_34
|
||||
|
||||
_llgo_34: ; preds = %_llgo_33, %_llgo_32
|
||||
%60 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%61 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %60, 0
|
||||
%62 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %61, i64 0, 1
|
||||
%63 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %62, i64 0, 2
|
||||
%64 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%65 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %64, 0
|
||||
%66 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %65, i64 0, 1
|
||||
%67 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %66, i64 0, 2
|
||||
%68 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %63, %"github.com/goplus/llgo/internal/runtime.Slice" %67, i1 false)
|
||||
%69 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 2 }, ptr %68, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%70 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 58)
|
||||
%71 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 5 }, ptr %70, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%72 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 112)
|
||||
%73 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %72, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %69, ptr %73, align 8
|
||||
%74 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %72, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %71, ptr %74, align 8
|
||||
%75 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %72, 0
|
||||
%76 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %75, i64 2, 1
|
||||
%77 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %76, i64 2, 2
|
||||
%78 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 4 }, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %77)
|
||||
store ptr %78, ptr @"main.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||
%79 = load ptr, ptr @"*_llgo_int", align 8
|
||||
%80 = icmp eq ptr %79, null
|
||||
br i1 %80, label %_llgo_35, label %_llgo_36
|
||||
|
||||
_llgo_35: ; preds = %_llgo_34
|
||||
%81 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%82 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %81)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %82)
|
||||
store ptr %82, ptr @"*_llgo_int", align 8
|
||||
br label %_llgo_36
|
||||
|
||||
_llgo_36: ; preds = %_llgo_35, %_llgo_34
|
||||
%83 = load ptr, ptr @"[]_llgo_int", align 8
|
||||
%84 = icmp eq ptr %83, null
|
||||
br i1 %84, label %_llgo_37, label %_llgo_38
|
||||
|
||||
_llgo_37: ; preds = %_llgo_36
|
||||
%85 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%86 = call ptr @"github.com/goplus/llgo/internal/runtime.SliceOf"(ptr %85)
|
||||
store ptr %86, ptr @"[]_llgo_int", align 8
|
||||
br label %_llgo_38
|
||||
|
||||
_llgo_38: ; preds = %_llgo_37, %_llgo_36
|
||||
%87 = load ptr, ptr @_llgo_string, align 8
|
||||
%88 = icmp eq ptr %87, null
|
||||
br i1 %88, label %_llgo_39, label %_llgo_40
|
||||
|
||||
_llgo_39: ; preds = %_llgo_38
|
||||
%89 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
store ptr %89, ptr @_llgo_string, align 8
|
||||
br label %_llgo_40
|
||||
|
||||
_llgo_40: ; preds = %_llgo_39, %_llgo_38
|
||||
%90 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 35)
|
||||
%91 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 1 }, ptr %90, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%92 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%93 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @8, i64 1 }, ptr %92, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%94 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%95 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @9, i64 1 }, ptr %94, i64 16, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%96 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 168)
|
||||
%97 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %96, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %91, ptr %97, align 8
|
||||
%98 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %96, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %93, ptr %98, align 8
|
||||
%99 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %96, i64 2
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %95, ptr %99, align 8
|
||||
%100 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %96, 0
|
||||
%101 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %100, i64 3, 1
|
||||
%102 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %101, i64 3, 2
|
||||
%103 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 4 }, i64 24, %"github.com/goplus/llgo/internal/runtime.Slice" %102)
|
||||
store ptr %103, ptr @"main.struct$RKbUG45GE4henGMAdmt0Rju0JptyR8NsX7IZLsOI0OM", align 8
|
||||
%104 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @10, i64 1 }, i64 24, i64 16, i64 0, i64 1)
|
||||
%105 = load ptr, ptr @_llgo_main.T, align 8
|
||||
%106 = icmp eq ptr %105, null
|
||||
br i1 %106, label %_llgo_41, label %_llgo_42
|
||||
|
||||
_llgo_41: ; preds = %_llgo_40
|
||||
store ptr %104, ptr @_llgo_main.T, align 8
|
||||
br label %_llgo_42
|
||||
|
||||
_llgo_42: ; preds = %_llgo_41, %_llgo_40
|
||||
%107 = load ptr, ptr @_llgo_string, align 8
|
||||
br i1 %106, label %_llgo_43, label %_llgo_44
|
||||
|
||||
_llgo_43: ; preds = %_llgo_42
|
||||
%108 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%109 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @11, i64 6 }, ptr undef, ptr undef, ptr undef }, ptr %108, 1
|
||||
%110 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %109, ptr @"main.(*T).Invoke", 2
|
||||
%111 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %110, ptr @"main.(*T).Invoke", 3
|
||||
%112 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
||||
%113 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %112, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %111, ptr %113, align 8
|
||||
%114 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %112, 0
|
||||
%115 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %114, i64 1, 1
|
||||
%116 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %115, i64 1, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %104, ptr %107, { ptr, i64, i64 } zeroinitializer, %"github.com/goplus/llgo/internal/runtime.Slice" %116)
|
||||
br label %_llgo_44
|
||||
|
||||
_llgo_44: ; preds = %_llgo_43, %_llgo_42
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64, ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
define linkonce void @"__llgo_stub.main.main$1"(ptr %0) {
|
||||
_llgo_0:
|
||||
tail call void @"main.main$1"()
|
||||
ret void
|
||||
}
|
||||
|
||||
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 void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.SliceOf"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", i64, i64, i64, i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr, ptr, %"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
28
compiler/cl/_testrt/float2any/in.go
Normal file
28
compiler/cl/_testrt/float2any/in.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
const pi = 3.14159265
|
||||
|
||||
func check32(v any) {
|
||||
if v.(float32) != pi {
|
||||
panic("error f32")
|
||||
}
|
||||
}
|
||||
|
||||
func check64(v any) {
|
||||
if v.(float64) != pi {
|
||||
panic("error f64")
|
||||
}
|
||||
}
|
||||
|
||||
func f32() float32 {
|
||||
return pi
|
||||
}
|
||||
|
||||
func f64() float64 {
|
||||
return pi
|
||||
}
|
||||
|
||||
func main() {
|
||||
check32(f32())
|
||||
check64(f64())
|
||||
}
|
||||
178
compiler/cl/_testrt/float2any/out.ll
Normal file
178
compiler/cl/_testrt/float2any/out.ll
Normal file
@@ -0,0 +1,178 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@_llgo_float32 = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [21 x i8] c"type assertion failed", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@1 = private unnamed_addr constant [9 x i8] c"error f32", align 1
|
||||
@_llgo_float64 = linkonce global ptr null, align 8
|
||||
@2 = private unnamed_addr constant [9 x i8] c"error f64", align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.check32(%"github.com/goplus/llgo/internal/runtime.eface" %0) {
|
||||
_llgo_0:
|
||||
%1 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0
|
||||
%2 = load ptr, ptr @_llgo_float32, align 8
|
||||
%3 = icmp eq ptr %1, %2
|
||||
br i1 %3, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_1: ; preds = %_llgo_3
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 9 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_3
|
||||
ret void
|
||||
|
||||
_llgo_3: ; preds = %_llgo_0
|
||||
%8 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1
|
||||
%9 = ptrtoint ptr %8 to i64
|
||||
%10 = trunc i64 %9 to i32
|
||||
%11 = bitcast i32 %10 to float
|
||||
%12 = fcmp une float %11, 0x400921FB60000000
|
||||
br i1 %12, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_4: ; preds = %_llgo_0
|
||||
%13 = load ptr, ptr @_llgo_string, align 8
|
||||
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 21 }, ptr %14, align 8
|
||||
%15 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %13, 0
|
||||
%16 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %15, ptr %14, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %16)
|
||||
unreachable
|
||||
}
|
||||
|
||||
define void @main.check64(%"github.com/goplus/llgo/internal/runtime.eface" %0) {
|
||||
_llgo_0:
|
||||
%1 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0
|
||||
%2 = load ptr, ptr @_llgo_float64, align 8
|
||||
%3 = icmp eq ptr %1, %2
|
||||
br i1 %3, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_1: ; preds = %_llgo_3
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 9 }, ptr %5, align 8
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_3
|
||||
ret void
|
||||
|
||||
_llgo_3: ; preds = %_llgo_0
|
||||
%8 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1
|
||||
%9 = ptrtoint ptr %8 to i64
|
||||
%10 = bitcast i64 %9 to double
|
||||
%11 = fcmp une double %10, 0x400921FB53C8D4F1
|
||||
br i1 %11, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_4: ; preds = %_llgo_0
|
||||
%12 = load ptr, ptr @_llgo_string, align 8
|
||||
%13 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 21 }, ptr %13, align 8
|
||||
%14 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %12, 0
|
||||
%15 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %14, ptr %13, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %15)
|
||||
unreachable
|
||||
}
|
||||
|
||||
define float @main.f32() {
|
||||
_llgo_0:
|
||||
ret float 0x400921FB60000000
|
||||
}
|
||||
|
||||
define double @main.f64() {
|
||||
_llgo_0:
|
||||
ret double 0x400921FB53C8D4F1
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"main.init$after"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call float @main.f32()
|
||||
%3 = load ptr, ptr @_llgo_float32, align 8
|
||||
%4 = bitcast float %2 to i32
|
||||
%5 = inttoptr i32 %4 to ptr
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %3, 0
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %5, 1
|
||||
call void @main.check32(%"github.com/goplus/llgo/internal/runtime.eface" %7)
|
||||
%8 = call double @main.f64()
|
||||
%9 = load ptr, ptr @_llgo_float64, align 8
|
||||
%10 = bitcast double %8 to i64
|
||||
%11 = inttoptr i64 %10 to ptr
|
||||
%12 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %9, 0
|
||||
%13 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %12, ptr %11, 1
|
||||
call void @main.check64(%"github.com/goplus/llgo/internal/runtime.eface" %13)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @"main.init$after"() {
|
||||
_llgo_0:
|
||||
%0 = load ptr, ptr @_llgo_float32, 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/internal/runtime.Basic"(i64 45)
|
||||
store ptr %2, ptr @_llgo_float32, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%3 = load ptr, ptr @_llgo_string, 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/internal/runtime.Basic"(i64 24)
|
||||
store ptr %5, ptr @_llgo_string, align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%6 = load ptr, ptr @_llgo_float64, align 8
|
||||
%7 = icmp eq ptr %6, null
|
||||
br i1 %7, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4
|
||||
%8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 46)
|
||||
store ptr %8, ptr @_llgo_float64, align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
16
compiler/cl/_testrt/fprintf/in.go
Normal file
16
compiler/cl/_testrt/fprintf/in.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import "unsafe"
|
||||
|
||||
//go:linkname cstr llgo.cstr
|
||||
func cstr(string) *int8
|
||||
|
||||
//go:linkname stderr __stderrp
|
||||
var stderr unsafe.Pointer
|
||||
|
||||
//go:linkname fprintf C.fprintf
|
||||
func fprintf(fp unsafe.Pointer, format *int8, __llgo_va_list ...any)
|
||||
|
||||
func main() {
|
||||
fprintf(stderr, cstr("Hello %d\n"), 100)
|
||||
}
|
||||
36
compiler/cl/_testrt/fprintf/out.ll
Normal file
36
compiler/cl/_testrt/fprintf/out.ll
Normal file
@@ -0,0 +1,36 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__stderrp = external global ptr, align 8
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [10 x i8] c"Hello %d\0A\00", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = load ptr, ptr @__stderrp, align 8
|
||||
call void (ptr, ptr, ...) @fprintf(ptr %2, ptr @0, i64 100)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare void @fprintf(ptr, ptr, ...)
|
||||
14
compiler/cl/_testrt/freevars/in.go
Normal file
14
compiler/cl/_testrt/freevars/in.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
func(resolve func(error)) {
|
||||
func(err error) {
|
||||
if err != nil {
|
||||
resolve(err)
|
||||
return
|
||||
}
|
||||
resolve(nil)
|
||||
}(nil)
|
||||
}(func(err error) {
|
||||
})
|
||||
}
|
||||
98
compiler/cl/_testrt/freevars/out.ll
Normal file
98
compiler/cl/_testrt/freevars/out.ll
Normal file
@@ -0,0 +1,98 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
call void @"main.main$1"({ ptr, ptr } { ptr @"__llgo_stub.main.main$2", ptr null })
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @"main.main$1"({ ptr, ptr } %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
store { ptr, ptr } %0, ptr %1, align 8
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%3 = getelementptr inbounds { ptr }, ptr %2, i32 0, i32 0
|
||||
store ptr %1, ptr %3, align 8
|
||||
%4 = insertvalue { ptr, ptr } { ptr @"main.main$1$1", ptr undef }, ptr %2, 1
|
||||
%5 = extractvalue { ptr, ptr } %4, 1
|
||||
%6 = extractvalue { ptr, ptr } %4, 0
|
||||
call void %6(ptr %5, %"github.com/goplus/llgo/internal/runtime.iface" zeroinitializer)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.main$1$1"(ptr %0, %"github.com/goplus/llgo/internal/runtime.iface" %1) {
|
||||
_llgo_0:
|
||||
%2 = load { ptr }, ptr %0, align 8
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" %1)
|
||||
%4 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %1, 1
|
||||
%5 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %3, 0
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %5, ptr %4, 1
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" zeroinitializer)
|
||||
%8 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %7, 0
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %8, ptr null, 1
|
||||
%10 = call i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface" %6, %"github.com/goplus/llgo/internal/runtime.eface" %9)
|
||||
%11 = xor i1 %10, true
|
||||
br i1 %11, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%12 = extractvalue { ptr } %2, 0
|
||||
%13 = load { ptr, ptr }, ptr %12, align 8
|
||||
%14 = extractvalue { ptr, ptr } %13, 1
|
||||
%15 = extractvalue { ptr, ptr } %13, 0
|
||||
call void %15(ptr %14, %"github.com/goplus/llgo/internal/runtime.iface" %1)
|
||||
ret void
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
%16 = extractvalue { ptr } %2, 0
|
||||
%17 = load { ptr, ptr }, ptr %16, align 8
|
||||
%18 = extractvalue { ptr, ptr } %17, 1
|
||||
%19 = extractvalue { ptr, ptr } %17, 0
|
||||
call void %19(ptr %18, %"github.com/goplus/llgo/internal/runtime.iface" zeroinitializer)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.main$2"(%"github.com/goplus/llgo/internal/runtime.iface" %0) {
|
||||
_llgo_0:
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
define linkonce void @"__llgo_stub.main.main$2"(ptr %0, %"github.com/goplus/llgo/internal/runtime.iface" %1) {
|
||||
_llgo_0:
|
||||
tail call void @"main.main$2"(%"github.com/goplus/llgo/internal/runtime.iface" %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface", %"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface")
|
||||
24
compiler/cl/_testrt/funcaddr/in.go
Normal file
24
compiler/cl/_testrt/funcaddr/in.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
//llgo:type C
|
||||
type Add func(int, int) int
|
||||
|
||||
func add(a, b int) int {
|
||||
return a + b
|
||||
}
|
||||
|
||||
func main() {
|
||||
var fn Add = add
|
||||
var myfn Add = func(a, b int) int {
|
||||
return a + b
|
||||
}
|
||||
println(c.Func(add) == c.Func(fn))
|
||||
println(c.Func(fn) == *(*unsafe.Pointer)(unsafe.Pointer(&fn)))
|
||||
println(c.Func(myfn) == *(*unsafe.Pointer)(unsafe.Pointer(&myfn)))
|
||||
}
|
||||
66
compiler/cl/_testrt/funcaddr/out.ll
Normal file
66
compiler/cl/_testrt/funcaddr/out.ll
Normal file
@@ -0,0 +1,66 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define i64 @main.add(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = add i64 %0, %1
|
||||
ret i64 %2
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
store ptr @main.add, ptr %2, align 8
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
store ptr @"main.main$1", ptr %3, align 8
|
||||
%4 = load ptr, ptr %2, align 8
|
||||
%5 = icmp eq ptr @main.add, %4
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %5)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%6 = load ptr, ptr %2, align 8
|
||||
%7 = load ptr, ptr %2, align 8
|
||||
%8 = icmp eq ptr %6, %7
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %8)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%9 = load ptr, ptr %3, align 8
|
||||
%10 = load ptr, ptr %3, align 8
|
||||
%11 = icmp eq ptr %9, %10
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %11)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define i64 @"main.main$1"(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = add i64 %0, %1
|
||||
ret i64 %2
|
||||
}
|
||||
|
||||
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.PrintBool"(i1)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
35
compiler/cl/_testrt/funcdecl/in.go
Normal file
35
compiler/cl/_testrt/funcdecl/in.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func main() {
|
||||
println("hello")
|
||||
check(demo)
|
||||
}
|
||||
|
||||
func check(fn func()) {
|
||||
var a any = demo
|
||||
var b any = fn
|
||||
fn1 := a.(func())
|
||||
fn2 := b.(func())
|
||||
println(a, b, fn, fn1, fn2, demo)
|
||||
println(closurePtr(a) == closurePtr(b))
|
||||
}
|
||||
|
||||
func closurePtr(a any) unsafe.Pointer {
|
||||
return (*rtype)(unsafe.Pointer(&a)).ptr.fn
|
||||
}
|
||||
|
||||
type rtype struct {
|
||||
typ unsafe.Pointer
|
||||
ptr *struct {
|
||||
fn unsafe.Pointer
|
||||
env unsafe.Pointer
|
||||
}
|
||||
}
|
||||
|
||||
func demo() {
|
||||
println("demo")
|
||||
}
|
||||
238
compiler/cl/_testrt/funcdecl/out.ll
Normal file
238
compiler/cl/_testrt/funcdecl/out.ll
Normal file
@@ -0,0 +1,238 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%main.rtype = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
%"github.com/goplus/llgo/internal/abi.StructField" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac" = linkonce global ptr null, align 8
|
||||
@_llgo_Pointer = linkonce global ptr null, align 8
|
||||
@"main.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8" = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [2 x i8] c"$f", align 1
|
||||
@1 = private unnamed_addr constant [5 x i8] c"$data", align 1
|
||||
@2 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@3 = private unnamed_addr constant [21 x i8] c"type assertion failed", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@4 = private unnamed_addr constant [4 x i8] c"demo", align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@5 = private unnamed_addr constant [5 x i8] c"hello", align 1
|
||||
|
||||
define void @main.check({ ptr, ptr } %0) {
|
||||
_llgo_0:
|
||||
%1 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%2 = load ptr, ptr @_llgo_Pointer, align 8
|
||||
%3 = load ptr, ptr @"main.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||
%4 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store { ptr, ptr } { ptr @__llgo_stub.main.demo, ptr null }, ptr %4, align 8
|
||||
%5 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %3, 0
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %5, ptr %4, 1
|
||||
%7 = load ptr, ptr @"main.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||
%8 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store { ptr, ptr } %0, ptr %8, align 8
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %7, 0
|
||||
%10 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %9, ptr %8, 1
|
||||
%11 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, 0
|
||||
%12 = load ptr, ptr @"main.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||
%13 = icmp eq ptr %11, %12
|
||||
br i1 %13, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%14 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %6, 1
|
||||
%15 = load { ptr, ptr }, ptr %14, align 8
|
||||
%16 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %10, 0
|
||||
%17 = load ptr, ptr @"main.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||
%18 = icmp eq ptr %16, %17
|
||||
br i1 %18, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
%19 = load ptr, ptr @_llgo_string, align 8
|
||||
%20 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 21 }, ptr %20, align 8
|
||||
%21 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %19, 0
|
||||
%22 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %21, ptr %20, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %22)
|
||||
unreachable
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
%23 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %10, 1
|
||||
%24 = load { ptr, ptr }, ptr %23, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintEface"(%"github.com/goplus/llgo/internal/runtime.eface" %6)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintEface"(%"github.com/goplus/llgo/internal/runtime.eface" %10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%25 = extractvalue { ptr, ptr } %0, 0
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %25)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%26 = extractvalue { ptr, ptr } %15, 0
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %26)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
%27 = extractvalue { ptr, ptr } %24, 0
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %27)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr @main.demo)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%28 = call ptr @main.closurePtr(%"github.com/goplus/llgo/internal/runtime.eface" %6)
|
||||
%29 = call ptr @main.closurePtr(%"github.com/goplus/llgo/internal/runtime.eface" %10)
|
||||
%30 = icmp eq ptr %28, %29
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %30)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
|
||||
_llgo_4: ; preds = %_llgo_1
|
||||
%31 = load ptr, ptr @_llgo_string, align 8
|
||||
%32 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 21 }, ptr %32, align 8
|
||||
%33 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %31, 0
|
||||
%34 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %33, ptr %32, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %34)
|
||||
unreachable
|
||||
}
|
||||
|
||||
define ptr @main.closurePtr(%"github.com/goplus/llgo/internal/runtime.eface" %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %0, ptr %1, align 8
|
||||
%2 = getelementptr inbounds %main.rtype, ptr %1, i32 0, i32 1
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
%4 = getelementptr inbounds { ptr, ptr }, ptr %3, i32 0, i32 0
|
||||
%5 = load ptr, ptr %4, align 8
|
||||
ret ptr %5
|
||||
}
|
||||
|
||||
define void @main.demo() {
|
||||
_llgo_0:
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 4 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"main.init$after"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 5 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
call void @main.check({ ptr, ptr } { ptr @__llgo_stub.main.demo, ptr null })
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define linkonce void @__llgo_stub.main.demo(ptr %0) {
|
||||
_llgo_0:
|
||||
tail call void @main.demo()
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.init$after"() {
|
||||
_llgo_0:
|
||||
%0 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", 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/internal/runtime.AllocU"(i64 0)
|
||||
%3 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %2, 0
|
||||
%4 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %3, i64 0, 1
|
||||
%5 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %4, i64 0, 2
|
||||
%6 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %6, 0
|
||||
%8 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, i64 0, 1
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %8, i64 0, 2
|
||||
%10 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %5, %"github.com/goplus/llgo/internal/runtime.Slice" %9, i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %10)
|
||||
store ptr %10, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%11 = load ptr, ptr @_llgo_Pointer, align 8
|
||||
%12 = icmp eq ptr %11, null
|
||||
br i1 %12, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_3: ; preds = %_llgo_2
|
||||
%13 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 58)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %13)
|
||||
store ptr %13, ptr @_llgo_Pointer, align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%15 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %14, 0
|
||||
%16 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %15, i64 0, 1
|
||||
%17 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %16, i64 0, 2
|
||||
%18 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%19 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %18, 0
|
||||
%20 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %19, i64 0, 1
|
||||
%21 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %20, i64 0, 2
|
||||
%22 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %17, %"github.com/goplus/llgo/internal/runtime.Slice" %21, i1 false)
|
||||
%23 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 2 }, ptr %22, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%24 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 58)
|
||||
%25 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 5 }, ptr %24, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%26 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 112)
|
||||
%27 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %26, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %23, ptr %27, align 8
|
||||
%28 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %26, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %25, ptr %28, align 8
|
||||
%29 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %26, 0
|
||||
%30 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %29, i64 2, 1
|
||||
%31 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %30, i64 2, 2
|
||||
%32 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 4 }, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %31)
|
||||
store ptr %32, ptr @"main.struct$b7Su1hWaFih-M0M9hMk6nO_RD1K_GQu5WjIXQp6Q2e8", align 8
|
||||
%33 = load ptr, ptr @_llgo_string, align 8
|
||||
%34 = icmp eq ptr %33, null
|
||||
br i1 %34, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4
|
||||
%35 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
store ptr %35, ptr @_llgo_string, align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
ret void
|
||||
}
|
||||
|
||||
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.AllocU"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintEface"(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1)
|
||||
|
||||
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.init"()
|
||||
32
compiler/cl/_testrt/gblarray/in.go
Normal file
32
compiler/cl/_testrt/gblarray/in.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/compiler/internal/abi"
|
||||
)
|
||||
|
||||
func Basic(kind abi.Kind) *abi.Type {
|
||||
return basicTypes[kind]
|
||||
}
|
||||
|
||||
var (
|
||||
basicTypes = [...]*abi.Type{
|
||||
abi.String: basicType(abi.String),
|
||||
}
|
||||
sizeBasicTypes = [...]uintptr{
|
||||
abi.String: 16,
|
||||
}
|
||||
)
|
||||
|
||||
func basicType(kind abi.Kind) *abi.Type {
|
||||
return &abi.Type{
|
||||
Size_: sizeBasicTypes[kind],
|
||||
Hash: uint32(kind),
|
||||
Kind_: uint8(kind),
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
t := Basic(abi.String)
|
||||
c.Printf(c.Str("Kind: %d, Size: %d\n"), int(t.Kind_), t.Size_)
|
||||
}
|
||||
82
compiler/cl/_testrt/gblarray/out.ll
Normal file
82
compiler/cl/_testrt/gblarray/out.ll
Normal file
@@ -0,0 +1,82 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/abi.Type" = type { i64, i64, i32, i8, i8, i8, i8, { ptr, ptr }, ptr, %"github.com/goplus/llgo/internal/runtime.String", ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
|
||||
@main.basicTypes = global [25 x ptr] zeroinitializer, align 8
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@main.sizeBasicTypes = global [25 x i64] zeroinitializer, align 8
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [20 x i8] c"Kind: %d, Size: %d\0A\00", align 1
|
||||
|
||||
define ptr @main.Basic(i64 %0) {
|
||||
_llgo_0:
|
||||
%1 = icmp sge i64 %0, 25
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %1)
|
||||
%2 = getelementptr inbounds ptr, ptr @main.basicTypes, i64 %0
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
ret ptr %3
|
||||
}
|
||||
|
||||
define ptr @main.basicType(i64 %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 72)
|
||||
%2 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %1, i32 0, i32 0
|
||||
%3 = icmp sge i64 %0, 25
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %3)
|
||||
%4 = getelementptr inbounds i64, ptr @main.sizeBasicTypes, i64 %0
|
||||
%5 = load i64, ptr %4, align 4
|
||||
%6 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %1, i32 0, i32 2
|
||||
%7 = trunc i64 %0 to i32
|
||||
%8 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %1, i32 0, i32 6
|
||||
%9 = trunc i64 %0 to i8
|
||||
store i64 %5, ptr %2, align 4
|
||||
store i32 %7, ptr %6, align 4
|
||||
store i8 %9, ptr %8, align 1
|
||||
ret ptr %1
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"github.com/goplus/llgo/internal/abi.init"()
|
||||
store i64 16, ptr getelementptr inbounds (i64, ptr @main.sizeBasicTypes, i64 24), align 4
|
||||
%1 = call ptr @main.basicType(i64 24)
|
||||
store ptr %1, ptr getelementptr inbounds (ptr, ptr @main.basicTypes, i64 24), align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call ptr @main.Basic(i64 24)
|
||||
%3 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %2, i32 0, i32 6
|
||||
%4 = load i8, ptr %3, align 1
|
||||
%5 = sext i8 %4 to i64
|
||||
%6 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %2, i32 0, i32 0
|
||||
%7 = load i64, ptr %6, align 4
|
||||
%8 = call i32 (ptr, ...) @printf(ptr @0, i64 %5, i64 %7)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/abi.init"()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
17
compiler/cl/_testrt/gotypes/in.go
Normal file
17
compiler/cl/_testrt/gotypes/in.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
type base interface {
|
||||
f(m map[string]func())
|
||||
}
|
||||
|
||||
type bar interface {
|
||||
base
|
||||
g(c chan func())
|
||||
}
|
||||
|
||||
func foo(bar) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
foo(nil)
|
||||
}
|
||||
38
compiler/cl/_testrt/gotypes/out.ll
Normal file
38
compiler/cl/_testrt/gotypes/out.ll
Normal file
@@ -0,0 +1,38 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.foo(%"github.com/goplus/llgo/internal/runtime.iface" %0) {
|
||||
_llgo_0:
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
call void @main.foo(%"github.com/goplus/llgo/internal/runtime.iface" zeroinitializer)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
10
compiler/cl/_testrt/hello/in.go
Normal file
10
compiler/cl/_testrt/hello/in.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import "github.com/goplus/llgo/compiler/cl/internal/libc"
|
||||
|
||||
var format = [...]int8{'H', 'e', 'l', 'l', 'o', ' ', '%', 'd', '\n', 0}
|
||||
|
||||
func main() {
|
||||
sfmt := &format[0]
|
||||
libc.Printf(sfmt, libc.Strlen(sfmt))
|
||||
}
|
||||
47
compiler/cl/_testrt/hello/out.ll
Normal file
47
compiler/cl/_testrt/hello/out.ll
Normal file
@@ -0,0 +1,47 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@main.format = global [10 x i8] zeroinitializer, align 1
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
store i8 72, ptr @main.format, align 1
|
||||
store i8 101, ptr getelementptr inbounds (i8, ptr @main.format, i64 1), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @main.format, i64 2), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @main.format, i64 3), align 1
|
||||
store i8 111, ptr getelementptr inbounds (i8, ptr @main.format, i64 4), align 1
|
||||
store i8 32, ptr getelementptr inbounds (i8, ptr @main.format, i64 5), align 1
|
||||
store i8 37, ptr getelementptr inbounds (i8, ptr @main.format, i64 6), align 1
|
||||
store i8 100, ptr getelementptr inbounds (i8, ptr @main.format, i64 7), align 1
|
||||
store i8 10, ptr getelementptr inbounds (i8, ptr @main.format, i64 8), align 1
|
||||
store i8 0, ptr getelementptr inbounds (i8, ptr @main.format, i64 9), align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call i32 @strlen(ptr @main.format)
|
||||
call void (ptr, ...) @printf(ptr @main.format, i32 %2)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare i32 @strlen(ptr)
|
||||
|
||||
declare void @printf(ptr, ...)
|
||||
33
compiler/cl/_testrt/index/in.go
Normal file
33
compiler/cl/_testrt/index/in.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
type point struct {
|
||||
x int
|
||||
y int
|
||||
}
|
||||
|
||||
type N [2]int
|
||||
type T *N
|
||||
type S []int
|
||||
|
||||
func main() {
|
||||
a := [...]point{{1, 2}, {3, 4}, {5, 6}}[2]
|
||||
println(a.x, a.y)
|
||||
|
||||
b := [...][2]int{[2]int{1, 2}, [2]int{3, 4}}[1]
|
||||
println(b[0], b[1])
|
||||
|
||||
var i int = 2
|
||||
println([...]int{1, 2, 3, 4, 5}[i])
|
||||
|
||||
s := "123456"
|
||||
println(string(s[i]))
|
||||
println(string("123456"[1]))
|
||||
|
||||
var n = N{1, 2}
|
||||
var t T = &n
|
||||
println(t[1])
|
||||
var s1 = S{1, 2, 3, 4}
|
||||
println(s1[1])
|
||||
|
||||
println([2]int{}[0])
|
||||
}
|
||||
167
compiler/cl/_testrt/index/out.ll
Normal file
167
compiler/cl/_testrt/index/out.ll
Normal file
@@ -0,0 +1,167 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%main.point = type { i64, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [6 x i8] c"123456", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = alloca %main.point, align 8
|
||||
call void @llvm.memset(ptr %2, i8 0, i64 16, i1 false)
|
||||
%3 = alloca [3 x %main.point], align 8
|
||||
call void @llvm.memset(ptr %3, i8 0, i64 48, i1 false)
|
||||
%4 = getelementptr inbounds %main.point, ptr %3, i64 0
|
||||
%5 = getelementptr inbounds %main.point, ptr %4, i32 0, i32 0
|
||||
%6 = getelementptr inbounds %main.point, ptr %4, i32 0, i32 1
|
||||
%7 = getelementptr inbounds %main.point, ptr %3, i64 1
|
||||
%8 = getelementptr inbounds %main.point, ptr %7, i32 0, i32 0
|
||||
%9 = getelementptr inbounds %main.point, ptr %7, i32 0, i32 1
|
||||
%10 = getelementptr inbounds %main.point, ptr %3, i64 2
|
||||
%11 = getelementptr inbounds %main.point, ptr %10, i32 0, i32 0
|
||||
%12 = getelementptr inbounds %main.point, ptr %10, i32 0, i32 1
|
||||
store i64 1, ptr %5, align 4
|
||||
store i64 2, ptr %6, align 4
|
||||
store i64 3, ptr %8, align 4
|
||||
store i64 4, ptr %9, align 4
|
||||
store i64 5, ptr %11, align 4
|
||||
store i64 6, ptr %12, align 4
|
||||
%13 = load [3 x %main.point], ptr %3, align 4
|
||||
%14 = getelementptr inbounds %main.point, ptr %3, i64 2
|
||||
%15 = load %main.point, ptr %14, align 4
|
||||
store %main.point %15, ptr %2, align 4
|
||||
%16 = getelementptr inbounds %main.point, ptr %2, i32 0, i32 0
|
||||
%17 = load i64, ptr %16, align 4
|
||||
%18 = getelementptr inbounds %main.point, ptr %2, i32 0, i32 1
|
||||
%19 = load i64, ptr %18, align 4
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %17)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %19)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%20 = alloca [2 x i64], align 8
|
||||
call void @llvm.memset(ptr %20, i8 0, i64 16, i1 false)
|
||||
%21 = alloca [2 x [2 x i64]], align 8
|
||||
call void @llvm.memset(ptr %21, i8 0, i64 32, i1 false)
|
||||
%22 = getelementptr inbounds [2 x i64], ptr %21, i64 0
|
||||
%23 = getelementptr inbounds i64, ptr %22, i64 0
|
||||
%24 = getelementptr inbounds i64, ptr %22, i64 1
|
||||
%25 = getelementptr inbounds [2 x i64], ptr %21, i64 1
|
||||
%26 = getelementptr inbounds i64, ptr %25, i64 0
|
||||
%27 = getelementptr inbounds i64, ptr %25, i64 1
|
||||
store i64 1, ptr %23, align 4
|
||||
store i64 2, ptr %24, align 4
|
||||
store i64 3, ptr %26, align 4
|
||||
store i64 4, ptr %27, align 4
|
||||
%28 = load [2 x [2 x i64]], ptr %21, align 4
|
||||
%29 = getelementptr inbounds [2 x i64], ptr %21, i64 1
|
||||
%30 = load [2 x i64], ptr %29, align 4
|
||||
store [2 x i64] %30, ptr %20, align 4
|
||||
%31 = getelementptr inbounds i64, ptr %20, i64 0
|
||||
%32 = load i64, ptr %31, align 4
|
||||
%33 = getelementptr inbounds i64, ptr %20, i64 1
|
||||
%34 = load i64, ptr %33, align 4
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %34)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%35 = alloca [5 x i64], align 8
|
||||
call void @llvm.memset(ptr %35, i8 0, i64 40, i1 false)
|
||||
%36 = getelementptr inbounds i64, ptr %35, i64 0
|
||||
%37 = getelementptr inbounds i64, ptr %35, i64 1
|
||||
%38 = getelementptr inbounds i64, ptr %35, i64 2
|
||||
%39 = getelementptr inbounds i64, ptr %35, i64 3
|
||||
%40 = getelementptr inbounds i64, ptr %35, i64 4
|
||||
store i64 1, ptr %36, align 4
|
||||
store i64 2, ptr %37, align 4
|
||||
store i64 3, ptr %38, align 4
|
||||
store i64 4, ptr %39, align 4
|
||||
store i64 5, ptr %40, align 4
|
||||
%41 = load [5 x i64], ptr %35, align 4
|
||||
%42 = getelementptr inbounds i64, ptr %35, i64 2
|
||||
%43 = load i64, ptr %42, align 4
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %43)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%44 = load i8, ptr getelementptr inbounds (i8, ptr @0, i64 2), align 1
|
||||
%45 = sext i8 %44 to i32
|
||||
%46 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringFromRune"(i32 %45)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %46)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%47 = load i8, ptr getelementptr inbounds (i8, ptr @0, i64 1), align 1
|
||||
%48 = sext i8 %47 to i32
|
||||
%49 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringFromRune"(i32 %48)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %49)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%50 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
%51 = getelementptr inbounds i64, ptr %50, i64 0
|
||||
%52 = getelementptr inbounds i64, ptr %50, i64 1
|
||||
store i64 1, ptr %51, align 4
|
||||
store i64 2, ptr %52, align 4
|
||||
%53 = getelementptr inbounds i64, ptr %50, i64 1
|
||||
%54 = load i64, ptr %53, align 4
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %54)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%55 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32)
|
||||
%56 = getelementptr inbounds i64, ptr %55, i64 0
|
||||
store i64 1, ptr %56, align 4
|
||||
%57 = getelementptr inbounds i64, ptr %55, i64 1
|
||||
store i64 2, ptr %57, align 4
|
||||
%58 = getelementptr inbounds i64, ptr %55, i64 2
|
||||
store i64 3, ptr %58, align 4
|
||||
%59 = getelementptr inbounds i64, ptr %55, i64 3
|
||||
store i64 4, ptr %59, align 4
|
||||
%60 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %55, 0
|
||||
%61 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %60, i64 4, 1
|
||||
%62 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %61, i64 4, 2
|
||||
%63 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %62, 0
|
||||
%64 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %62, 1
|
||||
%65 = icmp sge i64 1, %64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %65)
|
||||
%66 = getelementptr inbounds i64, ptr %63, i64 1
|
||||
%67 = load i64, ptr %66, align 4
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %67)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 0)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
; 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/internal/runtime.PrintInt"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringFromRune"(i32)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1)
|
||||
|
||||
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
|
||||
42
compiler/cl/_testrt/intgen/in.go
Normal file
42
compiler/cl/_testrt/intgen/in.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
type generator struct {
|
||||
val c.Int
|
||||
}
|
||||
|
||||
func (g *generator) next() c.Int {
|
||||
g.val++
|
||||
return g.val
|
||||
}
|
||||
|
||||
func genInts(n int, gen func() c.Int) []c.Int {
|
||||
a := make([]c.Int, n)
|
||||
for i := range a {
|
||||
a[i] = gen()
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func main() {
|
||||
for _, v := range genInts(5, c.Rand) {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
|
||||
initVal := c.Int(1)
|
||||
ints := genInts(5, func() c.Int {
|
||||
initVal *= 2
|
||||
return initVal
|
||||
})
|
||||
for _, v := range ints {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
|
||||
g := &generator{val: 1}
|
||||
for _, v := range genInts(5, g.next) {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
}
|
||||
199
compiler/cl/_testrt/intgen/out.ll
Normal file
199
compiler/cl/_testrt/intgen/out.ll
Normal file
@@ -0,0 +1,199 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
%main.generator = type { i32 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.Slice" @main.genInts(i64 %0, { ptr, ptr } %1) {
|
||||
_llgo_0:
|
||||
%2 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.MakeSlice"(i64 %0, i64 %0, i64 4)
|
||||
%3 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %2, 1
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%4 = phi i64 [ -1, %_llgo_0 ], [ %5, %_llgo_2 ]
|
||||
%5 = add i64 %4, 1
|
||||
%6 = icmp slt i64 %5, %3
|
||||
br i1 %6, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%7 = extractvalue { ptr, ptr } %1, 1
|
||||
%8 = extractvalue { ptr, ptr } %1, 0
|
||||
%9 = call i32 %8(ptr %7)
|
||||
%10 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %2, 0
|
||||
%11 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %2, 1
|
||||
%12 = icmp slt i64 %5, 0
|
||||
%13 = icmp sge i64 %5, %11
|
||||
%14 = or i1 %13, %12
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %14)
|
||||
%15 = getelementptr inbounds i32, ptr %10, i64 %5
|
||||
store i32 %9, ptr %15, align 4
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret %"github.com/goplus/llgo/internal/runtime.Slice" %2
|
||||
}
|
||||
|
||||
define i32 @"main.(*generator).next"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = getelementptr inbounds %main.generator, ptr %0, i32 0, i32 0
|
||||
%2 = load i32, ptr %1, align 4
|
||||
%3 = add i32 %2, 1
|
||||
%4 = getelementptr inbounds %main.generator, ptr %0, i32 0, i32 0
|
||||
store i32 %3, ptr %4, align 4
|
||||
%5 = getelementptr inbounds %main.generator, ptr %0, i32 0, i32 0
|
||||
%6 = load i32, ptr %5, align 4
|
||||
ret i32 %6
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call %"github.com/goplus/llgo/internal/runtime.Slice" @main.genInts(i64 5, { ptr, ptr } { ptr @__llgo_stub.rand, ptr null })
|
||||
%3 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %2, 1
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%4 = phi i64 [ -1, %_llgo_0 ], [ %5, %_llgo_2 ]
|
||||
%5 = add i64 %4, 1
|
||||
%6 = icmp slt i64 %5, %3
|
||||
br i1 %6, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%7 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %2, 0
|
||||
%8 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %2, 1
|
||||
%9 = icmp slt i64 %5, 0
|
||||
%10 = icmp sge i64 %5, %8
|
||||
%11 = or i1 %10, %9
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %11)
|
||||
%12 = getelementptr inbounds i32, ptr %7, i64 %5
|
||||
%13 = load i32, ptr %12, align 4
|
||||
%14 = call i32 (ptr, ...) @printf(ptr @0, i32 %13)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
%15 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 4)
|
||||
store i32 1, ptr %15, align 4
|
||||
%16 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%17 = getelementptr inbounds { ptr }, ptr %16, i32 0, i32 0
|
||||
store ptr %15, ptr %17, align 8
|
||||
%18 = insertvalue { ptr, ptr } { ptr @"main.main$1", ptr undef }, ptr %16, 1
|
||||
%19 = call %"github.com/goplus/llgo/internal/runtime.Slice" @main.genInts(i64 5, { ptr, ptr } %18)
|
||||
%20 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %19, 1
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_5, %_llgo_3
|
||||
%21 = phi i64 [ -1, %_llgo_3 ], [ %22, %_llgo_5 ]
|
||||
%22 = add i64 %21, 1
|
||||
%23 = icmp slt i64 %22, %20
|
||||
br i1 %23, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4
|
||||
%24 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %19, 0
|
||||
%25 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %19, 1
|
||||
%26 = icmp slt i64 %22, 0
|
||||
%27 = icmp sge i64 %22, %25
|
||||
%28 = or i1 %27, %26
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %28)
|
||||
%29 = getelementptr inbounds i32, ptr %24, i64 %22
|
||||
%30 = load i32, ptr %29, align 4
|
||||
%31 = call i32 (ptr, ...) @printf(ptr @1, i32 %30)
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_6: ; preds = %_llgo_4
|
||||
%32 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 4)
|
||||
%33 = getelementptr inbounds %main.generator, ptr %32, i32 0, i32 0
|
||||
store i32 1, ptr %33, align 4
|
||||
%34 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%35 = getelementptr inbounds { ptr }, ptr %34, i32 0, i32 0
|
||||
store ptr %32, ptr %35, align 8
|
||||
%36 = insertvalue { ptr, ptr } { ptr @"main.next$bound", ptr undef }, ptr %34, 1
|
||||
%37 = call %"github.com/goplus/llgo/internal/runtime.Slice" @main.genInts(i64 5, { ptr, ptr } %36)
|
||||
%38 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %37, 1
|
||||
br label %_llgo_7
|
||||
|
||||
_llgo_7: ; preds = %_llgo_8, %_llgo_6
|
||||
%39 = phi i64 [ -1, %_llgo_6 ], [ %40, %_llgo_8 ]
|
||||
%40 = add i64 %39, 1
|
||||
%41 = icmp slt i64 %40, %38
|
||||
br i1 %41, label %_llgo_8, label %_llgo_9
|
||||
|
||||
_llgo_8: ; preds = %_llgo_7
|
||||
%42 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %37, 0
|
||||
%43 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %37, 1
|
||||
%44 = icmp slt i64 %40, 0
|
||||
%45 = icmp sge i64 %40, %43
|
||||
%46 = or i1 %45, %44
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %46)
|
||||
%47 = getelementptr inbounds i32, ptr %42, i64 %40
|
||||
%48 = load i32, ptr %47, align 4
|
||||
%49 = call i32 (ptr, ...) @printf(ptr @2, i32 %48)
|
||||
br label %_llgo_7
|
||||
|
||||
_llgo_9: ; preds = %_llgo_7
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define i32 @"main.main$1"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { ptr }, ptr %0, align 8
|
||||
%2 = extractvalue { ptr } %1, 0
|
||||
%3 = load i32, ptr %2, align 4
|
||||
%4 = mul i32 %3, 2
|
||||
%5 = extractvalue { ptr } %1, 0
|
||||
store i32 %4, ptr %5, align 4
|
||||
%6 = extractvalue { ptr } %1, 0
|
||||
%7 = load i32, ptr %6, align 4
|
||||
ret i32 %7
|
||||
}
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.MakeSlice"(i64, i64, i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare i32 @rand()
|
||||
|
||||
define linkonce i32 @__llgo_stub.rand(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = tail call i32 @rand()
|
||||
ret i32 %1
|
||||
}
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
define i32 @"main.next$bound"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { ptr }, ptr %0, align 8
|
||||
%2 = extractvalue { ptr } %1, 0
|
||||
%3 = call i32 @"main.(*generator).next"(ptr %2)
|
||||
ret i32 %3
|
||||
}
|
||||
15
compiler/cl/_testrt/len/in.go
Normal file
15
compiler/cl/_testrt/len/in.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
type data struct {
|
||||
s string
|
||||
c chan int
|
||||
m map[int]string
|
||||
a []int
|
||||
}
|
||||
|
||||
func main() {
|
||||
d := &data{}
|
||||
println(len(d.s), len(d.c), len(d.m), len(d.a), cap(d.c), cap(d.a))
|
||||
v := &data{s: "hello", c: make(chan int, 2), m: map[int]string{1: "hello"}, a: []int{1, 2, 3}}
|
||||
println(len(v.s), len(v.c), len(v.m), len(v.a), cap(v.c), cap(v.a))
|
||||
}
|
||||
229
compiler/cl/_testrt/len/out.ll
Normal file
229
compiler/cl/_testrt/len/out.ll
Normal file
@@ -0,0 +1,229 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%main.data = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, ptr, %"github.com/goplus/llgo/internal/runtime.Slice" }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
%"github.com/goplus/llgo/internal/abi.StructField" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@_llgo_int = linkonce global ptr null, align 8
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@"map[_llgo_int]_llgo_string" = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [7 x i8] c"topbits", align 1
|
||||
@1 = private unnamed_addr constant [4 x i8] c"keys", align 1
|
||||
@2 = private unnamed_addr constant [5 x i8] c"elems", align 1
|
||||
@3 = private unnamed_addr constant [8 x i8] c"overflow", align 1
|
||||
@4 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@5 = private unnamed_addr constant [5 x i8] c"hello", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"main.init$after"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 56)
|
||||
%3 = getelementptr inbounds %main.data, ptr %2, i32 0, i32 0
|
||||
%4 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %3, align 8
|
||||
%5 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %4, 1
|
||||
%6 = getelementptr inbounds %main.data, ptr %2, i32 0, i32 1
|
||||
%7 = load ptr, ptr %6, align 8
|
||||
%8 = call i64 @"github.com/goplus/llgo/internal/runtime.ChanLen"(ptr %7)
|
||||
%9 = getelementptr inbounds %main.data, ptr %2, i32 0, i32 2
|
||||
%10 = load ptr, ptr %9, align 8
|
||||
%11 = call i64 @"github.com/goplus/llgo/internal/runtime.MapLen"(ptr %10)
|
||||
%12 = getelementptr inbounds %main.data, ptr %2, i32 0, i32 3
|
||||
%13 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %12, align 8
|
||||
%14 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %13, 1
|
||||
%15 = getelementptr inbounds %main.data, ptr %2, i32 0, i32 1
|
||||
%16 = load ptr, ptr %15, align 8
|
||||
%17 = call i64 @"github.com/goplus/llgo/internal/runtime.ChanCap"(ptr %16)
|
||||
%18 = getelementptr inbounds %main.data, ptr %2, i32 0, i32 3
|
||||
%19 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %18, align 8
|
||||
%20 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %19, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %5)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %8)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %11)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %14)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %17)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %20)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%21 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 56)
|
||||
%22 = getelementptr inbounds %main.data, ptr %21, i32 0, i32 0
|
||||
%23 = getelementptr inbounds %main.data, ptr %21, i32 0, i32 1
|
||||
%24 = call ptr @"github.com/goplus/llgo/internal/runtime.NewChan"(i64 8, i64 2)
|
||||
%25 = getelementptr inbounds %main.data, ptr %21, i32 0, i32 2
|
||||
%26 = load ptr, ptr @_llgo_int, align 8
|
||||
%27 = load ptr, ptr @_llgo_string, align 8
|
||||
%28 = load ptr, ptr @"map[_llgo_int]_llgo_string", align 8
|
||||
%29 = call ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr %28, i64 1)
|
||||
%30 = load ptr, ptr @"map[_llgo_int]_llgo_string", align 8
|
||||
%31 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
store i64 1, ptr %31, align 4
|
||||
%32 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %30, ptr %29, ptr %31)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 5 }, ptr %32, align 8
|
||||
%33 = getelementptr inbounds %main.data, ptr %21, i32 0, i32 3
|
||||
%34 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 24)
|
||||
%35 = getelementptr inbounds i64, ptr %34, i64 0
|
||||
store i64 1, ptr %35, align 4
|
||||
%36 = getelementptr inbounds i64, ptr %34, i64 1
|
||||
store i64 2, ptr %36, align 4
|
||||
%37 = getelementptr inbounds i64, ptr %34, i64 2
|
||||
store i64 3, ptr %37, align 4
|
||||
%38 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %34, 0
|
||||
%39 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %38, i64 3, 1
|
||||
%40 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %39, i64 3, 2
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 5 }, ptr %22, align 8
|
||||
store ptr %24, ptr %23, align 8
|
||||
store ptr %29, ptr %25, align 8
|
||||
store %"github.com/goplus/llgo/internal/runtime.Slice" %40, ptr %33, align 8
|
||||
%41 = getelementptr inbounds %main.data, ptr %21, i32 0, i32 0
|
||||
%42 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %41, align 8
|
||||
%43 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %42, 1
|
||||
%44 = getelementptr inbounds %main.data, ptr %21, i32 0, i32 1
|
||||
%45 = load ptr, ptr %44, align 8
|
||||
%46 = call i64 @"github.com/goplus/llgo/internal/runtime.ChanLen"(ptr %45)
|
||||
%47 = getelementptr inbounds %main.data, ptr %21, i32 0, i32 2
|
||||
%48 = load ptr, ptr %47, align 8
|
||||
%49 = call i64 @"github.com/goplus/llgo/internal/runtime.MapLen"(ptr %48)
|
||||
%50 = getelementptr inbounds %main.data, ptr %21, i32 0, i32 3
|
||||
%51 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %50, align 8
|
||||
%52 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %51, 1
|
||||
%53 = getelementptr inbounds %main.data, ptr %21, i32 0, i32 1
|
||||
%54 = load ptr, ptr %53, align 8
|
||||
%55 = call i64 @"github.com/goplus/llgo/internal/runtime.ChanCap"(ptr %54)
|
||||
%56 = getelementptr inbounds %main.data, ptr %21, i32 0, i32 3
|
||||
%57 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %56, align 8
|
||||
%58 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %57, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %43)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %46)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %49)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %52)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %55)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %58)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare i64 @"github.com/goplus/llgo/internal/runtime.ChanLen"(ptr)
|
||||
|
||||
declare i64 @"github.com/goplus/llgo/internal/runtime.MapLen"(ptr)
|
||||
|
||||
declare i64 @"github.com/goplus/llgo/internal/runtime.ChanCap"(ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.NewChan"(i64, i64)
|
||||
|
||||
define void @"main.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/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_string, 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/internal/runtime.Basic"(i64 24)
|
||||
store ptr %5, ptr @_llgo_string, align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%6 = load ptr, ptr @"map[_llgo_int]_llgo_string", align 8
|
||||
%7 = icmp eq ptr %6, null
|
||||
br i1 %7, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4
|
||||
%8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
%10 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 40)
|
||||
%11 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %10)
|
||||
%12 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 7 }, ptr %11, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%13 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %13)
|
||||
%15 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, ptr %14, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%16 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
%17 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %16)
|
||||
%18 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 5 }, ptr %17, i64 72, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%19 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 58)
|
||||
%20 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 8 }, ptr %19, i64 200, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%21 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 224)
|
||||
%22 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %21, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %12, ptr %22, align 8
|
||||
%23 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %21, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %15, ptr %23, align 8
|
||||
%24 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %21, i64 2
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %18, ptr %24, align 8
|
||||
%25 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %21, i64 3
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %20, ptr %25, align 8
|
||||
%26 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %21, 0
|
||||
%27 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %26, i64 4, 1
|
||||
%28 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %27, i64 4, 2
|
||||
%29 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 4 }, i64 208, %"github.com/goplus/llgo/internal/runtime.Slice" %28)
|
||||
%30 = call ptr @"github.com/goplus/llgo/internal/runtime.MapOf"(ptr %8, ptr %9, ptr %29, i64 4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %30)
|
||||
store ptr %30, ptr @"map[_llgo_int]_llgo_string", align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MapOf"(ptr, ptr, ptr, i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64, ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr, i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr, ptr, ptr)
|
||||
29
compiler/cl/_testrt/linkname/in.go
Normal file
29
compiler/cl/_testrt/linkname/in.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
_ "github.com/goplus/llgo/compiler/cl/internal/linktarget"
|
||||
)
|
||||
|
||||
//go:linkname print github.com/goplus/llgo/compiler/cl/internal/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
|
||||
func setInfo(*m, string)
|
||||
|
||||
//go:linkname info github.com/goplus/llgo/compiler/cl/internal/linktarget.m.info
|
||||
func info(m) string
|
||||
|
||||
func main() {
|
||||
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"))
|
||||
var m m
|
||||
setInfo(&m, "hello")
|
||||
println(info(m))
|
||||
}
|
||||
65
compiler/cl/_testrt/linkname/out.ll
Normal file
65
compiler/cl/_testrt/linkname/out.ll
Normal file
@@ -0,0 +1,65 @@
|
||||
; ModuleID = '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 i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [2 x i8] c"a\00", align 1
|
||||
@1 = private unnamed_addr constant [2 x i8] c"b\00", align 1
|
||||
@2 = private unnamed_addr constant [2 x i8] c"c\00", align 1
|
||||
@3 = private unnamed_addr constant [2 x i8] c"d\00", align 1
|
||||
@4 = private unnamed_addr constant [2 x i8] c"1\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
|
||||
@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/internal/runtime.String" @"github.com/goplus/llgo/cl/internal/linktarget.m.info"(%main.m)
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"github.com/goplus/llgo/cl/internal/linktarget.init"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.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 @4, ptr @5, ptr @6, ptr @7)
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
call void @"github.com/goplus/llgo/cl/internal/linktarget.(*m).setInfo"(ptr %2, %"github.com/goplus/llgo/internal/runtime.String" { ptr @8, i64 5 })
|
||||
%3 = load %main.m, ptr %2, align 8
|
||||
%4 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/cl/internal/linktarget.m.info"(%main.m %3)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
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.(*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 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)
|
||||
128
compiler/cl/_testrt/makemap/in.go
Normal file
128
compiler/cl/_testrt/makemap/in.go
Normal file
@@ -0,0 +1,128 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
make1()
|
||||
make2()
|
||||
make3()
|
||||
make4()
|
||||
make5()
|
||||
make6()
|
||||
make7()
|
||||
}
|
||||
|
||||
func make1() {
|
||||
m := make(map[int]string)
|
||||
m[1] = "hello"
|
||||
m[2] = "world"
|
||||
m[3] = "llgo"
|
||||
println(m, m[1], m[2], len(m))
|
||||
for k, v := range m {
|
||||
println(k, ":", v)
|
||||
}
|
||||
|
||||
s := make(map[string]int, len(m))
|
||||
for k, v := range m {
|
||||
s[v] = k
|
||||
}
|
||||
|
||||
id, ok := s["llgo"]
|
||||
println("llgo", id, ok)
|
||||
|
||||
none, ok := s["go"]
|
||||
println("go", none, ok)
|
||||
|
||||
delete(s, "llgo")
|
||||
if _, ok := s["llgo"]; ok {
|
||||
panic("bad key")
|
||||
}
|
||||
if len(s) != 2 {
|
||||
panic("bad len")
|
||||
}
|
||||
}
|
||||
|
||||
type N1 [1]int
|
||||
|
||||
func make2() {
|
||||
m2 := make(map[int]string)
|
||||
println(m2, len(m2), m2 == nil, m2 != nil)
|
||||
var m3 map[int]string
|
||||
println(m3, len(m3), m3 == nil, m3 != nil)
|
||||
|
||||
n := make(map[any]int)
|
||||
n[N1{1}] = 100
|
||||
n[N1{2}] = 200
|
||||
n[N1{3}] = 300
|
||||
n[N1{2}] = -200
|
||||
for k, v := range n {
|
||||
println(k.(N1)[0], v)
|
||||
}
|
||||
}
|
||||
|
||||
type N struct {
|
||||
n1 int8
|
||||
n2 int8
|
||||
}
|
||||
type K [1]N
|
||||
type K2 [1]*N
|
||||
|
||||
func make3() {
|
||||
var a any = K{N{1, 2}}
|
||||
var b any = K{N{1, 2}}
|
||||
println(a == b)
|
||||
|
||||
m := make(map[any]int)
|
||||
m[K{N{1, 2}}] = 100
|
||||
m[K{N{3, 4}}] = 200
|
||||
for k, v := range m {
|
||||
println(k.(K)[0].n1, v)
|
||||
}
|
||||
}
|
||||
|
||||
func make4() {
|
||||
var a any = K2{&N{1, 2}}
|
||||
var b any = K2{&N{1, 2}}
|
||||
println(a == b)
|
||||
|
||||
m := make(map[any]int)
|
||||
m[K2{&N{1, 2}}] = 100
|
||||
m[K2{&N{3, 4}}] = 200
|
||||
for k, v := range m {
|
||||
println(k.(K2)[0].n1, v)
|
||||
}
|
||||
}
|
||||
|
||||
func make5() {
|
||||
ch := make(chan int)
|
||||
var a any = ch
|
||||
var b any = ch
|
||||
println(a == b)
|
||||
m := make(map[chan int]int)
|
||||
m[ch] = 100
|
||||
m[ch] = 200
|
||||
for k, v := range m {
|
||||
println(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
type M map[int]string
|
||||
|
||||
func make6() {
|
||||
var m M
|
||||
m = make(map[int]string)
|
||||
m[1] = "hello"
|
||||
for k, v := range m {
|
||||
println(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
func make7() {
|
||||
type N int
|
||||
m := map[N]string{
|
||||
1: "hello",
|
||||
2: "world",
|
||||
}
|
||||
for k, v := range m {
|
||||
println(k, v)
|
||||
}
|
||||
println(m[1])
|
||||
}
|
||||
1335
compiler/cl/_testrt/makemap/out.ll
Normal file
1335
compiler/cl/_testrt/makemap/out.ll
Normal file
File diff suppressed because it is too large
Load Diff
10
compiler/cl/_testrt/map/in.go
Normal file
10
compiler/cl/_testrt/map/in.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
func main() {
|
||||
a := map[int]int{23: 100, 7: 29}
|
||||
c.Printf(c.Str("Hello %d\n"), a[23])
|
||||
}
|
||||
136
compiler/cl/_testrt/map/out.ll
Normal file
136
compiler/cl/_testrt/map/out.ll
Normal file
@@ -0,0 +1,136 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/abi.StructField" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1 }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@_llgo_int = linkonce global ptr null, align 8
|
||||
@"map[_llgo_int]_llgo_int" = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [7 x i8] c"topbits", align 1
|
||||
@1 = private unnamed_addr constant [4 x i8] c"keys", align 1
|
||||
@2 = private unnamed_addr constant [5 x i8] c"elems", align 1
|
||||
@3 = private unnamed_addr constant [8 x i8] c"overflow", align 1
|
||||
@4 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@5 = private unnamed_addr constant [10 x i8] c"Hello %d\0A\00", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"main.init$after"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = load ptr, ptr @_llgo_int, align 8
|
||||
%3 = load ptr, ptr @"map[_llgo_int]_llgo_int", align 8
|
||||
%4 = call ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr %3, i64 2)
|
||||
%5 = load ptr, ptr @"map[_llgo_int]_llgo_int", align 8
|
||||
%6 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
store i64 23, ptr %6, align 4
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %5, ptr %4, ptr %6)
|
||||
store i64 100, ptr %7, align 4
|
||||
%8 = load ptr, ptr @"map[_llgo_int]_llgo_int", align 8
|
||||
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
store i64 7, ptr %9, align 4
|
||||
%10 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %8, ptr %4, ptr %9)
|
||||
store i64 29, ptr %10, align 4
|
||||
%11 = load ptr, ptr @"map[_llgo_int]_llgo_int", align 8
|
||||
%12 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
store i64 23, ptr %12, align 4
|
||||
%13 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAccess1"(ptr %11, ptr %4, ptr %12)
|
||||
%14 = load i64, ptr %13, align 4
|
||||
%15 = call i32 (ptr, ...) @printf(ptr @5, i64 %14)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
define void @"main.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/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 @"map[_llgo_int]_llgo_int", 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/internal/runtime.Basic"(i64 34)
|
||||
%6 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 40)
|
||||
%8 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %7)
|
||||
%9 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 7 }, ptr %8, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%10 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%11 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %10)
|
||||
%12 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, ptr %11, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%13 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %13)
|
||||
%15 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 5 }, ptr %14, i64 72, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%16 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 44)
|
||||
%17 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 8 }, ptr %16, i64 136, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%18 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 224)
|
||||
%19 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %18, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %9, ptr %19, align 8
|
||||
%20 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %18, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %12, ptr %20, align 8
|
||||
%21 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %18, i64 2
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %15, ptr %21, align 8
|
||||
%22 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %18, i64 3
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %17, ptr %22, align 8
|
||||
%23 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %18, 0
|
||||
%24 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %23, i64 4, 1
|
||||
%25 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %24, i64 4, 2
|
||||
%26 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 4 }, i64 144, %"github.com/goplus/llgo/internal/runtime.Slice" %25)
|
||||
%27 = call ptr @"github.com/goplus/llgo/internal/runtime.MapOf"(ptr %5, ptr %6, ptr %26, i64 4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %27)
|
||||
store ptr %27, ptr @"map[_llgo_int]_llgo_int", align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MapOf"(ptr, ptr, ptr, i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64, ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr, i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr, ptr, ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MapAccess1"(ptr, ptr, ptr)
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
42
compiler/cl/_testrt/mask/in.go
Normal file
42
compiler/cl/_testrt/mask/in.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
println(mask(1))
|
||||
println(mask_shl(127, 5))
|
||||
println(mask_shl8(127, 5))
|
||||
println(mask_shl8u(127, 5))
|
||||
println(mask_shl8(127, 16))
|
||||
println(mask_shl8u(127, 16))
|
||||
println(mask_shr(127, 5))
|
||||
println(mask_shr8(127, 5))
|
||||
println(mask_shr8u(127, 5))
|
||||
println(mask_shr8(127, 16))
|
||||
}
|
||||
|
||||
func mask(x int8) int32 {
|
||||
return int32(x) << 31 >> 31
|
||||
}
|
||||
|
||||
func mask_shl8(x int8, y int) int8 {
|
||||
return x << y
|
||||
}
|
||||
|
||||
func mask_shl8u(x uint8, y int) uint8 {
|
||||
return x << y
|
||||
}
|
||||
|
||||
func mask_shl(x int, y int) int {
|
||||
return x << y
|
||||
}
|
||||
|
||||
func mask_shr8(x int8, y int) int8 {
|
||||
return x >> y
|
||||
}
|
||||
|
||||
func mask_shr8u(x uint8, y int) uint8 {
|
||||
return x >> y
|
||||
}
|
||||
|
||||
func mask_shr(x int, y int) int {
|
||||
return x >> y
|
||||
}
|
||||
149
compiler/cl/_testrt/mask/out.ll
Normal file
149
compiler/cl/_testrt/mask/out.ll
Normal file
@@ -0,0 +1,149 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call i32 @main.mask(i8 1)
|
||||
%3 = sext i32 %2 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %3)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%4 = call i64 @main.mask_shl(i64 127, i64 5)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%5 = call i8 @main.mask_shl8(i8 127, i64 5)
|
||||
%6 = sext i8 %5 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %6)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%7 = call i8 @main.mask_shl8u(i8 127, i64 5)
|
||||
%8 = zext i8 %7 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %8)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%9 = call i8 @main.mask_shl8(i8 127, i64 16)
|
||||
%10 = sext i8 %9 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %10)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%11 = call i8 @main.mask_shl8u(i8 127, i64 16)
|
||||
%12 = zext i8 %11 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %12)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%13 = call i64 @main.mask_shr(i64 127, i64 5)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %13)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%14 = call i8 @main.mask_shr8(i8 127, i64 5)
|
||||
%15 = sext i8 %14 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %15)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%16 = call i8 @main.mask_shr8u(i8 127, i64 5)
|
||||
%17 = zext i8 %16 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %17)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%18 = call i8 @main.mask_shr8(i8 127, i64 16)
|
||||
%19 = sext i8 %18 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %19)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define i32 @main.mask(i8 %0) {
|
||||
_llgo_0:
|
||||
%1 = sext i8 %0 to i32
|
||||
%2 = shl i32 %1, 31
|
||||
%3 = select i1 false, i32 0, i32 %2
|
||||
%4 = ashr i32 %3, 31
|
||||
ret i32 %4
|
||||
}
|
||||
|
||||
define i64 @main.mask_shl(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = icmp slt i64 %1, 0
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertNegativeShift"(i1 %2)
|
||||
%3 = icmp uge i64 %1, 64
|
||||
%4 = shl i64 %0, %1
|
||||
%5 = select i1 %3, i64 0, i64 %4
|
||||
ret i64 %5
|
||||
}
|
||||
|
||||
define i8 @main.mask_shl8(i8 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = icmp slt i64 %1, 0
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertNegativeShift"(i1 %2)
|
||||
%3 = trunc i64 %1 to i8
|
||||
%4 = icmp uge i8 %3, 8
|
||||
%5 = shl i8 %0, %3
|
||||
%6 = select i1 %4, i8 0, i8 %5
|
||||
ret i8 %6
|
||||
}
|
||||
|
||||
define i8 @main.mask_shl8u(i8 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = icmp slt i64 %1, 0
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertNegativeShift"(i1 %2)
|
||||
%3 = trunc i64 %1 to i8
|
||||
%4 = icmp uge i8 %3, 8
|
||||
%5 = shl i8 %0, %3
|
||||
%6 = select i1 %4, i8 0, i8 %5
|
||||
ret i8 %6
|
||||
}
|
||||
|
||||
define i64 @main.mask_shr(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = icmp slt i64 %1, 0
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertNegativeShift"(i1 %2)
|
||||
%3 = icmp uge i64 %1, 64
|
||||
%4 = select i1 %3, i64 63, i64 %1
|
||||
%5 = ashr i64 %0, %4
|
||||
ret i64 %5
|
||||
}
|
||||
|
||||
define i8 @main.mask_shr8(i8 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = icmp slt i64 %1, 0
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertNegativeShift"(i1 %2)
|
||||
%3 = trunc i64 %1 to i8
|
||||
%4 = icmp uge i8 %3, 8
|
||||
%5 = select i1 %4, i8 7, i8 %3
|
||||
%6 = ashr i8 %0, %5
|
||||
ret i8 %6
|
||||
}
|
||||
|
||||
define i8 @main.mask_shr8u(i8 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = icmp slt i64 %1, 0
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertNegativeShift"(i1 %2)
|
||||
%3 = trunc i64 %1 to i8
|
||||
%4 = icmp uge i8 %3, 8
|
||||
%5 = lshr i8 %0, %3
|
||||
%6 = select i1 %4, i8 0, i8 %5
|
||||
ret i8 %6
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.AssertNegativeShift"(i1)
|
||||
39
compiler/cl/_testrt/named/in.go
Normal file
39
compiler/cl/_testrt/named/in.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import "github.com/goplus/llgo/c"
|
||||
|
||||
type mSpanList struct {
|
||||
first *mspan
|
||||
last *mspan
|
||||
}
|
||||
|
||||
type minfo struct {
|
||||
span *mspan
|
||||
info int
|
||||
}
|
||||
|
||||
type mspan struct {
|
||||
next *mspan
|
||||
prev *mspan
|
||||
list *mSpanList
|
||||
info minfo
|
||||
value int
|
||||
check func(int) int
|
||||
}
|
||||
|
||||
func main() {
|
||||
m := &mspan{}
|
||||
m.value = 100
|
||||
m.next = &mspan{}
|
||||
m.next.value = 200
|
||||
m.list = &mSpanList{}
|
||||
m.list.last = &mspan{}
|
||||
m.list.last.value = 300
|
||||
m.info.info = 10
|
||||
m.info.span = m
|
||||
m.check = func(n int) int {
|
||||
return m.value * n
|
||||
}
|
||||
c.Printf(c.Str("%d %d %d %d %d %d\n"), m.next.value, m.list.last.value, m.info.info,
|
||||
m.info.span.value, m.check(-2), m.info.span.check(-3))
|
||||
}
|
||||
138
compiler/cl/_testrt/named/out.ll
Normal file
138
compiler/cl/_testrt/named/out.ll
Normal file
@@ -0,0 +1,138 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%main.mspan = type { ptr, ptr, ptr, %main.minfo, i64, { ptr, ptr } }
|
||||
%main.minfo = type { ptr, i64 }
|
||||
%main.mSpanList = type { ptr, ptr }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [19 x i8] c"%d %d %d %d %d %d\0A\00", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 64)
|
||||
store ptr %3, ptr %2, align 8
|
||||
%4 = load ptr, ptr %2, align 8
|
||||
%5 = getelementptr inbounds %main.mspan, ptr %4, i32 0, i32 4
|
||||
store i64 100, ptr %5, align 4
|
||||
%6 = load ptr, ptr %2, align 8
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 64)
|
||||
%8 = getelementptr inbounds %main.mspan, ptr %6, i32 0, i32 0
|
||||
store ptr %7, ptr %8, align 8
|
||||
%9 = load ptr, ptr %2, align 8
|
||||
%10 = getelementptr inbounds %main.mspan, ptr %9, i32 0, i32 0
|
||||
%11 = load ptr, ptr %10, align 8
|
||||
%12 = getelementptr inbounds %main.mspan, ptr %11, i32 0, i32 4
|
||||
store i64 200, ptr %12, align 4
|
||||
%13 = load ptr, ptr %2, align 8
|
||||
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
%15 = getelementptr inbounds %main.mspan, ptr %13, i32 0, i32 2
|
||||
store ptr %14, ptr %15, align 8
|
||||
%16 = load ptr, ptr %2, align 8
|
||||
%17 = getelementptr inbounds %main.mspan, ptr %16, i32 0, i32 2
|
||||
%18 = load ptr, ptr %17, align 8
|
||||
%19 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 64)
|
||||
%20 = getelementptr inbounds %main.mSpanList, ptr %18, i32 0, i32 1
|
||||
store ptr %19, ptr %20, align 8
|
||||
%21 = load ptr, ptr %2, align 8
|
||||
%22 = getelementptr inbounds %main.mspan, ptr %21, i32 0, i32 2
|
||||
%23 = load ptr, ptr %22, align 8
|
||||
%24 = getelementptr inbounds %main.mSpanList, ptr %23, i32 0, i32 1
|
||||
%25 = load ptr, ptr %24, align 8
|
||||
%26 = getelementptr inbounds %main.mspan, ptr %25, i32 0, i32 4
|
||||
store i64 300, ptr %26, align 4
|
||||
%27 = load ptr, ptr %2, align 8
|
||||
%28 = getelementptr inbounds %main.mspan, ptr %27, i32 0, i32 3
|
||||
%29 = getelementptr inbounds %main.minfo, ptr %28, i32 0, i32 1
|
||||
store i64 10, ptr %29, align 4
|
||||
%30 = load ptr, ptr %2, align 8
|
||||
%31 = getelementptr inbounds %main.mspan, ptr %30, i32 0, i32 3
|
||||
%32 = load ptr, ptr %2, align 8
|
||||
%33 = getelementptr inbounds %main.minfo, ptr %31, i32 0, i32 0
|
||||
store ptr %32, ptr %33, align 8
|
||||
%34 = load ptr, ptr %2, align 8
|
||||
%35 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%36 = getelementptr inbounds { ptr }, ptr %35, i32 0, i32 0
|
||||
store ptr %2, ptr %36, align 8
|
||||
%37 = insertvalue { ptr, ptr } { ptr @"main.main$1", ptr undef }, ptr %35, 1
|
||||
%38 = getelementptr inbounds %main.mspan, ptr %34, i32 0, i32 5
|
||||
store { ptr, ptr } %37, ptr %38, align 8
|
||||
%39 = load ptr, ptr %2, align 8
|
||||
%40 = getelementptr inbounds %main.mspan, ptr %39, i32 0, i32 0
|
||||
%41 = load ptr, ptr %40, align 8
|
||||
%42 = getelementptr inbounds %main.mspan, ptr %41, i32 0, i32 4
|
||||
%43 = load i64, ptr %42, align 4
|
||||
%44 = load ptr, ptr %2, align 8
|
||||
%45 = getelementptr inbounds %main.mspan, ptr %44, i32 0, i32 2
|
||||
%46 = load ptr, ptr %45, align 8
|
||||
%47 = getelementptr inbounds %main.mSpanList, ptr %46, i32 0, i32 1
|
||||
%48 = load ptr, ptr %47, align 8
|
||||
%49 = getelementptr inbounds %main.mspan, ptr %48, i32 0, i32 4
|
||||
%50 = load i64, ptr %49, align 4
|
||||
%51 = load ptr, ptr %2, align 8
|
||||
%52 = getelementptr inbounds %main.mspan, ptr %51, i32 0, i32 3
|
||||
%53 = getelementptr inbounds %main.minfo, ptr %52, i32 0, i32 1
|
||||
%54 = load i64, ptr %53, align 4
|
||||
%55 = load ptr, ptr %2, align 8
|
||||
%56 = getelementptr inbounds %main.mspan, ptr %55, i32 0, i32 3
|
||||
%57 = getelementptr inbounds %main.minfo, ptr %56, i32 0, i32 0
|
||||
%58 = load ptr, ptr %57, align 8
|
||||
%59 = getelementptr inbounds %main.mspan, ptr %58, i32 0, i32 4
|
||||
%60 = load i64, ptr %59, align 4
|
||||
%61 = load ptr, ptr %2, align 8
|
||||
%62 = getelementptr inbounds %main.mspan, ptr %61, i32 0, i32 5
|
||||
%63 = load { ptr, ptr }, ptr %62, align 8
|
||||
%64 = extractvalue { ptr, ptr } %63, 1
|
||||
%65 = extractvalue { ptr, ptr } %63, 0
|
||||
%66 = call i64 %65(ptr %64, i64 -2)
|
||||
%67 = load ptr, ptr %2, align 8
|
||||
%68 = getelementptr inbounds %main.mspan, ptr %67, i32 0, i32 3
|
||||
%69 = getelementptr inbounds %main.minfo, ptr %68, i32 0, i32 0
|
||||
%70 = load ptr, ptr %69, align 8
|
||||
%71 = getelementptr inbounds %main.mspan, ptr %70, i32 0, i32 5
|
||||
%72 = load { ptr, ptr }, ptr %71, align 8
|
||||
%73 = extractvalue { ptr, ptr } %72, 1
|
||||
%74 = extractvalue { ptr, ptr } %72, 0
|
||||
%75 = call i64 %74(ptr %73, i64 -3)
|
||||
%76 = call i32 (ptr, ...) @printf(ptr @0, i64 %43, i64 %50, i64 %54, i64 %60, i64 %66, i64 %75)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define i64 @"main.main$1"(ptr %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = load { ptr }, ptr %0, align 8
|
||||
%3 = extractvalue { ptr } %2, 0
|
||||
%4 = load ptr, ptr %3, align 8
|
||||
%5 = getelementptr inbounds %main.mspan, ptr %4, i32 0, i32 4
|
||||
%6 = load i64, ptr %5, align 4
|
||||
%7 = mul i64 %6, %1
|
||||
ret i64 %7
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
10
compiler/cl/_testrt/nextblock/in.go
Normal file
10
compiler/cl/_testrt/nextblock/in.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
syms := []int{}
|
||||
for range syms {
|
||||
}
|
||||
defer println("bye")
|
||||
for range syms {
|
||||
}
|
||||
}
|
||||
1
compiler/cl/_testrt/nextblock/out.ll
Normal file
1
compiler/cl/_testrt/nextblock/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
5
compiler/cl/_testrt/panic/in.go
Normal file
5
compiler/cl/_testrt/panic/in.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
panic("panic message")
|
||||
}
|
||||
63
compiler/cl/_testrt/panic/out.ll
Normal file
63
compiler/cl/_testrt/panic/out.ll
Normal file
@@ -0,0 +1,63 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [13 x i8] c"panic message", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"main.init$after"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = load ptr, ptr @_llgo_string, align 8
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 13 }, ptr %3, align 8
|
||||
%4 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %2, 0
|
||||
%5 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %4, ptr %3, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %5)
|
||||
unreachable
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
define void @"main.init$after"() {
|
||||
_llgo_0:
|
||||
%0 = load ptr, ptr @_llgo_string, 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/internal/runtime.Basic"(i64 24)
|
||||
store ptr %2, ptr @_llgo_string, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
20
compiler/cl/_testrt/qsort/in.go
Normal file
20
compiler/cl/_testrt/qsort/in.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
//go:linkname qsort C.qsort
|
||||
func qsort(base c.Pointer, count, elem uintptr, compar func(a, b c.Pointer) c.Int)
|
||||
|
||||
func main() {
|
||||
a := [...]int{100, 8, 23, 2, 7}
|
||||
qsort(c.Pointer(&a[0]), 5, unsafe.Sizeof(0), func(a, b c.Pointer) c.Int {
|
||||
return c.Int(*(*int)(a) - *(*int)(b))
|
||||
})
|
||||
for _, v := range a {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
}
|
||||
81
compiler/cl/_testrt/qsort/out.ll
Normal file
81
compiler/cl/_testrt/qsort/out.ll
Normal file
@@ -0,0 +1,81 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 40)
|
||||
%3 = getelementptr inbounds i64, ptr %2, i64 0
|
||||
%4 = getelementptr inbounds i64, ptr %2, i64 1
|
||||
%5 = getelementptr inbounds i64, ptr %2, i64 2
|
||||
%6 = getelementptr inbounds i64, ptr %2, i64 3
|
||||
%7 = getelementptr inbounds i64, ptr %2, i64 4
|
||||
store i64 100, ptr %3, align 4
|
||||
store i64 8, ptr %4, align 4
|
||||
store i64 23, ptr %5, align 4
|
||||
store i64 2, ptr %6, align 4
|
||||
store i64 7, ptr %7, align 4
|
||||
%8 = getelementptr inbounds i64, ptr %2, i64 0
|
||||
call void @qsort(ptr %8, i64 5, i64 8, ptr @"main.main$1")
|
||||
%9 = load [5 x i64], ptr %2, align 4
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%10 = phi i64 [ -1, %_llgo_0 ], [ %11, %_llgo_2 ]
|
||||
%11 = add i64 %10, 1
|
||||
%12 = icmp slt i64 %11, 5
|
||||
br i1 %12, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%13 = icmp slt i64 %11, 0
|
||||
%14 = icmp sge i64 %11, 5
|
||||
%15 = or i1 %14, %13
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %15)
|
||||
%16 = getelementptr inbounds i64, ptr %2, i64 %11
|
||||
%17 = load i64, ptr %16, align 4
|
||||
%18 = call i32 (ptr, ...) @printf(ptr @0, i64 %17)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define i32 @"main.main$1"(ptr %0, ptr %1) {
|
||||
_llgo_0:
|
||||
%2 = load i64, ptr %0, align 4
|
||||
%3 = load i64, ptr %1, align 4
|
||||
%4 = sub i64 %2, %3
|
||||
%5 = trunc i64 %4 to i32
|
||||
ret i32 %5
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare void @qsort(ptr, i64, i64, ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1)
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
150
compiler/cl/_testrt/qsortfn/in.go
Normal file
150
compiler/cl/_testrt/qsortfn/in.go
Normal file
@@ -0,0 +1,150 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
q "github.com/goplus/llgo/compiler/cl/internal/qsort"
|
||||
)
|
||||
|
||||
//llgo:type C
|
||||
type Comp func(a, b c.Pointer) c.Int
|
||||
|
||||
//go:linkname qsort C.qsort
|
||||
func qsort(base c.Pointer, count, elem uintptr, compar Comp)
|
||||
|
||||
//go:linkname qsort2 C.qsort
|
||||
func qsort2(base c.Pointer, count, elem uintptr, compar func(a, b c.Pointer) c.Int)
|
||||
|
||||
func main() {
|
||||
sort1a()
|
||||
sort1b()
|
||||
sort2a()
|
||||
sort2b()
|
||||
sort3a()
|
||||
sort3b()
|
||||
sort4a()
|
||||
sort4b()
|
||||
sort5a()
|
||||
sort5b()
|
||||
}
|
||||
|
||||
func sort1a() {
|
||||
c.Printf(c.Str("Comp => Comp\n"))
|
||||
a := [...]int{100, 8, 23, 2, 7}
|
||||
var fn Comp = func(a, b c.Pointer) c.Int {
|
||||
return c.Int(*(*int)(a) - *(*int)(b))
|
||||
}
|
||||
qsort(c.Pointer(&a[0]), 5, unsafe.Sizeof(0), fn)
|
||||
for _, v := range a {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
}
|
||||
|
||||
func sort1b() {
|
||||
c.Printf(c.Str("fn => Comp\n"))
|
||||
a := [...]int{100, 8, 23, 2, 7}
|
||||
var fn = func(a, b c.Pointer) c.Int {
|
||||
return c.Int(*(*int)(a) - *(*int)(b))
|
||||
}
|
||||
qsort(c.Pointer(&a[0]), 5, unsafe.Sizeof(0), fn)
|
||||
for _, v := range a {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
}
|
||||
|
||||
func sort2a() {
|
||||
c.Printf(c.Str("Comp => fn\n"))
|
||||
a := [...]int{100, 8, 23, 2, 7}
|
||||
var fn Comp = func(a, b c.Pointer) c.Int {
|
||||
return c.Int(*(*int)(a) - *(*int)(b))
|
||||
}
|
||||
qsort2(c.Pointer(&a[0]), 5, unsafe.Sizeof(0), fn)
|
||||
for _, v := range a {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
}
|
||||
|
||||
func sort2b() {
|
||||
c.Printf(c.Str("fn => fn\n"))
|
||||
a := [...]int{100, 8, 23, 2, 7}
|
||||
var fn = func(a, b c.Pointer) c.Int {
|
||||
return c.Int(*(*int)(a) - *(*int)(b))
|
||||
}
|
||||
qsort2(c.Pointer(&a[0]), 5, unsafe.Sizeof(0), fn)
|
||||
for _, v := range a {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
}
|
||||
|
||||
func sort3a() {
|
||||
c.Printf(c.Str("qsort.Comp => qsort.Comp\n"))
|
||||
a := [...]int{100, 8, 23, 2, 7}
|
||||
var fn q.Comp = func(a, b c.Pointer) c.Int {
|
||||
return c.Int(*(*int)(a) - *(*int)(b))
|
||||
}
|
||||
q.Qsort(c.Pointer(&a[0]), 5, unsafe.Sizeof(0), fn)
|
||||
for _, v := range a {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
}
|
||||
|
||||
func sort3b() {
|
||||
c.Printf(c.Str("fn => qsort.Comp\n"))
|
||||
a := [...]int{100, 8, 23, 2, 7}
|
||||
var fn = func(a, b c.Pointer) c.Int {
|
||||
return c.Int(*(*int)(a) - *(*int)(b))
|
||||
}
|
||||
q.Qsort(c.Pointer(&a[0]), 5, unsafe.Sizeof(0), fn)
|
||||
for _, v := range a {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
}
|
||||
|
||||
func sort4a() {
|
||||
c.Printf(c.Str("qsort.Comp => fn\n"))
|
||||
a := [...]int{100, 8, 23, 2, 7}
|
||||
var fn q.Comp = func(a, b c.Pointer) c.Int {
|
||||
return c.Int(*(*int)(a) - *(*int)(b))
|
||||
}
|
||||
qsort2(c.Pointer(&a[0]), 5, unsafe.Sizeof(0), fn)
|
||||
for _, v := range a {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
}
|
||||
|
||||
func sort4b() {
|
||||
c.Printf(c.Str("Comp => qsort.fn\n"))
|
||||
a := [...]int{100, 8, 23, 2, 7}
|
||||
var fn Comp = func(a, b c.Pointer) c.Int {
|
||||
return c.Int(*(*int)(a) - *(*int)(b))
|
||||
}
|
||||
q.Qsort2(c.Pointer(&a[0]), 5, unsafe.Sizeof(0), fn)
|
||||
for _, v := range a {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
}
|
||||
|
||||
func sort5a() {
|
||||
c.Printf(c.Str("qsort.Comp => Comp()\n"))
|
||||
a := [...]int{100, 8, 23, 2, 7}
|
||||
var fn q.Comp = func(a, b c.Pointer) c.Int {
|
||||
return c.Int(*(*int)(a) - *(*int)(b))
|
||||
}
|
||||
qsort(c.Pointer(&a[0]), 5, unsafe.Sizeof(0), Comp(fn))
|
||||
for _, v := range a {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
}
|
||||
|
||||
func sort5b() {
|
||||
c.Printf(c.Str("Comp => qsort.Comp()\n"))
|
||||
a := [...]int{100, 8, 23, 2, 7}
|
||||
var fn Comp = func(a, b c.Pointer) c.Int {
|
||||
return c.Int(*(*int)(a) - *(*int)(b))
|
||||
}
|
||||
q.Qsort(c.Pointer(&a[0]), 5, unsafe.Sizeof(0), q.Comp(fn))
|
||||
for _, v := range a {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
}
|
||||
548
compiler/cl/_testrt/qsortfn/out.ll
Normal file
548
compiler/cl/_testrt/qsortfn/out.ll
Normal file
@@ -0,0 +1,548 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [14 x i8] c"Comp => Comp\0A\00", align 1
|
||||
@1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@2 = private unnamed_addr constant [12 x i8] c"fn => Comp\0A\00", align 1
|
||||
@3 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@4 = private unnamed_addr constant [12 x i8] c"Comp => fn\0A\00", align 1
|
||||
@5 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@6 = private unnamed_addr constant [10 x i8] c"fn => fn\0A\00", align 1
|
||||
@7 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@8 = private unnamed_addr constant [26 x i8] c"qsort.Comp => qsort.Comp\0A\00", align 1
|
||||
@9 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@10 = private unnamed_addr constant [18 x i8] c"fn => qsort.Comp\0A\00", align 1
|
||||
@11 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@12 = private unnamed_addr constant [18 x i8] c"qsort.Comp => fn\0A\00", align 1
|
||||
@13 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@14 = private unnamed_addr constant [18 x i8] c"Comp => qsort.fn\0A\00", align 1
|
||||
@15 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@16 = private unnamed_addr constant [22 x i8] c"qsort.Comp => Comp()\0A\00", align 1
|
||||
@17 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@18 = private unnamed_addr constant [22 x i8] c"Comp => qsort.Comp()\0A\00", align 1
|
||||
@19 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
call void @main.sort1a()
|
||||
call void @main.sort1b()
|
||||
call void @main.sort2a()
|
||||
call void @main.sort2b()
|
||||
call void @main.sort3a()
|
||||
call void @main.sort3b()
|
||||
call void @main.sort4a()
|
||||
call void @main.sort4b()
|
||||
call void @main.sort5a()
|
||||
call void @main.sort5b()
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @main.sort1a() {
|
||||
_llgo_0:
|
||||
%0 = call i32 (ptr, ...) @printf(ptr @0)
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 40)
|
||||
%2 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
%3 = getelementptr inbounds i64, ptr %1, i64 1
|
||||
%4 = getelementptr inbounds i64, ptr %1, i64 2
|
||||
%5 = getelementptr inbounds i64, ptr %1, i64 3
|
||||
%6 = getelementptr inbounds i64, ptr %1, i64 4
|
||||
store i64 100, ptr %2, align 4
|
||||
store i64 8, ptr %3, align 4
|
||||
store i64 23, ptr %4, align 4
|
||||
store i64 2, ptr %5, align 4
|
||||
store i64 7, ptr %6, align 4
|
||||
%7 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
call void @qsort(ptr %7, i64 5, i64 8, ptr @"main.sort1a$1")
|
||||
%8 = load [5 x i64], ptr %1, align 4
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%9 = phi i64 [ -1, %_llgo_0 ], [ %10, %_llgo_2 ]
|
||||
%10 = add i64 %9, 1
|
||||
%11 = icmp slt i64 %10, 5
|
||||
br i1 %11, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%12 = icmp slt i64 %10, 0
|
||||
%13 = icmp sge i64 %10, 5
|
||||
%14 = or i1 %13, %12
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %14)
|
||||
%15 = getelementptr inbounds i64, ptr %1, i64 %10
|
||||
%16 = load i64, ptr %15, align 4
|
||||
%17 = call i32 (ptr, ...) @printf(ptr @1, i64 %16)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @"main.sort1a$1"(ptr %0, ptr %1) {
|
||||
_llgo_0:
|
||||
%2 = load i64, ptr %0, align 4
|
||||
%3 = load i64, ptr %1, align 4
|
||||
%4 = sub i64 %2, %3
|
||||
%5 = trunc i64 %4 to i32
|
||||
ret i32 %5
|
||||
}
|
||||
|
||||
define void @main.sort1b() {
|
||||
_llgo_0:
|
||||
%0 = call i32 (ptr, ...) @printf(ptr @2)
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 40)
|
||||
%2 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
%3 = getelementptr inbounds i64, ptr %1, i64 1
|
||||
%4 = getelementptr inbounds i64, ptr %1, i64 2
|
||||
%5 = getelementptr inbounds i64, ptr %1, i64 3
|
||||
%6 = getelementptr inbounds i64, ptr %1, i64 4
|
||||
store i64 100, ptr %2, align 4
|
||||
store i64 8, ptr %3, align 4
|
||||
store i64 23, ptr %4, align 4
|
||||
store i64 2, ptr %5, align 4
|
||||
store i64 7, ptr %6, align 4
|
||||
%7 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
call void @qsort(ptr %7, i64 5, i64 8, ptr @"main.sort1b$1")
|
||||
%8 = load [5 x i64], ptr %1, align 4
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%9 = phi i64 [ -1, %_llgo_0 ], [ %10, %_llgo_2 ]
|
||||
%10 = add i64 %9, 1
|
||||
%11 = icmp slt i64 %10, 5
|
||||
br i1 %11, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%12 = icmp slt i64 %10, 0
|
||||
%13 = icmp sge i64 %10, 5
|
||||
%14 = or i1 %13, %12
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %14)
|
||||
%15 = getelementptr inbounds i64, ptr %1, i64 %10
|
||||
%16 = load i64, ptr %15, align 4
|
||||
%17 = call i32 (ptr, ...) @printf(ptr @3, i64 %16)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @"main.sort1b$1"(ptr %0, ptr %1) {
|
||||
_llgo_0:
|
||||
%2 = load i64, ptr %0, align 4
|
||||
%3 = load i64, ptr %1, align 4
|
||||
%4 = sub i64 %2, %3
|
||||
%5 = trunc i64 %4 to i32
|
||||
ret i32 %5
|
||||
}
|
||||
|
||||
define void @main.sort2a() {
|
||||
_llgo_0:
|
||||
%0 = call i32 (ptr, ...) @printf(ptr @4)
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 40)
|
||||
%2 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
%3 = getelementptr inbounds i64, ptr %1, i64 1
|
||||
%4 = getelementptr inbounds i64, ptr %1, i64 2
|
||||
%5 = getelementptr inbounds i64, ptr %1, i64 3
|
||||
%6 = getelementptr inbounds i64, ptr %1, i64 4
|
||||
store i64 100, ptr %2, align 4
|
||||
store i64 8, ptr %3, align 4
|
||||
store i64 23, ptr %4, align 4
|
||||
store i64 2, ptr %5, align 4
|
||||
store i64 7, ptr %6, align 4
|
||||
%7 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
call void @qsort(ptr %7, i64 5, i64 8, ptr @"main.sort2a$1")
|
||||
%8 = load [5 x i64], ptr %1, align 4
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%9 = phi i64 [ -1, %_llgo_0 ], [ %10, %_llgo_2 ]
|
||||
%10 = add i64 %9, 1
|
||||
%11 = icmp slt i64 %10, 5
|
||||
br i1 %11, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%12 = icmp slt i64 %10, 0
|
||||
%13 = icmp sge i64 %10, 5
|
||||
%14 = or i1 %13, %12
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %14)
|
||||
%15 = getelementptr inbounds i64, ptr %1, i64 %10
|
||||
%16 = load i64, ptr %15, align 4
|
||||
%17 = call i32 (ptr, ...) @printf(ptr @5, i64 %16)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @"main.sort2a$1"(ptr %0, ptr %1) {
|
||||
_llgo_0:
|
||||
%2 = load i64, ptr %0, align 4
|
||||
%3 = load i64, ptr %1, align 4
|
||||
%4 = sub i64 %2, %3
|
||||
%5 = trunc i64 %4 to i32
|
||||
ret i32 %5
|
||||
}
|
||||
|
||||
define void @main.sort2b() {
|
||||
_llgo_0:
|
||||
%0 = call i32 (ptr, ...) @printf(ptr @6)
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 40)
|
||||
%2 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
%3 = getelementptr inbounds i64, ptr %1, i64 1
|
||||
%4 = getelementptr inbounds i64, ptr %1, i64 2
|
||||
%5 = getelementptr inbounds i64, ptr %1, i64 3
|
||||
%6 = getelementptr inbounds i64, ptr %1, i64 4
|
||||
store i64 100, ptr %2, align 4
|
||||
store i64 8, ptr %3, align 4
|
||||
store i64 23, ptr %4, align 4
|
||||
store i64 2, ptr %5, align 4
|
||||
store i64 7, ptr %6, align 4
|
||||
%7 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
call void @qsort(ptr %7, i64 5, i64 8, ptr @"main.sort2b$1")
|
||||
%8 = load [5 x i64], ptr %1, align 4
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%9 = phi i64 [ -1, %_llgo_0 ], [ %10, %_llgo_2 ]
|
||||
%10 = add i64 %9, 1
|
||||
%11 = icmp slt i64 %10, 5
|
||||
br i1 %11, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%12 = icmp slt i64 %10, 0
|
||||
%13 = icmp sge i64 %10, 5
|
||||
%14 = or i1 %13, %12
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %14)
|
||||
%15 = getelementptr inbounds i64, ptr %1, i64 %10
|
||||
%16 = load i64, ptr %15, align 4
|
||||
%17 = call i32 (ptr, ...) @printf(ptr @7, i64 %16)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @"main.sort2b$1"(ptr %0, ptr %1) {
|
||||
_llgo_0:
|
||||
%2 = load i64, ptr %0, align 4
|
||||
%3 = load i64, ptr %1, align 4
|
||||
%4 = sub i64 %2, %3
|
||||
%5 = trunc i64 %4 to i32
|
||||
ret i32 %5
|
||||
}
|
||||
|
||||
define void @main.sort3a() {
|
||||
_llgo_0:
|
||||
%0 = call i32 (ptr, ...) @printf(ptr @8)
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 40)
|
||||
%2 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
%3 = getelementptr inbounds i64, ptr %1, i64 1
|
||||
%4 = getelementptr inbounds i64, ptr %1, i64 2
|
||||
%5 = getelementptr inbounds i64, ptr %1, i64 3
|
||||
%6 = getelementptr inbounds i64, ptr %1, i64 4
|
||||
store i64 100, ptr %2, align 4
|
||||
store i64 8, ptr %3, align 4
|
||||
store i64 23, ptr %4, align 4
|
||||
store i64 2, ptr %5, align 4
|
||||
store i64 7, ptr %6, align 4
|
||||
%7 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
call void @qsort(ptr %7, i64 5, i64 8, ptr @"main.sort3a$1")
|
||||
%8 = load [5 x i64], ptr %1, align 4
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%9 = phi i64 [ -1, %_llgo_0 ], [ %10, %_llgo_2 ]
|
||||
%10 = add i64 %9, 1
|
||||
%11 = icmp slt i64 %10, 5
|
||||
br i1 %11, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%12 = icmp slt i64 %10, 0
|
||||
%13 = icmp sge i64 %10, 5
|
||||
%14 = or i1 %13, %12
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %14)
|
||||
%15 = getelementptr inbounds i64, ptr %1, i64 %10
|
||||
%16 = load i64, ptr %15, align 4
|
||||
%17 = call i32 (ptr, ...) @printf(ptr @9, i64 %16)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @"main.sort3a$1"(ptr %0, ptr %1) {
|
||||
_llgo_0:
|
||||
%2 = load i64, ptr %0, align 4
|
||||
%3 = load i64, ptr %1, align 4
|
||||
%4 = sub i64 %2, %3
|
||||
%5 = trunc i64 %4 to i32
|
||||
ret i32 %5
|
||||
}
|
||||
|
||||
define void @main.sort3b() {
|
||||
_llgo_0:
|
||||
%0 = call i32 (ptr, ...) @printf(ptr @10)
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 40)
|
||||
%2 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
%3 = getelementptr inbounds i64, ptr %1, i64 1
|
||||
%4 = getelementptr inbounds i64, ptr %1, i64 2
|
||||
%5 = getelementptr inbounds i64, ptr %1, i64 3
|
||||
%6 = getelementptr inbounds i64, ptr %1, i64 4
|
||||
store i64 100, ptr %2, align 4
|
||||
store i64 8, ptr %3, align 4
|
||||
store i64 23, ptr %4, align 4
|
||||
store i64 2, ptr %5, align 4
|
||||
store i64 7, ptr %6, align 4
|
||||
%7 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
call void @qsort(ptr %7, i64 5, i64 8, ptr @"main.sort3b$1")
|
||||
%8 = load [5 x i64], ptr %1, align 4
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%9 = phi i64 [ -1, %_llgo_0 ], [ %10, %_llgo_2 ]
|
||||
%10 = add i64 %9, 1
|
||||
%11 = icmp slt i64 %10, 5
|
||||
br i1 %11, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%12 = icmp slt i64 %10, 0
|
||||
%13 = icmp sge i64 %10, 5
|
||||
%14 = or i1 %13, %12
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %14)
|
||||
%15 = getelementptr inbounds i64, ptr %1, i64 %10
|
||||
%16 = load i64, ptr %15, align 4
|
||||
%17 = call i32 (ptr, ...) @printf(ptr @11, i64 %16)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @"main.sort3b$1"(ptr %0, ptr %1) {
|
||||
_llgo_0:
|
||||
%2 = load i64, ptr %0, align 4
|
||||
%3 = load i64, ptr %1, align 4
|
||||
%4 = sub i64 %2, %3
|
||||
%5 = trunc i64 %4 to i32
|
||||
ret i32 %5
|
||||
}
|
||||
|
||||
define void @main.sort4a() {
|
||||
_llgo_0:
|
||||
%0 = call i32 (ptr, ...) @printf(ptr @12)
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 40)
|
||||
%2 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
%3 = getelementptr inbounds i64, ptr %1, i64 1
|
||||
%4 = getelementptr inbounds i64, ptr %1, i64 2
|
||||
%5 = getelementptr inbounds i64, ptr %1, i64 3
|
||||
%6 = getelementptr inbounds i64, ptr %1, i64 4
|
||||
store i64 100, ptr %2, align 4
|
||||
store i64 8, ptr %3, align 4
|
||||
store i64 23, ptr %4, align 4
|
||||
store i64 2, ptr %5, align 4
|
||||
store i64 7, ptr %6, align 4
|
||||
%7 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
call void @qsort(ptr %7, i64 5, i64 8, ptr @"main.sort4a$1")
|
||||
%8 = load [5 x i64], ptr %1, align 4
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%9 = phi i64 [ -1, %_llgo_0 ], [ %10, %_llgo_2 ]
|
||||
%10 = add i64 %9, 1
|
||||
%11 = icmp slt i64 %10, 5
|
||||
br i1 %11, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%12 = icmp slt i64 %10, 0
|
||||
%13 = icmp sge i64 %10, 5
|
||||
%14 = or i1 %13, %12
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %14)
|
||||
%15 = getelementptr inbounds i64, ptr %1, i64 %10
|
||||
%16 = load i64, ptr %15, align 4
|
||||
%17 = call i32 (ptr, ...) @printf(ptr @13, i64 %16)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @"main.sort4a$1"(ptr %0, ptr %1) {
|
||||
_llgo_0:
|
||||
%2 = load i64, ptr %0, align 4
|
||||
%3 = load i64, ptr %1, align 4
|
||||
%4 = sub i64 %2, %3
|
||||
%5 = trunc i64 %4 to i32
|
||||
ret i32 %5
|
||||
}
|
||||
|
||||
define void @main.sort4b() {
|
||||
_llgo_0:
|
||||
%0 = call i32 (ptr, ...) @printf(ptr @14)
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 40)
|
||||
%2 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
%3 = getelementptr inbounds i64, ptr %1, i64 1
|
||||
%4 = getelementptr inbounds i64, ptr %1, i64 2
|
||||
%5 = getelementptr inbounds i64, ptr %1, i64 3
|
||||
%6 = getelementptr inbounds i64, ptr %1, i64 4
|
||||
store i64 100, ptr %2, align 4
|
||||
store i64 8, ptr %3, align 4
|
||||
store i64 23, ptr %4, align 4
|
||||
store i64 2, ptr %5, align 4
|
||||
store i64 7, ptr %6, align 4
|
||||
%7 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
call void @qsort(ptr %7, i64 5, i64 8, ptr @"main.sort4b$1")
|
||||
%8 = load [5 x i64], ptr %1, align 4
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%9 = phi i64 [ -1, %_llgo_0 ], [ %10, %_llgo_2 ]
|
||||
%10 = add i64 %9, 1
|
||||
%11 = icmp slt i64 %10, 5
|
||||
br i1 %11, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%12 = icmp slt i64 %10, 0
|
||||
%13 = icmp sge i64 %10, 5
|
||||
%14 = or i1 %13, %12
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %14)
|
||||
%15 = getelementptr inbounds i64, ptr %1, i64 %10
|
||||
%16 = load i64, ptr %15, align 4
|
||||
%17 = call i32 (ptr, ...) @printf(ptr @15, i64 %16)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @"main.sort4b$1"(ptr %0, ptr %1) {
|
||||
_llgo_0:
|
||||
%2 = load i64, ptr %0, align 4
|
||||
%3 = load i64, ptr %1, align 4
|
||||
%4 = sub i64 %2, %3
|
||||
%5 = trunc i64 %4 to i32
|
||||
ret i32 %5
|
||||
}
|
||||
|
||||
define void @main.sort5a() {
|
||||
_llgo_0:
|
||||
%0 = call i32 (ptr, ...) @printf(ptr @16)
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 40)
|
||||
%2 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
%3 = getelementptr inbounds i64, ptr %1, i64 1
|
||||
%4 = getelementptr inbounds i64, ptr %1, i64 2
|
||||
%5 = getelementptr inbounds i64, ptr %1, i64 3
|
||||
%6 = getelementptr inbounds i64, ptr %1, i64 4
|
||||
store i64 100, ptr %2, align 4
|
||||
store i64 8, ptr %3, align 4
|
||||
store i64 23, ptr %4, align 4
|
||||
store i64 2, ptr %5, align 4
|
||||
store i64 7, ptr %6, align 4
|
||||
%7 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
call void @qsort(ptr %7, i64 5, i64 8, ptr @"main.sort5a$1")
|
||||
%8 = load [5 x i64], ptr %1, align 4
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%9 = phi i64 [ -1, %_llgo_0 ], [ %10, %_llgo_2 ]
|
||||
%10 = add i64 %9, 1
|
||||
%11 = icmp slt i64 %10, 5
|
||||
br i1 %11, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%12 = icmp slt i64 %10, 0
|
||||
%13 = icmp sge i64 %10, 5
|
||||
%14 = or i1 %13, %12
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %14)
|
||||
%15 = getelementptr inbounds i64, ptr %1, i64 %10
|
||||
%16 = load i64, ptr %15, align 4
|
||||
%17 = call i32 (ptr, ...) @printf(ptr @17, i64 %16)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @"main.sort5a$1"(ptr %0, ptr %1) {
|
||||
_llgo_0:
|
||||
%2 = load i64, ptr %0, align 4
|
||||
%3 = load i64, ptr %1, align 4
|
||||
%4 = sub i64 %2, %3
|
||||
%5 = trunc i64 %4 to i32
|
||||
ret i32 %5
|
||||
}
|
||||
|
||||
define void @main.sort5b() {
|
||||
_llgo_0:
|
||||
%0 = call i32 (ptr, ...) @printf(ptr @18)
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 40)
|
||||
%2 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
%3 = getelementptr inbounds i64, ptr %1, i64 1
|
||||
%4 = getelementptr inbounds i64, ptr %1, i64 2
|
||||
%5 = getelementptr inbounds i64, ptr %1, i64 3
|
||||
%6 = getelementptr inbounds i64, ptr %1, i64 4
|
||||
store i64 100, ptr %2, align 4
|
||||
store i64 8, ptr %3, align 4
|
||||
store i64 23, ptr %4, align 4
|
||||
store i64 2, ptr %5, align 4
|
||||
store i64 7, ptr %6, align 4
|
||||
%7 = getelementptr inbounds i64, ptr %1, i64 0
|
||||
call void @qsort(ptr %7, i64 5, i64 8, ptr @"main.sort5b$1")
|
||||
%8 = load [5 x i64], ptr %1, align 4
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%9 = phi i64 [ -1, %_llgo_0 ], [ %10, %_llgo_2 ]
|
||||
%10 = add i64 %9, 1
|
||||
%11 = icmp slt i64 %10, 5
|
||||
br i1 %11, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%12 = icmp slt i64 %10, 0
|
||||
%13 = icmp sge i64 %10, 5
|
||||
%14 = or i1 %13, %12
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %14)
|
||||
%15 = getelementptr inbounds i64, ptr %1, i64 %10
|
||||
%16 = load i64, ptr %15, align 4
|
||||
%17 = call i32 (ptr, ...) @printf(ptr @19, i64 %16)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @"main.sort5b$1"(ptr %0, ptr %1) {
|
||||
_llgo_0:
|
||||
%2 = load i64, ptr %0, align 4
|
||||
%3 = load i64, ptr %1, align 4
|
||||
%4 = sub i64 %2, %3
|
||||
%5 = trunc i64 %4 to i32
|
||||
ret i32 %5
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare void @qsort(ptr, i64, i64, ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1)
|
||||
29
compiler/cl/_testrt/result/in.go
Normal file
29
compiler/cl/_testrt/result/in.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fn := func() func(int, int) int {
|
||||
return func(x, y int) int {
|
||||
return x + y
|
||||
}
|
||||
}()
|
||||
c.Printf(c.Str("%d\n"), fn(100, 200))
|
||||
c.Printf(c.Str("%d\n"), add()(100, 200))
|
||||
fn, n := add2()
|
||||
c.Printf(c.Str("%d %d\n"), add()(100, 200), n)
|
||||
}
|
||||
|
||||
func add() func(int, int) int {
|
||||
return func(x, y int) int {
|
||||
return x + y
|
||||
}
|
||||
}
|
||||
|
||||
func add2() (func(int, int) int, int) {
|
||||
return func(x, y int) int {
|
||||
return x + y
|
||||
}, 1
|
||||
}
|
||||
104
compiler/cl/_testrt/result/out.ll
Normal file
104
compiler/cl/_testrt/result/out.ll
Normal file
@@ -0,0 +1,104 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@2 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
|
||||
|
||||
define { ptr, ptr } @main.add() {
|
||||
_llgo_0:
|
||||
ret { ptr, ptr } { ptr @"__llgo_stub.main.add$1", ptr null }
|
||||
}
|
||||
|
||||
define i64 @"main.add$1"(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = add i64 %0, %1
|
||||
ret i64 %2
|
||||
}
|
||||
|
||||
define { { ptr, ptr }, i64 } @main.add2() {
|
||||
_llgo_0:
|
||||
ret { { ptr, ptr }, i64 } { { ptr, ptr } { ptr @"__llgo_stub.main.add2$1", ptr null }, i64 1 }
|
||||
}
|
||||
|
||||
define i64 @"main.add2$1"(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = add i64 %0, %1
|
||||
ret i64 %2
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call { ptr, ptr } @"main.main$1"()
|
||||
%3 = extractvalue { ptr, ptr } %2, 1
|
||||
%4 = extractvalue { ptr, ptr } %2, 0
|
||||
%5 = call i64 %4(ptr %3, i64 100, i64 200)
|
||||
%6 = call i32 (ptr, ...) @printf(ptr @0, i64 %5)
|
||||
%7 = call { ptr, ptr } @main.add()
|
||||
%8 = extractvalue { ptr, ptr } %7, 1
|
||||
%9 = extractvalue { ptr, ptr } %7, 0
|
||||
%10 = call i64 %9(ptr %8, i64 100, i64 200)
|
||||
%11 = call i32 (ptr, ...) @printf(ptr @1, i64 %10)
|
||||
%12 = call { { ptr, ptr }, i64 } @main.add2()
|
||||
%13 = extractvalue { { ptr, ptr }, i64 } %12, 0
|
||||
%14 = extractvalue { { ptr, ptr }, i64 } %12, 1
|
||||
%15 = call { ptr, ptr } @main.add()
|
||||
%16 = extractvalue { ptr, ptr } %15, 1
|
||||
%17 = extractvalue { ptr, ptr } %15, 0
|
||||
%18 = call i64 %17(ptr %16, i64 100, i64 200)
|
||||
%19 = call i32 (ptr, ...) @printf(ptr @2, i64 %18, i64 %14)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define { ptr, ptr } @"main.main$1"() {
|
||||
_llgo_0:
|
||||
ret { ptr, ptr } { ptr @"__llgo_stub.main.main$1$1", ptr null }
|
||||
}
|
||||
|
||||
define i64 @"main.main$1$1"(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = add i64 %0, %1
|
||||
ret i64 %2
|
||||
}
|
||||
|
||||
define linkonce i64 @"__llgo_stub.main.add$1"(ptr %0, i64 %1, i64 %2) {
|
||||
_llgo_0:
|
||||
%3 = tail call i64 @"main.add$1"(i64 %1, i64 %2)
|
||||
ret i64 %3
|
||||
}
|
||||
|
||||
define linkonce i64 @"__llgo_stub.main.add2$1"(ptr %0, i64 %1, i64 %2) {
|
||||
_llgo_0:
|
||||
%3 = tail call i64 @"main.add2$1"(i64 %1, i64 %2)
|
||||
ret i64 %3
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
|
||||
define linkonce i64 @"__llgo_stub.main.main$1$1"(ptr %0, i64 %1, i64 %2) {
|
||||
_llgo_0:
|
||||
%3 = tail call i64 @"main.main$1$1"(i64 %1, i64 %2)
|
||||
ret i64 %3
|
||||
}
|
||||
8
compiler/cl/_testrt/slice2array/in.go
Normal file
8
compiler/cl/_testrt/slice2array/in.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
array := [4]byte{1, 2, 3, 4}
|
||||
ptr := (*[4]byte)(array[:])
|
||||
println(array == *ptr)
|
||||
println(*(*[2]byte)(array[:]) == [2]byte{1, 2})
|
||||
}
|
||||
120
compiler/cl/_testrt/slice2array/out.ll
Normal file
120
compiler/cl/_testrt/slice2array/out.ll
Normal file
@@ -0,0 +1,120 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 4)
|
||||
%3 = getelementptr inbounds i8, ptr %2, i64 0
|
||||
%4 = getelementptr inbounds i8, ptr %2, i64 1
|
||||
%5 = getelementptr inbounds i8, ptr %2, i64 2
|
||||
%6 = getelementptr inbounds i8, ptr %2, i64 3
|
||||
store i8 1, ptr %3, align 1
|
||||
store i8 2, ptr %4, align 1
|
||||
store i8 3, ptr %5, align 1
|
||||
store i8 4, ptr %6, align 1
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %2, 0
|
||||
%8 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, i64 4, 1
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %8, i64 4, 2
|
||||
%10 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 1
|
||||
%11 = icmp slt i64 %10, 4
|
||||
br i1 %11, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%12 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PanicSliceConvert"(i64 %12, i64 4)
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%13 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, 0
|
||||
%14 = load [4 x i8], ptr %2, align 1
|
||||
%15 = load [4 x i8], ptr %13, align 1
|
||||
%16 = extractvalue [4 x i8] %14, 0
|
||||
%17 = extractvalue [4 x i8] %15, 0
|
||||
%18 = icmp eq i8 %16, %17
|
||||
%19 = and i1 true, %18
|
||||
%20 = extractvalue [4 x i8] %14, 1
|
||||
%21 = extractvalue [4 x i8] %15, 1
|
||||
%22 = icmp eq i8 %20, %21
|
||||
%23 = and i1 %19, %22
|
||||
%24 = extractvalue [4 x i8] %14, 2
|
||||
%25 = extractvalue [4 x i8] %15, 2
|
||||
%26 = icmp eq i8 %24, %25
|
||||
%27 = and i1 %23, %26
|
||||
%28 = extractvalue [4 x i8] %14, 3
|
||||
%29 = extractvalue [4 x i8] %15, 3
|
||||
%30 = icmp eq i8 %28, %29
|
||||
%31 = and i1 %27, %30
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %31)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%32 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %2, 0
|
||||
%33 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %32, i64 4, 1
|
||||
%34 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %33, i64 4, 2
|
||||
%35 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %34, 1
|
||||
%36 = icmp slt i64 %35, 2
|
||||
br i1 %36, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_3: ; preds = %_llgo_2
|
||||
%37 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %34, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PanicSliceConvert"(i64 %37, i64 2)
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%38 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %34, 0
|
||||
%39 = load [2 x i8], ptr %38, align 1
|
||||
%40 = alloca [2 x i8], align 1
|
||||
call void @llvm.memset(ptr %40, i8 0, i64 2, i1 false)
|
||||
%41 = getelementptr inbounds i8, ptr %40, i64 0
|
||||
%42 = getelementptr inbounds i8, ptr %40, i64 1
|
||||
store i8 1, ptr %41, align 1
|
||||
store i8 2, ptr %42, align 1
|
||||
%43 = load [2 x i8], ptr %40, align 1
|
||||
%44 = extractvalue [2 x i8] %39, 0
|
||||
%45 = extractvalue [2 x i8] %43, 0
|
||||
%46 = icmp eq i8 %44, %45
|
||||
%47 = and i1 true, %46
|
||||
%48 = extractvalue [2 x i8] %39, 1
|
||||
%49 = extractvalue [2 x i8] %43, 1
|
||||
%50 = icmp eq i8 %48, %49
|
||||
%51 = and i1 %47, %50
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %51)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
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.PanicSliceConvert"(i64, i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
|
||||
declare void @llvm.memset(ptr nocapture writeonly, i8, i64, i1 immarg) #0
|
||||
|
||||
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
|
||||
16
compiler/cl/_testrt/slicelen/in.go
Normal file
16
compiler/cl/_testrt/slicelen/in.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var s *int
|
||||
var lens uint32
|
||||
sl := unsafe.Slice(s, lens)
|
||||
slen := len(sl)
|
||||
println(slen)
|
||||
if slen > 0 {
|
||||
println("len > 0")
|
||||
}
|
||||
}
|
||||
49
compiler/cl/_testrt/slicelen/out.ll
Normal file
49
compiler/cl/_testrt/slicelen/out.ll
Normal file
@@ -0,0 +1,49 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [7 x i8] c"len > 0", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 0)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
br i1 false, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 7 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
17
compiler/cl/_testrt/strlen/in.go
Normal file
17
compiler/cl/_testrt/strlen/in.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import "C"
|
||||
import _ "unsafe"
|
||||
|
||||
//go:linkname printf C.printf
|
||||
func printf(format *int8, __llgo_va_list ...any)
|
||||
|
||||
//go:linkname strlen C.strlen
|
||||
func strlen(str *int8) C.int
|
||||
|
||||
var format = [...]int8{'H', 'e', 'l', 'l', 'o', ' ', '%', 'd', '\n', 0}
|
||||
|
||||
func main() {
|
||||
sfmt := &format[0]
|
||||
printf(sfmt, strlen(sfmt))
|
||||
}
|
||||
62
compiler/cl/_testrt/strlen/out.ll
Normal file
62
compiler/cl/_testrt/strlen/out.ll
Normal file
@@ -0,0 +1,62 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
|
||||
@"github.com/goplus/llgo/internal/runtime.cgoAlwaysFalse" = external global i1, align 1
|
||||
@main.format = global [10 x i8] zeroinitializer, align 1
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define ptr @main._Cgo_ptr(ptr %0) {
|
||||
_llgo_0:
|
||||
ret ptr %0
|
||||
}
|
||||
|
||||
declare void @runtime.cgoUse(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
declare void @main._cgoCheckResult(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @syscall.init()
|
||||
store i8 72, ptr @main.format, align 1
|
||||
store i8 101, ptr getelementptr inbounds (i8, ptr @main.format, i64 1), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @main.format, i64 2), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @main.format, i64 3), align 1
|
||||
store i8 111, ptr getelementptr inbounds (i8, ptr @main.format, i64 4), align 1
|
||||
store i8 32, ptr getelementptr inbounds (i8, ptr @main.format, i64 5), align 1
|
||||
store i8 37, ptr getelementptr inbounds (i8, ptr @main.format, i64 6), align 1
|
||||
store i8 100, ptr getelementptr inbounds (i8, ptr @main.format, i64 7), align 1
|
||||
store i8 10, ptr getelementptr inbounds (i8, ptr @main.format, i64 8), align 1
|
||||
store i8 0, ptr getelementptr inbounds (i8, ptr @main.format, i64 9), align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call i32 @strlen(ptr @main.format)
|
||||
call void (ptr, ...) @printf(ptr @main.format, i32 %2)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @syscall.init()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare i32 @strlen(ptr)
|
||||
|
||||
declare void @printf(ptr, ...)
|
||||
25
compiler/cl/_testrt/struct/in.go
Normal file
25
compiler/cl/_testrt/struct/in.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import "C"
|
||||
import _ "unsafe"
|
||||
|
||||
//go:linkname printf C.printf
|
||||
func printf(format *int8, __llgo_va_list ...any)
|
||||
|
||||
type Foo struct {
|
||||
A C.int
|
||||
ok bool
|
||||
}
|
||||
|
||||
var format = [...]int8{'H', 'e', 'l', 'l', 'o', ' ', '%', 'd', '\n', 0}
|
||||
|
||||
func (p Foo) Print() {
|
||||
if p.ok {
|
||||
printf(&format[0], p.A)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
foo := Foo{100, true}
|
||||
foo.Print()
|
||||
}
|
||||
98
compiler/cl/_testrt/struct/out.ll
Normal file
98
compiler/cl/_testrt/struct/out.ll
Normal file
@@ -0,0 +1,98 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%main.Foo = type { i32, i1 }
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
|
||||
@"github.com/goplus/llgo/internal/runtime.cgoAlwaysFalse" = external global i1, align 1
|
||||
@main.format = global [10 x i8] zeroinitializer, align 1
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.Foo.Print(%main.Foo %0) {
|
||||
_llgo_0:
|
||||
%1 = alloca %main.Foo, align 8
|
||||
call void @llvm.memset(ptr %1, i8 0, i64 8, i1 false)
|
||||
store %main.Foo %0, ptr %1, align 4
|
||||
%2 = getelementptr inbounds %main.Foo, ptr %1, i32 0, i32 1
|
||||
%3 = load i1, ptr %2, align 1
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%4 = getelementptr inbounds %main.Foo, ptr %1, i32 0, i32 0
|
||||
%5 = load i32, ptr %4, align 4
|
||||
call void (ptr, ...) @printf(ptr @main.format, i32 %5)
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.(*Foo).Print"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load %main.Foo, ptr %0, align 4
|
||||
call void @main.Foo.Print(%main.Foo %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
define ptr @main._Cgo_ptr(ptr %0) {
|
||||
_llgo_0:
|
||||
ret ptr %0
|
||||
}
|
||||
|
||||
declare void @runtime.cgoUse(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
declare void @main._cgoCheckResult(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @syscall.init()
|
||||
store i8 72, ptr @main.format, align 1
|
||||
store i8 101, ptr getelementptr inbounds (i8, ptr @main.format, i64 1), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @main.format, i64 2), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @main.format, i64 3), align 1
|
||||
store i8 111, ptr getelementptr inbounds (i8, ptr @main.format, i64 4), align 1
|
||||
store i8 32, ptr getelementptr inbounds (i8, ptr @main.format, i64 5), align 1
|
||||
store i8 37, ptr getelementptr inbounds (i8, ptr @main.format, i64 6), align 1
|
||||
store i8 100, ptr getelementptr inbounds (i8, ptr @main.format, i64 7), align 1
|
||||
store i8 10, ptr getelementptr inbounds (i8, ptr @main.format, i64 8), align 1
|
||||
store i8 0, ptr getelementptr inbounds (i8, ptr @main.format, i64 9), align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = alloca %main.Foo, align 8
|
||||
call void @llvm.memset(ptr %2, i8 0, i64 8, i1 false)
|
||||
%3 = getelementptr inbounds %main.Foo, ptr %2, i32 0, i32 0
|
||||
%4 = getelementptr inbounds %main.Foo, ptr %2, i32 0, i32 1
|
||||
store i32 100, ptr %3, align 4
|
||||
store i1 true, ptr %4, align 1
|
||||
%5 = load %main.Foo, ptr %2, align 4
|
||||
call void @main.Foo.Print(%main.Foo %5)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
|
||||
declare void @llvm.memset(ptr nocapture writeonly, i8, i64, i1 immarg) #0
|
||||
|
||||
declare void @printf(ptr, ...)
|
||||
|
||||
declare void @syscall.init()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
|
||||
19
compiler/cl/_testrt/structsize/in.go
Normal file
19
compiler/cl/_testrt/structsize/in.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
type Foo struct {
|
||||
A byte
|
||||
B uint8
|
||||
C uint16
|
||||
D byte
|
||||
E [8]int8
|
||||
}
|
||||
|
||||
func main() {
|
||||
c.Printf(c.Str("%d"), unsafe.Sizeof(Foo{}))
|
||||
}
|
||||
34
compiler/cl/_testrt/structsize/out.ll
Normal file
34
compiler/cl/_testrt/structsize/out.ll
Normal file
@@ -0,0 +1,34 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call i32 (ptr, ...) @printf(ptr @0, i64 14)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
16
compiler/cl/_testrt/sum/in.go
Normal file
16
compiler/cl/_testrt/sum/in.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
func sum(args ...int) (ret int) {
|
||||
for _, v := range args {
|
||||
ret += v
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func main() {
|
||||
c.Printf(c.Str("Hello %d\n"), sum(1, 2, 3, 4))
|
||||
}
|
||||
81
compiler/cl/_testrt/sum/out.ll
Normal file
81
compiler/cl/_testrt/sum/out.ll
Normal file
@@ -0,0 +1,81 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [10 x i8] c"Hello %d\0A\00", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32)
|
||||
%3 = getelementptr inbounds i64, ptr %2, i64 0
|
||||
store i64 1, ptr %3, align 4
|
||||
%4 = getelementptr inbounds i64, ptr %2, i64 1
|
||||
store i64 2, ptr %4, align 4
|
||||
%5 = getelementptr inbounds i64, ptr %2, i64 2
|
||||
store i64 3, ptr %5, align 4
|
||||
%6 = getelementptr inbounds i64, ptr %2, i64 3
|
||||
store i64 4, ptr %6, align 4
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %2, 0
|
||||
%8 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, i64 4, 1
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %8, i64 4, 2
|
||||
%10 = call i64 @main.sum(%"github.com/goplus/llgo/internal/runtime.Slice" %9)
|
||||
%11 = call i32 (ptr, ...) @printf(ptr @0, i64 %10)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define i64 @main.sum(%"github.com/goplus/llgo/internal/runtime.Slice" %0) {
|
||||
_llgo_0:
|
||||
%1 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 1
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%2 = phi i64 [ 0, %_llgo_0 ], [ %13, %_llgo_2 ]
|
||||
%3 = phi i64 [ -1, %_llgo_0 ], [ %4, %_llgo_2 ]
|
||||
%4 = add i64 %3, 1
|
||||
%5 = icmp slt i64 %4, %1
|
||||
br i1 %5, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%6 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 0
|
||||
%7 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 1
|
||||
%8 = icmp slt i64 %4, 0
|
||||
%9 = icmp sge i64 %4, %7
|
||||
%10 = or i1 %9, %8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %10)
|
||||
%11 = getelementptr inbounds i64, ptr %6, i64 %4
|
||||
%12 = load i64, ptr %11, align 4
|
||||
%13 = add i64 %2, %12
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret i64 %2
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1)
|
||||
38
compiler/cl/_testrt/tpabi/in.go
Normal file
38
compiler/cl/_testrt/tpabi/in.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import "github.com/goplus/llgo/c"
|
||||
|
||||
type T[M, N any] struct {
|
||||
m M
|
||||
n N
|
||||
}
|
||||
|
||||
func (t *T[M, N]) Demo() {
|
||||
println(t.m, t.n)
|
||||
}
|
||||
|
||||
func (t T[M, N]) Info() {
|
||||
println(t.m, t.n)
|
||||
}
|
||||
|
||||
type I interface {
|
||||
Demo()
|
||||
}
|
||||
|
||||
type K[N any] [4]N
|
||||
|
||||
//llgo:link (*K).Advance llgo.advance
|
||||
func (t *K[N]) Advance(n int) *K[N] {
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var a any = T[string, int]{"a", 1}
|
||||
println(a.(T[string, int]).m)
|
||||
var i I = &T[string, int]{"hello", 100}
|
||||
i.Demo()
|
||||
|
||||
k := &K[int]{1, 2, 3, 4}
|
||||
println(c.Advance(k, 1))
|
||||
println(k.Advance(1))
|
||||
}
|
||||
333
compiler/cl/_testrt/tpabi/out.ll
Normal file
333
compiler/cl/_testrt/tpabi/out.ll
Normal file
@@ -0,0 +1,333 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"main.T[string,int]" = type { %"github.com/goplus/llgo/internal/runtime.String", i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/abi.StructField" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1 }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
%"github.com/goplus/llgo/internal/abi.Method" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/abi.Imethod" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [1 x i8] c"a", align 1
|
||||
@"_llgo_main.T[string,int]" = linkonce global ptr null, align 8
|
||||
@1 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@2 = private unnamed_addr constant [1 x i8] c"T", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@_llgo_int = linkonce global ptr null, align 8
|
||||
@"main.struct$A2OTYqQyUOqOQ-i_F5iXeAKWtxeWGEuyeN7HCfULCDk" = linkonce global ptr null, align 8
|
||||
@3 = private unnamed_addr constant [1 x i8] c"m", align 1
|
||||
@4 = private unnamed_addr constant [1 x i8] c"n", align 1
|
||||
@5 = private unnamed_addr constant [4 x i8] c"Demo", align 1
|
||||
@"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac" = linkonce global ptr null, align 8
|
||||
@6 = private unnamed_addr constant [4 x i8] c"Info", align 1
|
||||
@7 = private unnamed_addr constant [21 x i8] c"type assertion failed", align 1
|
||||
@8 = private unnamed_addr constant [5 x i8] c"hello", align 1
|
||||
@"*_llgo_main.T[string,int]" = linkonce global ptr null, align 8
|
||||
@"_llgo_iface$BP0p_lUsEd-IbbtJVukGmgrdQkqzcoYzSiwgUvgFvUs" = linkonce global ptr null, align 8
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"main.init$after"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = alloca %"main.T[string,int]", align 8
|
||||
call void @llvm.memset(ptr %2, i8 0, i64 24, i1 false)
|
||||
%3 = getelementptr inbounds %"main.T[string,int]", ptr %2, i32 0, i32 0
|
||||
%4 = getelementptr inbounds %"main.T[string,int]", ptr %2, i32 0, i32 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 1 }, ptr %3, align 8
|
||||
store i64 1, ptr %4, align 4
|
||||
%5 = load %"main.T[string,int]", ptr %2, align 8
|
||||
%6 = load ptr, ptr @"_llgo_main.T[string,int]", align 8
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
|
||||
store %"main.T[string,int]" %5, ptr %7, align 8
|
||||
%8 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %6, 0
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %8, ptr %7, 1
|
||||
%10 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %9, 0
|
||||
%11 = load ptr, ptr @"_llgo_main.T[string,int]", align 8
|
||||
%12 = icmp eq ptr %10, %11
|
||||
br i1 %12, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%13 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %9, 1
|
||||
%14 = load %"main.T[string,int]", ptr %13, align 8
|
||||
%15 = extractvalue %"main.T[string,int]" %14, 0
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %15)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%16 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 24)
|
||||
%17 = getelementptr inbounds %"main.T[string,int]", ptr %16, i32 0, i32 0
|
||||
%18 = getelementptr inbounds %"main.T[string,int]", ptr %16, i32 0, i32 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @8, i64 5 }, ptr %17, align 8
|
||||
store i64 100, ptr %18, align 4
|
||||
%19 = load ptr, ptr @"*_llgo_main.T[string,int]", align 8
|
||||
%20 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%21 = load ptr, ptr @"_llgo_iface$BP0p_lUsEd-IbbtJVukGmgrdQkqzcoYzSiwgUvgFvUs", align 8
|
||||
%22 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %21, ptr %19)
|
||||
%23 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %22, 0
|
||||
%24 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %23, ptr %16, 1
|
||||
%25 = call ptr @"github.com/goplus/llgo/internal/runtime.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface" %24)
|
||||
%26 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %24, 0
|
||||
%27 = getelementptr ptr, ptr %26, i64 3
|
||||
%28 = load ptr, ptr %27, align 8
|
||||
%29 = insertvalue { ptr, ptr } undef, ptr %28, 0
|
||||
%30 = insertvalue { ptr, ptr } %29, ptr %25, 1
|
||||
%31 = extractvalue { ptr, ptr } %30, 1
|
||||
%32 = extractvalue { ptr, ptr } %30, 0
|
||||
call void %32(ptr %31)
|
||||
%33 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32)
|
||||
%34 = getelementptr inbounds i64, ptr %33, i64 0
|
||||
%35 = getelementptr inbounds i64, ptr %33, i64 1
|
||||
%36 = getelementptr inbounds i64, ptr %33, i64 2
|
||||
%37 = getelementptr inbounds i64, ptr %33, i64 3
|
||||
store i64 1, ptr %34, align 4
|
||||
store i64 2, ptr %35, align 4
|
||||
store i64 3, ptr %36, align 4
|
||||
store i64 4, ptr %37, align 4
|
||||
%38 = getelementptr [4 x i64], ptr %33, i64 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %38)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%39 = getelementptr [4 x i64], ptr %33, i64 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %39)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
%40 = load ptr, ptr @_llgo_string, align 8
|
||||
%41 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 21 }, ptr %41, align 8
|
||||
%42 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %40, 0
|
||||
%43 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %42, ptr %41, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %43)
|
||||
unreachable
|
||||
}
|
||||
|
||||
define linkonce void @"main.T[string,int].Info"(%"main.T[string,int]" %0) {
|
||||
_llgo_0:
|
||||
%1 = alloca %"main.T[string,int]", align 8
|
||||
call void @llvm.memset(ptr %1, i8 0, i64 24, i1 false)
|
||||
store %"main.T[string,int]" %0, ptr %1, align 8
|
||||
%2 = getelementptr inbounds %"main.T[string,int]", ptr %1, i32 0, i32 0
|
||||
%3 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %2, align 8
|
||||
%4 = getelementptr inbounds %"main.T[string,int]", ptr %1, i32 0, i32 1
|
||||
%5 = load i64, ptr %4, align 4
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %3)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %5)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
define linkonce void @"main.(*T[string,int]).Demo"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = getelementptr inbounds %"main.T[string,int]", ptr %0, i32 0, i32 0
|
||||
%2 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %1, align 8
|
||||
%3 = getelementptr inbounds %"main.T[string,int]", ptr %0, i32 0, i32 1
|
||||
%4 = load i64, ptr %3, align 4
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %2)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.(*T[string,int]).Info"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load %"main.T[string,int]", ptr %0, align 8
|
||||
call void @"main.T[string,int].Info"(%"main.T[string,int]" %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
|
||||
declare void @llvm.memset(ptr nocapture writeonly, i8, i64, i1 immarg) #0
|
||||
|
||||
define void @"main.init$after"() {
|
||||
_llgo_0:
|
||||
%0 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 1 }, i64 25, i64 24, i64 1, i64 2)
|
||||
%1 = load ptr, ptr @"_llgo_main.T[string,int]", 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_main.T[string,int]", align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%3 = load ptr, ptr @_llgo_string, 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/internal/runtime.Basic"(i64 24)
|
||||
store ptr %5, ptr @_llgo_string, align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%6 = load ptr, ptr @_llgo_string, align 8
|
||||
%7 = load ptr, ptr @_llgo_int, align 8
|
||||
%8 = icmp eq ptr %7, null
|
||||
br i1 %8, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4
|
||||
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
store ptr %9, ptr @_llgo_int, align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
%10 = load ptr, ptr @_llgo_int, align 8
|
||||
%11 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
%12 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 1 }, ptr %11, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%13 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%14 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 1 }, ptr %13, i64 16, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%15 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 112)
|
||||
%16 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %15, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %12, ptr %16, align 8
|
||||
%17 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %15, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %14, ptr %17, align 8
|
||||
%18 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %15, 0
|
||||
%19 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %18, i64 2, 1
|
||||
%20 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %19, i64 2, 2
|
||||
%21 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, i64 24, %"github.com/goplus/llgo/internal/runtime.Slice" %20)
|
||||
store ptr %21, ptr @"main.struct$A2OTYqQyUOqOQ-i_F5iXeAKWtxeWGEuyeN7HCfULCDk", align 8
|
||||
%22 = load ptr, ptr @"main.struct$A2OTYqQyUOqOQ-i_F5iXeAKWtxeWGEuyeN7HCfULCDk", align 8
|
||||
br i1 %2, label %_llgo_7, label %_llgo_8
|
||||
|
||||
_llgo_7: ; preds = %_llgo_6
|
||||
%23 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%24 = icmp eq ptr %23, null
|
||||
br i1 %24, label %_llgo_9, label %_llgo_10
|
||||
|
||||
_llgo_8: ; preds = %_llgo_10, %_llgo_6
|
||||
%25 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 1 }, i64 25, i64 24, i64 1, i64 2)
|
||||
%26 = load ptr, ptr @"*_llgo_main.T[string,int]", align 8
|
||||
%27 = icmp eq ptr %26, null
|
||||
br i1 %27, label %_llgo_11, label %_llgo_12
|
||||
|
||||
_llgo_9: ; preds = %_llgo_7
|
||||
%28 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%29 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %28, 0
|
||||
%30 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %29, i64 0, 1
|
||||
%31 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %30, i64 0, 2
|
||||
%32 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%33 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %32, 0
|
||||
%34 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %33, i64 0, 1
|
||||
%35 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %34, i64 0, 2
|
||||
%36 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %31, %"github.com/goplus/llgo/internal/runtime.Slice" %35, i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %36)
|
||||
store ptr %36, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
br label %_llgo_10
|
||||
|
||||
_llgo_10: ; preds = %_llgo_9, %_llgo_7
|
||||
%37 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%38 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 4 }, ptr undef, ptr undef, ptr undef }, ptr %37, 1
|
||||
%39 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %38, ptr @"main.(*T[string,int]).Demo", 2
|
||||
%40 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %39, ptr @"main.(*T[string,int]).Demo", 3
|
||||
%41 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%42 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 4 }, ptr undef, ptr undef, ptr undef }, ptr %41, 1
|
||||
%43 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %42, ptr @"main.(*T[string,int]).Info", 2
|
||||
%44 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %43, ptr @"main.(*T[string,int]).Info", 3
|
||||
%45 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 4 }, ptr undef, ptr undef, ptr undef }, ptr %41, 1
|
||||
%46 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %45, ptr @"main.(*T[string,int]).Info", 2
|
||||
%47 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %46, ptr @"main.T[string,int].Info", 3
|
||||
%48 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
||||
%49 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %48, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %47, ptr %49, align 8
|
||||
%50 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %48, 0
|
||||
%51 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %50, i64 1, 1
|
||||
%52 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %51, i64 1, 2
|
||||
%53 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 80)
|
||||
%54 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %53, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %40, ptr %54, align 8
|
||||
%55 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %53, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %44, ptr %55, align 8
|
||||
%56 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %53, 0
|
||||
%57 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %56, i64 2, 1
|
||||
%58 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %57, i64 2, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %0, ptr %22, %"github.com/goplus/llgo/internal/runtime.Slice" %52, %"github.com/goplus/llgo/internal/runtime.Slice" %58)
|
||||
br label %_llgo_8
|
||||
|
||||
_llgo_11: ; preds = %_llgo_8
|
||||
%59 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %25)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %59)
|
||||
store ptr %59, ptr @"*_llgo_main.T[string,int]", align 8
|
||||
br label %_llgo_12
|
||||
|
||||
_llgo_12: ; preds = %_llgo_11, %_llgo_8
|
||||
%60 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%61 = load ptr, ptr @"_llgo_iface$BP0p_lUsEd-IbbtJVukGmgrdQkqzcoYzSiwgUvgFvUs", align 8
|
||||
%62 = icmp eq ptr %61, null
|
||||
br i1 %62, label %_llgo_13, label %_llgo_14
|
||||
|
||||
_llgo_13: ; preds = %_llgo_12
|
||||
%63 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 4 }, ptr undef }, ptr %60, 1
|
||||
%64 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
|
||||
%65 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %64, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %63, ptr %65, align 8
|
||||
%66 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %64, 0
|
||||
%67 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %66, i64 1, 1
|
||||
%68 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %67, i64 1, 2
|
||||
%69 = call ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, %"github.com/goplus/llgo/internal/runtime.Slice" %68)
|
||||
store ptr %69, ptr @"_llgo_iface$BP0p_lUsEd-IbbtJVukGmgrdQkqzcoYzSiwgUvgFvUs", align 8
|
||||
br label %_llgo_14
|
||||
|
||||
_llgo_14: ; preds = %_llgo_13, %_llgo_12
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", i64, i64, i64, i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr, ptr, %"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
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 void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
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)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
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.Slice")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr, ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64)
|
||||
|
||||
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
|
||||
26
compiler/cl/_testrt/tpfunc/in.go
Normal file
26
compiler/cl/_testrt/tpfunc/in.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type Func func(*int)
|
||||
|
||||
//llgo:type C
|
||||
type CFunc func(*int)
|
||||
|
||||
//llgo:type C
|
||||
type Callback[T any] func(*T)
|
||||
|
||||
func main() {
|
||||
var fn1 Func = func(v *int) {
|
||||
println(*v)
|
||||
}
|
||||
var fn2 CFunc = func(v *int) {
|
||||
println(*v)
|
||||
}
|
||||
var fn3 Callback[int] = func(v *int) {
|
||||
println(*v)
|
||||
}
|
||||
println(unsafe.Sizeof(fn1), unsafe.Sizeof(fn2), unsafe.Sizeof(fn3))
|
||||
}
|
||||
72
compiler/cl/_testrt/tpfunc/out.ll
Normal file
72
compiler/cl/_testrt/tpfunc/out.ll
Normal file
@@ -0,0 +1,72 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 16)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 8)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 8)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @"main.main$1"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load i64, ptr %0, align 4
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %1)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.main$2"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load i64, ptr %0, align 4
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %1)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.main$3"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load i64, ptr %0, align 4
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %1)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
define linkonce void @"__llgo_stub.main.main$1"(ptr %0, ptr %1) {
|
||||
_llgo_0:
|
||||
tail call void @"main.main$1"(ptr %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64)
|
||||
26
compiler/cl/_testrt/tpmap/in.go
Normal file
26
compiler/cl/_testrt/tpmap/in.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
type T1 int
|
||||
|
||||
type T2 struct {
|
||||
v int
|
||||
}
|
||||
|
||||
type T3[T any] struct {
|
||||
v T
|
||||
}
|
||||
|
||||
type cacheKey struct {
|
||||
t1 T1
|
||||
t2 T2
|
||||
t3 T3[any]
|
||||
t4 *int
|
||||
t5 uintptr
|
||||
}
|
||||
|
||||
func main() {
|
||||
m := map[cacheKey]string{}
|
||||
m[cacheKey{0, T2{0}, T3[any]{0}, nil, 0}] = "world"
|
||||
v, ok := m[cacheKey{0, T2{0}, T3[any]{0}, nil, 0}]
|
||||
println(v, ok)
|
||||
}
|
||||
372
compiler/cl/_testrt/tpmap/out.ll
Normal file
372
compiler/cl/_testrt/tpmap/out.ll
Normal file
@@ -0,0 +1,372 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%main.cacheKey = type { i64, %main.T2, %"main.T3[any]", ptr, i64 }
|
||||
%main.T2 = type { i64 }
|
||||
%"main.T3[any]" = type { %"github.com/goplus/llgo/internal/runtime.eface" }
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/internal/abi.StructField" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1 }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@_llgo_main.cacheKey = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@1 = private unnamed_addr constant [8 x i8] c"cacheKey", align 1
|
||||
@_llgo_main.T1 = linkonce global ptr null, align 8
|
||||
@2 = private unnamed_addr constant [2 x i8] c"T1", align 1
|
||||
@_llgo_int = linkonce global ptr null, align 8
|
||||
@_llgo_main.T2 = linkonce global ptr null, align 8
|
||||
@3 = private unnamed_addr constant [2 x i8] c"T2", align 1
|
||||
@"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88" = linkonce global ptr null, align 8
|
||||
@4 = private unnamed_addr constant [1 x i8] c"v", align 1
|
||||
@"_llgo_main.T3[any]" = linkonce global ptr null, align 8
|
||||
@5 = private unnamed_addr constant [2 x i8] c"T3", align 1
|
||||
@_llgo_any = linkonce global ptr null, align 8
|
||||
@"main.struct$op7q0963ur0ih9ul6OteH-C75UVydPxwKOVpX1hUjzo" = linkonce global ptr null, align 8
|
||||
@"*_llgo_int" = linkonce global ptr null, align 8
|
||||
@_llgo_uintptr = linkonce global ptr null, align 8
|
||||
@"main.struct$ZLgMjv1XBA1L4yXCpdouRvQF2okeuHQ-YWVTE34gq4I" = linkonce global ptr null, align 8
|
||||
@6 = private unnamed_addr constant [2 x i8] c"t1", align 1
|
||||
@7 = private unnamed_addr constant [2 x i8] c"t2", align 1
|
||||
@8 = private unnamed_addr constant [2 x i8] c"t3", align 1
|
||||
@9 = private unnamed_addr constant [2 x i8] c"t4", align 1
|
||||
@10 = private unnamed_addr constant [2 x i8] c"t5", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@"map[_llgo_main.cacheKey]_llgo_string" = linkonce global ptr null, align 8
|
||||
@11 = private unnamed_addr constant [7 x i8] c"topbits", align 1
|
||||
@12 = private unnamed_addr constant [4 x i8] c"keys", align 1
|
||||
@13 = private unnamed_addr constant [5 x i8] c"elems", align 1
|
||||
@14 = private unnamed_addr constant [8 x i8] c"overflow", align 1
|
||||
@15 = private unnamed_addr constant [5 x i8] c"world", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"main.init$after"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = load ptr, ptr @_llgo_main.cacheKey, align 8
|
||||
%3 = load ptr, ptr @_llgo_string, align 8
|
||||
%4 = load ptr, ptr @"map[_llgo_main.cacheKey]_llgo_string", align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr %4, i64 0)
|
||||
%6 = alloca %main.cacheKey, align 8
|
||||
call void @llvm.memset(ptr %6, i8 0, i64 48, i1 false)
|
||||
%7 = getelementptr inbounds %main.cacheKey, ptr %6, i32 0, i32 0
|
||||
%8 = getelementptr inbounds %main.cacheKey, ptr %6, i32 0, i32 1
|
||||
%9 = getelementptr inbounds %main.T2, ptr %8, i32 0, i32 0
|
||||
%10 = getelementptr inbounds %main.cacheKey, ptr %6, i32 0, i32 2
|
||||
%11 = getelementptr inbounds %"main.T3[any]", ptr %10, i32 0, i32 0
|
||||
%12 = getelementptr inbounds %main.cacheKey, ptr %6, i32 0, i32 3
|
||||
%13 = getelementptr inbounds %main.cacheKey, ptr %6, i32 0, i32 4
|
||||
store i64 0, ptr %7, align 4
|
||||
store i64 0, ptr %9, align 4
|
||||
%14 = load ptr, ptr @_llgo_int, align 8
|
||||
%15 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %14, 0
|
||||
%16 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %15, ptr null, 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %16, ptr %11, align 8
|
||||
store ptr null, ptr %12, align 8
|
||||
store i64 0, ptr %13, align 4
|
||||
%17 = load %main.cacheKey, ptr %6, align 8
|
||||
%18 = load ptr, ptr @"map[_llgo_main.cacheKey]_llgo_string", align 8
|
||||
%19 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
|
||||
store %main.cacheKey %17, ptr %19, align 8
|
||||
%20 = call ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr %18, ptr %5, ptr %19)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @15, i64 5 }, ptr %20, align 8
|
||||
%21 = alloca %main.cacheKey, align 8
|
||||
call void @llvm.memset(ptr %21, i8 0, i64 48, i1 false)
|
||||
%22 = getelementptr inbounds %main.cacheKey, ptr %21, i32 0, i32 0
|
||||
%23 = getelementptr inbounds %main.cacheKey, ptr %21, i32 0, i32 1
|
||||
%24 = getelementptr inbounds %main.T2, ptr %23, i32 0, i32 0
|
||||
%25 = getelementptr inbounds %main.cacheKey, ptr %21, i32 0, i32 2
|
||||
%26 = getelementptr inbounds %"main.T3[any]", ptr %25, i32 0, i32 0
|
||||
%27 = getelementptr inbounds %main.cacheKey, ptr %21, i32 0, i32 3
|
||||
%28 = getelementptr inbounds %main.cacheKey, ptr %21, i32 0, i32 4
|
||||
store i64 0, ptr %22, align 4
|
||||
store i64 0, ptr %24, align 4
|
||||
%29 = load ptr, ptr @_llgo_int, align 8
|
||||
%30 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %29, 0
|
||||
%31 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %30, ptr null, 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %31, ptr %26, align 8
|
||||
store ptr null, ptr %27, align 8
|
||||
store i64 0, ptr %28, align 4
|
||||
%32 = load %main.cacheKey, ptr %21, align 8
|
||||
%33 = load ptr, ptr @"map[_llgo_main.cacheKey]_llgo_string", align 8
|
||||
%34 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
|
||||
store %main.cacheKey %32, ptr %34, align 8
|
||||
%35 = call { ptr, i1 } @"github.com/goplus/llgo/internal/runtime.MapAccess2"(ptr %33, ptr %5, ptr %34)
|
||||
%36 = extractvalue { ptr, i1 } %35, 0
|
||||
%37 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %36, align 8
|
||||
%38 = extractvalue { ptr, i1 } %35, 1
|
||||
%39 = insertvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } undef, %"github.com/goplus/llgo/internal/runtime.String" %37, 0
|
||||
%40 = insertvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } %39, i1 %38, 1
|
||||
%41 = extractvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } %40, 0
|
||||
%42 = extractvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } %40, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %41)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %42)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
define void @"main.init$after"() {
|
||||
_llgo_0:
|
||||
%0 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 8 }, i64 25, i64 48, i64 0, i64 0)
|
||||
store ptr %0, ptr @_llgo_main.cacheKey, align 8
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 2 }, i64 2, i64 8, i64 0, i64 0)
|
||||
%2 = load ptr, ptr @_llgo_main.T1, align 8
|
||||
%3 = icmp eq ptr %2, null
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store ptr %1, ptr @_llgo_main.T1, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_int, align 8
|
||||
%5 = icmp eq ptr %4, null
|
||||
br i1 %5, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_3: ; preds = %_llgo_2
|
||||
%6 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
store ptr %6, ptr @_llgo_int, align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%7 = load ptr, ptr @_llgo_int, align 8
|
||||
br i1 %3, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %1, ptr %7, { ptr, i64, i64 } zeroinitializer, { ptr, i64, i64 } zeroinitializer)
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
%8 = load ptr, ptr @_llgo_main.T1, align 8
|
||||
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 2 }, i64 25, i64 8, i64 0, i64 0)
|
||||
%10 = load ptr, ptr @_llgo_main.T2, align 8
|
||||
%11 = icmp eq ptr %10, null
|
||||
br i1 %11, label %_llgo_7, label %_llgo_8
|
||||
|
||||
_llgo_7: ; preds = %_llgo_6
|
||||
store ptr %9, ptr @_llgo_main.T2, align 8
|
||||
br label %_llgo_8
|
||||
|
||||
_llgo_8: ; preds = %_llgo_7, %_llgo_6
|
||||
%12 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%13 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 1 }, ptr %12, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 56)
|
||||
%15 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %14, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %13, ptr %15, align 8
|
||||
%16 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %14, 0
|
||||
%17 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %16, i64 1, 1
|
||||
%18 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %17, i64 1, 2
|
||||
%19 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, i64 8, %"github.com/goplus/llgo/internal/runtime.Slice" %18)
|
||||
store ptr %19, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8
|
||||
%20 = load ptr, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8
|
||||
br i1 %11, label %_llgo_9, label %_llgo_10
|
||||
|
||||
_llgo_9: ; preds = %_llgo_8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %9, ptr %20, { ptr, i64, i64 } zeroinitializer, { ptr, i64, i64 } zeroinitializer)
|
||||
br label %_llgo_10
|
||||
|
||||
_llgo_10: ; preds = %_llgo_9, %_llgo_8
|
||||
%21 = load ptr, ptr @_llgo_main.T2, align 8
|
||||
%22 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 2 }, i64 25, i64 16, i64 0, i64 0)
|
||||
%23 = load ptr, ptr @"_llgo_main.T3[any]", align 8
|
||||
%24 = icmp eq ptr %23, null
|
||||
br i1 %24, label %_llgo_11, label %_llgo_12
|
||||
|
||||
_llgo_11: ; preds = %_llgo_10
|
||||
store ptr %22, ptr @"_llgo_main.T3[any]", align 8
|
||||
br label %_llgo_12
|
||||
|
||||
_llgo_12: ; preds = %_llgo_11, %_llgo_10
|
||||
%25 = load ptr, ptr @_llgo_any, align 8
|
||||
%26 = icmp eq ptr %25, null
|
||||
br i1 %26, label %_llgo_13, label %_llgo_14
|
||||
|
||||
_llgo_13: ; preds = %_llgo_12
|
||||
%27 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%28 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %27, 0
|
||||
%29 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %28, i64 0, 1
|
||||
%30 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %29, i64 0, 2
|
||||
%31 = call ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.Slice" %30)
|
||||
store ptr %31, ptr @_llgo_any, align 8
|
||||
br label %_llgo_14
|
||||
|
||||
_llgo_14: ; preds = %_llgo_13, %_llgo_12
|
||||
%32 = load ptr, ptr @_llgo_any, align 8
|
||||
%33 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%34 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %33, 0
|
||||
%35 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %34, i64 0, 1
|
||||
%36 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %35, i64 0, 2
|
||||
%37 = call ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.Slice" %36)
|
||||
%38 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 1 }, ptr %37, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%39 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 56)
|
||||
%40 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %39, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %38, ptr %40, align 8
|
||||
%41 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %39, 0
|
||||
%42 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %41, i64 1, 1
|
||||
%43 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %42, i64 1, 2
|
||||
%44 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %43)
|
||||
store ptr %44, ptr @"main.struct$op7q0963ur0ih9ul6OteH-C75UVydPxwKOVpX1hUjzo", align 8
|
||||
%45 = load ptr, ptr @"main.struct$op7q0963ur0ih9ul6OteH-C75UVydPxwKOVpX1hUjzo", align 8
|
||||
br i1 %24, label %_llgo_15, label %_llgo_16
|
||||
|
||||
_llgo_15: ; preds = %_llgo_14
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %22, ptr %45, { ptr, i64, i64 } zeroinitializer, { ptr, i64, i64 } zeroinitializer)
|
||||
br label %_llgo_16
|
||||
|
||||
_llgo_16: ; preds = %_llgo_15, %_llgo_14
|
||||
%46 = load ptr, ptr @"_llgo_main.T3[any]", align 8
|
||||
%47 = load ptr, ptr @"*_llgo_int", align 8
|
||||
%48 = icmp eq ptr %47, null
|
||||
br i1 %48, label %_llgo_17, label %_llgo_18
|
||||
|
||||
_llgo_17: ; preds = %_llgo_16
|
||||
%49 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%50 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %49)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %50)
|
||||
store ptr %50, ptr @"*_llgo_int", align 8
|
||||
br label %_llgo_18
|
||||
|
||||
_llgo_18: ; preds = %_llgo_17, %_llgo_16
|
||||
%51 = load ptr, ptr @"*_llgo_int", align 8
|
||||
%52 = load ptr, ptr @_llgo_uintptr, align 8
|
||||
%53 = icmp eq ptr %52, null
|
||||
br i1 %53, label %_llgo_19, label %_llgo_20
|
||||
|
||||
_llgo_19: ; preds = %_llgo_18
|
||||
%54 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 44)
|
||||
store ptr %54, ptr @_llgo_uintptr, align 8
|
||||
br label %_llgo_20
|
||||
|
||||
_llgo_20: ; preds = %_llgo_19, %_llgo_18
|
||||
%55 = load ptr, ptr @_llgo_uintptr, align 8
|
||||
%56 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 2 }, i64 2, i64 8, i64 0, i64 0)
|
||||
%57 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 2 }, i64 25, i64 8, i64 0, i64 0)
|
||||
%58 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 2 }, i64 25, i64 16, i64 0, i64 0)
|
||||
%59 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 2 }, ptr %56, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%60 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 2 }, ptr %57, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%61 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @8, i64 2 }, ptr %58, i64 16, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%62 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%63 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %62)
|
||||
%64 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @9, i64 2 }, ptr %63, i64 32, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%65 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 44)
|
||||
%66 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @10, i64 2 }, ptr %65, i64 40, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%67 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 280)
|
||||
%68 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %67, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %59, ptr %68, align 8
|
||||
%69 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %67, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %60, ptr %69, align 8
|
||||
%70 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %67, i64 2
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %61, ptr %70, align 8
|
||||
%71 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %67, i64 3
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %64, ptr %71, align 8
|
||||
%72 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %67, i64 4
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %66, ptr %72, align 8
|
||||
%73 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %67, 0
|
||||
%74 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %73, i64 5, 1
|
||||
%75 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %74, i64 5, 2
|
||||
%76 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, i64 48, %"github.com/goplus/llgo/internal/runtime.Slice" %75)
|
||||
store ptr %76, ptr @"main.struct$ZLgMjv1XBA1L4yXCpdouRvQF2okeuHQ-YWVTE34gq4I", align 8
|
||||
%77 = load ptr, ptr @"main.struct$ZLgMjv1XBA1L4yXCpdouRvQF2okeuHQ-YWVTE34gq4I", align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %0, ptr %77, { ptr, i64, i64 } zeroinitializer, { ptr, i64, i64 } zeroinitializer)
|
||||
%78 = load ptr, ptr @_llgo_string, align 8
|
||||
%79 = icmp eq ptr %78, null
|
||||
br i1 %79, label %_llgo_21, label %_llgo_22
|
||||
|
||||
_llgo_21: ; preds = %_llgo_20
|
||||
%80 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
store ptr %80, ptr @_llgo_string, align 8
|
||||
br label %_llgo_22
|
||||
|
||||
_llgo_22: ; preds = %_llgo_21, %_llgo_20
|
||||
%81 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 8 }, i64 25, i64 48, i64 0, i64 0)
|
||||
%82 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 8 }, i64 25, i64 48, i64 0, i64 0)
|
||||
%83 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
%84 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 40)
|
||||
%85 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %84)
|
||||
%86 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @11, i64 7 }, ptr %85, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%87 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %82)
|
||||
%88 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @12, i64 4 }, ptr %87, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%89 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
%90 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %89)
|
||||
%91 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @13, i64 5 }, ptr %90, i64 392, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%92 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 58)
|
||||
%93 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @14, i64 8 }, ptr %92, i64 520, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%94 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 224)
|
||||
%95 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %94, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %86, ptr %95, align 8
|
||||
%96 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %94, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %88, ptr %96, align 8
|
||||
%97 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %94, i64 2
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %91, ptr %97, align 8
|
||||
%98 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %94, i64 3
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %93, ptr %98, align 8
|
||||
%99 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %94, 0
|
||||
%100 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %99, i64 4, 1
|
||||
%101 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %100, i64 4, 2
|
||||
%102 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, i64 528, %"github.com/goplus/llgo/internal/runtime.Slice" %101)
|
||||
%103 = call ptr @"github.com/goplus/llgo/internal/runtime.MapOf"(ptr %81, ptr %83, ptr %102, i64 24)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %103)
|
||||
store ptr %103, ptr @"map[_llgo_main.cacheKey]_llgo_string", align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", i64, i64, i64, i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr, ptr, %"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MapOf"(ptr, ptr, ptr, i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64, ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr, i64)
|
||||
|
||||
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
|
||||
declare void @llvm.memset(ptr nocapture writeonly, i8, i64, i1 immarg) #0
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MapAssign"(ptr, ptr, ptr)
|
||||
|
||||
declare { ptr, i1 } @"github.com/goplus/llgo/internal/runtime.MapAccess2"(ptr, ptr, ptr)
|
||||
|
||||
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)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1)
|
||||
|
||||
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
|
||||
37
compiler/cl/_testrt/tpmethod/in.go
Normal file
37
compiler/cl/_testrt/tpmethod/in.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
type Tuple[T any] struct {
|
||||
v T
|
||||
}
|
||||
|
||||
func (t Tuple[T]) Get() T {
|
||||
return t.v
|
||||
}
|
||||
|
||||
type Future[T any] interface {
|
||||
Then(func(T))
|
||||
}
|
||||
|
||||
type future[T any] struct {
|
||||
fn func(func(T))
|
||||
}
|
||||
|
||||
func (f *future[T]) Then(callback func(T)) {
|
||||
f.fn(callback)
|
||||
}
|
||||
|
||||
func Async[T any](fn func(func(T))) Future[T] {
|
||||
return &future[T]{fn: fn}
|
||||
}
|
||||
|
||||
func ReadFile(fileName string) Future[Tuple[error]] {
|
||||
return Async[Tuple[error]](func(resolve func(Tuple[error])) {
|
||||
resolve(Tuple[error]{v: nil})
|
||||
})
|
||||
}
|
||||
|
||||
func main() {
|
||||
ReadFile("foo.txt").Then(func(v Tuple[error]) {
|
||||
println(v.Get())
|
||||
})
|
||||
}
|
||||
514
compiler/cl/_testrt/tpmethod/out.ll
Normal file
514
compiler/cl/_testrt/tpmethod/out.ll
Normal file
@@ -0,0 +1,514 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%"main.Tuple[error]" = type { %"github.com/goplus/llgo/internal/runtime.iface" }
|
||||
%"main.future[main.Tuple[error]]" = type { { ptr, ptr } }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
%"github.com/goplus/llgo/internal/abi.Imethod" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr }
|
||||
%"github.com/goplus/llgo/internal/abi.StructField" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1 }
|
||||
%"github.com/goplus/llgo/internal/abi.Method" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, ptr, ptr }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [7 x i8] c"foo.txt", align 1
|
||||
@"_llgo_main.future[main.Tuple[error]]" = linkonce global ptr null, align 8
|
||||
@1 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@2 = private unnamed_addr constant [6 x i8] c"future", align 1
|
||||
@"_llgo_main.Tuple[error]" = linkonce global ptr null, align 8
|
||||
@3 = private unnamed_addr constant [5 x i8] c"Tuple", align 1
|
||||
@_llgo_error = linkonce global ptr null, align 8
|
||||
@4 = private unnamed_addr constant [5 x i8] c"error", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to" = linkonce global ptr null, align 8
|
||||
@5 = private unnamed_addr constant [5 x i8] c"Error", align 1
|
||||
@"main.struct$ddtj0teo4LtYcagzh1w6BsSZ7226uefXlqreeHsfVRo" = linkonce global ptr null, align 8
|
||||
@6 = private unnamed_addr constant [1 x i8] c"v", align 1
|
||||
@7 = private unnamed_addr constant [3 x i8] c"Get", align 1
|
||||
@"_llgo_func$8rsrSd_r3UHd_2DiYTyaOKR7BYkei4zw5ysG35KF38w" = linkonce global ptr null, align 8
|
||||
@"_llgo_func$1BeCdGdxwWG-Dtl1HbNuSy2_sb8rBMTmu7zhcPPofmU" = linkonce global ptr null, align 8
|
||||
@_llgo_Pointer = linkonce global ptr null, align 8
|
||||
@"main.struct$vwhCZhgsid50r1SsT8OmKpRI0Cpljg78h5JlpD1CTR4" = linkonce global ptr null, align 8
|
||||
@8 = private unnamed_addr constant [2 x i8] c"$f", align 1
|
||||
@9 = private unnamed_addr constant [5 x i8] c"$data", align 1
|
||||
@"_llgo_func$_so3zZGPIhTQghxFcf7CCCVzSOk2lxOt7xgGKcTzc0s" = linkonce global ptr null, align 8
|
||||
@"main.struct$awGH2Wh33bS1v_s7SNAwKW27E20HcwiiPPzh9UA7QDs" = linkonce global ptr null, align 8
|
||||
@"main.struct$N1awC7qGapVTS_NFj1Q0jk6nCjATrIK-60oOEyDjabo" = linkonce global ptr null, align 8
|
||||
@10 = private unnamed_addr constant [2 x i8] c"fn", align 1
|
||||
@11 = private unnamed_addr constant [4 x i8] c"Then", align 1
|
||||
@"*_llgo_main.future[main.Tuple[error]]" = linkonce global ptr null, align 8
|
||||
@"_llgo_iface$pTofAxYfPZHsCMD5T70nrOx1gjHf9m2QCLNvEOl1py0" = linkonce global ptr null, align 8
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.iface" @main.ReadFile(%"github.com/goplus/llgo/internal/runtime.String" %0) {
|
||||
_llgo_0:
|
||||
%1 = call %"github.com/goplus/llgo/internal/runtime.iface" @"main.Async[main.Tuple[error]]"({ ptr, ptr } { ptr @"__llgo_stub.main.ReadFile$1", ptr null })
|
||||
ret %"github.com/goplus/llgo/internal/runtime.iface" %1
|
||||
}
|
||||
|
||||
define void @"main.ReadFile$1"({ ptr, ptr } %0) {
|
||||
_llgo_0:
|
||||
%1 = alloca %"main.Tuple[error]", align 8
|
||||
call void @llvm.memset(ptr %1, i8 0, i64 16, i1 false)
|
||||
%2 = getelementptr inbounds %"main.Tuple[error]", ptr %1, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" zeroinitializer, ptr %2, align 8
|
||||
%3 = load %"main.Tuple[error]", ptr %1, align 8
|
||||
%4 = extractvalue { ptr, ptr } %0, 1
|
||||
%5 = extractvalue { ptr, ptr } %0, 0
|
||||
call void %5(ptr %4, %"main.Tuple[error]" %3)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"main.init$after"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call %"github.com/goplus/llgo/internal/runtime.iface" @main.ReadFile(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 7 })
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface" %2)
|
||||
%4 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %2, 0
|
||||
%5 = getelementptr ptr, ptr %4, i64 3
|
||||
%6 = load ptr, ptr %5, align 8
|
||||
%7 = insertvalue { ptr, ptr } undef, ptr %6, 0
|
||||
%8 = insertvalue { ptr, ptr } %7, ptr %3, 1
|
||||
%9 = extractvalue { ptr, ptr } %8, 1
|
||||
%10 = extractvalue { ptr, ptr } %8, 0
|
||||
call void %10(ptr %9, { ptr, ptr } { ptr @"__llgo_stub.main.main$1", ptr null })
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @"main.main$1"(%"main.Tuple[error]" %0) {
|
||||
_llgo_0:
|
||||
%1 = call %"github.com/goplus/llgo/internal/runtime.iface" @"main.Tuple[error].Get"(%"main.Tuple[error]" %0)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintIface"(%"github.com/goplus/llgo/internal/runtime.iface" %1)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
define linkonce %"github.com/goplus/llgo/internal/runtime.iface" @"main.Tuple[error].Get"(%"main.Tuple[error]" %0) {
|
||||
_llgo_0:
|
||||
%1 = alloca %"main.Tuple[error]", align 8
|
||||
call void @llvm.memset(ptr %1, i8 0, i64 16, i1 false)
|
||||
store %"main.Tuple[error]" %0, ptr %1, align 8
|
||||
%2 = getelementptr inbounds %"main.Tuple[error]", ptr %1, i32 0, i32 0
|
||||
%3 = load %"github.com/goplus/llgo/internal/runtime.iface", ptr %2, align 8
|
||||
ret %"github.com/goplus/llgo/internal/runtime.iface" %3
|
||||
}
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.iface" @"main.(*Tuple[error]).Get"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load %"main.Tuple[error]", ptr %0, align 8
|
||||
%2 = call %"github.com/goplus/llgo/internal/runtime.iface" @"main.Tuple[error].Get"(%"main.Tuple[error]" %1)
|
||||
ret %"github.com/goplus/llgo/internal/runtime.iface" %2
|
||||
}
|
||||
|
||||
define linkonce void @"main.(*future[main.Tuple[error]]).Then"(ptr %0, { ptr, ptr } %1) {
|
||||
_llgo_0:
|
||||
%2 = getelementptr inbounds %"main.future[main.Tuple[error]]", ptr %0, i32 0, i32 0
|
||||
%3 = load { ptr, ptr }, ptr %2, align 8
|
||||
%4 = extractvalue { ptr, ptr } %3, 1
|
||||
%5 = extractvalue { ptr, ptr } %3, 0
|
||||
call void %5(ptr %4, { ptr, ptr } %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
define linkonce %"github.com/goplus/llgo/internal/runtime.iface" @"main.Async[main.Tuple[error]]"({ ptr, ptr } %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
%2 = getelementptr inbounds %"main.future[main.Tuple[error]]", ptr %1, i32 0, i32 0
|
||||
store { ptr, ptr } %0, ptr %2, align 8
|
||||
%3 = load ptr, ptr @"_llgo_main.future[main.Tuple[error]]", align 8
|
||||
%4 = load ptr, ptr @"*_llgo_main.future[main.Tuple[error]]", align 8
|
||||
%5 = load ptr, ptr @"_llgo_func$1BeCdGdxwWG-Dtl1HbNuSy2_sb8rBMTmu7zhcPPofmU", align 8
|
||||
%6 = load ptr, ptr @"main.struct$vwhCZhgsid50r1SsT8OmKpRI0Cpljg78h5JlpD1CTR4", align 8
|
||||
%7 = load ptr, ptr @"_llgo_func$_so3zZGPIhTQghxFcf7CCCVzSOk2lxOt7xgGKcTzc0s", align 8
|
||||
%8 = load ptr, ptr @"_llgo_iface$pTofAxYfPZHsCMD5T70nrOx1gjHf9m2QCLNvEOl1py0", align 8
|
||||
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %8, ptr %4)
|
||||
%10 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %9, 0
|
||||
%11 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %10, ptr %1, 1
|
||||
ret %"github.com/goplus/llgo/internal/runtime.iface" %11
|
||||
}
|
||||
|
||||
define linkonce void @"__llgo_stub.main.ReadFile$1"(ptr %0, { ptr, ptr } %1) {
|
||||
_llgo_0:
|
||||
tail call void @"main.ReadFile$1"({ ptr, ptr } %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
; 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/internal/runtime.init"()
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface")
|
||||
|
||||
define linkonce void @"__llgo_stub.main.main$1"(ptr %0, %"main.Tuple[error]" %1) {
|
||||
_llgo_0:
|
||||
tail call void @"main.main$1"(%"main.Tuple[error]" %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintIface"(%"github.com/goplus/llgo/internal/runtime.iface")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
define void @"main.init$after"() {
|
||||
_llgo_0:
|
||||
%0 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 6 }, i64 25, i64 24, i64 0, i64 1)
|
||||
store ptr %0, ptr @"_llgo_main.future[main.Tuple[error]]", align 8
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 5 }, i64 25, i64 16, i64 1, i64 1)
|
||||
%2 = load ptr, ptr @"_llgo_main.Tuple[error]", align 8
|
||||
%3 = icmp eq ptr %2, null
|
||||
br i1 %3, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store ptr %1, ptr @"_llgo_main.Tuple[error]", align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%4 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 5 })
|
||||
%5 = load ptr, ptr @_llgo_error, align 8
|
||||
%6 = icmp eq ptr %5, null
|
||||
br i1 %6, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_3: ; preds = %_llgo_2
|
||||
store ptr %4, ptr @_llgo_error, align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%7 = load ptr, ptr @_llgo_string, align 8
|
||||
%8 = icmp eq ptr %7, null
|
||||
br i1 %8, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4
|
||||
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
store ptr %9, ptr @_llgo_string, align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
%10 = load ptr, ptr @_llgo_string, align 8
|
||||
%11 = load ptr, ptr @_llgo_string, align 8
|
||||
%12 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
%13 = icmp eq ptr %12, null
|
||||
br i1 %13, label %_llgo_7, label %_llgo_8
|
||||
|
||||
_llgo_7: ; preds = %_llgo_6
|
||||
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%15 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %14, 0
|
||||
%16 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %15, i64 0, 1
|
||||
%17 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %16, i64 0, 2
|
||||
%18 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%19 = getelementptr ptr, ptr %18, i64 0
|
||||
store ptr %11, ptr %19, align 8
|
||||
%20 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %18, 0
|
||||
%21 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %20, i64 1, 1
|
||||
%22 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %21, i64 1, 2
|
||||
%23 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %17, %"github.com/goplus/llgo/internal/runtime.Slice" %22, i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %23)
|
||||
store ptr %23, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
br label %_llgo_8
|
||||
|
||||
_llgo_8: ; preds = %_llgo_7, %_llgo_6
|
||||
%24 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
br i1 %6, label %_llgo_9, label %_llgo_10
|
||||
|
||||
_llgo_9: ; preds = %_llgo_8
|
||||
%25 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 5 }, ptr undef }, ptr %24, 1
|
||||
%26 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
|
||||
%27 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %26, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %25, ptr %27, align 8
|
||||
%28 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %26, 0
|
||||
%29 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %28, i64 1, 1
|
||||
%30 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %29, i64 1, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr %4, %"github.com/goplus/llgo/internal/runtime.Slice" %30)
|
||||
br label %_llgo_10
|
||||
|
||||
_llgo_10: ; preds = %_llgo_9, %_llgo_8
|
||||
%31 = load ptr, ptr @_llgo_error, align 8
|
||||
%32 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 5 })
|
||||
%33 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 1 }, ptr %32, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%34 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 56)
|
||||
%35 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %34, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %33, ptr %35, align 8
|
||||
%36 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %34, 0
|
||||
%37 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %36, i64 1, 1
|
||||
%38 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %37, i64 1, 2
|
||||
%39 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %38)
|
||||
store ptr %39, ptr @"main.struct$ddtj0teo4LtYcagzh1w6BsSZ7226uefXlqreeHsfVRo", align 8
|
||||
%40 = load ptr, ptr @"main.struct$ddtj0teo4LtYcagzh1w6BsSZ7226uefXlqreeHsfVRo", align 8
|
||||
br i1 %3, label %_llgo_11, label %_llgo_12
|
||||
|
||||
_llgo_11: ; preds = %_llgo_10
|
||||
%41 = load ptr, ptr @_llgo_error, align 8
|
||||
%42 = load ptr, ptr @"_llgo_func$8rsrSd_r3UHd_2DiYTyaOKR7BYkei4zw5ysG35KF38w", align 8
|
||||
%43 = icmp eq ptr %42, null
|
||||
br i1 %43, label %_llgo_13, label %_llgo_14
|
||||
|
||||
_llgo_12: ; preds = %_llgo_14, %_llgo_10
|
||||
%44 = load ptr, ptr @"_llgo_main.Tuple[error]", align 8
|
||||
%45 = load ptr, ptr @"_llgo_main.Tuple[error]", align 8
|
||||
%46 = load ptr, ptr @"_llgo_func$1BeCdGdxwWG-Dtl1HbNuSy2_sb8rBMTmu7zhcPPofmU", align 8
|
||||
%47 = icmp eq ptr %46, null
|
||||
br i1 %47, label %_llgo_15, label %_llgo_16
|
||||
|
||||
_llgo_13: ; preds = %_llgo_11
|
||||
%48 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%49 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %48, 0
|
||||
%50 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %49, i64 0, 1
|
||||
%51 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %50, i64 0, 2
|
||||
%52 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%53 = getelementptr ptr, ptr %52, i64 0
|
||||
store ptr %41, ptr %53, align 8
|
||||
%54 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %52, 0
|
||||
%55 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %54, i64 1, 1
|
||||
%56 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %55, i64 1, 2
|
||||
%57 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %51, %"github.com/goplus/llgo/internal/runtime.Slice" %56, i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %57)
|
||||
store ptr %57, ptr @"_llgo_func$8rsrSd_r3UHd_2DiYTyaOKR7BYkei4zw5ysG35KF38w", align 8
|
||||
br label %_llgo_14
|
||||
|
||||
_llgo_14: ; preds = %_llgo_13, %_llgo_11
|
||||
%58 = load ptr, ptr @"_llgo_func$8rsrSd_r3UHd_2DiYTyaOKR7BYkei4zw5ysG35KF38w", align 8
|
||||
%59 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 3 }, ptr undef, ptr undef, ptr undef }, ptr %58, 1
|
||||
%60 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %59, ptr @"main.(*Tuple[error]).Get", 2
|
||||
%61 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %60, ptr @"main.(*Tuple[error]).Get", 3
|
||||
%62 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 3 }, ptr undef, ptr undef, ptr undef }, ptr %58, 1
|
||||
%63 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %62, ptr @"main.(*Tuple[error]).Get", 2
|
||||
%64 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %63, ptr @"main.Tuple[error].Get", 3
|
||||
%65 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
||||
%66 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %65, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %64, ptr %66, align 8
|
||||
%67 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %65, 0
|
||||
%68 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %67, i64 1, 1
|
||||
%69 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %68, i64 1, 2
|
||||
%70 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
||||
%71 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %70, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %61, ptr %71, align 8
|
||||
%72 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %70, 0
|
||||
%73 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %72, i64 1, 1
|
||||
%74 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %73, i64 1, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %1, ptr %40, %"github.com/goplus/llgo/internal/runtime.Slice" %69, %"github.com/goplus/llgo/internal/runtime.Slice" %74)
|
||||
br label %_llgo_12
|
||||
|
||||
_llgo_15: ; preds = %_llgo_12
|
||||
%75 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%76 = getelementptr ptr, ptr %75, i64 0
|
||||
store ptr %45, ptr %76, align 8
|
||||
%77 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %75, 0
|
||||
%78 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %77, i64 1, 1
|
||||
%79 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %78, i64 1, 2
|
||||
%80 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%81 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %80, 0
|
||||
%82 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %81, i64 0, 1
|
||||
%83 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %82, i64 0, 2
|
||||
%84 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %79, %"github.com/goplus/llgo/internal/runtime.Slice" %83, i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %84)
|
||||
store ptr %84, ptr @"_llgo_func$1BeCdGdxwWG-Dtl1HbNuSy2_sb8rBMTmu7zhcPPofmU", align 8
|
||||
br label %_llgo_16
|
||||
|
||||
_llgo_16: ; preds = %_llgo_15, %_llgo_12
|
||||
%85 = load ptr, ptr @"_llgo_func$1BeCdGdxwWG-Dtl1HbNuSy2_sb8rBMTmu7zhcPPofmU", align 8
|
||||
%86 = load ptr, ptr @_llgo_Pointer, align 8
|
||||
%87 = icmp eq ptr %86, null
|
||||
br i1 %87, label %_llgo_17, label %_llgo_18
|
||||
|
||||
_llgo_17: ; preds = %_llgo_16
|
||||
%88 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 58)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %88)
|
||||
store ptr %88, ptr @_llgo_Pointer, align 8
|
||||
br label %_llgo_18
|
||||
|
||||
_llgo_18: ; preds = %_llgo_17, %_llgo_16
|
||||
%89 = load ptr, ptr @_llgo_Pointer, align 8
|
||||
%90 = load ptr, ptr @"_llgo_main.Tuple[error]", align 8
|
||||
%91 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%92 = getelementptr ptr, ptr %91, i64 0
|
||||
store ptr %90, ptr %92, align 8
|
||||
%93 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %91, 0
|
||||
%94 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %93, i64 1, 1
|
||||
%95 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %94, i64 1, 2
|
||||
%96 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%97 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %96, 0
|
||||
%98 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %97, i64 0, 1
|
||||
%99 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %98, i64 0, 2
|
||||
%100 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %95, %"github.com/goplus/llgo/internal/runtime.Slice" %99, i1 false)
|
||||
%101 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @8, i64 2 }, ptr %100, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%102 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 58)
|
||||
%103 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @9, i64 5 }, ptr %102, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%104 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 112)
|
||||
%105 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %104, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %101, ptr %105, align 8
|
||||
%106 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %104, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %103, ptr %106, align 8
|
||||
%107 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %104, 0
|
||||
%108 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %107, i64 2, 1
|
||||
%109 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %108, i64 2, 2
|
||||
%110 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %109)
|
||||
store ptr %110, ptr @"main.struct$vwhCZhgsid50r1SsT8OmKpRI0Cpljg78h5JlpD1CTR4", align 8
|
||||
%111 = load ptr, ptr @"main.struct$vwhCZhgsid50r1SsT8OmKpRI0Cpljg78h5JlpD1CTR4", align 8
|
||||
%112 = load ptr, ptr @"main.struct$vwhCZhgsid50r1SsT8OmKpRI0Cpljg78h5JlpD1CTR4", align 8
|
||||
%113 = load ptr, ptr @"_llgo_func$_so3zZGPIhTQghxFcf7CCCVzSOk2lxOt7xgGKcTzc0s", align 8
|
||||
%114 = icmp eq ptr %113, null
|
||||
br i1 %114, label %_llgo_19, label %_llgo_20
|
||||
|
||||
_llgo_19: ; preds = %_llgo_18
|
||||
%115 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%116 = getelementptr ptr, ptr %115, i64 0
|
||||
store ptr %112, ptr %116, align 8
|
||||
%117 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %115, 0
|
||||
%118 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %117, i64 1, 1
|
||||
%119 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %118, i64 1, 2
|
||||
%120 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%121 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %120, 0
|
||||
%122 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %121, i64 0, 1
|
||||
%123 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %122, i64 0, 2
|
||||
%124 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %119, %"github.com/goplus/llgo/internal/runtime.Slice" %123, i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %124)
|
||||
store ptr %124, ptr @"_llgo_func$_so3zZGPIhTQghxFcf7CCCVzSOk2lxOt7xgGKcTzc0s", align 8
|
||||
br label %_llgo_20
|
||||
|
||||
_llgo_20: ; preds = %_llgo_19, %_llgo_18
|
||||
%125 = load ptr, ptr @"_llgo_func$_so3zZGPIhTQghxFcf7CCCVzSOk2lxOt7xgGKcTzc0s", align 8
|
||||
%126 = load ptr, ptr @"main.struct$vwhCZhgsid50r1SsT8OmKpRI0Cpljg78h5JlpD1CTR4", align 8
|
||||
%127 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%128 = getelementptr ptr, ptr %127, i64 0
|
||||
store ptr %126, ptr %128, align 8
|
||||
%129 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %127, 0
|
||||
%130 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %129, i64 1, 1
|
||||
%131 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %130, i64 1, 2
|
||||
%132 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%133 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %132, 0
|
||||
%134 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %133, i64 0, 1
|
||||
%135 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %134, i64 0, 2
|
||||
%136 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %131, %"github.com/goplus/llgo/internal/runtime.Slice" %135, i1 false)
|
||||
%137 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @8, i64 2 }, ptr %136, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%138 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 58)
|
||||
%139 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @9, i64 5 }, ptr %138, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%140 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 112)
|
||||
%141 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %140, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %137, ptr %141, align 8
|
||||
%142 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %140, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %139, ptr %142, align 8
|
||||
%143 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %140, 0
|
||||
%144 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %143, i64 2, 1
|
||||
%145 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %144, i64 2, 2
|
||||
%146 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %145)
|
||||
store ptr %146, ptr @"main.struct$awGH2Wh33bS1v_s7SNAwKW27E20HcwiiPPzh9UA7QDs", align 8
|
||||
%147 = load ptr, ptr @"main.struct$awGH2Wh33bS1v_s7SNAwKW27E20HcwiiPPzh9UA7QDs", align 8
|
||||
%148 = load ptr, ptr @"main.struct$vwhCZhgsid50r1SsT8OmKpRI0Cpljg78h5JlpD1CTR4", align 8
|
||||
%149 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%150 = getelementptr ptr, ptr %149, i64 0
|
||||
store ptr %148, ptr %150, align 8
|
||||
%151 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %149, 0
|
||||
%152 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %151, i64 1, 1
|
||||
%153 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %152, i64 1, 2
|
||||
%154 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%155 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %154, 0
|
||||
%156 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %155, i64 0, 1
|
||||
%157 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %156, i64 0, 2
|
||||
%158 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %153, %"github.com/goplus/llgo/internal/runtime.Slice" %157, i1 false)
|
||||
%159 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @8, i64 2 }, ptr %158, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%160 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 58)
|
||||
%161 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @9, i64 5 }, ptr %160, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%162 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 112)
|
||||
%163 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %162, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %159, ptr %163, align 8
|
||||
%164 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %162, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %161, ptr %164, align 8
|
||||
%165 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %162, 0
|
||||
%166 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %165, i64 2, 1
|
||||
%167 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %166, i64 2, 2
|
||||
%168 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %167)
|
||||
%169 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @10, i64 2 }, ptr %168, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%170 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 56)
|
||||
%171 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %170, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %169, ptr %171, align 8
|
||||
%172 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %170, 0
|
||||
%173 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %172, i64 1, 1
|
||||
%174 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %173, i64 1, 2
|
||||
%175 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %174)
|
||||
store ptr %175, ptr @"main.struct$N1awC7qGapVTS_NFj1Q0jk6nCjATrIK-60oOEyDjabo", align 8
|
||||
%176 = load ptr, ptr @"main.struct$N1awC7qGapVTS_NFj1Q0jk6nCjATrIK-60oOEyDjabo", align 8
|
||||
%177 = load ptr, ptr @"_llgo_func$1BeCdGdxwWG-Dtl1HbNuSy2_sb8rBMTmu7zhcPPofmU", align 8
|
||||
%178 = load ptr, ptr @"main.struct$vwhCZhgsid50r1SsT8OmKpRI0Cpljg78h5JlpD1CTR4", align 8
|
||||
%179 = load ptr, ptr @"_llgo_func$_so3zZGPIhTQghxFcf7CCCVzSOk2lxOt7xgGKcTzc0s", align 8
|
||||
%180 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @11, i64 4 }, ptr undef, ptr undef, ptr undef }, ptr %179, 1
|
||||
%181 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %180, ptr @"main.(*future[main.Tuple[error]]).Then", 2
|
||||
%182 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %181, ptr @"main.(*future[main.Tuple[error]]).Then", 3
|
||||
%183 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
||||
%184 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %183, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %182, ptr %184, align 8
|
||||
%185 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %183, 0
|
||||
%186 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %185, i64 1, 1
|
||||
%187 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %186, i64 1, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %0, ptr %176, { ptr, i64, i64 } zeroinitializer, %"github.com/goplus/llgo/internal/runtime.Slice" %187)
|
||||
%188 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 6 }, i64 25, i64 24, i64 0, i64 1)
|
||||
%189 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %188)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %189)
|
||||
store ptr %189, ptr @"*_llgo_main.future[main.Tuple[error]]", align 8
|
||||
%190 = load ptr, ptr @"_llgo_func$_so3zZGPIhTQghxFcf7CCCVzSOk2lxOt7xgGKcTzc0s", align 8
|
||||
%191 = load ptr, ptr @"_llgo_iface$pTofAxYfPZHsCMD5T70nrOx1gjHf9m2QCLNvEOl1py0", align 8
|
||||
%192 = icmp eq ptr %191, null
|
||||
br i1 %192, label %_llgo_21, label %_llgo_22
|
||||
|
||||
_llgo_21: ; preds = %_llgo_20
|
||||
%193 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @11, i64 4 }, ptr undef }, ptr %190, 1
|
||||
%194 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
|
||||
%195 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %194, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %193, ptr %195, align 8
|
||||
%196 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %194, 0
|
||||
%197 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %196, i64 1, 1
|
||||
%198 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %197, i64 1, 2
|
||||
%199 = call ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, %"github.com/goplus/llgo/internal/runtime.Slice" %198)
|
||||
store ptr %199, ptr @"_llgo_iface$pTofAxYfPZHsCMD5T70nrOx1gjHf9m2QCLNvEOl1py0", align 8
|
||||
br label %_llgo_22
|
||||
|
||||
_llgo_22: ; preds = %_llgo_21, %_llgo_20
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", i64, i64, i64, i64)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
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.AllocU"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr, ptr, %"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
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.Slice")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr, ptr)
|
||||
|
||||
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
|
||||
25
compiler/cl/_testrt/typalias/in.go
Normal file
25
compiler/cl/_testrt/typalias/in.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import "C"
|
||||
import _ "unsafe"
|
||||
|
||||
//go:linkname printf C.printf
|
||||
func printf(format *int8, __llgo_va_list ...any)
|
||||
|
||||
type Foo = struct {
|
||||
A C.int
|
||||
ok bool
|
||||
}
|
||||
|
||||
var format = [...]int8{'H', 'e', 'l', 'l', 'o', ' ', '%', 'd', '\n', 0}
|
||||
|
||||
func Print(p *Foo) {
|
||||
if p.ok {
|
||||
printf(&format[0], p.A)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
foo := &Foo{100, true}
|
||||
Print(foo)
|
||||
}
|
||||
82
compiler/cl/_testrt/typalias/out.ll
Normal file
82
compiler/cl/_testrt/typalias/out.ll
Normal file
@@ -0,0 +1,82 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
|
||||
@"github.com/goplus/llgo/internal/runtime.cgoAlwaysFalse" = external global i1, align 1
|
||||
@main.format = global [10 x i8] zeroinitializer, align 1
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.Print(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = getelementptr inbounds { i32, i1 }, ptr %0, i32 0, i32 1
|
||||
%2 = load i1, ptr %1, align 1
|
||||
br i1 %2, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%3 = getelementptr inbounds { i32, i1 }, ptr %0, i32 0, i32 0
|
||||
%4 = load i32, ptr %3, align 4
|
||||
call void (ptr, ...) @printf(ptr @main.format, i32 %4)
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define ptr @main._Cgo_ptr(ptr %0) {
|
||||
_llgo_0:
|
||||
ret ptr %0
|
||||
}
|
||||
|
||||
declare void @runtime.cgoUse(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
declare void @main._cgoCheckResult(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @syscall.init()
|
||||
store i8 72, ptr @main.format, align 1
|
||||
store i8 101, ptr getelementptr inbounds (i8, ptr @main.format, i64 1), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @main.format, i64 2), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @main.format, i64 3), align 1
|
||||
store i8 111, ptr getelementptr inbounds (i8, ptr @main.format, i64 4), align 1
|
||||
store i8 32, ptr getelementptr inbounds (i8, ptr @main.format, i64 5), align 1
|
||||
store i8 37, ptr getelementptr inbounds (i8, ptr @main.format, i64 6), align 1
|
||||
store i8 100, ptr getelementptr inbounds (i8, ptr @main.format, i64 7), align 1
|
||||
store i8 10, ptr getelementptr inbounds (i8, ptr @main.format, i64 8), align 1
|
||||
store i8 0, ptr getelementptr inbounds (i8, ptr @main.format, i64 9), align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%3 = getelementptr inbounds { i32, i1 }, ptr %2, i32 0, i32 0
|
||||
%4 = getelementptr inbounds { i32, i1 }, ptr %2, i32 0, i32 1
|
||||
store i32 100, ptr %3, align 4
|
||||
store i1 true, ptr %4, align 1
|
||||
call void @main.Print(ptr %2)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @printf(ptr, ...)
|
||||
|
||||
declare void @syscall.init()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user