build: separate compiler and libs
This commit is contained in:
8
compiler/cl/_testdata/apkg/in.go
Normal file
8
compiler/cl/_testdata/apkg/in.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package apkg
|
||||
|
||||
func Max(a, b float64) float64 {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
29
compiler/cl/_testdata/apkg/out.ll
Normal file
29
compiler/cl/_testdata/apkg/out.ll
Normal file
@@ -0,0 +1,29 @@
|
||||
; ModuleID = 'github.com/goplus/llgo/cl/_testdata/apkg'
|
||||
source_filename = "github.com/goplus/llgo/cl/_testdata/apkg"
|
||||
|
||||
@"github.com/goplus/llgo/cl/_testdata/apkg.init$guard" = global i1 false, align 1
|
||||
|
||||
define double @"github.com/goplus/llgo/cl/_testdata/apkg.Max"(double %0, double %1) {
|
||||
_llgo_0:
|
||||
%2 = fcmp ogt double %0, %1
|
||||
br i1 %2, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
ret double %0
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret double %1
|
||||
}
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testdata/apkg.init"() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"github.com/goplus/llgo/cl/_testdata/apkg.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/_testdata/apkg.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
1
compiler/cl/_testdata/debug/flags.txt
Normal file
1
compiler/cl/_testdata/debug/flags.txt
Normal file
@@ -0,0 +1 @@
|
||||
-dbg
|
||||
569
compiler/cl/_testdata/debug/in.go
Normal file
569
compiler/cl/_testdata/debug/in.go
Normal file
@@ -0,0 +1,569 @@
|
||||
package main
|
||||
|
||||
import "errors"
|
||||
|
||||
type Base struct {
|
||||
name string
|
||||
}
|
||||
|
||||
type E struct {
|
||||
// Base
|
||||
i int
|
||||
}
|
||||
type StructWithAllTypeFields struct {
|
||||
i8 int8
|
||||
i16 int16
|
||||
i32 int32
|
||||
i64 int64
|
||||
i int
|
||||
u8 uint8
|
||||
u16 uint16
|
||||
u32 uint32
|
||||
u64 uint64
|
||||
u uint
|
||||
f32 float32
|
||||
f64 float64
|
||||
b bool
|
||||
c64 complex64
|
||||
c128 complex128
|
||||
slice []int
|
||||
arr [3]int
|
||||
arr2 [3]E
|
||||
s string
|
||||
e E
|
||||
pf *StructWithAllTypeFields // resursive
|
||||
pi *int
|
||||
intr Interface
|
||||
m map[string]uint64
|
||||
c chan int
|
||||
err error
|
||||
fn func(string) (int, error)
|
||||
pad1 int
|
||||
pad2 int
|
||||
}
|
||||
|
||||
type Interface interface {
|
||||
Foo(a []int, b string) int
|
||||
}
|
||||
|
||||
type Struct struct{}
|
||||
|
||||
func (s *Struct) Foo(a []int, b string) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
func FuncWithAllTypeStructParam(s StructWithAllTypeFields) {
|
||||
println(&s)
|
||||
// Expected:
|
||||
// all variables: s
|
||||
// s.i8: '\x01'
|
||||
// s.i16: 2
|
||||
// s.i32: 3
|
||||
// s.i64: 4
|
||||
// s.i: 5
|
||||
// s.u8: '\x06'
|
||||
// s.u16: 7
|
||||
// s.u32: 8
|
||||
// s.u64: 9
|
||||
// s.u: 10
|
||||
// s.f32: 11
|
||||
// s.f64: 12
|
||||
// s.b: true
|
||||
// s.c64: complex64{real = 13, imag = 14}
|
||||
// s.c128: complex128{real = 15, imag = 16}
|
||||
// s.slice: []int{21, 22, 23}
|
||||
// s.arr: [3]int{24, 25, 26}
|
||||
// s.arr2: [3]github.com/goplus/llgo/compiler/cl/_testdata/debug.E{{i = 27}, {i = 28}, {i = 29}}
|
||||
// s.s: "hello"
|
||||
// s.e: github.com/goplus/llgo/compiler/cl/_testdata/debug.E{i = 30}
|
||||
// s.pad1: 100
|
||||
// s.pad2: 200
|
||||
s.i8 = '\b'
|
||||
// Expected:
|
||||
// s.i8: '\b'
|
||||
// s.i16: 2
|
||||
println(len(s.s), s.i8)
|
||||
}
|
||||
|
||||
// Params is a function with all types of parameters.
|
||||
func FuncWithAllTypeParams(
|
||||
i8 int8,
|
||||
i16 int16,
|
||||
i32 int32,
|
||||
i64 int64,
|
||||
i int,
|
||||
u8 uint8,
|
||||
u16 uint16,
|
||||
u32 uint32,
|
||||
u64 uint64,
|
||||
u uint,
|
||||
f32 float32,
|
||||
f64 float64,
|
||||
b bool,
|
||||
c64 complex64,
|
||||
c128 complex128,
|
||||
slice []int,
|
||||
arr [3]int,
|
||||
arr2 [3]E,
|
||||
s string,
|
||||
e E,
|
||||
f StructWithAllTypeFields,
|
||||
pf *StructWithAllTypeFields,
|
||||
pi *int,
|
||||
intr Interface,
|
||||
m map[string]uint64,
|
||||
c chan int,
|
||||
err error,
|
||||
fn func(string) (int, error),
|
||||
) (int, error) {
|
||||
// Expected:
|
||||
// all variables: i8 i16 i32 i64 i u8 u16 u32 u64 u f32 f64 b c64 c128 slice arr arr2 s e f pf pi intr m c err fn
|
||||
// i32: 3
|
||||
// i64: 4
|
||||
// i: 5
|
||||
// u32: 8
|
||||
// u64: 9
|
||||
// u: 10
|
||||
// f32: 11
|
||||
// f64: 12
|
||||
// slice: []int{21, 22, 23}
|
||||
// arr: [3]int{24, 25, 26}
|
||||
// arr2: [3]github.com/goplus/llgo/compiler/cl/_testdata/debug.E{{i = 27}, {i = 28}, {i = 29}}
|
||||
// slice[0]: 21
|
||||
// slice[1]: 22
|
||||
// slice[2]: 23
|
||||
// arr[0]: 24
|
||||
// arr[1]: 25
|
||||
// arr[2]: 26
|
||||
// arr2[0].i: 27
|
||||
// arr2[1].i: 28
|
||||
// arr2[2].i: 29
|
||||
// e: github.com/goplus/llgo/compiler/cl/_testdata/debug.E{i = 30}
|
||||
|
||||
// Expected(skip):
|
||||
// i8: '\b'
|
||||
// i16: 2
|
||||
// u8: '\x06'
|
||||
// u16: 7
|
||||
// b: true
|
||||
println(
|
||||
i8, i16, i32, i64, i, u8, u16, u32, u64, u,
|
||||
f32, f64, b,
|
||||
c64, c128,
|
||||
slice, arr[0:],
|
||||
s,
|
||||
&e,
|
||||
&f, pf, pi, intr, m,
|
||||
c,
|
||||
err,
|
||||
fn,
|
||||
)
|
||||
i8 = 9
|
||||
i16 = 10
|
||||
i32 = 11
|
||||
i64 = 12
|
||||
i = 13
|
||||
u8 = 14
|
||||
u16 = 15
|
||||
u32 = 16
|
||||
u64 = 17
|
||||
u = 18
|
||||
f32 = 19
|
||||
f64 = 20
|
||||
b = false
|
||||
c64 = 21 + 22i
|
||||
c128 = 23 + 24i
|
||||
slice = []int{31, 32, 33}
|
||||
arr = [3]int{34, 35, 36}
|
||||
arr2 = [3]E{{i: 37}, {i: 38}, {i: 39}}
|
||||
s = "world"
|
||||
e = E{i: 40}
|
||||
|
||||
println(i8, i16, i32, i64, i, u8, u16, u32, u64, u,
|
||||
f32, f64, b,
|
||||
c64, c128,
|
||||
slice, arr[0:], &arr2,
|
||||
s,
|
||||
&e,
|
||||
&f, pf, pi, intr, m,
|
||||
c,
|
||||
err,
|
||||
fn,
|
||||
)
|
||||
// Expected:
|
||||
// i8: '\t'
|
||||
// i16: 10
|
||||
// i32: 11
|
||||
// i64: 12
|
||||
// i: 13
|
||||
// u8: '\x0e'
|
||||
// u16: 15
|
||||
// u32: 16
|
||||
// u64: 17
|
||||
// u: 18
|
||||
// f32: 19
|
||||
// f64: 20
|
||||
// b: false
|
||||
// c64: complex64{real = 21, imag = 22}
|
||||
// c128: complex128{real = 23, imag = 24}
|
||||
// slice: []int{31, 32, 33}
|
||||
// arr2: [3]github.com/goplus/llgo/compiler/cl/_testdata/debug.E{{i = 37}, {i = 38}, {i = 39}}
|
||||
// s: "world"
|
||||
// e: github.com/goplus/llgo/compiler/cl/_testdata/debug.E{i = 40}
|
||||
|
||||
// Expected(skip):
|
||||
// arr: [3]int{34, 35, 36}
|
||||
return 1, errors.New("some error")
|
||||
}
|
||||
|
||||
type TinyStruct struct {
|
||||
I int
|
||||
}
|
||||
|
||||
type SmallStruct struct {
|
||||
I int
|
||||
J int
|
||||
}
|
||||
|
||||
type MidStruct struct {
|
||||
I int
|
||||
J int
|
||||
K int
|
||||
}
|
||||
|
||||
type BigStruct struct {
|
||||
I int
|
||||
J int
|
||||
K int
|
||||
L int
|
||||
M int
|
||||
N int
|
||||
O int
|
||||
P int
|
||||
Q int
|
||||
R int
|
||||
}
|
||||
|
||||
func FuncStructParams(t TinyStruct, s SmallStruct, m MidStruct, b BigStruct) {
|
||||
// println(&t, &s, &m, &b)
|
||||
// Expected:
|
||||
// all variables: t s m b
|
||||
// t.I: 1
|
||||
// s.I: 2
|
||||
// s.J: 3
|
||||
// m.I: 4
|
||||
// m.J: 5
|
||||
// m.K: 6
|
||||
// b.I: 7
|
||||
// b.J: 8
|
||||
// b.K: 9
|
||||
// b.L: 10
|
||||
// b.M: 11
|
||||
// b.N: 12
|
||||
// b.O: 13
|
||||
// b.P: 14
|
||||
// b.Q: 15
|
||||
// b.R: 16
|
||||
println(t.I, s.I, s.J, m.I, m.J, m.K, b.I, b.J, b.K, b.L, b.M, b.N, b.O, b.P, b.Q, b.R)
|
||||
t.I = 10
|
||||
s.I = 20
|
||||
s.J = 21
|
||||
m.I = 40
|
||||
m.J = 41
|
||||
m.K = 42
|
||||
b.I = 70
|
||||
b.J = 71
|
||||
b.K = 72
|
||||
b.L = 73
|
||||
b.M = 74
|
||||
b.N = 75
|
||||
b.O = 76
|
||||
b.P = 77
|
||||
b.Q = 78
|
||||
b.R = 79
|
||||
// Expected:
|
||||
// all variables: t s m b
|
||||
// t.I: 10
|
||||
// s.I: 20
|
||||
// s.J: 21
|
||||
// m.I: 40
|
||||
// m.J: 41
|
||||
// m.K: 42
|
||||
// b.I: 70
|
||||
// b.J: 71
|
||||
// b.K: 72
|
||||
// b.L: 73
|
||||
// b.M: 74
|
||||
// b.N: 75
|
||||
// b.O: 76
|
||||
// b.P: 77
|
||||
// b.Q: 78
|
||||
// b.R: 79
|
||||
println("done")
|
||||
}
|
||||
|
||||
func FuncStructPtrParams(t *TinyStruct, s *SmallStruct, m *MidStruct, b *BigStruct) {
|
||||
// Expected:
|
||||
// all variables: t s m b
|
||||
// t.I: 1
|
||||
// s.I: 2
|
||||
// s.J: 3
|
||||
// m.I: 4
|
||||
// m.J: 5
|
||||
// m.K: 6
|
||||
// b.I: 7
|
||||
// b.J: 8
|
||||
// b.K: 9
|
||||
// b.L: 10
|
||||
// b.M: 11
|
||||
// b.N: 12
|
||||
// b.O: 13
|
||||
// b.P: 14
|
||||
// b.Q: 15
|
||||
// b.R: 16
|
||||
println(t, s, m, b)
|
||||
t.I = 10
|
||||
s.I = 20
|
||||
s.J = 21
|
||||
m.I = 40
|
||||
m.J = 41
|
||||
m.K = 42
|
||||
b.I = 70
|
||||
b.J = 71
|
||||
b.K = 72
|
||||
b.L = 73
|
||||
b.M = 74
|
||||
b.N = 75
|
||||
b.O = 76
|
||||
b.P = 77
|
||||
b.Q = 78
|
||||
b.R = 79
|
||||
// Expected:
|
||||
// all variables: t s m b
|
||||
// t.I: 10
|
||||
// s.I: 20
|
||||
// s.J: 21
|
||||
// m.I: 40
|
||||
// m.J: 41
|
||||
// m.K: 42
|
||||
// b.I: 70
|
||||
// b.J: 71
|
||||
// b.K: 72
|
||||
// b.L: 73
|
||||
// b.M: 74
|
||||
// b.N: 75
|
||||
// b.O: 76
|
||||
// b.P: 77
|
||||
// b.Q: 78
|
||||
// b.R: 79
|
||||
println(t.I, s.I, s.J, m.I, m.J, m.K, b.I, b.J, b.K, b.L, b.M, b.N, b.O, b.P, b.Q, b.R)
|
||||
println("done")
|
||||
}
|
||||
|
||||
func ScopeIf(branch int) {
|
||||
a := 1
|
||||
// Expected:
|
||||
// all variables: a branch
|
||||
// a: 1
|
||||
if branch == 1 {
|
||||
b := 2
|
||||
c := 3
|
||||
// Expected:
|
||||
// all variables: a b c branch
|
||||
// a: 1
|
||||
// b: 2
|
||||
// c: 3
|
||||
// branch: 1
|
||||
println(a, b, c)
|
||||
} else {
|
||||
c := 3
|
||||
d := 4
|
||||
// Expected:
|
||||
// all variables: a c d branch
|
||||
// a: 1
|
||||
// c: 3
|
||||
// d: 4
|
||||
// branch: 0
|
||||
println(a, c, d)
|
||||
}
|
||||
// Expected:
|
||||
// all variables: a branch
|
||||
// a: 1
|
||||
println("a:", a)
|
||||
}
|
||||
|
||||
func ScopeFor() {
|
||||
a := 1
|
||||
for i := 0; i < 10; i++ {
|
||||
switch i {
|
||||
case 0:
|
||||
println("i is 0")
|
||||
// Expected:
|
||||
// all variables: i a
|
||||
// i: 0
|
||||
// a: 1
|
||||
println("i:", i)
|
||||
case 1:
|
||||
println("i is 1")
|
||||
// Expected:
|
||||
// all variables: i a
|
||||
// i: 1
|
||||
// a: 1
|
||||
println("i:", i)
|
||||
default:
|
||||
println("i is", i)
|
||||
}
|
||||
}
|
||||
println("a:", a)
|
||||
}
|
||||
|
||||
func ScopeSwitch(i int) {
|
||||
a := 0
|
||||
switch i {
|
||||
case 1:
|
||||
b := 1
|
||||
println("i is 1")
|
||||
// Expected:
|
||||
// all variables: i a b
|
||||
// i: 1
|
||||
// a: 0
|
||||
// b: 1
|
||||
println("i:", i, "a:", a, "b:", b)
|
||||
case 2:
|
||||
c := 2
|
||||
println("i is 2")
|
||||
// Expected:
|
||||
// all variables: i a c
|
||||
// i: 2
|
||||
// a: 0
|
||||
// c: 2
|
||||
println("i:", i, "a:", a, "c:", c)
|
||||
default:
|
||||
d := 3
|
||||
println("i is", i)
|
||||
// Expected:
|
||||
// all variables: i a d
|
||||
// i: 3
|
||||
// a: 0
|
||||
// d: 3
|
||||
println("i:", i, "a:", a, "d:", d)
|
||||
}
|
||||
// Expected:
|
||||
// all variables: a i
|
||||
// a: 0
|
||||
println("a:", a)
|
||||
}
|
||||
|
||||
func main() {
|
||||
FuncStructParams(TinyStruct{I: 1}, SmallStruct{I: 2, J: 3}, MidStruct{I: 4, J: 5, K: 6}, BigStruct{I: 7, J: 8, K: 9, L: 10, M: 11, N: 12, O: 13, P: 14, Q: 15, R: 16})
|
||||
FuncStructPtrParams(&TinyStruct{I: 1}, &SmallStruct{I: 2, J: 3}, &MidStruct{I: 4, J: 5, K: 6}, &BigStruct{I: 7, J: 8, K: 9, L: 10, M: 11, N: 12, O: 13, P: 14, Q: 15, R: 16})
|
||||
i := 100
|
||||
s := StructWithAllTypeFields{
|
||||
i8: 1,
|
||||
i16: 2,
|
||||
i32: 3,
|
||||
i64: 4,
|
||||
i: 5,
|
||||
u8: 6,
|
||||
u16: 7,
|
||||
u32: 8,
|
||||
u64: 9,
|
||||
u: 10,
|
||||
f32: 11,
|
||||
f64: 12,
|
||||
b: true,
|
||||
c64: 13 + 14i,
|
||||
c128: 15 + 16i,
|
||||
slice: []int{21, 22, 23},
|
||||
arr: [3]int{24, 25, 26},
|
||||
arr2: [3]E{{i: 27}, {i: 28}, {i: 29}},
|
||||
s: "hello",
|
||||
e: E{i: 30},
|
||||
pf: &StructWithAllTypeFields{i16: 100},
|
||||
pi: &i,
|
||||
intr: &Struct{},
|
||||
m: map[string]uint64{"a": 31, "b": 32},
|
||||
c: make(chan int),
|
||||
err: errors.New("Test error"),
|
||||
fn: func(s string) (int, error) {
|
||||
println("fn:", s)
|
||||
i = 201
|
||||
return 1, errors.New("fn error")
|
||||
},
|
||||
pad1: 100,
|
||||
pad2: 200,
|
||||
}
|
||||
// Expected:
|
||||
// all variables: s i err
|
||||
// s.i8: '\x01'
|
||||
// s.i16: 2
|
||||
// s.i32: 3
|
||||
// s.i64: 4
|
||||
// s.i: 5
|
||||
// s.u8: '\x06'
|
||||
// s.u16: 7
|
||||
// s.u32: 8
|
||||
// s.u64: 9
|
||||
// s.u: 10
|
||||
// s.f32: 11
|
||||
// s.f64: 12
|
||||
// s.b: true
|
||||
// s.c64: complex64{real = 13, imag = 14}
|
||||
// s.c128: complex128{real = 15, imag = 16}
|
||||
// s.slice: []int{21, 22, 23}
|
||||
// s.arr: [3]int{24, 25, 26}
|
||||
// s.arr2: [3]github.com/goplus/llgo/compiler/cl/_testdata/debug.E{{i = 27}, {i = 28}, {i = 29}}
|
||||
// s.s: "hello"
|
||||
// s.e: github.com/goplus/llgo/compiler/cl/_testdata/debug.E{i = 30}
|
||||
// s.pf.i16: 100
|
||||
// *(s.pf).i16: 100
|
||||
// *(s.pi): 100
|
||||
globalStructPtr = &s
|
||||
globalStruct = s
|
||||
println("globalInt:", globalInt)
|
||||
// Expected(skip):
|
||||
// all variables: globalInt globalStruct globalStructPtr s i err
|
||||
println("s:", &s)
|
||||
FuncWithAllTypeStructParam(s)
|
||||
println("called function with struct")
|
||||
i, err := FuncWithAllTypeParams(
|
||||
s.i8, s.i16, s.i32, s.i64, s.i, s.u8, s.u16, s.u32, s.u64, s.u,
|
||||
s.f32, s.f64, s.b,
|
||||
s.c64, s.c128,
|
||||
s.slice, s.arr, s.arr2,
|
||||
s.s,
|
||||
s.e, s,
|
||||
s.pf, s.pi,
|
||||
s.intr,
|
||||
s.m,
|
||||
s.c,
|
||||
s.err,
|
||||
s.fn,
|
||||
)
|
||||
println(i, err)
|
||||
ScopeIf(1)
|
||||
ScopeIf(0)
|
||||
ScopeFor()
|
||||
ScopeSwitch(1)
|
||||
ScopeSwitch(2)
|
||||
ScopeSwitch(3)
|
||||
println(globalStructPtr)
|
||||
println(&globalStruct)
|
||||
s.i8 = 0x12
|
||||
println(s.i8)
|
||||
// Expected:
|
||||
// all variables: s i err
|
||||
// s.i8: '\x12'
|
||||
|
||||
// Expected(skip):
|
||||
// globalStruct.i8: '\x01'
|
||||
println((*globalStructPtr).i8)
|
||||
println("done")
|
||||
println("")
|
||||
println(&s, &globalStruct, globalStructPtr.i16, globalStructPtr)
|
||||
globalStructPtr = nil
|
||||
}
|
||||
|
||||
var globalInt int = 301
|
||||
var globalStruct StructWithAllTypeFields
|
||||
var globalStructPtr *StructWithAllTypeFields
|
||||
1
compiler/cl/_testdata/debug/out.ll
Normal file
1
compiler/cl/_testdata/debug/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
12
compiler/cl/_testdata/fncall/in.go
Normal file
12
compiler/cl/_testdata/fncall/in.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
func max(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func main() {
|
||||
_ = max(1, 2)
|
||||
}
|
||||
43
compiler/cl/_testdata/fncall/out.ll
Normal file
43
compiler/cl/_testdata/fncall/out.ll
Normal file
@@ -0,0 +1,43 @@
|
||||
; 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 i64 @main.max(i64 1, i64 2)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define i64 @main.max(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = icmp sgt i64 %0, %1
|
||||
br i1 %2, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
ret i64 %0
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret i64 %1
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
10
compiler/cl/_testdata/importpkg/in.go
Normal file
10
compiler/cl/_testdata/importpkg/in.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import "github.com/goplus/llgo/compiler/cl/internal/stdio"
|
||||
|
||||
var hello = [...]int8{'H', 'e', 'l', 'l', 'o', '\n', 0}
|
||||
|
||||
func main() {
|
||||
_ = stdio.Max(2, 100)
|
||||
stdio.Printf(&hello[0])
|
||||
}
|
||||
47
compiler/cl/_testdata/importpkg/out.ll
Normal file
47
compiler/cl/_testdata/importpkg/out.ll
Normal file
@@ -0,0 +1,47 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@main.hello = global [7 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
|
||||
call void @"github.com/goplus/llgo/cl/internal/stdio.init"()
|
||||
store i8 72, ptr @main.hello, align 1
|
||||
store i8 101, ptr getelementptr inbounds (i8, ptr @main.hello, i64 1), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @main.hello, i64 2), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @main.hello, i64 3), align 1
|
||||
store i8 111, ptr getelementptr inbounds (i8, ptr @main.hello, i64 4), align 1
|
||||
store i8 10, ptr getelementptr inbounds (i8, ptr @main.hello, i64 5), align 1
|
||||
store i8 0, ptr getelementptr inbounds (i8, ptr @main.hello, i64 6), 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 i64 @"github.com/goplus/llgo/cl/internal/stdio.Max"(i64 2, i64 100)
|
||||
call void (ptr, ...) @printf(ptr @main.hello)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/cl/internal/stdio.init"()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare i64 @"github.com/goplus/llgo/cl/internal/stdio.Max"(i64, i64)
|
||||
|
||||
declare void @printf(ptr, ...)
|
||||
7
compiler/cl/_testdata/llgotag/in.go
Normal file
7
compiler/cl/_testdata/llgotag/in.go
Normal file
@@ -0,0 +1,7 @@
|
||||
//go:build llgo
|
||||
// +build llgo
|
||||
|
||||
package llgotag
|
||||
|
||||
func Foo() {
|
||||
}
|
||||
22
compiler/cl/_testdata/llgotag/out.ll
Normal file
22
compiler/cl/_testdata/llgotag/out.ll
Normal file
@@ -0,0 +1,22 @@
|
||||
; ModuleID = 'github.com/goplus/llgo/cl/_testdata/llgotag'
|
||||
source_filename = "github.com/goplus/llgo/cl/_testdata/llgotag"
|
||||
|
||||
@"github.com/goplus/llgo/cl/_testdata/llgotag.init$guard" = global i1 false, align 1
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testdata/llgotag.Foo"() {
|
||||
_llgo_0:
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testdata/llgotag.init"() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"github.com/goplus/llgo/cl/_testdata/llgotag.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/_testdata/llgotag.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
19
compiler/cl/_testdata/method/in.go
Normal file
19
compiler/cl/_testdata/method/in.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import _ "unsafe"
|
||||
|
||||
type T int
|
||||
|
||||
func (a T) Add(b T) T {
|
||||
return a + b
|
||||
}
|
||||
|
||||
//go:linkname printf C.printf
|
||||
func printf(format *int8, __llgo_va_list ...any)
|
||||
|
||||
var format = [...]int8{'H', 'e', 'l', 'l', 'o', ' ', '%', 'd', '\n', 0}
|
||||
|
||||
func main() {
|
||||
a := T(1)
|
||||
printf(&format[0], a.Add(2))
|
||||
}
|
||||
58
compiler/cl/_testdata/method/out.ll
Normal file
58
compiler/cl/_testdata/method/out.ll
Normal file
@@ -0,0 +1,58 @@
|
||||
; 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 i64 @main.T.Add(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = add i64 %0, %1
|
||||
ret i64 %2
|
||||
}
|
||||
|
||||
define i64 @"main.(*T).Add"(ptr %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = load i64, ptr %0, align 4
|
||||
%3 = call i64 @main.T.Add(i64 %2, i64 %1)
|
||||
ret i64 %3
|
||||
}
|
||||
|
||||
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 i64 @main.T.Add(i64 1, i64 2)
|
||||
call void (ptr, ...) @printf(ptr @main.format, i64 %2)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare void @printf(ptr, ...)
|
||||
277
compiler/cl/_testdata/print/in.go
Normal file
277
compiler/cl/_testdata/print/in.go
Normal file
@@ -0,0 +1,277 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
func gwrite(b []byte) {
|
||||
if len(b) == 0 {
|
||||
return
|
||||
}
|
||||
for _, v := range b {
|
||||
c.Printf(c.Str("%c"), v)
|
||||
}
|
||||
}
|
||||
|
||||
func printbool(v bool) {
|
||||
if v {
|
||||
printstring("true")
|
||||
} else {
|
||||
printstring("false")
|
||||
}
|
||||
}
|
||||
|
||||
func printfloat(v float64) {
|
||||
switch {
|
||||
case v != v:
|
||||
printstring("NaN")
|
||||
return
|
||||
case v+v == v && v > 0:
|
||||
printstring("+Inf")
|
||||
return
|
||||
case v+v == v && v < 0:
|
||||
printstring("-Inf")
|
||||
return
|
||||
}
|
||||
|
||||
const n = 7 // digits printed
|
||||
var buf [n + 7]byte
|
||||
buf[0] = '+'
|
||||
e := 0 // exp
|
||||
if v == 0 {
|
||||
if 1/v < 0 {
|
||||
buf[0] = '-'
|
||||
}
|
||||
} else {
|
||||
if v < 0 {
|
||||
v = -v
|
||||
buf[0] = '-'
|
||||
}
|
||||
|
||||
// normalize
|
||||
for v >= 10 {
|
||||
e++
|
||||
v /= 10
|
||||
}
|
||||
for v < 1 {
|
||||
e--
|
||||
v *= 10
|
||||
}
|
||||
|
||||
// round
|
||||
h := 5.0
|
||||
for i := 0; i < n; i++ {
|
||||
h /= 10
|
||||
}
|
||||
v += h
|
||||
if v >= 10 {
|
||||
e++
|
||||
v /= 10
|
||||
}
|
||||
}
|
||||
|
||||
// format +d.dddd+edd
|
||||
for i := 0; i < n; i++ {
|
||||
s := int(v)
|
||||
buf[i+2] = byte(s + '0')
|
||||
v -= float64(s)
|
||||
v *= 10
|
||||
}
|
||||
buf[1] = buf[2]
|
||||
buf[2] = '.'
|
||||
|
||||
buf[n+2] = 'e'
|
||||
buf[n+3] = '+'
|
||||
if e < 0 {
|
||||
e = -e
|
||||
buf[n+3] = '-'
|
||||
}
|
||||
|
||||
buf[n+4] = byte(e/100) + '0'
|
||||
buf[n+5] = byte(e/10)%10 + '0'
|
||||
buf[n+6] = byte(e%10) + '0'
|
||||
gwrite(buf[:])
|
||||
}
|
||||
|
||||
func printuint(v uint64) {
|
||||
var buf [100]byte
|
||||
i := len(buf)
|
||||
for i--; i > 0; i-- {
|
||||
buf[i] = byte(v%10 + '0')
|
||||
if v < 10 {
|
||||
break
|
||||
}
|
||||
v /= 10
|
||||
}
|
||||
gwrite(buf[i:])
|
||||
}
|
||||
|
||||
func printint(v int64) {
|
||||
if v < 0 {
|
||||
printstring("-")
|
||||
v = -v
|
||||
}
|
||||
printuint(uint64(v))
|
||||
}
|
||||
|
||||
var minhexdigits = 0
|
||||
|
||||
func printhex(v uint64) {
|
||||
const dig = "0123456789abcdef"
|
||||
var buf [100]byte
|
||||
i := len(buf)
|
||||
for i--; i > 0; i-- {
|
||||
buf[i] = dig[v%16]
|
||||
if v < 16 && len(buf)-i >= minhexdigits {
|
||||
break
|
||||
}
|
||||
v /= 16
|
||||
}
|
||||
i--
|
||||
buf[i] = 'x'
|
||||
i--
|
||||
buf[i] = '0'
|
||||
gwrite(buf[i:])
|
||||
}
|
||||
|
||||
func printsp() {
|
||||
printstring(" ")
|
||||
}
|
||||
|
||||
func printnl() {
|
||||
printstring("\n")
|
||||
}
|
||||
|
||||
func printstring(s string) {
|
||||
gwrite(bytes(s))
|
||||
}
|
||||
|
||||
type slice struct {
|
||||
array unsafe.Pointer
|
||||
len int
|
||||
cap int
|
||||
}
|
||||
|
||||
type stringStruct struct {
|
||||
str unsafe.Pointer
|
||||
len int
|
||||
}
|
||||
|
||||
func stringStructOf(sp *string) *stringStruct {
|
||||
return (*stringStruct)(unsafe.Pointer(sp))
|
||||
}
|
||||
|
||||
func bytes(s string) (ret []byte) {
|
||||
rp := (*slice)(unsafe.Pointer(&ret))
|
||||
sp := stringStructOf(&s)
|
||||
rp.array = sp.str
|
||||
rp.len = sp.len
|
||||
rp.cap = sp.len
|
||||
return
|
||||
}
|
||||
|
||||
func main() {
|
||||
printstring("llgo")
|
||||
printnl()
|
||||
printuint(1024)
|
||||
printnl()
|
||||
printhex(0x1234abcf)
|
||||
printnl()
|
||||
prinxor(1)
|
||||
printnl()
|
||||
prinsub(100)
|
||||
printnl()
|
||||
prinusub(1<<64 - 1)
|
||||
printnl()
|
||||
prinfsub(100.1)
|
||||
printnl()
|
||||
printany(float32(1e9))
|
||||
printnl()
|
||||
printany(float64(2e9))
|
||||
printnl()
|
||||
var b bool = true
|
||||
if b == true && b != false {
|
||||
println("check bool", b)
|
||||
}
|
||||
n1 := 0b1001
|
||||
n2 := 0b0011
|
||||
println("check &^", n1&^n2 == 0b1000, n2&^n1 == 0b0010)
|
||||
println(true, false, 'a', 'A', rune('中'),
|
||||
int8(1), int16(2), int32(3), int64(4), 5,
|
||||
uint8(1), uint16(2), uint32(3), uint64(4), uintptr(5),
|
||||
"llgo")
|
||||
println(1 + 2i)
|
||||
}
|
||||
|
||||
func println(args ...any) {
|
||||
for i, v := range args {
|
||||
if i != 0 {
|
||||
printstring(" ")
|
||||
}
|
||||
printany(v)
|
||||
}
|
||||
printnl()
|
||||
}
|
||||
|
||||
func printany(v any) {
|
||||
switch v := v.(type) {
|
||||
case bool:
|
||||
printbool(v)
|
||||
case int:
|
||||
printint(int64(v))
|
||||
case int8:
|
||||
printint(int64(v))
|
||||
case int16:
|
||||
printint(int64(v))
|
||||
case int32:
|
||||
printint(int64(v))
|
||||
case int64:
|
||||
printint(int64(v))
|
||||
case uint:
|
||||
printuint(uint64(v))
|
||||
case uint8:
|
||||
printuint(uint64(v))
|
||||
case uint16:
|
||||
printuint(uint64(v))
|
||||
case uint32:
|
||||
printuint(uint64(v))
|
||||
case uint64:
|
||||
printuint(uint64(v))
|
||||
case uintptr:
|
||||
printuint(uint64(v))
|
||||
case float32:
|
||||
printfloat(float64(v))
|
||||
case float64:
|
||||
printfloat(float64(v))
|
||||
case complex64:
|
||||
printstring("(")
|
||||
printfloat(float64(real(v)))
|
||||
printfloat(float64(imag(v)))
|
||||
printstring("i)")
|
||||
case complex128:
|
||||
printstring("(")
|
||||
printfloat(real(v))
|
||||
printfloat(imag(v))
|
||||
printstring("i)")
|
||||
case string:
|
||||
printstring(v)
|
||||
}
|
||||
}
|
||||
|
||||
func prinxor(n int64) {
|
||||
printint(^n)
|
||||
}
|
||||
|
||||
func prinsub(n int64) {
|
||||
printint(-n)
|
||||
}
|
||||
|
||||
func prinusub(n uint64) {
|
||||
printuint(-n)
|
||||
}
|
||||
|
||||
func prinfsub(n float64) {
|
||||
printfloat(-n)
|
||||
}
|
||||
1363
compiler/cl/_testdata/print/out.ll
Normal file
1363
compiler/cl/_testdata/print/out.ll
Normal file
File diff suppressed because it is too large
Load Diff
12
compiler/cl/_testdata/printf/in.go
Normal file
12
compiler/cl/_testdata/printf/in.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import _ "unsafe"
|
||||
|
||||
//go:linkname printf C.printf
|
||||
func printf(format *int8, __llgo_va_list ...any)
|
||||
|
||||
var hello = [...]int8{'H', 'e', 'l', 'l', 'o', '\n', 0}
|
||||
|
||||
func main() {
|
||||
printf(&hello[0])
|
||||
}
|
||||
41
compiler/cl/_testdata/printf/out.ll
Normal file
41
compiler/cl/_testdata/printf/out.ll
Normal file
@@ -0,0 +1,41 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@main.hello = global [7 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.hello, align 1
|
||||
store i8 101, ptr getelementptr inbounds (i8, ptr @main.hello, i64 1), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @main.hello, i64 2), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @main.hello, i64 3), align 1
|
||||
store i8 111, ptr getelementptr inbounds (i8, ptr @main.hello, i64 4), align 1
|
||||
store i8 10, ptr getelementptr inbounds (i8, ptr @main.hello, i64 5), align 1
|
||||
store i8 0, ptr getelementptr inbounds (i8, ptr @main.hello, i64 6), 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 @main.hello)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare void @printf(ptr, ...)
|
||||
12
compiler/cl/_testdata/printval/in.go
Normal file
12
compiler/cl/_testdata/printval/in.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import _ "unsafe"
|
||||
|
||||
//go:linkname printf C.printf
|
||||
func printf(format *int8, __llgo_va_list ...any)
|
||||
|
||||
var format = [...]int8{'H', 'e', 'l', 'l', 'o', ' ', '%', 'd', '\n', 0}
|
||||
|
||||
func main() {
|
||||
printf(&format[0], 100)
|
||||
}
|
||||
44
compiler/cl/_testdata/printval/out.ll
Normal file
44
compiler/cl/_testdata/printval/out.ll
Normal file
@@ -0,0 +1,44 @@
|
||||
; 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()
|
||||
call void (ptr, ...) @printf(ptr @main.format, i64 100)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare void @printf(ptr, ...)
|
||||
19
compiler/cl/_testdata/ptrmthd/in.go
Normal file
19
compiler/cl/_testdata/ptrmthd/in.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import _ "unsafe"
|
||||
|
||||
//go:linkname printf C.printf
|
||||
func printf(format *int8, __llgo_va_list ...any)
|
||||
|
||||
type T int8
|
||||
|
||||
func (f *T) Print(v int) {
|
||||
printf((*int8)(f), v)
|
||||
}
|
||||
|
||||
var format = [...]T{'H', 'e', 'l', 'l', 'o', ' ', '%', 'd', '\n', 0}
|
||||
|
||||
func main() {
|
||||
f := &format[0]
|
||||
f.Print(100)
|
||||
}
|
||||
50
compiler/cl/_testdata/ptrmthd/out.ll
Normal file
50
compiler/cl/_testdata/ptrmthd/out.ll
Normal file
@@ -0,0 +1,50 @@
|
||||
; 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.(*T).Print"(ptr %0, i64 %1) {
|
||||
_llgo_0:
|
||||
call void (ptr, ...) @printf(ptr %0, i64 %1)
|
||||
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
|
||||
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()
|
||||
call void @"main.(*T).Print"(ptr @main.format, i64 100)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @printf(ptr, ...)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
13
compiler/cl/_testdata/uint/in.go
Normal file
13
compiler/cl/_testdata/uint/in.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import "github.com/goplus/llgo/c"
|
||||
|
||||
func f(a c.Uint) c.Uint {
|
||||
a++
|
||||
return a
|
||||
}
|
||||
|
||||
func main() {
|
||||
var a c.Uint = 100
|
||||
c.Printf(c.Str("Hello, %u\n"), f(a))
|
||||
}
|
||||
41
compiler/cl/_testdata/uint/out.ll
Normal file
41
compiler/cl/_testdata/uint/out.ll
Normal file
@@ -0,0 +1,41 @@
|
||||
; 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 [11 x i8] c"Hello, %u\0A\00", align 1
|
||||
|
||||
define i32 @main.f(i32 %0) {
|
||||
_llgo_0:
|
||||
%1 = add i32 %0, 1
|
||||
ret i32 %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 @main.f(i32 100)
|
||||
%3 = call i32 (ptr, ...) @printf(ptr @0, i32 %2)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
11
compiler/cl/_testdata/untyped/in.go
Normal file
11
compiler/cl/_testdata/untyped/in.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
const c = 100
|
||||
|
||||
var a float64 = 1
|
||||
|
||||
func main() {
|
||||
if c > 100 {
|
||||
a = 0
|
||||
}
|
||||
}
|
||||
39
compiler/cl/_testdata/untyped/out.ll
Normal file
39
compiler/cl/_testdata/untyped/out.ll
Normal file
@@ -0,0 +1,39 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@main.a = global double 0.000000e+00, align 8
|
||||
@"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 double 1.000000e+00, ptr @main.a, 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()
|
||||
br i1 false, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store double 0.000000e+00, ptr @main.a, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
23
compiler/cl/_testdata/utf8/in.go
Normal file
23
compiler/cl/_testdata/utf8/in.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var str = "中abcd"
|
||||
for i := 0; i < len(str); {
|
||||
r, n := utf8.DecodeRuneInString(str[i:])
|
||||
i += n
|
||||
println(r)
|
||||
}
|
||||
println(index(2) == 3)
|
||||
}
|
||||
|
||||
var array = [...]uint8{
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
}
|
||||
|
||||
func index(n int8) uint8 {
|
||||
return array[n]
|
||||
}
|
||||
92
compiler/cl/_testdata/utf8/out.ll
Normal file
92
compiler/cl/_testdata/utf8/out.ll
Normal file
@@ -0,0 +1,92 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
|
||||
@main.array = global [8 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
|
||||
@0 = private unnamed_addr constant [7 x i8] c"\E4\B8\ADabcd", align 1
|
||||
|
||||
define i8 @main.index(i8 %0) {
|
||||
_llgo_0:
|
||||
%1 = sext i8 %0 to i64
|
||||
%2 = icmp slt i64 %1, 0
|
||||
%3 = icmp sge i64 %1, 8
|
||||
%4 = or i1 %3, %2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %4)
|
||||
%5 = getelementptr inbounds i8, ptr @main.array, i64 %1
|
||||
%6 = load i8, ptr %5, align 1
|
||||
ret i8 %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
|
||||
call void @"unicode/utf8.init"()
|
||||
store i8 1, ptr @main.array, align 1
|
||||
store i8 2, ptr getelementptr inbounds (i8, ptr @main.array, i64 1), align 1
|
||||
store i8 3, ptr getelementptr inbounds (i8, ptr @main.array, i64 2), align 1
|
||||
store i8 4, ptr getelementptr inbounds (i8, ptr @main.array, i64 3), align 1
|
||||
store i8 5, ptr getelementptr inbounds (i8, ptr @main.array, i64 4), align 1
|
||||
store i8 6, ptr getelementptr inbounds (i8, ptr @main.array, i64 5), align 1
|
||||
store i8 7, ptr getelementptr inbounds (i8, ptr @main.array, i64 6), align 1
|
||||
store i8 8, ptr getelementptr inbounds (i8, ptr @main.array, i64 7), 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()
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%2 = phi i64 [ 0, %_llgo_0 ], [ %8, %_llgo_2 ]
|
||||
%3 = icmp slt i64 %2, 7
|
||||
br i1 %3, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%4 = 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 7 }, i64 %2, i64 7)
|
||||
%5 = call { i32, i64 } @"unicode/utf8.DecodeRuneInString"(%"github.com/goplus/llgo/internal/runtime.String" %4)
|
||||
%6 = extractvalue { i32, i64 } %5, 0
|
||||
%7 = extractvalue { i32, i64 } %5, 1
|
||||
%8 = add i64 %2, %7
|
||||
%9 = sext i32 %6 to i64
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %9)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
%10 = call i8 @main.index(i8 2)
|
||||
%11 = icmp eq i8 %10, 3
|
||||
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
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1)
|
||||
|
||||
declare void @"unicode/utf8.init"()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
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 { i32, i64 } @"unicode/utf8.DecodeRuneInString"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
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.PrintBool"(i1)
|
||||
13
compiler/cl/_testdata/vargs/in.go
Normal file
13
compiler/cl/_testdata/vargs/in.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import "github.com/goplus/llgo/c"
|
||||
|
||||
func test(a ...any) {
|
||||
for _, v := range a {
|
||||
c.Printf(c.Str("%d\n"), v.(int))
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
test(1, 2, 3)
|
||||
}
|
||||
140
compiler/cl/_testdata/vargs/out.ll
Normal file
140
compiler/cl/_testdata/vargs/out.ll
Normal file
@@ -0,0 +1,140 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
%"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
|
||||
@_llgo_int = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
@1 = private unnamed_addr constant [21 x i8] c"type assertion failed", 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 48)
|
||||
%3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i64 0
|
||||
%4 = load ptr, ptr @_llgo_int, align 8
|
||||
%5 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %5, ptr inttoptr (i64 1 to ptr), 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %6, ptr %3, align 8
|
||||
%7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i64 1
|
||||
%8 = load ptr, ptr @_llgo_int, 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 inttoptr (i64 2 to ptr), 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %10, ptr %7, align 8
|
||||
%11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i64 2
|
||||
%12 = load ptr, ptr @_llgo_int, align 8
|
||||
%13 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %12, 0
|
||||
%14 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %13, ptr inttoptr (i64 3 to ptr), 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %14, ptr %11, align 8
|
||||
%15 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %2, 0
|
||||
%16 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %15, i64 3, 1
|
||||
%17 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %16, i64 3, 2
|
||||
call void @main.test(%"github.com/goplus/llgo/internal/runtime.Slice" %17)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @main.test(%"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_4, %_llgo_0
|
||||
%2 = phi i64 [ -1, %_llgo_0 ], [ %3, %_llgo_4 ]
|
||||
%3 = add i64 %2, 1
|
||||
%4 = icmp slt i64 %3, %1
|
||||
br i1 %4, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%5 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 0
|
||||
%6 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 1
|
||||
%7 = icmp slt i64 %3, 0
|
||||
%8 = icmp sge i64 %3, %6
|
||||
%9 = or i1 %8, %7
|
||||
call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %9)
|
||||
%10 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %5, i64 %3
|
||||
%11 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8
|
||||
%12 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %11, 0
|
||||
%13 = load ptr, ptr @_llgo_int, align 8
|
||||
%14 = icmp eq ptr %12, %13
|
||||
br i1 %14, label %_llgo_4, label %_llgo_5
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
ret void
|
||||
|
||||
_llgo_4: ; preds = %_llgo_2
|
||||
%15 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %11, 1
|
||||
%16 = ptrtoint ptr %15 to i64
|
||||
%17 = call i32 (ptr, ...) @printf(ptr @0, i64 %16)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_5: ; preds = %_llgo_2
|
||||
%18 = load ptr, ptr @_llgo_string, align 8
|
||||
%19 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 21 }, ptr %19, align 8
|
||||
%20 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %18, 0
|
||||
%21 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %20, ptr %19, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %21)
|
||||
unreachable
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(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
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1)
|
||||
|
||||
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 i32 @printf(ptr, ...)
|
||||
8
compiler/cl/_testdata/varinit/in.go
Normal file
8
compiler/cl/_testdata/varinit/in.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package main
|
||||
|
||||
var a = 100
|
||||
|
||||
func main() {
|
||||
a++
|
||||
_ = a
|
||||
}
|
||||
36
compiler/cl/_testdata/varinit/out.ll
Normal file
36
compiler/cl/_testdata/varinit/out.ll
Normal file
@@ -0,0 +1,36 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
@main.a = global i64 0, align 8
|
||||
@"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 i64 100, ptr @main.a, 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 = load i64, ptr @main.a, align 4
|
||||
%3 = add i64 %2, 1
|
||||
store i64 %3, ptr @main.a, align 4
|
||||
%4 = load i64, ptr @main.a, align 4
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
16
compiler/cl/_testdefer/firstloop1/in.go
Normal file
16
compiler/cl/_testdefer/firstloop1/in.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package foo
|
||||
|
||||
func f(s string) bool {
|
||||
return len(s) > 2
|
||||
}
|
||||
|
||||
func Loop() {
|
||||
for i := 0; i < 3; i++ {
|
||||
if s := "hello"; f(s) {
|
||||
defer println(s)
|
||||
} else {
|
||||
defer println("world")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
7
compiler/cl/_testdefer/firstloop1/out.txt
Normal file
7
compiler/cl/_testdefer/firstloop1/out.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
0: always
|
||||
6: cond
|
||||
1: loop
|
||||
2: loop
|
||||
4: loop
|
||||
3: cond
|
||||
5: cond
|
||||
7
compiler/cl/_testdefer/firstloop2/in.go
Normal file
7
compiler/cl/_testdefer/firstloop2/in.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package foo
|
||||
|
||||
func Loop() {
|
||||
for i := 0; i < 3; i++ {
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
4
compiler/cl/_testdefer/firstloop2/out.txt
Normal file
4
compiler/cl/_testdefer/firstloop2/out.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
0: always
|
||||
1: loop
|
||||
2: loop
|
||||
3: always
|
||||
20
compiler/cl/_testdefer/loop/in.go
Normal file
20
compiler/cl/_testdefer/loop/in.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
func f(s string) bool {
|
||||
return len(s) > 2
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
println("hi")
|
||||
}()
|
||||
for i := 0; i < 3; i++ {
|
||||
if s := "hello"; f(s) {
|
||||
defer println(s)
|
||||
} else {
|
||||
defer println("world")
|
||||
return
|
||||
}
|
||||
}
|
||||
defer println("bye")
|
||||
}
|
||||
7
compiler/cl/_testdefer/loop/out.txt
Normal file
7
compiler/cl/_testdefer/loop/out.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
0: always
|
||||
1: cond
|
||||
2: loop
|
||||
3: loop
|
||||
5: loop
|
||||
4: cond
|
||||
6: cond
|
||||
18
compiler/cl/_testdefer/multiret/in.go
Normal file
18
compiler/cl/_testdefer/multiret/in.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
func f(s string) bool {
|
||||
return len(s) > 2
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
println("hi")
|
||||
}()
|
||||
if s := "hello"; f(s) {
|
||||
defer println(s)
|
||||
} else {
|
||||
defer println("world")
|
||||
return
|
||||
}
|
||||
defer println("bye")
|
||||
}
|
||||
4
compiler/cl/_testdefer/multiret/out.txt
Normal file
4
compiler/cl/_testdefer/multiret/out.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
0: always
|
||||
1: cond
|
||||
2: cond
|
||||
3: cond
|
||||
52
compiler/cl/_testdefer/print/in.go
Normal file
52
compiler/cl/_testdefer/print/in.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package main
|
||||
|
||||
func f() float64 {
|
||||
return 1.0
|
||||
}
|
||||
|
||||
func main() {
|
||||
var v = f()
|
||||
const n = 7 // digits printed
|
||||
var buf [n + 7]byte
|
||||
buf[0] = '+'
|
||||
e := 0 // exp
|
||||
if v == 0 {
|
||||
if 1/v < 0 {
|
||||
buf[0] = '-'
|
||||
}
|
||||
} else {
|
||||
if v < 0 {
|
||||
v = -v
|
||||
buf[0] = '-'
|
||||
}
|
||||
|
||||
// normalize
|
||||
for v >= 10 {
|
||||
e++
|
||||
v /= 10
|
||||
}
|
||||
for v < 1 {
|
||||
e--
|
||||
v *= 10
|
||||
}
|
||||
|
||||
// round
|
||||
h := 5.0
|
||||
for i := 0; i < n; i++ {
|
||||
h /= 10
|
||||
}
|
||||
v += h
|
||||
if v >= 10 {
|
||||
e++
|
||||
v /= 10
|
||||
}
|
||||
}
|
||||
|
||||
// format +d.dddd+edd
|
||||
for i := 0; i < n; i++ {
|
||||
s := int(v)
|
||||
buf[i+2] = byte(s + '0')
|
||||
v -= float64(s)
|
||||
v *= 10
|
||||
}
|
||||
}
|
||||
18
compiler/cl/_testdefer/print/out.txt
Normal file
18
compiler/cl/_testdefer/print/out.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
0: always
|
||||
1: cond
|
||||
3: cond
|
||||
4: cond
|
||||
5: cond
|
||||
7: loop
|
||||
6: loop
|
||||
10: loop
|
||||
8: loop
|
||||
9: cond
|
||||
11: loop
|
||||
12: loop
|
||||
13: cond
|
||||
14: cond
|
||||
2: cond
|
||||
15: loop
|
||||
16: loop
|
||||
17: always
|
||||
17
compiler/cl/_testdefer/singleret/in.go
Normal file
17
compiler/cl/_testdefer/singleret/in.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
func f(s string) bool {
|
||||
return len(s) > 2
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
println("hi")
|
||||
}()
|
||||
if s := "hello"; f(s) {
|
||||
defer println(s)
|
||||
} else {
|
||||
defer println("world")
|
||||
}
|
||||
defer println("bye")
|
||||
}
|
||||
5
compiler/cl/_testdefer/singleret/out.txt
Normal file
5
compiler/cl/_testdefer/singleret/out.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
0: always
|
||||
1: cond
|
||||
2: cond
|
||||
4: cond
|
||||
3: always
|
||||
17
compiler/cl/_testgo/allocinloop/in.go
Normal file
17
compiler/cl/_testgo/allocinloop/in.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
func Foo(s string) int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func Test() {
|
||||
j := 0
|
||||
for i := 0; i < 10000000; i++ {
|
||||
j += Foo("hello")
|
||||
}
|
||||
println(j)
|
||||
}
|
||||
|
||||
func main() {
|
||||
Test()
|
||||
}
|
||||
66
compiler/cl/_testgo/allocinloop/out.ll
Normal file
66
compiler/cl/_testgo/allocinloop/out.ll
Normal file
@@ -0,0 +1,66 @@
|
||||
; 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 [5 x i8] c"hello", align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define i64 @main.Foo(%"github.com/goplus/llgo/internal/runtime.String" %0) {
|
||||
_llgo_0:
|
||||
%1 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %0, 1
|
||||
ret i64 %1
|
||||
}
|
||||
|
||||
define void @main.Test() {
|
||||
_llgo_0:
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||
%0 = phi i64 [ 0, %_llgo_0 ], [ %4, %_llgo_2 ]
|
||||
%1 = phi i64 [ 0, %_llgo_0 ], [ %5, %_llgo_2 ]
|
||||
%2 = icmp slt i64 %1, 10000000
|
||||
br i1 %2, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%3 = call i64 @main.Foo(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 })
|
||||
%4 = add i64 %0, %3
|
||||
%5 = add i64 %1, 1
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %0)
|
||||
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
|
||||
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.Test()
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
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.init"()
|
||||
55
compiler/cl/_testgo/cgobasic/cgobasic.go
Normal file
55
compiler/cl/_testgo/cgobasic/cgobasic.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"fmt"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// C.CString example
|
||||
cstr := C.CString("Hello, World!")
|
||||
C.puts(cstr)
|
||||
|
||||
// C.CBytes example
|
||||
bytes := []byte{65, 66, 67, 68} // ABCD
|
||||
cbytes := C.CBytes(bytes)
|
||||
|
||||
// C.GoString example
|
||||
gostr := C.GoString(cstr)
|
||||
println("Converted back to Go string: ", gostr)
|
||||
|
||||
// C.GoStringN example (with length limit)
|
||||
gostringN := C.GoStringN(cstr, 5) // only take first 5 characters
|
||||
println("Length-limited string: ", gostringN)
|
||||
|
||||
// C.GoBytes example
|
||||
gobytes := C.GoBytes(cbytes, 4) // 4 is the length
|
||||
println("Converted back to Go byte slice: ", gobytes)
|
||||
|
||||
// C math library examples
|
||||
x := 2.0
|
||||
// Calculate square root
|
||||
sqrtResult := C.sqrt(C.double(x))
|
||||
fmt.Printf("sqrt(%v) = %v\n", x, float64(sqrtResult))
|
||||
|
||||
// Calculate sine
|
||||
sinResult := C.sin(C.double(x))
|
||||
fmt.Printf("sin(%v) = %v\n", x, float64(sinResult))
|
||||
|
||||
// Calculate cosine
|
||||
cosResult := C.cos(C.double(x))
|
||||
fmt.Printf("cos(%v) = %v\n", x, float64(cosResult))
|
||||
|
||||
// Calculate natural logarithm
|
||||
logResult := C.log(C.double(x))
|
||||
fmt.Printf("log(%v) = %v\n", x, float64(logResult))
|
||||
|
||||
C.free(unsafe.Pointer(cstr))
|
||||
C.free(cbytes)
|
||||
}
|
||||
404
compiler/cl/_testgo/cgobasic/out.ll
Normal file
404
compiler/cl/_testgo/cgobasic/out.ll
Normal file
@@ -0,0 +1,404 @@
|
||||
; 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/runtime.iface" = type { ptr, ptr }
|
||||
|
||||
@"github.com/goplus/llgo/internal/runtime.cgoAlwaysFalse" = external global i1, align 1
|
||||
@_cgo_62905c3ec377_Cfunc__Cmalloc = external global i8, align 1
|
||||
@_cgo_62905c3ec377_Cfunc_cos = external global i8, align 1
|
||||
@_cgo_62905c3ec377_Cfunc_free = external global i8, align 1
|
||||
@_cgo_62905c3ec377_Cfunc_log = external global i8, align 1
|
||||
@_cgo_62905c3ec377_Cfunc_puts = external global i8, align 1
|
||||
@_cgo_62905c3ec377_Cfunc_sin = external global i8, align 1
|
||||
@_cgo_62905c3ec377_Cfunc_sqrt = external global i8, align 1
|
||||
@main._cgo_62905c3ec377_Cfunc__Cmalloc = global ptr null, align 8
|
||||
@main._cgo_62905c3ec377_Cfunc_cos = global ptr null, align 8
|
||||
@main._cgo_62905c3ec377_Cfunc_free = global ptr null, align 8
|
||||
@main._cgo_62905c3ec377_Cfunc_log = global ptr null, align 8
|
||||
@main._cgo_62905c3ec377_Cfunc_puts = global ptr null, align 8
|
||||
@main._cgo_62905c3ec377_Cfunc_sin = global ptr null, align 8
|
||||
@main._cgo_62905c3ec377_Cfunc_sqrt = global ptr null, align 8
|
||||
@"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"Hello, World!", align 1
|
||||
@1 = private unnamed_addr constant [29 x i8] c"Converted back to Go string: ", align 1
|
||||
@2 = private unnamed_addr constant [23 x i8] c"Length-limited string: ", align 1
|
||||
@3 = private unnamed_addr constant [33 x i8] c"Converted back to Go byte slice: ", align 1
|
||||
@_llgo_float64 = linkonce global ptr null, align 8
|
||||
@4 = private unnamed_addr constant [14 x i8] c"sqrt(%v) = %v\0A", align 1
|
||||
@5 = private unnamed_addr constant [13 x i8] c"sin(%v) = %v\0A", align 1
|
||||
@6 = private unnamed_addr constant [13 x i8] c"cos(%v) = %v\0A", align 1
|
||||
@7 = private unnamed_addr constant [13 x i8] c"log(%v) = %v\0A", align 1
|
||||
@_llgo_byte = linkonce global ptr null, align 8
|
||||
@"[]_llgo_byte" = linkonce global ptr null, align 8
|
||||
@_llgo_Pointer = linkonce global ptr null, align 8
|
||||
|
||||
define double @main._Cfunc_cos(double %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%2 = load ptr, ptr @main._cgo_62905c3ec377_Cfunc_cos, align 8
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
%4 = call double %3(double %0)
|
||||
ret double %4
|
||||
}
|
||||
|
||||
define [0 x i8] @main._Cfunc_free(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%2 = load ptr, ptr @main._cgo_62905c3ec377_Cfunc_free, align 8
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
%4 = call [0 x i8] %3(ptr %0)
|
||||
ret [0 x i8] %4
|
||||
}
|
||||
|
||||
define double @main._Cfunc_log(double %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%2 = load ptr, ptr @main._cgo_62905c3ec377_Cfunc_log, align 8
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
%4 = call double %3(double %0)
|
||||
ret double %4
|
||||
}
|
||||
|
||||
define i32 @main._Cfunc_puts(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%2 = load ptr, ptr @main._cgo_62905c3ec377_Cfunc_puts, align 8
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
%4 = call i32 %3(ptr %0)
|
||||
ret i32 %4
|
||||
}
|
||||
|
||||
define double @main._Cfunc_sin(double %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%2 = load ptr, ptr @main._cgo_62905c3ec377_Cfunc_sin, align 8
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
%4 = call double %3(double %0)
|
||||
ret double %4
|
||||
}
|
||||
|
||||
define double @main._Cfunc_sqrt(double %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%2 = load ptr, ptr @main._cgo_62905c3ec377_Cfunc_sqrt, align 8
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
%4 = call double %3(double %0)
|
||||
ret double %4
|
||||
}
|
||||
|
||||
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()
|
||||
call void @fmt.init()
|
||||
call void @"main.init$after"()
|
||||
store ptr @_cgo_62905c3ec377_Cfunc_cos, ptr @main._cgo_62905c3ec377_Cfunc_cos, align 8
|
||||
store ptr @_cgo_62905c3ec377_Cfunc_free, ptr @main._cgo_62905c3ec377_Cfunc_free, align 8
|
||||
store ptr @_cgo_62905c3ec377_Cfunc_log, ptr @main._cgo_62905c3ec377_Cfunc_log, align 8
|
||||
store ptr @_cgo_62905c3ec377_Cfunc_puts, ptr @main._cgo_62905c3ec377_Cfunc_puts, align 8
|
||||
store ptr @_cgo_62905c3ec377_Cfunc_sin, ptr @main._cgo_62905c3ec377_Cfunc_sin, align 8
|
||||
store ptr @_cgo_62905c3ec377_Cfunc_sqrt, ptr @main._cgo_62905c3ec377_Cfunc_sqrt, align 8
|
||||
store ptr @_cgo_62905c3ec377_Cfunc__Cmalloc, ptr @main._cgo_62905c3ec377_Cfunc__Cmalloc, 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 @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.CString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 13 })
|
||||
store ptr %3, ptr %2, align 8
|
||||
%4 = load ptr, ptr %2, align 8
|
||||
%5 = call i32 @main._Cfunc_puts(ptr %4)
|
||||
%6 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 24)
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 4)
|
||||
%8 = getelementptr inbounds i8, ptr %7, i64 0
|
||||
store i8 65, ptr %8, align 1
|
||||
%9 = getelementptr inbounds i8, ptr %7, i64 1
|
||||
store i8 66, ptr %9, align 1
|
||||
%10 = getelementptr inbounds i8, ptr %7, i64 2
|
||||
store i8 67, ptr %10, align 1
|
||||
%11 = getelementptr inbounds i8, ptr %7, i64 3
|
||||
store i8 68, ptr %11, align 1
|
||||
%12 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %7, 0
|
||||
%13 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %12, i64 4, 1
|
||||
%14 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %13, i64 4, 2
|
||||
store %"github.com/goplus/llgo/internal/runtime.Slice" %14, ptr %6, align 8
|
||||
%15 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%16 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%17 = getelementptr inbounds { ptr }, ptr %16, i32 0, i32 0
|
||||
store ptr %6, ptr %17, align 8
|
||||
%18 = insertvalue { ptr, ptr } { ptr @"main.main$1", ptr undef }, ptr %16, 1
|
||||
%19 = extractvalue { ptr, ptr } %18, 1
|
||||
%20 = extractvalue { ptr, ptr } %18, 0
|
||||
%21 = call ptr %20(ptr %19)
|
||||
store ptr %21, ptr %15, align 8
|
||||
%22 = load ptr, ptr %2, align 8
|
||||
%23 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.GoString"(ptr %22)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 29 })
|
||||
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" %23)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%24 = load ptr, ptr %2, align 8
|
||||
%25 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.GoStringN"(ptr %24, i32 5)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 23 })
|
||||
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" %25)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%26 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%27 = getelementptr inbounds { ptr }, ptr %26, i32 0, i32 0
|
||||
store ptr %15, ptr %27, align 8
|
||||
%28 = insertvalue { ptr, ptr } { ptr @"main.main$2", ptr undef }, ptr %26, 1
|
||||
%29 = extractvalue { ptr, ptr } %28, 1
|
||||
%30 = extractvalue { ptr, ptr } %28, 0
|
||||
%31 = call %"github.com/goplus/llgo/internal/runtime.Slice" %30(ptr %29)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 33 })
|
||||
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" %31)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%32 = call double @main._Cfunc_sqrt(double 2.000000e+00)
|
||||
%33 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32)
|
||||
%34 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %33, i64 0
|
||||
%35 = load ptr, ptr @_llgo_float64, 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 inttoptr (i64 4611686018427387904 to ptr), 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %37, ptr %34, align 8
|
||||
%38 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %33, i64 1
|
||||
%39 = load ptr, ptr @_llgo_float64, align 8
|
||||
%40 = bitcast double %32 to i64
|
||||
%41 = inttoptr i64 %40 to ptr
|
||||
%42 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %39, 0
|
||||
%43 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %42, ptr %41, 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %43, ptr %38, align 8
|
||||
%44 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %33, 0
|
||||
%45 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %44, i64 2, 1
|
||||
%46 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %45, i64 2, 2
|
||||
%47 = call { i64, %"github.com/goplus/llgo/internal/runtime.iface" } @fmt.Printf(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 14 }, %"github.com/goplus/llgo/internal/runtime.Slice" %46)
|
||||
%48 = call double @main._Cfunc_sin(double 2.000000e+00)
|
||||
%49 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32)
|
||||
%50 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %49, i64 0
|
||||
%51 = load ptr, ptr @_llgo_float64, align 8
|
||||
%52 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %51, 0
|
||||
%53 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %52, ptr inttoptr (i64 4611686018427387904 to ptr), 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %53, ptr %50, align 8
|
||||
%54 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %49, i64 1
|
||||
%55 = load ptr, ptr @_llgo_float64, align 8
|
||||
%56 = bitcast double %48 to i64
|
||||
%57 = inttoptr i64 %56 to ptr
|
||||
%58 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %55, 0
|
||||
%59 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %58, ptr %57, 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %59, ptr %54, align 8
|
||||
%60 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %49, 0
|
||||
%61 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %60, i64 2, 1
|
||||
%62 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %61, i64 2, 2
|
||||
%63 = call { i64, %"github.com/goplus/llgo/internal/runtime.iface" } @fmt.Printf(%"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 13 }, %"github.com/goplus/llgo/internal/runtime.Slice" %62)
|
||||
%64 = call double @main._Cfunc_cos(double 2.000000e+00)
|
||||
%65 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32)
|
||||
%66 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %65, i64 0
|
||||
%67 = load ptr, ptr @_llgo_float64, align 8
|
||||
%68 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %67, 0
|
||||
%69 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %68, ptr inttoptr (i64 4611686018427387904 to ptr), 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %69, ptr %66, align 8
|
||||
%70 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %65, i64 1
|
||||
%71 = load ptr, ptr @_llgo_float64, align 8
|
||||
%72 = bitcast double %64 to i64
|
||||
%73 = inttoptr i64 %72 to ptr
|
||||
%74 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %71, 0
|
||||
%75 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %74, ptr %73, 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %75, ptr %70, align 8
|
||||
%76 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %65, 0
|
||||
%77 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %76, i64 2, 1
|
||||
%78 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %77, i64 2, 2
|
||||
%79 = call { i64, %"github.com/goplus/llgo/internal/runtime.iface" } @fmt.Printf(%"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 13 }, %"github.com/goplus/llgo/internal/runtime.Slice" %78)
|
||||
%80 = call double @main._Cfunc_log(double 2.000000e+00)
|
||||
%81 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32)
|
||||
%82 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %81, i64 0
|
||||
%83 = load ptr, ptr @_llgo_float64, align 8
|
||||
%84 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %83, 0
|
||||
%85 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %84, ptr inttoptr (i64 4611686018427387904 to ptr), 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %85, ptr %82, align 8
|
||||
%86 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %81, i64 1
|
||||
%87 = load ptr, ptr @_llgo_float64, align 8
|
||||
%88 = bitcast double %80 to i64
|
||||
%89 = inttoptr i64 %88 to ptr
|
||||
%90 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %87, 0
|
||||
%91 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %90, ptr %89, 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %91, ptr %86, align 8
|
||||
%92 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %81, 0
|
||||
%93 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %92, i64 2, 1
|
||||
%94 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %93, i64 2, 2
|
||||
%95 = call { i64, %"github.com/goplus/llgo/internal/runtime.iface" } @fmt.Printf(%"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 13 }, %"github.com/goplus/llgo/internal/runtime.Slice" %94)
|
||||
%96 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%97 = getelementptr inbounds { ptr }, ptr %96, i32 0, i32 0
|
||||
store ptr %2, ptr %97, align 8
|
||||
%98 = insertvalue { ptr, ptr } { ptr @"main.main$3", ptr undef }, ptr %96, 1
|
||||
%99 = extractvalue { ptr, ptr } %98, 1
|
||||
%100 = extractvalue { ptr, ptr } %98, 0
|
||||
call void %100(ptr %99)
|
||||
%101 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%102 = getelementptr inbounds { ptr }, ptr %101, i32 0, i32 0
|
||||
store ptr %15, ptr %102, align 8
|
||||
%103 = insertvalue { ptr, ptr } { ptr @"main.main$4", ptr undef }, ptr %101, 1
|
||||
%104 = extractvalue { ptr, ptr } %103, 1
|
||||
%105 = extractvalue { ptr, ptr } %103, 0
|
||||
call void %105(ptr %104)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define ptr @"main.main$1"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { ptr }, ptr %0, align 8
|
||||
%2 = extractvalue { ptr } %1, 0
|
||||
%3 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %2, align 8
|
||||
%4 = load ptr, ptr @_llgo_byte, align 8
|
||||
%5 = load ptr, ptr @"[]_llgo_byte", align 8
|
||||
%6 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
|
||||
store %"github.com/goplus/llgo/internal/runtime.Slice" %3, ptr %6, align 8
|
||||
%7 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %5, 0
|
||||
%8 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %7, ptr %6, 1
|
||||
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.CBytes"(%"github.com/goplus/llgo/internal/runtime.Slice" %3)
|
||||
ret ptr %9
|
||||
}
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.Slice" @"main.main$2"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { ptr }, ptr %0, align 8
|
||||
%2 = extractvalue { ptr } %1, 0
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
%4 = load ptr, ptr @_llgo_Pointer, align 8
|
||||
%5 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %5, ptr %3, 1
|
||||
%7 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.GoBytes"(ptr %3, i32 4)
|
||||
ret %"github.com/goplus/llgo/internal/runtime.Slice" %7
|
||||
}
|
||||
|
||||
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 %2, align 8
|
||||
%4 = load ptr, ptr @_llgo_Pointer, align 8
|
||||
%5 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %5, ptr %3, 1
|
||||
%7 = call [0 x i8] @main._Cfunc_free(ptr %3)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.main$4"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { ptr }, ptr %0, align 8
|
||||
%2 = extractvalue { ptr } %1, 0
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
%4 = load ptr, ptr @_llgo_Pointer, align 8
|
||||
%5 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %4, 0
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %5, ptr %3, 1
|
||||
%7 = call [0 x i8] @main._Cfunc_free(ptr %3)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @runtime.throw(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare void @syscall.init()
|
||||
|
||||
declare void @fmt.init()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.CString"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.GoString"(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 %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.GoStringN"(ptr, i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
define void @"main.init$after"() {
|
||||
_llgo_0:
|
||||
%0 = load ptr, ptr @_llgo_float64, 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 46)
|
||||
store ptr %2, ptr @_llgo_float64, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%3 = load ptr, ptr @_llgo_byte, 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 40)
|
||||
store ptr %5, ptr @_llgo_byte, align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%6 = load ptr, ptr @"[]_llgo_byte", 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 40)
|
||||
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.SliceOf"(ptr %8)
|
||||
store ptr %9, ptr @"[]_llgo_byte", align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
%10 = load ptr, ptr @_llgo_Pointer, 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 58)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %12)
|
||||
store ptr %12, ptr @_llgo_Pointer, 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 { i64, %"github.com/goplus/llgo/internal/runtime.iface" } @fmt.Printf(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.SliceOf"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.CBytes"(%"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr)
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.GoBytes"(ptr, i64)
|
||||
15
compiler/cl/_testgo/cgocfiles/cgocfiles.go
Normal file
15
compiler/cl/_testgo/cgocfiles/cgocfiles.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include "in.h"
|
||||
*/
|
||||
import "C"
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
r := C.test_structs(&C.s4{a: 1}, &C.s8{a: 1, b: 2}, &C.s12{a: 1, b: 2, c: 3}, &C.s16{a: 1, b: 2, c: 3, d: 4}, &C.s20{a: 1, b: 2, c: 3, d: 4, e: 5})
|
||||
fmt.Println(r)
|
||||
if r != 35 {
|
||||
panic("test_structs failed")
|
||||
}
|
||||
}
|
||||
12
compiler/cl/_testgo/cgocfiles/in.c
Normal file
12
compiler/cl/_testgo/cgocfiles/in.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include "in.h"
|
||||
|
||||
int test_structs(s4* s4, s8* s8, s12* s12, s16* s16, s20* s20) {
|
||||
printf("s4.a: %d\n", s4->a);
|
||||
printf("s8.a: %d, s8.b: %d\n", s8->a, s8->b);
|
||||
printf("s12.a: %d, s12.b: %d, s12.c: %d\n", s12->a, s12->b, s12->c);
|
||||
printf("s16.a: %d, s16.b: %d, s16.c: %d, s16.d: %d\n", s16->a, s16->b, s16->c, s16->d);
|
||||
printf("s20.a: %d, s20.b: %d, s20.c: %d, s20.d: %d, s20.e: %d\n", s20->a, s20->b, s20->c, s20->d, s20->e);
|
||||
|
||||
return s4->a + s8->a + s8->b + s12->a + s12->b + s12->c + s16->a + s16->b + s16->c + s16->d + s20->a + s20->b + s20->c + s20->d + s20->e;
|
||||
}
|
||||
33
compiler/cl/_testgo/cgocfiles/in.h
Normal file
33
compiler/cl/_testgo/cgocfiles/in.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
typedef struct {
|
||||
int a;
|
||||
} s4;
|
||||
|
||||
typedef struct {
|
||||
int a;
|
||||
int b;
|
||||
} s8;
|
||||
|
||||
typedef struct {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
} s12;
|
||||
|
||||
typedef struct {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
int d;
|
||||
} s16;
|
||||
|
||||
typedef struct {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
int d;
|
||||
int e;
|
||||
} s20;
|
||||
|
||||
extern int test_structs(s4* s4, s8* s8, s12* s12, s16* s16, s20* s20);
|
||||
179
compiler/cl/_testgo/cgocfiles/out.ll
Normal file
179
compiler/cl/_testgo/cgocfiles/out.ll
Normal file
@@ -0,0 +1,179 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
%main._Ctype_struct___3 = type { i32 }
|
||||
%main._Ctype_struct___4 = type { i32, i32 }
|
||||
%main._Ctype_struct___0 = type { i32, i32, i32 }
|
||||
%main._Ctype_struct___1 = type { i32, i32, i32, i32 }
|
||||
%main._Ctype_struct___2 = type { i32, i32, i32, i32, i32 }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
%"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
|
||||
@"github.com/goplus/llgo/internal/runtime.cgoAlwaysFalse" = external global i1, align 1
|
||||
@_cgo_35faaf752e93_Cfunc_test_structs = external global i8, align 1
|
||||
@main._cgo_35faaf752e93_Cfunc_test_structs = global ptr null, align 8
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@_llgo_main._Ctype_int = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@1 = private unnamed_addr constant [10 x i8] c"_Ctype_int", align 1
|
||||
@_llgo_int32 = linkonce global ptr null, align 8
|
||||
@2 = private unnamed_addr constant [19 x i8] c"test_structs failed", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
|
||||
define i32 @main._Cfunc_test_structs(ptr %0, ptr %1, ptr %2, ptr %3, ptr %4) {
|
||||
_llgo_0:
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%6 = load ptr, ptr @main._cgo_35faaf752e93_Cfunc_test_structs, align 8
|
||||
%7 = load ptr, ptr %6, align 8
|
||||
%8 = call i32 %7(ptr %0, ptr %1, ptr %2, ptr %3, ptr %4)
|
||||
ret i32 %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()
|
||||
call void @fmt.init()
|
||||
call void @"main.init$after"()
|
||||
store ptr @_cgo_35faaf752e93_Cfunc_test_structs, ptr @main._cgo_35faaf752e93_Cfunc_test_structs, 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 @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 4)
|
||||
%3 = getelementptr inbounds %main._Ctype_struct___3, ptr %2, i32 0, i32 0
|
||||
store i32 1, ptr %3, align 4
|
||||
%4 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%5 = getelementptr inbounds %main._Ctype_struct___4, ptr %4, i32 0, i32 0
|
||||
%6 = getelementptr inbounds %main._Ctype_struct___4, ptr %4, i32 0, i32 1
|
||||
store i32 1, ptr %5, align 4
|
||||
store i32 2, ptr %6, align 4
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 12)
|
||||
%8 = getelementptr inbounds %main._Ctype_struct___0, ptr %7, i32 0, i32 0
|
||||
%9 = getelementptr inbounds %main._Ctype_struct___0, ptr %7, i32 0, i32 1
|
||||
%10 = getelementptr inbounds %main._Ctype_struct___0, ptr %7, i32 0, i32 2
|
||||
store i32 1, ptr %8, align 4
|
||||
store i32 2, ptr %9, align 4
|
||||
store i32 3, ptr %10, align 4
|
||||
%11 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
%12 = getelementptr inbounds %main._Ctype_struct___1, ptr %11, i32 0, i32 0
|
||||
%13 = getelementptr inbounds %main._Ctype_struct___1, ptr %11, i32 0, i32 1
|
||||
%14 = getelementptr inbounds %main._Ctype_struct___1, ptr %11, i32 0, i32 2
|
||||
%15 = getelementptr inbounds %main._Ctype_struct___1, ptr %11, i32 0, i32 3
|
||||
store i32 1, ptr %12, align 4
|
||||
store i32 2, ptr %13, align 4
|
||||
store i32 3, ptr %14, align 4
|
||||
store i32 4, ptr %15, align 4
|
||||
%16 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 20)
|
||||
%17 = getelementptr inbounds %main._Ctype_struct___2, ptr %16, i32 0, i32 0
|
||||
%18 = getelementptr inbounds %main._Ctype_struct___2, ptr %16, i32 0, i32 1
|
||||
%19 = getelementptr inbounds %main._Ctype_struct___2, ptr %16, i32 0, i32 2
|
||||
%20 = getelementptr inbounds %main._Ctype_struct___2, ptr %16, i32 0, i32 3
|
||||
%21 = getelementptr inbounds %main._Ctype_struct___2, ptr %16, i32 0, i32 4
|
||||
store i32 1, ptr %17, align 4
|
||||
store i32 2, ptr %18, align 4
|
||||
store i32 3, ptr %19, align 4
|
||||
store i32 4, ptr %20, align 4
|
||||
store i32 5, ptr %21, align 4
|
||||
%22 = call i32 @main._Cfunc_test_structs(ptr %2, ptr %4, ptr %7, ptr %11, ptr %16)
|
||||
%23 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
%24 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %23, i64 0
|
||||
%25 = load ptr, ptr @_llgo_main._Ctype_int, align 8
|
||||
%26 = sext i32 %22 to i64
|
||||
%27 = inttoptr i64 %26 to ptr
|
||||
%28 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %25, 0
|
||||
%29 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %28, ptr %27, 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %29, ptr %24, align 8
|
||||
%30 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %23, 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 { i64, %"github.com/goplus/llgo/internal/runtime.iface" } @fmt.Println(%"github.com/goplus/llgo/internal/runtime.Slice" %32)
|
||||
%34 = icmp ne i32 %22, 35
|
||||
br i1 %34, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%35 = load ptr, ptr @_llgo_string, align 8
|
||||
%36 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 19 }, ptr %36, align 8
|
||||
%37 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %35, 0
|
||||
%38 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %37, ptr %36, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %38)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare void @syscall.init()
|
||||
|
||||
declare void @fmt.init()
|
||||
|
||||
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 10 }, i64 5, i64 4, i64 0, i64 0)
|
||||
store ptr %0, ptr @_llgo_main._Ctype_int, align 8
|
||||
%1 = load ptr, ptr @_llgo_int32, align 8
|
||||
%2 = icmp eq ptr %1, null
|
||||
br i1 %2, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 37)
|
||||
store ptr %3, ptr @_llgo_int32, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_int32, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %0, ptr %4, { ptr, i64, i64 } zeroinitializer, { ptr, i64, i64 } zeroinitializer)
|
||||
%5 = load ptr, ptr @_llgo_string, 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.Basic"(i64 24)
|
||||
store ptr %7, ptr @_llgo_string, align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
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 { i64, %"github.com/goplus/llgo/internal/runtime.iface" } @fmt.Println(%"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
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")
|
||||
11
compiler/cl/_testgo/cgodefer/cgodefer.go
Normal file
11
compiler/cl/_testgo/cgodefer/cgodefer.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
p := C.malloc(1024)
|
||||
defer C.free(p)
|
||||
}
|
||||
1
compiler/cl/_testgo/cgodefer/out.ll
Normal file
1
compiler/cl/_testgo/cgodefer/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
16
compiler/cl/_testgo/cgofull/bar.go
Normal file
16
compiler/cl/_testgo/cgofull/bar.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -DBAR
|
||||
#include <stdio.h>
|
||||
#include "foo.h"
|
||||
static void foo(Foo* f) {
|
||||
printf("foo in bar: %d\n", f->a);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func Bar(f *C.Foo) {
|
||||
C.print_foo(f)
|
||||
C.foo(f)
|
||||
}
|
||||
157
compiler/cl/_testgo/cgofull/cgofull.go
Normal file
157
compiler/cl/_testgo/cgofull/cgofull.go
Normal file
@@ -0,0 +1,157 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#cgo windows,!amd64 CFLAGS: -D_WIN32
|
||||
#cgo !windows CFLAGS: -D_POSIX
|
||||
#cgo windows,amd64 CFLAGS: -D_WIN64
|
||||
#cgo linux,amd64 CFLAGS: -D_LINUX64
|
||||
#cgo !windows,amd64 CFLAGS: -D_UNIX64
|
||||
#cgo pkg-config: python3-embed
|
||||
#include <stdio.h>
|
||||
#include <Python.h>
|
||||
#include "foo.h"
|
||||
typedef struct {
|
||||
int a;
|
||||
} s4;
|
||||
|
||||
typedef struct {
|
||||
int a;
|
||||
int b;
|
||||
} s8;
|
||||
|
||||
typedef struct {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
} s12;
|
||||
|
||||
typedef struct {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
int d;
|
||||
} s16;
|
||||
|
||||
typedef struct {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
int d;
|
||||
int e;
|
||||
} s20;
|
||||
|
||||
static int test_structs(s4* s4, s8* s8, s12* s12, s16* s16, s20* s20) {
|
||||
printf("s4.a: %d\n", s4->a);
|
||||
printf("s8.a: %d, s8.b: %d\n", s8->a, s8->b);
|
||||
printf("s12.a: %d, s12.b: %d, s12.c: %d\n", s12->a, s12->b, s12->c);
|
||||
printf("s16.a: %d, s16.b: %d, s16.c: %d, s16.d: %d\n", s16->a, s16->b, s16->c, s16->d);
|
||||
printf("s20.a: %d, s20.b: %d, s20.c: %d, s20.d: %d, s20.e: %d\n", s20->a, s20->b, s20->c, s20->d, s20->e);
|
||||
|
||||
return s4->a + s8->a + s8->b + s12->a + s12->b + s12->c + s16->a + s16->b + s16->c + s16->d + s20->a + s20->b + s20->c + s20->d + s20->e;
|
||||
}
|
||||
|
||||
static void test_macros() {
|
||||
#ifdef FOO
|
||||
printf("FOO is defined\n");
|
||||
#endif
|
||||
#ifdef BAR
|
||||
printf("BAR is defined\n");
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
printf("WIN32 is defined\n");
|
||||
#endif
|
||||
#ifdef _POSIX
|
||||
printf("POSIX is defined\n");
|
||||
#endif
|
||||
#ifdef _WIN64
|
||||
printf("WIN64 is defined\n");
|
||||
#endif
|
||||
#ifdef _LINUX64
|
||||
printf("LINUX64 is defined\n");
|
||||
#endif
|
||||
#ifdef _UNIX64
|
||||
printf("UNIX64 is defined\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
#define MY_VERSION "1.0.0"
|
||||
#define MY_CODE 0x12345678
|
||||
|
||||
static void test_void() {
|
||||
printf("test_void\n");
|
||||
}
|
||||
|
||||
typedef int (*Cb)(int);
|
||||
|
||||
extern int go_callback(int);
|
||||
|
||||
extern int c_callback(int i);
|
||||
|
||||
static void test_callback(Cb cb) {
|
||||
printf("test_callback, cb: %p, go_callback: %p, c_callback: %p\n", cb, go_callback, c_callback);
|
||||
printf("test_callback, *cb: %p, *go_callback: %p, *c_callback: %p\n", *(void**)cb, *(void**)(go_callback), *(void**)(c_callback));
|
||||
printf("cb result: %d\n", cb(123));
|
||||
printf("done\n");
|
||||
}
|
||||
|
||||
extern int go_callback_not_use_in_go(int);
|
||||
|
||||
static void run_callback() {
|
||||
test_callback(c_callback);
|
||||
test_callback(go_callback_not_use_in_go);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"fmt"
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/compiler/cl/_testgo/cgofull/pymod1"
|
||||
"github.com/goplus/llgo/compiler/cl/_testgo/cgofull/pymod2"
|
||||
)
|
||||
|
||||
//export go_callback_not_use_in_go
|
||||
func go_callback_not_use_in_go(i C.int) C.int {
|
||||
return i + 1
|
||||
}
|
||||
|
||||
//export go_callback
|
||||
func go_callback(i C.int) C.int {
|
||||
return i + 1
|
||||
}
|
||||
|
||||
func main() {
|
||||
runPy()
|
||||
f := &C.Foo{a: 1}
|
||||
Foo(f)
|
||||
Bar(f)
|
||||
C.test_macros()
|
||||
r := C.test_structs(&C.s4{a: 1}, &C.s8{a: 1, b: 2}, &C.s12{a: 1, b: 2, c: 3}, &C.s16{a: 1, b: 2, c: 3, d: 4}, &C.s20{a: 1, b: 2, c: 3, d: 4, e: 5})
|
||||
fmt.Println(r)
|
||||
if r != 35 {
|
||||
panic("test_structs failed")
|
||||
}
|
||||
fmt.Println(C.MY_VERSION)
|
||||
fmt.Println(int(C.MY_CODE))
|
||||
C.test_void()
|
||||
|
||||
println("call run_callback")
|
||||
C.run_callback()
|
||||
|
||||
// test _Cgo_ptr and _cgoCheckResult
|
||||
println("call with go_callback")
|
||||
C.test_callback((C.Cb)(C.go_callback))
|
||||
|
||||
println("call with c_callback")
|
||||
C.test_callback((C.Cb)(C.c_callback))
|
||||
}
|
||||
|
||||
func runPy() {
|
||||
Initialize()
|
||||
defer Finalize()
|
||||
Run("print('Hello, Python!')")
|
||||
C.PyObject_Print((*C.PyObject)(unsafe.Pointer(pymod1.Float(1.23))), C.stderr, 0)
|
||||
C.PyObject_Print((*C.PyObject)(unsafe.Pointer(pymod2.Long(123))), C.stdout, 0)
|
||||
// test _Cgo_use
|
||||
C.PyObject_Print((*C.PyObject)(unsafe.Pointer(C.PyComplex_FromDoubles(C.double(1.23), C.double(4.56)))), C.stdout, 0)
|
||||
}
|
||||
12
compiler/cl/_testgo/cgofull/foo.c
Normal file
12
compiler/cl/_testgo/cgofull/foo.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include "foo.h"
|
||||
|
||||
void print_foo(Foo *f)
|
||||
{
|
||||
printf("print_foo: %d\n", f->a);
|
||||
}
|
||||
|
||||
int c_callback(int i)
|
||||
{
|
||||
return i + 1;
|
||||
}
|
||||
16
compiler/cl/_testgo/cgofull/foo.go
Normal file
16
compiler/cl/_testgo/cgofull/foo.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -DFOO
|
||||
#include <stdio.h>
|
||||
#include "foo.h"
|
||||
static void foo(Foo* f) {
|
||||
printf("foo in bar: %d\n", f->a);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func Foo(f *C.Foo) {
|
||||
C.print_foo(f)
|
||||
C.foo(f)
|
||||
}
|
||||
7
compiler/cl/_testgo/cgofull/foo.h
Normal file
7
compiler/cl/_testgo/cgofull/foo.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
typedef struct {
|
||||
int a;
|
||||
} Foo;
|
||||
|
||||
extern void print_foo(Foo* f);
|
||||
1
compiler/cl/_testgo/cgofull/out.ll
Normal file
1
compiler/cl/_testgo/cgofull/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
24
compiler/cl/_testgo/cgofull/py.go
Normal file
24
compiler/cl/_testgo/cgofull/py.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#cgo pkg-config: python3-embed
|
||||
#include <Python.h>
|
||||
*/
|
||||
import "C"
|
||||
import "fmt"
|
||||
|
||||
func Initialize() {
|
||||
C.Py_Initialize()
|
||||
}
|
||||
|
||||
func Finalize() {
|
||||
C.Py_Finalize()
|
||||
}
|
||||
|
||||
func Run(code string) error {
|
||||
if C.PyRun_SimpleString(C.CString(code)) != 0 {
|
||||
C.PyErr_Print()
|
||||
return fmt.Errorf("failed to run code")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
11
compiler/cl/_testgo/cgofull/pymod1/pymod1.go
Normal file
11
compiler/cl/_testgo/cgofull/pymod1/pymod1.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package pymod1
|
||||
|
||||
/*
|
||||
#cgo pkg-config: python3-embed
|
||||
#include <Python.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func Float(f float64) *C.PyObject {
|
||||
return C.PyFloat_FromDouble(C.double(f))
|
||||
}
|
||||
11
compiler/cl/_testgo/cgofull/pymod2/pymod2.go
Normal file
11
compiler/cl/_testgo/cgofull/pymod2/pymod2.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package pymod2
|
||||
|
||||
/*
|
||||
#cgo pkg-config: python3-embed
|
||||
#include <Python.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func Long(l int64) *C.PyObject {
|
||||
return C.PyLong_FromLongLong(C.longlong(l))
|
||||
}
|
||||
31
compiler/cl/_testgo/cgomacro/cgomacro.go
Normal file
31
compiler/cl/_testgo/cgomacro/cgomacro.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#cgo pkg-config: python3-embed
|
||||
#include <stdio.h>
|
||||
#include <Python.h>
|
||||
|
||||
void test_stdout() {
|
||||
printf("stdout ptr: %p\n", stdout);
|
||||
fputs("outputs to stdout\n", stdout);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
func main() {
|
||||
C.test_stdout()
|
||||
C.fputs((*C.char)(unsafe.Pointer(c.Str("hello\n"))), C.stdout)
|
||||
C.Py_Initialize()
|
||||
defer C.Py_Finalize()
|
||||
C.PyObject_Print(C.Py_True, C.stdout, 0)
|
||||
C.fputs((*C.char)(unsafe.Pointer(c.Str("\n"))), C.stdout)
|
||||
C.PyObject_Print(C.Py_False, C.stdout, 0)
|
||||
C.fputs((*C.char)(unsafe.Pointer(c.Str("\n"))), C.stdout)
|
||||
C.PyObject_Print(C.Py_None, C.stdout, 0)
|
||||
C.fputs((*C.char)(unsafe.Pointer(c.Str("\n"))), C.stdout)
|
||||
}
|
||||
1
compiler/cl/_testgo/cgomacro/out.ll
Normal file
1
compiler/cl/_testgo/cgomacro/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
13
compiler/cl/_testgo/cgopython/cgopython.go
Normal file
13
compiler/cl/_testgo/cgopython/cgopython.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#cgo pkg-config: python3-embed
|
||||
#include <Python.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
C.Py_Initialize()
|
||||
defer C.Py_Finalize()
|
||||
C.PyRun_SimpleString(C.CString("print('Hello, Python!')"))
|
||||
}
|
||||
1
compiler/cl/_testgo/cgopython/out.ll
Normal file
1
compiler/cl/_testgo/cgopython/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
19
compiler/cl/_testgo/chan/in.go
Normal file
19
compiler/cl/_testgo/chan/in.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
ch := make(chan int, 10)
|
||||
var v any = ch
|
||||
println(ch, len(ch), cap(ch), v)
|
||||
go func() {
|
||||
ch <- 100
|
||||
}()
|
||||
n := <-ch
|
||||
println(n)
|
||||
|
||||
ch2 := make(chan int, 10)
|
||||
go func() {
|
||||
close(ch2)
|
||||
}()
|
||||
n2, ok := <-ch2
|
||||
println(n2, ok)
|
||||
}
|
||||
1
compiler/cl/_testgo/chan/out.ll
Normal file
1
compiler/cl/_testgo/chan/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
15
compiler/cl/_testgo/closure/in.go
Normal file
15
compiler/cl/_testgo/closure/in.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
type T func(n int)
|
||||
|
||||
func main() {
|
||||
var env string = "env"
|
||||
var v1 T = func(i int) {
|
||||
println("func", i)
|
||||
}
|
||||
var v2 T = func(i int) {
|
||||
println("closure", i, env)
|
||||
}
|
||||
v1(100)
|
||||
v2(200)
|
||||
}
|
||||
88
compiler/cl/_testgo/closure/out.ll
Normal file
88
compiler/cl/_testgo/closure/out.ll
Normal file
@@ -0,0 +1,88 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%main.T = 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 [3 x i8] c"env", align 1
|
||||
@1 = private unnamed_addr constant [4 x i8] c"func", align 1
|
||||
@2 = private unnamed_addr constant [7 x i8] c"closure", 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 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 3 }, 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$2", ptr undef }, ptr %3, 1
|
||||
%6 = alloca %main.T, align 8
|
||||
store { ptr, ptr } %5, ptr %6, align 8
|
||||
%7 = load %main.T, ptr %6, align 8
|
||||
call void @"__llgo_stub.main.main$1"(ptr null, i64 100)
|
||||
%8 = extractvalue %main.T %7, 1
|
||||
%9 = extractvalue %main.T %7, 0
|
||||
call void %9(ptr %8, i64 200)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @"main.main$1"(i64 %0) {
|
||||
_llgo_0:
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 })
|
||||
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 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.main$2"(ptr %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = load { ptr }, ptr %0, align 8
|
||||
%3 = extractvalue { ptr } %2, 0
|
||||
%4 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %3, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 7 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %1)
|
||||
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" %4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
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$1"(ptr %0, i64 %1) {
|
||||
_llgo_0:
|
||||
tail call void @"main.main$1"(i64 %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(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)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64)
|
||||
11
compiler/cl/_testgo/closure2/in.go
Normal file
11
compiler/cl/_testgo/closure2/in.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
x := 1
|
||||
f := func(i int) func(int) {
|
||||
return func(i int) {
|
||||
println("closure", i, x)
|
||||
}
|
||||
}
|
||||
f(1)(2)
|
||||
}
|
||||
80
compiler/cl/_testgo/closure2/out.ll
Normal file
80
compiler/cl/_testgo/closure2/out.ll
Normal file
@@ -0,0 +1,80 @@
|
||||
; 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"closure", 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)
|
||||
store i64 1, 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 = extractvalue { ptr, ptr } %5, 1
|
||||
%7 = extractvalue { ptr, ptr } %5, 0
|
||||
%8 = call { ptr, ptr } %7(ptr %6, i64 1)
|
||||
%9 = extractvalue { ptr, ptr } %8, 1
|
||||
%10 = extractvalue { ptr, ptr } %8, 0
|
||||
call void %10(ptr %9, i64 2)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define { ptr, ptr } @"main.main$1"(ptr %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = load { ptr }, ptr %0, align 8
|
||||
%3 = extractvalue { ptr } %2, 0
|
||||
%4 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%5 = getelementptr inbounds { ptr }, ptr %4, i32 0, i32 0
|
||||
store ptr %3, ptr %5, align 8
|
||||
%6 = insertvalue { ptr, ptr } { ptr @"main.main$1$1", ptr undef }, ptr %4, 1
|
||||
ret { ptr, ptr } %6
|
||||
}
|
||||
|
||||
define void @"main.main$1$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
|
||||
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 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %1)
|
||||
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
|
||||
}
|
||||
|
||||
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 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.PrintInt"(i64)
|
||||
9
compiler/cl/_testgo/constconv/in.go
Normal file
9
compiler/cl/_testgo/constconv/in.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
var i64 int64 = 1
|
||||
var u64 uint64 = 1
|
||||
var c int64 = i64 + (1.0 / (1.0 / 10))
|
||||
var d uint64 = u64 + (1.0 / (1.0 / 10))
|
||||
println(u64, i64, c, d)
|
||||
}
|
||||
44
compiler/cl/_testgo/constconv/out.ll
Normal file
44
compiler/cl/_testgo/constconv/out.ll
Normal file
@@ -0,0 +1,44 @@
|
||||
; 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 1)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 1)
|
||||
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.PrintUint"(i64 11)
|
||||
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.PrintUint"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64)
|
||||
18
compiler/cl/_testgo/defer1/in.go
Normal file
18
compiler/cl/_testgo/defer1/in.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
func f(s string) bool {
|
||||
return len(s) > 2
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
println("hi")
|
||||
}()
|
||||
if s := "hello"; f(s) {
|
||||
defer println(s)
|
||||
} else {
|
||||
defer println("world")
|
||||
return
|
||||
}
|
||||
defer println("bye")
|
||||
}
|
||||
1
compiler/cl/_testgo/defer1/out.ll
Normal file
1
compiler/cl/_testgo/defer1/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
15
compiler/cl/_testgo/defer2/in.go
Normal file
15
compiler/cl/_testgo/defer2/in.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
func f(s string) bool {
|
||||
return len(s) > 2
|
||||
}
|
||||
|
||||
func main() {
|
||||
if s := "hello"; f(s) {
|
||||
defer println(s)
|
||||
} else {
|
||||
defer println("world")
|
||||
return
|
||||
}
|
||||
defer println("bye")
|
||||
}
|
||||
1
compiler/cl/_testgo/defer2/out.ll
Normal file
1
compiler/cl/_testgo/defer2/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
24
compiler/cl/_testgo/defer3/in.go
Normal file
24
compiler/cl/_testgo/defer3/in.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
func f(s string) bool {
|
||||
return len(s) > 2
|
||||
}
|
||||
|
||||
func fail() {
|
||||
defer println("bye")
|
||||
panic("panic message")
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
println("hi")
|
||||
}()
|
||||
if s := "hello"; f(s) {
|
||||
defer println(s)
|
||||
} else {
|
||||
defer println("world")
|
||||
return
|
||||
}
|
||||
fail()
|
||||
println("unreachable")
|
||||
}
|
||||
1
compiler/cl/_testgo/defer3/out.ll
Normal file
1
compiler/cl/_testgo/defer3/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
29
compiler/cl/_testgo/defer4/in.go
Normal file
29
compiler/cl/_testgo/defer4/in.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
func f(s string) bool {
|
||||
return len(s) > 2
|
||||
}
|
||||
|
||||
func fail() {
|
||||
defer println("bye")
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
println("recover:", e.(string))
|
||||
}
|
||||
}()
|
||||
panic("panic message")
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
println("hi")
|
||||
}()
|
||||
if s := "hello"; f(s) {
|
||||
defer println(s)
|
||||
} else {
|
||||
defer println("world")
|
||||
return
|
||||
}
|
||||
fail()
|
||||
println("reachable")
|
||||
}
|
||||
1
compiler/cl/_testgo/defer4/out.ll
Normal file
1
compiler/cl/_testgo/defer4/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
17
compiler/cl/_testgo/defer5/in.go
Normal file
17
compiler/cl/_testgo/defer5/in.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
defer println("A")
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
println("in defer 1")
|
||||
panic("panic in defer 1")
|
||||
}
|
||||
}()
|
||||
defer func() {
|
||||
println("in defer 2")
|
||||
panic("panic in defer 2")
|
||||
}()
|
||||
defer println("B")
|
||||
panic("panic in main")
|
||||
}
|
||||
1
compiler/cl/_testgo/defer5/out.ll
Normal file
1
compiler/cl/_testgo/defer5/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
109
compiler/cl/_testgo/equal/in.go
Normal file
109
compiler/cl/_testgo/equal/in.go
Normal file
@@ -0,0 +1,109 @@
|
||||
package main
|
||||
|
||||
func test() {}
|
||||
|
||||
// func
|
||||
func init() {
|
||||
fn1 := test
|
||||
fn2 := func(i, j int) int { return i + j }
|
||||
var n int
|
||||
fn3 := func() { println(n) }
|
||||
var fn4 func() int
|
||||
assert(test != nil)
|
||||
assert(nil != test)
|
||||
assert(fn1 != nil)
|
||||
assert(nil != fn1)
|
||||
assert(fn2 != nil)
|
||||
assert(nil != fn2)
|
||||
assert(fn3 != nil)
|
||||
assert(nil != fn3)
|
||||
assert(fn4 == nil)
|
||||
assert(nil == fn4)
|
||||
}
|
||||
|
||||
// array
|
||||
func init() {
|
||||
assert([0]float64{} == [0]float64{})
|
||||
ar1 := [...]int{1, 2, 3}
|
||||
ar2 := [...]int{1, 2, 3}
|
||||
assert(ar1 == ar2)
|
||||
ar2[1] = 1
|
||||
assert(ar1 != ar2)
|
||||
}
|
||||
|
||||
type T struct {
|
||||
X int
|
||||
Y int
|
||||
Z string
|
||||
V any
|
||||
}
|
||||
|
||||
type N struct{}
|
||||
|
||||
// struct
|
||||
func init() {
|
||||
var n1, n2 N
|
||||
var t1, t2 T
|
||||
x := T{10, 20, "hello", 1}
|
||||
y := T{10, 20, "hello", 1}
|
||||
z := T{10, 20, "hello", "ok"}
|
||||
assert(n1 == n2)
|
||||
assert(t1 == t2)
|
||||
assert(x == y)
|
||||
assert(x != z)
|
||||
assert(y != z)
|
||||
}
|
||||
|
||||
// slice
|
||||
func init() {
|
||||
var a []int
|
||||
var b = []int{1, 2, 3}
|
||||
c := make([]int, 2)
|
||||
d := make([]int, 0, 2)
|
||||
assert(a == nil)
|
||||
assert(b != nil)
|
||||
assert(c != nil)
|
||||
assert(d != nil)
|
||||
b = nil
|
||||
assert(b == nil)
|
||||
}
|
||||
|
||||
// iface
|
||||
func init() {
|
||||
var a any = 100
|
||||
var b any = struct{}{}
|
||||
var c any = T{10, 20, "hello", 1}
|
||||
x := T{10, 20, "hello", 1}
|
||||
y := T{10, 20, "hello", "ok"}
|
||||
assert(a == 100)
|
||||
assert(b == struct{}{})
|
||||
assert(b != N{})
|
||||
assert(c == x)
|
||||
assert(c != y)
|
||||
}
|
||||
|
||||
// chan
|
||||
func init() {
|
||||
a := make(chan int)
|
||||
b := make(chan int)
|
||||
assert(a == a)
|
||||
assert(a != b)
|
||||
assert(a != nil)
|
||||
}
|
||||
|
||||
// map
|
||||
func init() {
|
||||
m1 := make(map[int]string)
|
||||
var m2 map[int]string
|
||||
assert(m1 != nil)
|
||||
assert(m2 == nil)
|
||||
}
|
||||
|
||||
func assert(cond bool) {
|
||||
if !cond {
|
||||
panic("failed")
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
}
|
||||
649
compiler/cl/_testgo/equal/out.ll
Normal file
649
compiler/cl/_testgo/equal/out.ll
Normal file
@@ -0,0 +1,649 @@
|
||||
; 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.T = type { i64, i64, %"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.eface" }
|
||||
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
||||
%main.N = type {}
|
||||
%"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
|
||||
@0 = private unnamed_addr constant [6 x i8] c"failed", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@1 = private unnamed_addr constant [5 x i8] c"hello", align 1
|
||||
@_llgo_int = linkonce global ptr null, align 8
|
||||
@2 = private unnamed_addr constant [2 x i8] c"ok", align 1
|
||||
@"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw" = linkonce global ptr null, align 8
|
||||
@3 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@_llgo_main.T = linkonce global ptr null, align 8
|
||||
@4 = private unnamed_addr constant [1 x i8] c"T", align 1
|
||||
@_llgo_any = linkonce global ptr null, align 8
|
||||
@"_llgo_struct$5D_KhR3tDEp-wpx9caTiVZca43wS-XW6slE9Bsr8rsk" = linkonce global ptr null, align 8
|
||||
@5 = private unnamed_addr constant [1 x i8] c"X", align 1
|
||||
@6 = private unnamed_addr constant [1 x i8] c"Y", align 1
|
||||
@7 = private unnamed_addr constant [1 x i8] c"Z", align 1
|
||||
@8 = private unnamed_addr constant [1 x i8] c"V", align 1
|
||||
@_llgo_main.N = linkonce global ptr null, align 8
|
||||
@9 = private unnamed_addr constant [1 x i8] c"N", align 1
|
||||
@"map[_llgo_int]_llgo_string" = linkonce global ptr null, align 8
|
||||
@10 = private unnamed_addr constant [7 x i8] c"topbits", align 1
|
||||
@11 = private unnamed_addr constant [4 x i8] c"keys", align 1
|
||||
@12 = private unnamed_addr constant [5 x i8] c"elems", align 1
|
||||
@13 = private unnamed_addr constant [8 x i8] c"overflow", align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
|
||||
define void @main.assert(i1 %0) {
|
||||
_llgo_0:
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%1 = load ptr, ptr @_llgo_string, align 8
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 6 }, ptr %2, align 8
|
||||
%3 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %1, 0
|
||||
%4 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %3, ptr %2, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %4)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_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"()
|
||||
call void @"main.init#1"()
|
||||
call void @"main.init#2"()
|
||||
call void @"main.init#3"()
|
||||
call void @"main.init#4"()
|
||||
call void @"main.init#5"()
|
||||
call void @"main.init#6"()
|
||||
call void @"main.init#7"()
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.init#1"() {
|
||||
_llgo_0:
|
||||
%0 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%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.init#1$2", ptr undef }, ptr %1, 1
|
||||
call void @main.assert(i1 true)
|
||||
call void @main.assert(i1 true)
|
||||
call void @main.assert(i1 true)
|
||||
call void @main.assert(i1 true)
|
||||
call void @main.assert(i1 true)
|
||||
call void @main.assert(i1 true)
|
||||
%4 = extractvalue { ptr, ptr } %3, 0
|
||||
%5 = icmp ne ptr %4, null
|
||||
call void @main.assert(i1 %5)
|
||||
%6 = extractvalue { ptr, ptr } %3, 0
|
||||
%7 = icmp ne ptr null, %6
|
||||
call void @main.assert(i1 %7)
|
||||
call void @main.assert(i1 true)
|
||||
call void @main.assert(i1 true)
|
||||
ret void
|
||||
}
|
||||
|
||||
define i64 @"main.init#1$1"(i64 %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = add i64 %0, %1
|
||||
ret i64 %2
|
||||
}
|
||||
|
||||
define void @"main.init#1$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
|
||||
}
|
||||
|
||||
define void @"main.init#2"() {
|
||||
_llgo_0:
|
||||
call void @main.assert(i1 true)
|
||||
%0 = alloca [3 x i64], align 8
|
||||
call void @llvm.memset(ptr %0, i8 0, i64 24, i1 false)
|
||||
%1 = getelementptr inbounds i64, ptr %0, i64 0
|
||||
%2 = getelementptr inbounds i64, ptr %0, i64 1
|
||||
%3 = getelementptr inbounds i64, ptr %0, i64 2
|
||||
store i64 1, ptr %1, align 4
|
||||
store i64 2, ptr %2, align 4
|
||||
store i64 3, ptr %3, align 4
|
||||
%4 = alloca [3 x i64], align 8
|
||||
call void @llvm.memset(ptr %4, i8 0, i64 24, i1 false)
|
||||
%5 = getelementptr inbounds i64, ptr %4, i64 0
|
||||
%6 = getelementptr inbounds i64, ptr %4, i64 1
|
||||
%7 = getelementptr inbounds i64, ptr %4, i64 2
|
||||
store i64 1, ptr %5, align 4
|
||||
store i64 2, ptr %6, align 4
|
||||
store i64 3, ptr %7, align 4
|
||||
%8 = load [3 x i64], ptr %0, align 4
|
||||
%9 = load [3 x i64], ptr %4, align 4
|
||||
%10 = extractvalue [3 x i64] %8, 0
|
||||
%11 = extractvalue [3 x i64] %9, 0
|
||||
%12 = icmp eq i64 %10, %11
|
||||
%13 = and i1 true, %12
|
||||
%14 = extractvalue [3 x i64] %8, 1
|
||||
%15 = extractvalue [3 x i64] %9, 1
|
||||
%16 = icmp eq i64 %14, %15
|
||||
%17 = and i1 %13, %16
|
||||
%18 = extractvalue [3 x i64] %8, 2
|
||||
%19 = extractvalue [3 x i64] %9, 2
|
||||
%20 = icmp eq i64 %18, %19
|
||||
%21 = and i1 %17, %20
|
||||
call void @main.assert(i1 %21)
|
||||
%22 = getelementptr inbounds i64, ptr %4, i64 1
|
||||
store i64 1, ptr %22, align 4
|
||||
%23 = load [3 x i64], ptr %0, align 4
|
||||
%24 = load [3 x i64], ptr %4, align 4
|
||||
%25 = extractvalue [3 x i64] %23, 0
|
||||
%26 = extractvalue [3 x i64] %24, 0
|
||||
%27 = icmp eq i64 %25, %26
|
||||
%28 = and i1 true, %27
|
||||
%29 = extractvalue [3 x i64] %23, 1
|
||||
%30 = extractvalue [3 x i64] %24, 1
|
||||
%31 = icmp eq i64 %29, %30
|
||||
%32 = and i1 %28, %31
|
||||
%33 = extractvalue [3 x i64] %23, 2
|
||||
%34 = extractvalue [3 x i64] %24, 2
|
||||
%35 = icmp eq i64 %33, %34
|
||||
%36 = and i1 %32, %35
|
||||
%37 = xor i1 %36, true
|
||||
call void @main.assert(i1 %37)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.init#3"() {
|
||||
_llgo_0:
|
||||
%0 = alloca %main.T, align 8
|
||||
call void @llvm.memset(ptr %0, i8 0, i64 48, i1 false)
|
||||
%1 = getelementptr inbounds %main.T, ptr %0, i32 0, i32 0
|
||||
%2 = getelementptr inbounds %main.T, ptr %0, i32 0, i32 1
|
||||
%3 = getelementptr inbounds %main.T, ptr %0, i32 0, i32 2
|
||||
%4 = getelementptr inbounds %main.T, ptr %0, i32 0, i32 3
|
||||
store i64 10, ptr %1, align 4
|
||||
store i64 20, ptr %2, align 4
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 5 }, ptr %3, align 8
|
||||
%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 inttoptr (i64 1 to ptr), 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %7, ptr %4, align 8
|
||||
%8 = alloca %main.T, align 8
|
||||
call void @llvm.memset(ptr %8, i8 0, i64 48, i1 false)
|
||||
%9 = getelementptr inbounds %main.T, ptr %8, i32 0, i32 0
|
||||
%10 = getelementptr inbounds %main.T, ptr %8, i32 0, i32 1
|
||||
%11 = getelementptr inbounds %main.T, ptr %8, i32 0, i32 2
|
||||
%12 = getelementptr inbounds %main.T, ptr %8, i32 0, i32 3
|
||||
store i64 10, ptr %9, align 4
|
||||
store i64 20, ptr %10, align 4
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 5 }, ptr %11, align 8
|
||||
%13 = load ptr, ptr @_llgo_int, align 8
|
||||
%14 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %13, 0
|
||||
%15 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %14, ptr inttoptr (i64 1 to ptr), 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %15, ptr %12, align 8
|
||||
%16 = alloca %main.T, align 8
|
||||
call void @llvm.memset(ptr %16, i8 0, i64 48, i1 false)
|
||||
%17 = getelementptr inbounds %main.T, ptr %16, i32 0, i32 0
|
||||
%18 = getelementptr inbounds %main.T, ptr %16, i32 0, i32 1
|
||||
%19 = getelementptr inbounds %main.T, ptr %16, i32 0, i32 2
|
||||
%20 = getelementptr inbounds %main.T, ptr %16, i32 0, i32 3
|
||||
store i64 10, ptr %17, align 4
|
||||
store i64 20, ptr %18, align 4
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 5 }, ptr %19, align 8
|
||||
%21 = load ptr, ptr @_llgo_string, align 8
|
||||
%22 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 2 }, ptr %22, align 8
|
||||
%23 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %21, 0
|
||||
%24 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %23, ptr %22, 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %24, ptr %20, align 8
|
||||
call void @main.assert(i1 true)
|
||||
%25 = call i1 @"github.com/goplus/llgo/internal/runtime.StringEqual"(%"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer)
|
||||
%26 = and i1 true, %25
|
||||
%27 = call i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface" zeroinitializer, %"github.com/goplus/llgo/internal/runtime.eface" zeroinitializer)
|
||||
%28 = and i1 %26, %27
|
||||
call void @main.assert(i1 %28)
|
||||
%29 = load %main.T, ptr %0, align 8
|
||||
%30 = load %main.T, ptr %8, align 8
|
||||
%31 = extractvalue %main.T %29, 0
|
||||
%32 = extractvalue %main.T %30, 0
|
||||
%33 = icmp eq i64 %31, %32
|
||||
%34 = and i1 true, %33
|
||||
%35 = extractvalue %main.T %29, 1
|
||||
%36 = extractvalue %main.T %30, 1
|
||||
%37 = icmp eq i64 %35, %36
|
||||
%38 = and i1 %34, %37
|
||||
%39 = extractvalue %main.T %29, 2
|
||||
%40 = extractvalue %main.T %30, 2
|
||||
%41 = call i1 @"github.com/goplus/llgo/internal/runtime.StringEqual"(%"github.com/goplus/llgo/internal/runtime.String" %39, %"github.com/goplus/llgo/internal/runtime.String" %40)
|
||||
%42 = and i1 %38, %41
|
||||
%43 = extractvalue %main.T %29, 3
|
||||
%44 = extractvalue %main.T %30, 3
|
||||
%45 = call i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface" %43, %"github.com/goplus/llgo/internal/runtime.eface" %44)
|
||||
%46 = and i1 %42, %45
|
||||
call void @main.assert(i1 %46)
|
||||
%47 = load %main.T, ptr %0, align 8
|
||||
%48 = load %main.T, ptr %16, align 8
|
||||
%49 = extractvalue %main.T %47, 0
|
||||
%50 = extractvalue %main.T %48, 0
|
||||
%51 = icmp eq i64 %49, %50
|
||||
%52 = and i1 true, %51
|
||||
%53 = extractvalue %main.T %47, 1
|
||||
%54 = extractvalue %main.T %48, 1
|
||||
%55 = icmp eq i64 %53, %54
|
||||
%56 = and i1 %52, %55
|
||||
%57 = extractvalue %main.T %47, 2
|
||||
%58 = extractvalue %main.T %48, 2
|
||||
%59 = call i1 @"github.com/goplus/llgo/internal/runtime.StringEqual"(%"github.com/goplus/llgo/internal/runtime.String" %57, %"github.com/goplus/llgo/internal/runtime.String" %58)
|
||||
%60 = and i1 %56, %59
|
||||
%61 = extractvalue %main.T %47, 3
|
||||
%62 = extractvalue %main.T %48, 3
|
||||
%63 = call i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface" %61, %"github.com/goplus/llgo/internal/runtime.eface" %62)
|
||||
%64 = and i1 %60, %63
|
||||
%65 = xor i1 %64, true
|
||||
call void @main.assert(i1 %65)
|
||||
%66 = load %main.T, ptr %8, align 8
|
||||
%67 = load %main.T, ptr %16, align 8
|
||||
%68 = extractvalue %main.T %66, 0
|
||||
%69 = extractvalue %main.T %67, 0
|
||||
%70 = icmp eq i64 %68, %69
|
||||
%71 = and i1 true, %70
|
||||
%72 = extractvalue %main.T %66, 1
|
||||
%73 = extractvalue %main.T %67, 1
|
||||
%74 = icmp eq i64 %72, %73
|
||||
%75 = and i1 %71, %74
|
||||
%76 = extractvalue %main.T %66, 2
|
||||
%77 = extractvalue %main.T %67, 2
|
||||
%78 = call i1 @"github.com/goplus/llgo/internal/runtime.StringEqual"(%"github.com/goplus/llgo/internal/runtime.String" %76, %"github.com/goplus/llgo/internal/runtime.String" %77)
|
||||
%79 = and i1 %75, %78
|
||||
%80 = extractvalue %main.T %66, 3
|
||||
%81 = extractvalue %main.T %67, 3
|
||||
%82 = call i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface" %80, %"github.com/goplus/llgo/internal/runtime.eface" %81)
|
||||
%83 = and i1 %79, %82
|
||||
%84 = xor i1 %83, true
|
||||
call void @main.assert(i1 %84)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.init#4"() {
|
||||
_llgo_0:
|
||||
%0 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 24)
|
||||
%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 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %0, 0
|
||||
%5 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %4, i64 3, 1
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %5, i64 3, 2
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
%8 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %7, i64 8, i64 2, i64 0, i64 2, i64 2)
|
||||
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
%10 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %9, i64 8, i64 2, i64 0, i64 0, i64 2)
|
||||
call void @main.assert(i1 true)
|
||||
%11 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %6, 0
|
||||
%12 = icmp ne ptr %11, null
|
||||
call void @main.assert(i1 %12)
|
||||
%13 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %8, 0
|
||||
%14 = icmp ne ptr %13, null
|
||||
call void @main.assert(i1 %14)
|
||||
%15 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %10, 0
|
||||
%16 = icmp ne ptr %15, null
|
||||
call void @main.assert(i1 %16)
|
||||
call void @main.assert(i1 true)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.init#5"() {
|
||||
_llgo_0:
|
||||
%0 = load ptr, ptr @_llgo_int, align 8
|
||||
%1 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %0, 0
|
||||
%2 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %1, ptr inttoptr (i64 100 to ptr), 1
|
||||
%3 = load ptr, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
%4 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
store {} zeroinitializer, ptr %4, align 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 = alloca %main.T, align 8
|
||||
call void @llvm.memset(ptr %7, i8 0, i64 48, i1 false)
|
||||
%8 = getelementptr inbounds %main.T, ptr %7, i32 0, i32 0
|
||||
%9 = getelementptr inbounds %main.T, ptr %7, i32 0, i32 1
|
||||
%10 = getelementptr inbounds %main.T, ptr %7, i32 0, i32 2
|
||||
%11 = getelementptr inbounds %main.T, ptr %7, i32 0, i32 3
|
||||
store i64 10, ptr %8, align 4
|
||||
store i64 20, ptr %9, align 4
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 5 }, ptr %10, align 8
|
||||
%12 = load ptr, ptr @_llgo_int, align 8
|
||||
%13 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %12, 0
|
||||
%14 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %13, ptr inttoptr (i64 1 to ptr), 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %14, ptr %11, align 8
|
||||
%15 = load %main.T, ptr %7, align 8
|
||||
%16 = load ptr, ptr @_llgo_main.T, align 8
|
||||
%17 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
|
||||
store %main.T %15, 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
|
||||
%20 = alloca %main.T, align 8
|
||||
call void @llvm.memset(ptr %20, i8 0, i64 48, i1 false)
|
||||
%21 = getelementptr inbounds %main.T, ptr %20, i32 0, i32 0
|
||||
%22 = getelementptr inbounds %main.T, ptr %20, i32 0, i32 1
|
||||
%23 = getelementptr inbounds %main.T, ptr %20, i32 0, i32 2
|
||||
%24 = getelementptr inbounds %main.T, ptr %20, i32 0, i32 3
|
||||
store i64 10, ptr %21, align 4
|
||||
store i64 20, ptr %22, align 4
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 5 }, ptr %23, align 8
|
||||
%25 = load ptr, ptr @_llgo_int, align 8
|
||||
%26 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %25, 0
|
||||
%27 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %26, ptr inttoptr (i64 1 to ptr), 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %27, ptr %24, align 8
|
||||
%28 = alloca %main.T, align 8
|
||||
call void @llvm.memset(ptr %28, i8 0, i64 48, i1 false)
|
||||
%29 = getelementptr inbounds %main.T, ptr %28, i32 0, i32 0
|
||||
%30 = getelementptr inbounds %main.T, ptr %28, i32 0, i32 1
|
||||
%31 = getelementptr inbounds %main.T, ptr %28, i32 0, i32 2
|
||||
%32 = getelementptr inbounds %main.T, ptr %28, i32 0, i32 3
|
||||
store i64 10, ptr %29, align 4
|
||||
store i64 20, ptr %30, align 4
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 5 }, ptr %31, align 8
|
||||
%33 = load ptr, ptr @_llgo_string, align 8
|
||||
%34 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 2 }, ptr %34, align 8
|
||||
%35 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %33, 0
|
||||
%36 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %35, ptr %34, 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.eface" %36, ptr %32, align 8
|
||||
%37 = load ptr, ptr @_llgo_int, align 8
|
||||
%38 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %37, 0
|
||||
%39 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %38, ptr inttoptr (i64 100 to ptr), 1
|
||||
%40 = call i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface" %2, %"github.com/goplus/llgo/internal/runtime.eface" %39)
|
||||
call void @main.assert(i1 %40)
|
||||
%41 = load ptr, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
%42 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
store {} zeroinitializer, ptr %42, align 1
|
||||
%43 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %41, 0
|
||||
%44 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %43, ptr %42, 1
|
||||
%45 = call i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface" %6, %"github.com/goplus/llgo/internal/runtime.eface" %44)
|
||||
call void @main.assert(i1 %45)
|
||||
%46 = load ptr, ptr @_llgo_main.N, align 8
|
||||
%47 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
store %main.N zeroinitializer, ptr %47, align 1
|
||||
%48 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %46, 0
|
||||
%49 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %48, ptr %47, 1
|
||||
%50 = call i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface" %6, %"github.com/goplus/llgo/internal/runtime.eface" %49)
|
||||
%51 = xor i1 %50, true
|
||||
call void @main.assert(i1 %51)
|
||||
%52 = load %main.T, ptr %20, align 8
|
||||
%53 = load ptr, ptr @_llgo_main.T, align 8
|
||||
%54 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
|
||||
store %main.T %52, ptr %54, align 8
|
||||
%55 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %53, 0
|
||||
%56 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %55, ptr %54, 1
|
||||
%57 = call i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface" %19, %"github.com/goplus/llgo/internal/runtime.eface" %56)
|
||||
call void @main.assert(i1 %57)
|
||||
%58 = load %main.T, ptr %28, align 8
|
||||
%59 = load ptr, ptr @_llgo_main.T, align 8
|
||||
%60 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
|
||||
store %main.T %58, ptr %60, align 8
|
||||
%61 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %59, 0
|
||||
%62 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %61, ptr %60, 1
|
||||
%63 = call i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface" %19, %"github.com/goplus/llgo/internal/runtime.eface" %62)
|
||||
%64 = xor i1 %63, true
|
||||
call void @main.assert(i1 %64)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.init#6"() {
|
||||
_llgo_0:
|
||||
%0 = call ptr @"github.com/goplus/llgo/internal/runtime.NewChan"(i64 8, i64 0)
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.NewChan"(i64 8, i64 0)
|
||||
%2 = icmp eq ptr %0, %0
|
||||
call void @main.assert(i1 %2)
|
||||
%3 = icmp ne ptr %0, %1
|
||||
call void @main.assert(i1 %3)
|
||||
%4 = icmp ne ptr %0, null
|
||||
call void @main.assert(i1 %4)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.init#7"() {
|
||||
_llgo_0:
|
||||
%0 = load ptr, ptr @"map[_llgo_int]_llgo_string", align 8
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr %0, i64 0)
|
||||
%2 = icmp ne ptr %1, null
|
||||
call void @main.assert(i1 %2)
|
||||
call void @main.assert(i1 true)
|
||||
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()
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
define void @main.test() {
|
||||
_llgo_0:
|
||||
ret void
|
||||
}
|
||||
|
||||
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
|
||||
%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_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", 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.AllocU"(i64 0)
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %8, 0
|
||||
%10 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, i64 0, 1
|
||||
%11 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %10, i64 0, 2
|
||||
%12 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 4 }, i64 0, %"github.com/goplus/llgo/internal/runtime.Slice" %11)
|
||||
store ptr %12, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
%13 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 1 }, i64 25, i64 48, i64 0, i64 0)
|
||||
%14 = load ptr, ptr @_llgo_main.T, align 8
|
||||
%15 = icmp eq ptr %14, null
|
||||
br i1 %15, label %_llgo_7, label %_llgo_8
|
||||
|
||||
_llgo_7: ; preds = %_llgo_6
|
||||
store ptr %13, ptr @_llgo_main.T, align 8
|
||||
br label %_llgo_8
|
||||
|
||||
_llgo_8: ; preds = %_llgo_7, %_llgo_6
|
||||
%16 = load ptr, ptr @_llgo_any, align 8
|
||||
%17 = icmp eq ptr %16, null
|
||||
br i1 %17, label %_llgo_9, label %_llgo_10
|
||||
|
||||
_llgo_9: ; preds = %_llgo_8
|
||||
%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.Interface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 4 }, %"github.com/goplus/llgo/internal/runtime.Slice" %21)
|
||||
store ptr %22, ptr @_llgo_any, align 8
|
||||
br label %_llgo_10
|
||||
|
||||
_llgo_10: ; preds = %_llgo_9, %_llgo_8
|
||||
%23 = load ptr, ptr @_llgo_any, align 8
|
||||
%24 = load ptr, ptr @"_llgo_struct$5D_KhR3tDEp-wpx9caTiVZca43wS-XW6slE9Bsr8rsk", align 8
|
||||
%25 = icmp eq ptr %24, null
|
||||
br i1 %25, label %_llgo_11, label %_llgo_12
|
||||
|
||||
_llgo_11: ; preds = %_llgo_10
|
||||
%26 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%27 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 1 }, ptr %26, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%28 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%29 = 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 %28, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%30 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
%31 = 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 %30, i64 16, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%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.Interface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 4 }, %"github.com/goplus/llgo/internal/runtime.Slice" %35)
|
||||
%37 = 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 %36, i64 32, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%38 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 224)
|
||||
%39 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %38, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %27, ptr %39, align 8
|
||||
%40 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %38, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %29, ptr %40, align 8
|
||||
%41 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %38, i64 2
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %31, ptr %41, align 8
|
||||
%42 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %38, i64 3
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %37, ptr %42, align 8
|
||||
%43 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %38, 0
|
||||
%44 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %43, i64 4, 1
|
||||
%45 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %44, i64 4, 2
|
||||
%46 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 4 }, i64 48, %"github.com/goplus/llgo/internal/runtime.Slice" %45)
|
||||
store ptr %46, ptr @"_llgo_struct$5D_KhR3tDEp-wpx9caTiVZca43wS-XW6slE9Bsr8rsk", align 8
|
||||
br label %_llgo_12
|
||||
|
||||
_llgo_12: ; preds = %_llgo_11, %_llgo_10
|
||||
%47 = load ptr, ptr @"_llgo_struct$5D_KhR3tDEp-wpx9caTiVZca43wS-XW6slE9Bsr8rsk", align 8
|
||||
br i1 %15, label %_llgo_13, label %_llgo_14
|
||||
|
||||
_llgo_13: ; preds = %_llgo_12
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %13, ptr %47, { ptr, i64, i64 } zeroinitializer, { ptr, i64, i64 } zeroinitializer)
|
||||
br label %_llgo_14
|
||||
|
||||
_llgo_14: ; preds = %_llgo_13, %_llgo_12
|
||||
%48 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @9, i64 1 }, i64 25, i64 0, i64 0, i64 0)
|
||||
%49 = load ptr, ptr @_llgo_main.N, align 8
|
||||
%50 = icmp eq ptr %49, null
|
||||
br i1 %50, label %_llgo_15, label %_llgo_16
|
||||
|
||||
_llgo_15: ; preds = %_llgo_14
|
||||
store ptr %48, ptr @_llgo_main.N, align 8
|
||||
br label %_llgo_16
|
||||
|
||||
_llgo_16: ; preds = %_llgo_15, %_llgo_14
|
||||
%51 = load ptr, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
br i1 %50, label %_llgo_17, label %_llgo_18
|
||||
|
||||
_llgo_17: ; preds = %_llgo_16
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %48, ptr %51, { ptr, i64, i64 } zeroinitializer, { ptr, i64, i64 } zeroinitializer)
|
||||
br label %_llgo_18
|
||||
|
||||
_llgo_18: ; preds = %_llgo_17, %_llgo_16
|
||||
%52 = load ptr, ptr @"map[_llgo_int]_llgo_string", 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 34)
|
||||
%55 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
%56 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 40)
|
||||
%57 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %56)
|
||||
%58 = 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 7 }, ptr %57, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%59 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
%60 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, ptr %59)
|
||||
%61 = 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 4 }, ptr %60, i64 8, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%62 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
%63 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 8, 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 @12, i64 5 }, ptr %63, i64 72, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%65 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 58)
|
||||
%66 = 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 8 }, ptr %65, i64 200, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%67 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 224)
|
||||
%68 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %67, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %58, 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" %61, 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" %64, 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" %66, ptr %71, align 8
|
||||
%72 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %67, 0
|
||||
%73 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %72, i64 4, 1
|
||||
%74 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %73, i64 4, 2
|
||||
%75 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 4 }, i64 208, %"github.com/goplus/llgo/internal/runtime.Slice" %74)
|
||||
%76 = call ptr @"github.com/goplus/llgo/internal/runtime.MapOf"(ptr %54, ptr %55, ptr %75, i64 4)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %76)
|
||||
store ptr %76, ptr @"map[_llgo_int]_llgo_string", align 8
|
||||
br label %_llgo_20
|
||||
|
||||
_llgo_20: ; preds = %_llgo_19, %_llgo_18
|
||||
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 ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64)
|
||||
|
||||
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
|
||||
|
||||
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.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface", %"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr, i64, i64, i64, i64, 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.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.Interface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
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.NewChan"(i64, i64)
|
||||
|
||||
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 void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.MakeMap"(ptr, i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
|
||||
22
compiler/cl/_testgo/errors/in.go
Normal file
22
compiler/cl/_testgo/errors/in.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
// New returns an error that formats as the given text.
|
||||
// Each call to New returns a distinct error value even if the text is identical.
|
||||
func New(text string) error {
|
||||
return &errorString{text}
|
||||
}
|
||||
|
||||
// errorString is a trivial implementation of error.
|
||||
type errorString struct {
|
||||
s string
|
||||
}
|
||||
|
||||
func (e *errorString) Error() string {
|
||||
return e.s
|
||||
}
|
||||
|
||||
func main() {
|
||||
err := New("an error")
|
||||
println(err)
|
||||
println(err.Error())
|
||||
}
|
||||
202
compiler/cl/_testgo/errors/out.ll
Normal file
202
compiler/cl/_testgo/errors/out.ll
Normal file
@@ -0,0 +1,202 @@
|
||||
; 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.errorString = type { %"github.com/goplus/llgo/internal/runtime.String" }
|
||||
%"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_main.errorString = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@1 = private unnamed_addr constant [11 x i8] c"errorString", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@"main.struct$QTufDJA9wEDzuzgkA-ZSrLqW-B6lWN8O25mTSglAoLQ" = linkonce global ptr null, align 8
|
||||
@2 = private unnamed_addr constant [1 x i8] c"s", align 1
|
||||
@3 = private unnamed_addr constant [5 x i8] c"Error", align 1
|
||||
@"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to" = linkonce global ptr null, align 8
|
||||
@"*_llgo_main.errorString" = linkonce global ptr null, align 8
|
||||
@"_llgo_iface$Fh8eUJ-Gw4e6TYuajcFIOSCuqSPKAt5nS4ow7xeGXEU" = linkonce global ptr null, align 8
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@4 = private unnamed_addr constant [8 x i8] c"an error", align 1
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.iface" @main.New(%"github.com/goplus/llgo/internal/runtime.String" %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
%2 = getelementptr inbounds %main.errorString, ptr %1, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" %0, ptr %2, align 8
|
||||
%3 = load ptr, ptr @_llgo_main.errorString, align 8
|
||||
%4 = load ptr, ptr @"*_llgo_main.errorString", align 8
|
||||
%5 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
%6 = load ptr, ptr @"_llgo_iface$Fh8eUJ-Gw4e6TYuajcFIOSCuqSPKAt5nS4ow7xeGXEU", align 8
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %6, ptr %4)
|
||||
%8 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %7, 0
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %8, ptr %1, 1
|
||||
ret %"github.com/goplus/llgo/internal/runtime.iface" %9
|
||||
}
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.String" @"main.(*errorString).Error"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = getelementptr inbounds %main.errorString, ptr %0, i32 0, i32 0
|
||||
%2 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %1, align 8
|
||||
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
|
||||
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.New(%"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 8 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintIface"(%"github.com/goplus/llgo/internal/runtime.iface" %2)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%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
|
||||
%11 = call %"github.com/goplus/llgo/internal/runtime.String" %10(ptr %9)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %11)
|
||||
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 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 11 }, i64 25, i64 16, i64 0, i64 1)
|
||||
store ptr %0, ptr @_llgo_main.errorString, align 8
|
||||
%1 = load ptr, ptr @_llgo_string, align 8
|
||||
%2 = icmp eq ptr %1, null
|
||||
br i1 %2, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
store ptr %3, ptr @_llgo_string, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%4 = load ptr, ptr @_llgo_string, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
%6 = 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 1 }, ptr %5, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 false)
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 56)
|
||||
%8 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %7, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %6, 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.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %11)
|
||||
store ptr %12, ptr @"main.struct$QTufDJA9wEDzuzgkA-ZSrLqW-B6lWN8O25mTSglAoLQ", align 8
|
||||
%13 = load ptr, ptr @"main.struct$QTufDJA9wEDzuzgkA-ZSrLqW-B6lWN8O25mTSglAoLQ", align 8
|
||||
%14 = load ptr, ptr @_llgo_string, align 8
|
||||
%15 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
%16 = icmp eq ptr %15, null
|
||||
br i1 %16, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_3: ; preds = %_llgo_2
|
||||
%17 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%18 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %17, 0
|
||||
%19 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %18, i64 0, 1
|
||||
%20 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %19, i64 0, 2
|
||||
%21 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%22 = getelementptr ptr, ptr %21, i64 0
|
||||
store ptr %14, ptr %22, align 8
|
||||
%23 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %21, 0
|
||||
%24 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %23, i64 1, 1
|
||||
%25 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %24, i64 1, 2
|
||||
%26 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %20, %"github.com/goplus/llgo/internal/runtime.Slice" %25, i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %26)
|
||||
store ptr %26, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%27 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
%28 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 5 }, ptr undef, ptr undef, ptr undef }, ptr %27, 1
|
||||
%29 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %28, ptr @"main.(*errorString).Error", 2
|
||||
%30 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %29, ptr @"main.(*errorString).Error", 3
|
||||
%31 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
||||
%32 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %31, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %30, ptr %32, align 8
|
||||
%33 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %31, 0
|
||||
%34 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %33, i64 1, 1
|
||||
%35 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %34, i64 1, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %0, ptr %13, { ptr, i64, i64 } zeroinitializer, %"github.com/goplus/llgo/internal/runtime.Slice" %35)
|
||||
%36 = 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 11 }, i64 25, i64 16, i64 0, i64 1)
|
||||
%37 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %36)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %37)
|
||||
store ptr %37, ptr @"*_llgo_main.errorString", align 8
|
||||
%38 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
%39 = load ptr, ptr @"_llgo_iface$Fh8eUJ-Gw4e6TYuajcFIOSCuqSPKAt5nS4ow7xeGXEU", align 8
|
||||
%40 = icmp eq ptr %39, null
|
||||
br i1 %40, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4
|
||||
%41 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 5 }, ptr undef }, ptr %38, 1
|
||||
%42 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
|
||||
%43 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %42, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %41, ptr %43, align 8
|
||||
%44 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %42, 0
|
||||
%45 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %44, i64 1, 1
|
||||
%46 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %45, i64 1, 2
|
||||
%47 = 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" %46)
|
||||
store ptr %47, ptr @"_llgo_iface$Fh8eUJ-Gw4e6TYuajcFIOSCuqSPKAt5nS4ow7xeGXEU", align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
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 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 void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
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.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
13
compiler/cl/_testgo/goroutine/in.go
Normal file
13
compiler/cl/_testgo/goroutine/in.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
done := false
|
||||
go println("hello")
|
||||
go func(s string) {
|
||||
println(s)
|
||||
done = true
|
||||
}("Hello, goroutine")
|
||||
for !done {
|
||||
print(".")
|
||||
}
|
||||
}
|
||||
110
compiler/cl/_testgo/goroutine/out.ll
Normal file
110
compiler/cl/_testgo/goroutine/out.ll
Normal file
@@ -0,0 +1,110 @@
|
||||
; 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 [5 x i8] c"hello", align 1
|
||||
@1 = private unnamed_addr constant [16 x i8] c"Hello, goroutine", align 1
|
||||
@2 = private unnamed_addr constant [1 x i8] c".", 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 1)
|
||||
store i1 false, ptr %2, align 1
|
||||
%3 = call ptr @malloc(i64 16)
|
||||
%4 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.String" }, ptr %3, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 5 }, ptr %4, align 8
|
||||
%5 = alloca i8, i64 8, align 1
|
||||
%6 = call i32 @"github.com/goplus/llgo/internal/runtime.CreateThread"(ptr %5, ptr null, ptr @"main._llgo_routine$1", ptr %3)
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%8 = getelementptr inbounds { ptr }, ptr %7, i32 0, i32 0
|
||||
store ptr %2, ptr %8, align 8
|
||||
%9 = insertvalue { ptr, ptr } { ptr @"main.main$1", ptr undef }, ptr %7, 1
|
||||
%10 = call ptr @malloc(i64 32)
|
||||
%11 = getelementptr inbounds { { ptr, ptr }, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %10, i32 0, i32 0
|
||||
store { ptr, ptr } %9, ptr %11, align 8
|
||||
%12 = getelementptr inbounds { { ptr, ptr }, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %10, i32 0, i32 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 16 }, ptr %12, align 8
|
||||
%13 = alloca i8, i64 8, align 1
|
||||
%14 = call i32 @"github.com/goplus/llgo/internal/runtime.CreateThread"(ptr %13, ptr null, ptr @"main._llgo_routine$2", ptr %10)
|
||||
br label %_llgo_3
|
||||
|
||||
_llgo_1: ; preds = %_llgo_3
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 1 })
|
||||
br label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_3
|
||||
ret i32 0
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1, %_llgo_0
|
||||
%15 = load i1, ptr %2, align 1
|
||||
br i1 %15, label %_llgo_2, label %_llgo_1
|
||||
}
|
||||
|
||||
define void @"main.main$1"(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)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
%2 = load { ptr }, ptr %0, align 8
|
||||
%3 = extractvalue { ptr } %2, 0
|
||||
store i1 true, ptr %3, align 1
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare ptr @malloc(i64)
|
||||
|
||||
define ptr @"main._llgo_routine$1"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { %"github.com/goplus/llgo/internal/runtime.String" }, ptr %0, align 8
|
||||
%2 = extractvalue { %"github.com/goplus/llgo/internal/runtime.String" } %1, 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 10)
|
||||
call void @free(ptr %0)
|
||||
ret ptr null
|
||||
}
|
||||
|
||||
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 @free(ptr)
|
||||
|
||||
declare i32 @"github.com/goplus/llgo/internal/runtime.CreateThread"(ptr, ptr, ptr, ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
define ptr @"main._llgo_routine$2"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { { ptr, ptr }, %"github.com/goplus/llgo/internal/runtime.String" }, ptr %0, align 8
|
||||
%2 = extractvalue { { ptr, ptr }, %"github.com/goplus/llgo/internal/runtime.String" } %1, 0
|
||||
%3 = extractvalue { { ptr, ptr }, %"github.com/goplus/llgo/internal/runtime.String" } %1, 1
|
||||
%4 = extractvalue { ptr, ptr } %2, 1
|
||||
%5 = extractvalue { ptr, ptr } %2, 0
|
||||
call void %5(ptr %4, %"github.com/goplus/llgo/internal/runtime.String" %3)
|
||||
call void @free(ptr %0)
|
||||
ret ptr null
|
||||
}
|
||||
85
compiler/cl/_testgo/ifaceconv/in.go
Normal file
85
compiler/cl/_testgo/ifaceconv/in.go
Normal file
@@ -0,0 +1,85 @@
|
||||
package main
|
||||
|
||||
// Tests of interface conversions and type assertions.
|
||||
|
||||
type I0 interface {
|
||||
}
|
||||
type I1 interface {
|
||||
f()
|
||||
}
|
||||
type I2 interface {
|
||||
f()
|
||||
g()
|
||||
}
|
||||
|
||||
type C0 struct{}
|
||||
type C1 struct{}
|
||||
|
||||
func (C1) f() {}
|
||||
|
||||
type C2 struct{}
|
||||
|
||||
func (C2) f() {}
|
||||
func (C2) g() {}
|
||||
|
||||
func main() {
|
||||
var i0 I0
|
||||
var i1 I1
|
||||
var i2 I2
|
||||
|
||||
// Nil always causes a type assertion to fail, even to the
|
||||
// same type.
|
||||
if _, ok := i0.(I0); ok {
|
||||
panic("nil i0.(I0) succeeded")
|
||||
}
|
||||
if _, ok := i1.(I1); ok {
|
||||
panic("nil i1.(I1) succeeded")
|
||||
}
|
||||
if _, ok := i2.(I2); ok {
|
||||
panic("nil i2.(I2) succeeded")
|
||||
}
|
||||
|
||||
// Conversions can't fail, even with nil.
|
||||
_ = I0(i0)
|
||||
|
||||
_ = I0(i1)
|
||||
_ = I1(i1)
|
||||
|
||||
_ = I0(i2)
|
||||
_ = I1(i2)
|
||||
_ = I2(i2)
|
||||
|
||||
// Non-nil type assertions pass or fail based on the concrete type.
|
||||
i1 = C1{}
|
||||
if _, ok := i1.(I0); !ok {
|
||||
panic("C1 i1.(I0) failed")
|
||||
}
|
||||
if _, ok := i1.(I1); !ok {
|
||||
panic("C1 i1.(I1) failed")
|
||||
}
|
||||
if _, ok := i1.(I2); ok {
|
||||
panic("C1 i1.(I2) succeeded")
|
||||
}
|
||||
|
||||
i1 = C2{}
|
||||
if _, ok := i1.(I0); !ok {
|
||||
panic("C2 i1.(I0) failed")
|
||||
}
|
||||
if _, ok := i1.(I1); !ok {
|
||||
panic("C2 i1.(I1) failed")
|
||||
}
|
||||
if _, ok := i1.(I2); !ok {
|
||||
panic("C2 i1.(I2) failed")
|
||||
}
|
||||
|
||||
// Conversions can't fail.
|
||||
i1 = C1{}
|
||||
if I0(i1) == nil {
|
||||
panic("C1 I0(i1) was nil")
|
||||
}
|
||||
if I1(i1) == nil {
|
||||
panic("C1 I1(i1) was nil")
|
||||
}
|
||||
|
||||
println("pass")
|
||||
}
|
||||
740
compiler/cl/_testgo/ifaceconv/out.ll
Normal file
740
compiler/cl/_testgo/ifaceconv/out.ll
Normal file
@@ -0,0 +1,740 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%main.C1 = type {}
|
||||
%main.C2 = type {}
|
||||
%"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/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.Method" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, 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 }
|
||||
|
||||
@"main.init$guard" = global i1 false, align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@_llgo_main.I0 = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@1 = private unnamed_addr constant [2 x i8] c"I0", align 1
|
||||
@2 = private unnamed_addr constant [21 x i8] c"nil i0.(I0) succeeded", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@_llgo_main.I1 = linkonce global ptr null, align 8
|
||||
@3 = private unnamed_addr constant [2 x i8] c"I1", align 1
|
||||
@"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac" = linkonce global ptr null, align 8
|
||||
@4 = private unnamed_addr constant [6 x i8] c"main.f", align 1
|
||||
@"main.iface$brpgdLtIeRlPi8QUoTgPCXzlehUkncg7v9aITo-GsF4" = linkonce global ptr null, align 8
|
||||
@5 = private unnamed_addr constant [21 x i8] c"nil i1.(I1) succeeded", align 1
|
||||
@_llgo_main.I2 = linkonce global ptr null, align 8
|
||||
@6 = private unnamed_addr constant [2 x i8] c"I2", align 1
|
||||
@7 = private unnamed_addr constant [6 x i8] c"main.g", align 1
|
||||
@"main.iface$gZBF8fFlqIMZ9M6lT2VWPyc3eu5Co6j0WoKGIEgDPAw" = linkonce global ptr null, align 8
|
||||
@8 = private unnamed_addr constant [21 x i8] c"nil i2.(I2) succeeded", align 1
|
||||
@_llgo_main.C1 = linkonce global ptr null, align 8
|
||||
@9 = private unnamed_addr constant [2 x i8] c"C1", align 1
|
||||
@"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw" = linkonce global ptr null, align 8
|
||||
@10 = private unnamed_addr constant [1 x i8] c"f", align 1
|
||||
@11 = private unnamed_addr constant [17 x i8] c"C1 i1.(I0) failed", align 1
|
||||
@12 = private unnamed_addr constant [17 x i8] c"C1 i1.(I1) failed", align 1
|
||||
@13 = private unnamed_addr constant [20 x i8] c"C1 i1.(I2) succeeded", align 1
|
||||
@_llgo_main.C2 = linkonce global ptr null, align 8
|
||||
@14 = private unnamed_addr constant [2 x i8] c"C2", align 1
|
||||
@15 = private unnamed_addr constant [1 x i8] c"g", align 1
|
||||
@16 = private unnamed_addr constant [17 x i8] c"C2 i1.(I0) failed", align 1
|
||||
@17 = private unnamed_addr constant [17 x i8] c"C2 i1.(I1) failed", align 1
|
||||
@18 = private unnamed_addr constant [17 x i8] c"C2 i1.(I2) failed", align 1
|
||||
@19 = private unnamed_addr constant [17 x i8] c"C1 I0(i1) was nil", align 1
|
||||
@20 = private unnamed_addr constant [17 x i8] c"C1 I1(i1) was nil", align 1
|
||||
@21 = private unnamed_addr constant [4 x i8] c"pass", align 1
|
||||
|
||||
define void @main.C1.f(%main.C1 %0) {
|
||||
_llgo_0:
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.(*C1).f"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load %main.C1, ptr %0, align 1
|
||||
call void @main.C1.f(%main.C1 %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.C2.f(%main.C2 %0) {
|
||||
_llgo_0:
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.C2.g(%main.C2 %0) {
|
||||
_llgo_0:
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.(*C2).f"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load %main.C2, ptr %0, align 1
|
||||
call void @main.C2.f(%main.C2 %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.(*C2).g"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load %main.C2, ptr %0, align 1
|
||||
call void @main.C2.g(%main.C2 %1)
|
||||
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 = load ptr, ptr @_llgo_main.I0, align 8
|
||||
%3 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %2, ptr null)
|
||||
br i1 %3, label %_llgo_23, label %_llgo_24
|
||||
|
||||
_llgo_1: ; preds = %_llgo_25
|
||||
%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 21 }, 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_25
|
||||
%8 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" zeroinitializer)
|
||||
%9 = load ptr, ptr @_llgo_main.I1, align 8
|
||||
%10 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %9, ptr %8)
|
||||
br i1 %10, label %_llgo_26, label %_llgo_27
|
||||
|
||||
_llgo_3: ; preds = %_llgo_28
|
||||
%11 = load ptr, ptr @_llgo_string, align 8
|
||||
%12 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 21 }, ptr %12, align 8
|
||||
%13 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %11, 0
|
||||
%14 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %13, ptr %12, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %14)
|
||||
unreachable
|
||||
|
||||
_llgo_4: ; preds = %_llgo_28
|
||||
%15 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" zeroinitializer)
|
||||
%16 = load ptr, ptr @_llgo_main.I2, align 8
|
||||
%17 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %16, ptr %15)
|
||||
br i1 %17, label %_llgo_29, label %_llgo_30
|
||||
|
||||
_llgo_5: ; preds = %_llgo_31
|
||||
%18 = load ptr, ptr @_llgo_string, align 8
|
||||
%19 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @8, i64 21 }, ptr %19, align 8
|
||||
%20 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %18, 0
|
||||
%21 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %20, ptr %19, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %21)
|
||||
unreachable
|
||||
|
||||
_llgo_6: ; preds = %_llgo_31
|
||||
%22 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" zeroinitializer)
|
||||
%23 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %22, 0
|
||||
%24 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %23, ptr null, 1
|
||||
%25 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" zeroinitializer)
|
||||
%26 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %25, 0
|
||||
%27 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %26, ptr null, 1
|
||||
%28 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" zeroinitializer)
|
||||
%29 = load ptr, ptr @"main.iface$brpgdLtIeRlPi8QUoTgPCXzlehUkncg7v9aITo-GsF4", align 8
|
||||
%30 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %29, ptr %28)
|
||||
%31 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %30, 0
|
||||
%32 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %31, ptr null, 1
|
||||
%33 = load ptr, ptr @_llgo_main.C1, align 8
|
||||
%34 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
store %main.C1 zeroinitializer, ptr %34, align 1
|
||||
%35 = load ptr, ptr @"main.iface$brpgdLtIeRlPi8QUoTgPCXzlehUkncg7v9aITo-GsF4", align 8
|
||||
%36 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %35, ptr %33)
|
||||
%37 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %36, 0
|
||||
%38 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %37, ptr %34, 1
|
||||
%39 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" %38)
|
||||
%40 = load ptr, ptr @_llgo_main.I0, align 8
|
||||
%41 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %40, ptr %39)
|
||||
br i1 %41, label %_llgo_32, label %_llgo_33
|
||||
|
||||
_llgo_7: ; preds = %_llgo_34
|
||||
%42 = load ptr, ptr @_llgo_string, align 8
|
||||
%43 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @11, i64 17 }, ptr %43, align 8
|
||||
%44 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %42, 0
|
||||
%45 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %44, ptr %43, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %45)
|
||||
unreachable
|
||||
|
||||
_llgo_8: ; preds = %_llgo_34
|
||||
%46 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" %38)
|
||||
%47 = load ptr, ptr @_llgo_main.I1, align 8
|
||||
%48 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %47, ptr %46)
|
||||
br i1 %48, label %_llgo_35, label %_llgo_36
|
||||
|
||||
_llgo_9: ; preds = %_llgo_37
|
||||
%49 = load ptr, ptr @_llgo_string, align 8
|
||||
%50 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @12, i64 17 }, ptr %50, align 8
|
||||
%51 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %49, 0
|
||||
%52 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %51, ptr %50, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %52)
|
||||
unreachable
|
||||
|
||||
_llgo_10: ; preds = %_llgo_37
|
||||
%53 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" %38)
|
||||
%54 = load ptr, ptr @_llgo_main.I2, align 8
|
||||
%55 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %54, ptr %53)
|
||||
br i1 %55, label %_llgo_38, label %_llgo_39
|
||||
|
||||
_llgo_11: ; preds = %_llgo_40
|
||||
%56 = load ptr, ptr @_llgo_string, align 8
|
||||
%57 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @13, i64 20 }, ptr %57, align 8
|
||||
%58 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %56, 0
|
||||
%59 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %58, ptr %57, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %59)
|
||||
unreachable
|
||||
|
||||
_llgo_12: ; preds = %_llgo_40
|
||||
%60 = load ptr, ptr @_llgo_main.C2, align 8
|
||||
%61 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
store %main.C2 zeroinitializer, ptr %61, align 1
|
||||
%62 = load ptr, ptr @"main.iface$brpgdLtIeRlPi8QUoTgPCXzlehUkncg7v9aITo-GsF4", align 8
|
||||
%63 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %62, ptr %60)
|
||||
%64 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %63, 0
|
||||
%65 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %64, ptr %61, 1
|
||||
%66 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" %65)
|
||||
%67 = load ptr, ptr @_llgo_main.I0, align 8
|
||||
%68 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %67, ptr %66)
|
||||
br i1 %68, label %_llgo_41, label %_llgo_42
|
||||
|
||||
_llgo_13: ; preds = %_llgo_43
|
||||
%69 = load ptr, ptr @_llgo_string, align 8
|
||||
%70 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @16, i64 17 }, ptr %70, align 8
|
||||
%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 @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %72)
|
||||
unreachable
|
||||
|
||||
_llgo_14: ; preds = %_llgo_43
|
||||
%73 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" %65)
|
||||
%74 = load ptr, ptr @_llgo_main.I1, align 8
|
||||
%75 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %74, ptr %73)
|
||||
br i1 %75, label %_llgo_44, label %_llgo_45
|
||||
|
||||
_llgo_15: ; preds = %_llgo_46
|
||||
%76 = load ptr, ptr @_llgo_string, align 8
|
||||
%77 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @17, i64 17 }, ptr %77, align 8
|
||||
%78 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %76, 0
|
||||
%79 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %78, ptr %77, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %79)
|
||||
unreachable
|
||||
|
||||
_llgo_16: ; preds = %_llgo_46
|
||||
%80 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" %65)
|
||||
%81 = load ptr, ptr @_llgo_main.I2, align 8
|
||||
%82 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %81, ptr %80)
|
||||
br i1 %82, label %_llgo_47, label %_llgo_48
|
||||
|
||||
_llgo_17: ; preds = %_llgo_49
|
||||
%83 = load ptr, ptr @_llgo_string, align 8
|
||||
%84 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @18, i64 17 }, ptr %84, align 8
|
||||
%85 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %83, 0
|
||||
%86 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %85, ptr %84, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %86)
|
||||
unreachable
|
||||
|
||||
_llgo_18: ; preds = %_llgo_49
|
||||
%87 = load ptr, ptr @_llgo_main.C1, align 8
|
||||
%88 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
store %main.C1 zeroinitializer, ptr %88, align 1
|
||||
%89 = load ptr, ptr @"main.iface$brpgdLtIeRlPi8QUoTgPCXzlehUkncg7v9aITo-GsF4", align 8
|
||||
%90 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %89, ptr %87)
|
||||
%91 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %90, 0
|
||||
%92 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %91, ptr %88, 1
|
||||
%93 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" %92)
|
||||
%94 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %92, 1
|
||||
%95 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %93, 0
|
||||
%96 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %95, ptr %94, 1
|
||||
%97 = call i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface" %96, %"github.com/goplus/llgo/internal/runtime.eface" zeroinitializer)
|
||||
br i1 %97, label %_llgo_19, label %_llgo_20
|
||||
|
||||
_llgo_19: ; preds = %_llgo_18
|
||||
%98 = load ptr, ptr @_llgo_string, align 8
|
||||
%99 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @19, i64 17 }, ptr %99, align 8
|
||||
%100 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %98, 0
|
||||
%101 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %100, ptr %99, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %101)
|
||||
unreachable
|
||||
|
||||
_llgo_20: ; preds = %_llgo_18
|
||||
%102 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" %92)
|
||||
%103 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %92, 1
|
||||
%104 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %102, 0
|
||||
%105 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %104, ptr %103, 1
|
||||
%106 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" zeroinitializer)
|
||||
%107 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %106, 0
|
||||
%108 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %107, ptr null, 1
|
||||
%109 = call i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface" %105, %"github.com/goplus/llgo/internal/runtime.eface" %108)
|
||||
br i1 %109, label %_llgo_21, label %_llgo_22
|
||||
|
||||
_llgo_21: ; preds = %_llgo_20
|
||||
%110 = load ptr, ptr @_llgo_string, align 8
|
||||
%111 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @20, i64 17 }, ptr %111, align 8
|
||||
%112 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %110, 0
|
||||
%113 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %112, ptr %111, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %113)
|
||||
unreachable
|
||||
|
||||
_llgo_22: ; preds = %_llgo_20
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @21, i64 4 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
|
||||
_llgo_23: ; preds = %_llgo_0
|
||||
br label %_llgo_25
|
||||
|
||||
_llgo_24: ; preds = %_llgo_0
|
||||
br label %_llgo_25
|
||||
|
||||
_llgo_25: ; preds = %_llgo_24, %_llgo_23
|
||||
%114 = phi { %"github.com/goplus/llgo/internal/runtime.eface", i1 } [ { %"github.com/goplus/llgo/internal/runtime.eface" zeroinitializer, i1 true }, %_llgo_23 ], [ zeroinitializer, %_llgo_24 ]
|
||||
%115 = extractvalue { %"github.com/goplus/llgo/internal/runtime.eface", i1 } %114, 0
|
||||
%116 = extractvalue { %"github.com/goplus/llgo/internal/runtime.eface", i1 } %114, 1
|
||||
br i1 %116, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_26: ; preds = %_llgo_2
|
||||
%117 = load ptr, ptr @"main.iface$brpgdLtIeRlPi8QUoTgPCXzlehUkncg7v9aITo-GsF4", align 8
|
||||
%118 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %117, ptr %8)
|
||||
%119 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %118, 0
|
||||
%120 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %119, ptr null, 1
|
||||
%121 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } undef, %"github.com/goplus/llgo/internal/runtime.iface" %120, 0
|
||||
%122 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %121, i1 true, 1
|
||||
br label %_llgo_28
|
||||
|
||||
_llgo_27: ; preds = %_llgo_2
|
||||
br label %_llgo_28
|
||||
|
||||
_llgo_28: ; preds = %_llgo_27, %_llgo_26
|
||||
%123 = phi { %"github.com/goplus/llgo/internal/runtime.iface", i1 } [ %122, %_llgo_26 ], [ zeroinitializer, %_llgo_27 ]
|
||||
%124 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %123, 0
|
||||
%125 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %123, 1
|
||||
br i1 %125, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_29: ; preds = %_llgo_4
|
||||
%126 = load ptr, ptr @"main.iface$gZBF8fFlqIMZ9M6lT2VWPyc3eu5Co6j0WoKGIEgDPAw", align 8
|
||||
%127 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %126, ptr %15)
|
||||
%128 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %127, 0
|
||||
%129 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %128, ptr null, 1
|
||||
%130 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } undef, %"github.com/goplus/llgo/internal/runtime.iface" %129, 0
|
||||
%131 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %130, i1 true, 1
|
||||
br label %_llgo_31
|
||||
|
||||
_llgo_30: ; preds = %_llgo_4
|
||||
br label %_llgo_31
|
||||
|
||||
_llgo_31: ; preds = %_llgo_30, %_llgo_29
|
||||
%132 = phi { %"github.com/goplus/llgo/internal/runtime.iface", i1 } [ %131, %_llgo_29 ], [ zeroinitializer, %_llgo_30 ]
|
||||
%133 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %132, 0
|
||||
%134 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %132, 1
|
||||
br i1 %134, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_32: ; preds = %_llgo_6
|
||||
%135 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %38, 1
|
||||
%136 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %39, 0
|
||||
%137 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %136, ptr %135, 1
|
||||
%138 = insertvalue { %"github.com/goplus/llgo/internal/runtime.eface", i1 } undef, %"github.com/goplus/llgo/internal/runtime.eface" %137, 0
|
||||
%139 = insertvalue { %"github.com/goplus/llgo/internal/runtime.eface", i1 } %138, i1 true, 1
|
||||
br label %_llgo_34
|
||||
|
||||
_llgo_33: ; preds = %_llgo_6
|
||||
br label %_llgo_34
|
||||
|
||||
_llgo_34: ; preds = %_llgo_33, %_llgo_32
|
||||
%140 = phi { %"github.com/goplus/llgo/internal/runtime.eface", i1 } [ %139, %_llgo_32 ], [ zeroinitializer, %_llgo_33 ]
|
||||
%141 = extractvalue { %"github.com/goplus/llgo/internal/runtime.eface", i1 } %140, 0
|
||||
%142 = extractvalue { %"github.com/goplus/llgo/internal/runtime.eface", i1 } %140, 1
|
||||
br i1 %142, label %_llgo_8, label %_llgo_7
|
||||
|
||||
_llgo_35: ; preds = %_llgo_8
|
||||
%143 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %38, 1
|
||||
%144 = load ptr, ptr @"main.iface$brpgdLtIeRlPi8QUoTgPCXzlehUkncg7v9aITo-GsF4", align 8
|
||||
%145 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %144, ptr %46)
|
||||
%146 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %145, 0
|
||||
%147 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %146, ptr %143, 1
|
||||
%148 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } undef, %"github.com/goplus/llgo/internal/runtime.iface" %147, 0
|
||||
%149 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %148, i1 true, 1
|
||||
br label %_llgo_37
|
||||
|
||||
_llgo_36: ; preds = %_llgo_8
|
||||
br label %_llgo_37
|
||||
|
||||
_llgo_37: ; preds = %_llgo_36, %_llgo_35
|
||||
%150 = phi { %"github.com/goplus/llgo/internal/runtime.iface", i1 } [ %149, %_llgo_35 ], [ zeroinitializer, %_llgo_36 ]
|
||||
%151 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %150, 0
|
||||
%152 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %150, 1
|
||||
br i1 %152, label %_llgo_10, label %_llgo_9
|
||||
|
||||
_llgo_38: ; preds = %_llgo_10
|
||||
%153 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %38, 1
|
||||
%154 = load ptr, ptr @"main.iface$gZBF8fFlqIMZ9M6lT2VWPyc3eu5Co6j0WoKGIEgDPAw", align 8
|
||||
%155 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %154, ptr %53)
|
||||
%156 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %155, 0
|
||||
%157 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %156, ptr %153, 1
|
||||
%158 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } undef, %"github.com/goplus/llgo/internal/runtime.iface" %157, 0
|
||||
%159 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %158, i1 true, 1
|
||||
br label %_llgo_40
|
||||
|
||||
_llgo_39: ; preds = %_llgo_10
|
||||
br label %_llgo_40
|
||||
|
||||
_llgo_40: ; preds = %_llgo_39, %_llgo_38
|
||||
%160 = phi { %"github.com/goplus/llgo/internal/runtime.iface", i1 } [ %159, %_llgo_38 ], [ zeroinitializer, %_llgo_39 ]
|
||||
%161 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %160, 0
|
||||
%162 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %160, 1
|
||||
br i1 %162, label %_llgo_11, label %_llgo_12
|
||||
|
||||
_llgo_41: ; preds = %_llgo_12
|
||||
%163 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %65, 1
|
||||
%164 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %66, 0
|
||||
%165 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %164, ptr %163, 1
|
||||
%166 = insertvalue { %"github.com/goplus/llgo/internal/runtime.eface", i1 } undef, %"github.com/goplus/llgo/internal/runtime.eface" %165, 0
|
||||
%167 = insertvalue { %"github.com/goplus/llgo/internal/runtime.eface", i1 } %166, i1 true, 1
|
||||
br label %_llgo_43
|
||||
|
||||
_llgo_42: ; preds = %_llgo_12
|
||||
br label %_llgo_43
|
||||
|
||||
_llgo_43: ; preds = %_llgo_42, %_llgo_41
|
||||
%168 = phi { %"github.com/goplus/llgo/internal/runtime.eface", i1 } [ %167, %_llgo_41 ], [ zeroinitializer, %_llgo_42 ]
|
||||
%169 = extractvalue { %"github.com/goplus/llgo/internal/runtime.eface", i1 } %168, 0
|
||||
%170 = extractvalue { %"github.com/goplus/llgo/internal/runtime.eface", i1 } %168, 1
|
||||
br i1 %170, label %_llgo_14, label %_llgo_13
|
||||
|
||||
_llgo_44: ; preds = %_llgo_14
|
||||
%171 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %65, 1
|
||||
%172 = load ptr, ptr @"main.iface$brpgdLtIeRlPi8QUoTgPCXzlehUkncg7v9aITo-GsF4", align 8
|
||||
%173 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %172, ptr %73)
|
||||
%174 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %173, 0
|
||||
%175 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %174, ptr %171, 1
|
||||
%176 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } undef, %"github.com/goplus/llgo/internal/runtime.iface" %175, 0
|
||||
%177 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %176, i1 true, 1
|
||||
br label %_llgo_46
|
||||
|
||||
_llgo_45: ; preds = %_llgo_14
|
||||
br label %_llgo_46
|
||||
|
||||
_llgo_46: ; preds = %_llgo_45, %_llgo_44
|
||||
%178 = phi { %"github.com/goplus/llgo/internal/runtime.iface", i1 } [ %177, %_llgo_44 ], [ zeroinitializer, %_llgo_45 ]
|
||||
%179 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %178, 0
|
||||
%180 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %178, 1
|
||||
br i1 %180, label %_llgo_16, label %_llgo_15
|
||||
|
||||
_llgo_47: ; preds = %_llgo_16
|
||||
%181 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %65, 1
|
||||
%182 = load ptr, ptr @"main.iface$gZBF8fFlqIMZ9M6lT2VWPyc3eu5Co6j0WoKGIEgDPAw", align 8
|
||||
%183 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %182, ptr %80)
|
||||
%184 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %183, 0
|
||||
%185 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %184, ptr %181, 1
|
||||
%186 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } undef, %"github.com/goplus/llgo/internal/runtime.iface" %185, 0
|
||||
%187 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %186, i1 true, 1
|
||||
br label %_llgo_49
|
||||
|
||||
_llgo_48: ; preds = %_llgo_16
|
||||
br label %_llgo_49
|
||||
|
||||
_llgo_49: ; preds = %_llgo_48, %_llgo_47
|
||||
%188 = phi { %"github.com/goplus/llgo/internal/runtime.iface", i1 } [ %187, %_llgo_47 ], [ zeroinitializer, %_llgo_48 ]
|
||||
%189 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %188, 0
|
||||
%190 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %188, 1
|
||||
br i1 %190, label %_llgo_18, label %_llgo_17
|
||||
}
|
||||
|
||||
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.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 2 })
|
||||
%1 = load ptr, ptr @_llgo_main.I0, 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.I0, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
br i1 %2, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_3: ; preds = %_llgo_2
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%4 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %3, 0
|
||||
%5 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %4, i64 0, 1
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %5, i64 0, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr %0, %"github.com/goplus/llgo/internal/runtime.Slice" %6)
|
||||
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 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 2 })
|
||||
%11 = load ptr, ptr @_llgo_main.I1, align 8
|
||||
%12 = icmp eq ptr %11, null
|
||||
br i1 %12, label %_llgo_7, label %_llgo_8
|
||||
|
||||
_llgo_7: ; preds = %_llgo_6
|
||||
store ptr %10, ptr @_llgo_main.I1, align 8
|
||||
br label %_llgo_8
|
||||
|
||||
_llgo_8: ; preds = %_llgo_7, %_llgo_6
|
||||
%13 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%14 = icmp eq ptr %13, null
|
||||
br i1 %14, label %_llgo_9, label %_llgo_10
|
||||
|
||||
_llgo_9: ; preds = %_llgo_8
|
||||
%15 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%16 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %15, 0
|
||||
%17 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %16, i64 0, 1
|
||||
%18 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %17, i64 0, 2
|
||||
%19 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%20 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %19, 0
|
||||
%21 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %20, i64 0, 1
|
||||
%22 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %21, i64 0, 2
|
||||
%23 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %18, %"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$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
br label %_llgo_10
|
||||
|
||||
_llgo_10: ; preds = %_llgo_9, %_llgo_8
|
||||
%24 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
br i1 %12, label %_llgo_11, label %_llgo_12
|
||||
|
||||
_llgo_11: ; preds = %_llgo_10
|
||||
%25 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 6 }, 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 %10, %"github.com/goplus/llgo/internal/runtime.Slice" %30)
|
||||
br label %_llgo_12
|
||||
|
||||
_llgo_12: ; preds = %_llgo_11, %_llgo_10
|
||||
%31 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%32 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 6 }, ptr undef }, ptr %31, 1
|
||||
%33 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
|
||||
%34 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %33, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %32, ptr %34, align 8
|
||||
%35 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %33, 0
|
||||
%36 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %35, i64 1, 1
|
||||
%37 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %36, i64 1, 2
|
||||
%38 = 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" %37)
|
||||
store ptr %38, ptr @"main.iface$brpgdLtIeRlPi8QUoTgPCXzlehUkncg7v9aITo-GsF4", align 8
|
||||
%39 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 2 })
|
||||
%40 = load ptr, ptr @_llgo_main.I2, align 8
|
||||
%41 = icmp eq ptr %40, null
|
||||
br i1 %41, label %_llgo_13, label %_llgo_14
|
||||
|
||||
_llgo_13: ; preds = %_llgo_12
|
||||
store ptr %39, ptr @_llgo_main.I2, align 8
|
||||
br label %_llgo_14
|
||||
|
||||
_llgo_14: ; preds = %_llgo_13, %_llgo_12
|
||||
%42 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%43 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
br i1 %41, label %_llgo_15, label %_llgo_16
|
||||
|
||||
_llgo_15: ; preds = %_llgo_14
|
||||
%44 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 6 }, ptr undef }, ptr %42, 1
|
||||
%45 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 6 }, ptr undef }, ptr %43, 1
|
||||
%46 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
|
||||
%47 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %46, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %44, ptr %47, align 8
|
||||
%48 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %46, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %45, ptr %48, align 8
|
||||
%49 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %46, 0
|
||||
%50 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %49, i64 2, 1
|
||||
%51 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %50, i64 2, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr %39, %"github.com/goplus/llgo/internal/runtime.Slice" %51)
|
||||
br label %_llgo_16
|
||||
|
||||
_llgo_16: ; preds = %_llgo_15, %_llgo_14
|
||||
%52 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%53 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%54 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 6 }, ptr undef }, ptr %52, 1
|
||||
%55 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 6 }, ptr undef }, ptr %53, 1
|
||||
%56 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
|
||||
%57 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %56, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %54, ptr %57, align 8
|
||||
%58 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %56, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %55, ptr %58, align 8
|
||||
%59 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %56, 0
|
||||
%60 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %59, i64 2, 1
|
||||
%61 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %60, i64 2, 2
|
||||
%62 = 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" %61)
|
||||
store ptr %62, ptr @"main.iface$gZBF8fFlqIMZ9M6lT2VWPyc3eu5Co6j0WoKGIEgDPAw", align 8
|
||||
%63 = 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 @9, i64 2 }, i64 25, i64 0, i64 1, i64 1)
|
||||
%64 = load ptr, ptr @_llgo_main.C1, align 8
|
||||
%65 = icmp eq ptr %64, null
|
||||
br i1 %65, label %_llgo_17, label %_llgo_18
|
||||
|
||||
_llgo_17: ; preds = %_llgo_16
|
||||
store ptr %63, ptr @_llgo_main.C1, align 8
|
||||
br label %_llgo_18
|
||||
|
||||
_llgo_18: ; preds = %_llgo_17, %_llgo_16
|
||||
%66 = load ptr, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
%67 = icmp eq ptr %66, null
|
||||
br i1 %67, label %_llgo_19, label %_llgo_20
|
||||
|
||||
_llgo_19: ; preds = %_llgo_18
|
||||
%68 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%69 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %68, 0
|
||||
%70 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %69, i64 0, 1
|
||||
%71 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %70, i64 0, 2
|
||||
%72 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, i64 0, %"github.com/goplus/llgo/internal/runtime.Slice" %71)
|
||||
store ptr %72, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
br label %_llgo_20
|
||||
|
||||
_llgo_20: ; preds = %_llgo_19, %_llgo_18
|
||||
%73 = load ptr, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
br i1 %65, label %_llgo_21, label %_llgo_22
|
||||
|
||||
_llgo_21: ; preds = %_llgo_20
|
||||
%74 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%75 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 6 }, ptr undef, ptr undef, ptr undef }, ptr %74, 1
|
||||
%76 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %75, ptr @"main.(*C1).f", 2
|
||||
%77 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %76, ptr @"main.(*C1).f", 3
|
||||
%78 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 6 }, ptr undef, ptr undef, ptr undef }, ptr %74, 1
|
||||
%79 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %78, ptr @"main.(*C1).f", 2
|
||||
%80 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %79, ptr @main.C1.f, 3
|
||||
%81 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
||||
%82 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %81, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %80, ptr %82, align 8
|
||||
%83 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %81, 0
|
||||
%84 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %83, i64 1, 1
|
||||
%85 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %84, i64 1, 2
|
||||
%86 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
||||
%87 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %86, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %77, ptr %87, align 8
|
||||
%88 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %86, 0
|
||||
%89 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %88, i64 1, 1
|
||||
%90 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %89, i64 1, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %63, ptr %73, %"github.com/goplus/llgo/internal/runtime.Slice" %85, %"github.com/goplus/llgo/internal/runtime.Slice" %90)
|
||||
br label %_llgo_22
|
||||
|
||||
_llgo_22: ; preds = %_llgo_21, %_llgo_20
|
||||
%91 = 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 @14, i64 2 }, i64 25, i64 0, i64 2, i64 2)
|
||||
%92 = load ptr, ptr @_llgo_main.C2, align 8
|
||||
%93 = icmp eq ptr %92, null
|
||||
br i1 %93, label %_llgo_23, label %_llgo_24
|
||||
|
||||
_llgo_23: ; preds = %_llgo_22
|
||||
store ptr %91, ptr @_llgo_main.C2, align 8
|
||||
br label %_llgo_24
|
||||
|
||||
_llgo_24: ; preds = %_llgo_23, %_llgo_22
|
||||
%94 = load ptr, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
br i1 %93, label %_llgo_25, label %_llgo_26
|
||||
|
||||
_llgo_25: ; preds = %_llgo_24
|
||||
%95 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%96 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 6 }, ptr undef, ptr undef, ptr undef }, ptr %95, 1
|
||||
%97 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %96, ptr @"main.(*C2).f", 2
|
||||
%98 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %97, ptr @"main.(*C2).f", 3
|
||||
%99 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 6 }, ptr undef, ptr undef, ptr undef }, ptr %95, 1
|
||||
%100 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %99, ptr @"main.(*C2).f", 2
|
||||
%101 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %100, ptr @main.C2.f, 3
|
||||
%102 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%103 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 6 }, ptr undef, ptr undef, ptr undef }, ptr %102, 1
|
||||
%104 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %103, ptr @"main.(*C2).g", 2
|
||||
%105 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %104, ptr @"main.(*C2).g", 3
|
||||
%106 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 6 }, ptr undef, ptr undef, ptr undef }, ptr %102, 1
|
||||
%107 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %106, ptr @"main.(*C2).g", 2
|
||||
%108 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %107, ptr @main.C2.g, 3
|
||||
%109 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 80)
|
||||
%110 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %109, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %101, ptr %110, align 8
|
||||
%111 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %109, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %108, ptr %111, align 8
|
||||
%112 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %109, 0
|
||||
%113 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %112, i64 2, 1
|
||||
%114 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %113, i64 2, 2
|
||||
%115 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 80)
|
||||
%116 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %115, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %98, ptr %116, align 8
|
||||
%117 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %115, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %105, ptr %117, align 8
|
||||
%118 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %115, 0
|
||||
%119 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %118, i64 2, 1
|
||||
%120 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %119, i64 2, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %91, ptr %94, %"github.com/goplus/llgo/internal/runtime.Slice" %114, %"github.com/goplus/llgo/internal/runtime.Slice" %120)
|
||||
br label %_llgo_26
|
||||
|
||||
_llgo_26: ; preds = %_llgo_25, %_llgo_24
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr, ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface")
|
||||
|
||||
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.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.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.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 i1 @"github.com/goplus/llgo/internal/runtime.EfaceEqual"(%"github.com/goplus/llgo/internal/runtime.eface", %"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)
|
||||
60
compiler/cl/_testgo/ifaceprom/in.go
Normal file
60
compiler/cl/_testgo/ifaceprom/in.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package main
|
||||
|
||||
// Test of promotion of methods of an interface embedded within a
|
||||
// struct. In particular, this test exercises that the correct
|
||||
// method is called.
|
||||
|
||||
type I interface {
|
||||
one() int
|
||||
two() string
|
||||
}
|
||||
|
||||
type S struct {
|
||||
I
|
||||
}
|
||||
|
||||
type impl struct{}
|
||||
|
||||
func (impl) one() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
func (impl) two() string {
|
||||
return "two"
|
||||
}
|
||||
|
||||
func main() {
|
||||
var s S
|
||||
s.I = impl{}
|
||||
if one := s.I.one(); one != 1 {
|
||||
panic(one)
|
||||
}
|
||||
if one := s.one(); one != 1 {
|
||||
panic(one)
|
||||
}
|
||||
closOne := s.I.one
|
||||
if one := closOne(); one != 1 {
|
||||
panic(one)
|
||||
}
|
||||
closOne = s.one
|
||||
if one := closOne(); one != 1 {
|
||||
panic(one)
|
||||
}
|
||||
|
||||
if two := s.I.two(); two != "two" {
|
||||
panic(two)
|
||||
}
|
||||
if two := s.two(); two != "two" {
|
||||
panic(two)
|
||||
}
|
||||
closTwo := s.I.two
|
||||
if two := closTwo(); two != "two" {
|
||||
panic(two)
|
||||
}
|
||||
closTwo = s.two
|
||||
if two := closTwo(); two != "two" {
|
||||
panic(two)
|
||||
}
|
||||
|
||||
println("pass")
|
||||
}
|
||||
668
compiler/cl/_testgo/ifaceprom/out.ll
Normal file
668
compiler/cl/_testgo/ifaceprom/out.ll
Normal file
@@ -0,0 +1,668 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%main.S = type { %"github.com/goplus/llgo/internal/runtime.iface" }
|
||||
%"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
||||
%main.impl = type {}
|
||||
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
||||
%"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 }
|
||||
%"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
|
||||
@0 = private unnamed_addr constant [3 x i8] c"two", align 1
|
||||
@__llgo_argc = global i32 0, align 4
|
||||
@__llgo_argv = global ptr null, align 8
|
||||
@_llgo_main.impl = linkonce global ptr null, align 8
|
||||
@1 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@2 = private unnamed_addr constant [4 x i8] c"impl", align 1
|
||||
@"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw" = linkonce global ptr null, align 8
|
||||
@3 = private unnamed_addr constant [3 x i8] c"one", align 1
|
||||
@4 = private unnamed_addr constant [8 x i8] c"main.one", align 1
|
||||
@_llgo_int = linkonce global ptr null, align 8
|
||||
@"_llgo_func$ETeB8WwW04JEq0ztcm-XPTJtuYvtpkjIsAc0-2NT9zA" = linkonce global ptr null, align 8
|
||||
@5 = private unnamed_addr constant [8 x i8] c"main.two", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to" = linkonce global ptr null, align 8
|
||||
@"main.iface$zZ89tENb5h_KNjvpxf1TXPfaWFYn0IZrZwyVf42lRtA" = linkonce global ptr null, align 8
|
||||
@_llgo_main.I = linkonce global ptr null, align 8
|
||||
@6 = private unnamed_addr constant [1 x i8] c"I", align 1
|
||||
@7 = private unnamed_addr constant [21 x i8] c"type assertion failed", align 1
|
||||
@8 = private unnamed_addr constant [4 x i8] c"pass", align 1
|
||||
|
||||
define i64 @main.S.one(%main.S %0) {
|
||||
_llgo_0:
|
||||
%1 = alloca %main.S, align 8
|
||||
call void @llvm.memset(ptr %1, i8 0, i64 16, i1 false)
|
||||
store %main.S %0, ptr %1, align 8
|
||||
%2 = getelementptr inbounds %main.S, ptr %1, i32 0, i32 0
|
||||
%3 = load %"github.com/goplus/llgo/internal/runtime.iface", ptr %2, align 8
|
||||
%4 = call ptr @"github.com/goplus/llgo/internal/runtime.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface" %3)
|
||||
%5 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %3, 0
|
||||
%6 = getelementptr ptr, ptr %5, i64 3
|
||||
%7 = load ptr, ptr %6, align 8
|
||||
%8 = insertvalue { ptr, ptr } undef, ptr %7, 0
|
||||
%9 = insertvalue { ptr, ptr } %8, ptr %4, 1
|
||||
%10 = extractvalue { ptr, ptr } %9, 1
|
||||
%11 = extractvalue { ptr, ptr } %9, 0
|
||||
%12 = call i64 %11(ptr %10)
|
||||
ret i64 %12
|
||||
}
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.String" @main.S.two(%main.S %0) {
|
||||
_llgo_0:
|
||||
%1 = alloca %main.S, align 8
|
||||
call void @llvm.memset(ptr %1, i8 0, i64 16, i1 false)
|
||||
store %main.S %0, ptr %1, align 8
|
||||
%2 = getelementptr inbounds %main.S, ptr %1, i32 0, i32 0
|
||||
%3 = load %"github.com/goplus/llgo/internal/runtime.iface", ptr %2, align 8
|
||||
%4 = call ptr @"github.com/goplus/llgo/internal/runtime.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface" %3)
|
||||
%5 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %3, 0
|
||||
%6 = getelementptr ptr, ptr %5, i64 4
|
||||
%7 = load ptr, ptr %6, align 8
|
||||
%8 = insertvalue { ptr, ptr } undef, ptr %7, 0
|
||||
%9 = insertvalue { ptr, ptr } %8, ptr %4, 1
|
||||
%10 = extractvalue { ptr, ptr } %9, 1
|
||||
%11 = extractvalue { ptr, ptr } %9, 0
|
||||
%12 = call %"github.com/goplus/llgo/internal/runtime.String" %11(ptr %10)
|
||||
ret %"github.com/goplus/llgo/internal/runtime.String" %12
|
||||
}
|
||||
|
||||
define i64 @"main.(*S).one"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = getelementptr inbounds %main.S, ptr %0, i32 0, i32 0
|
||||
%2 = load %"github.com/goplus/llgo/internal/runtime.iface", ptr %1, align 8
|
||||
%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
|
||||
%11 = call i64 %10(ptr %9)
|
||||
ret i64 %11
|
||||
}
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.String" @"main.(*S).two"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = getelementptr inbounds %main.S, ptr %0, i32 0, i32 0
|
||||
%2 = load %"github.com/goplus/llgo/internal/runtime.iface", ptr %1, align 8
|
||||
%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 4
|
||||
%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
|
||||
%11 = call %"github.com/goplus/llgo/internal/runtime.String" %10(ptr %9)
|
||||
ret %"github.com/goplus/llgo/internal/runtime.String" %11
|
||||
}
|
||||
|
||||
define i64 @main.impl.one(%main.impl %0) {
|
||||
_llgo_0:
|
||||
ret i64 1
|
||||
}
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.String" @main.impl.two(%main.impl %0) {
|
||||
_llgo_0:
|
||||
ret %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 3 }
|
||||
}
|
||||
|
||||
define i64 @"main.(*impl).one"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load %main.impl, ptr %0, align 1
|
||||
%2 = call i64 @main.impl.one(%main.impl %1)
|
||||
ret i64 %2
|
||||
}
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.String" @"main.(*impl).two"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load %main.impl, ptr %0, align 1
|
||||
%2 = call %"github.com/goplus/llgo/internal/runtime.String" @main.impl.two(%main.impl %1)
|
||||
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
|
||||
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.S, align 8
|
||||
call void @llvm.memset(ptr %2, i8 0, i64 16, i1 false)
|
||||
%3 = getelementptr inbounds %main.S, ptr %2, i32 0, i32 0
|
||||
%4 = load ptr, ptr @_llgo_main.impl, align 8
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
store %main.impl zeroinitializer, ptr %5, align 1
|
||||
%6 = load ptr, ptr @"_llgo_func$ETeB8WwW04JEq0ztcm-XPTJtuYvtpkjIsAc0-2NT9zA", align 8
|
||||
%7 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
%8 = load ptr, ptr @"main.iface$zZ89tENb5h_KNjvpxf1TXPfaWFYn0IZrZwyVf42lRtA", 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 %5, 1
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %11, ptr %3, align 8
|
||||
%12 = getelementptr inbounds %main.S, ptr %2, i32 0, i32 0
|
||||
%13 = load %"github.com/goplus/llgo/internal/runtime.iface", ptr %12, align 8
|
||||
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface" %13)
|
||||
%15 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %13, 0
|
||||
%16 = getelementptr ptr, ptr %15, i64 3
|
||||
%17 = load ptr, ptr %16, align 8
|
||||
%18 = insertvalue { ptr, ptr } undef, ptr %17, 0
|
||||
%19 = insertvalue { ptr, ptr } %18, ptr %14, 1
|
||||
%20 = extractvalue { ptr, ptr } %19, 1
|
||||
%21 = extractvalue { ptr, ptr } %19, 0
|
||||
%22 = call i64 %21(ptr %20)
|
||||
%23 = icmp ne i64 %22, 1
|
||||
br i1 %23, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%24 = load ptr, ptr @_llgo_int, align 8
|
||||
%25 = inttoptr i64 %22 to ptr
|
||||
%26 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %24, 0
|
||||
%27 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %26, ptr %25, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %27)
|
||||
unreachable
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
%28 = load %main.S, ptr %2, align 8
|
||||
%29 = extractvalue %main.S %28, 0
|
||||
%30 = call ptr @"github.com/goplus/llgo/internal/runtime.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface" %29)
|
||||
%31 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %29, 0
|
||||
%32 = getelementptr ptr, ptr %31, i64 3
|
||||
%33 = load ptr, ptr %32, align 8
|
||||
%34 = insertvalue { ptr, ptr } undef, ptr %33, 0
|
||||
%35 = insertvalue { ptr, ptr } %34, ptr %30, 1
|
||||
%36 = extractvalue { ptr, ptr } %35, 1
|
||||
%37 = extractvalue { ptr, ptr } %35, 0
|
||||
%38 = call i64 %37(ptr %36)
|
||||
%39 = icmp ne i64 %38, 1
|
||||
br i1 %39, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_3: ; preds = %_llgo_2
|
||||
%40 = load ptr, ptr @_llgo_int, align 8
|
||||
%41 = inttoptr i64 %38 to ptr
|
||||
%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
|
||||
|
||||
_llgo_4: ; preds = %_llgo_2
|
||||
%44 = getelementptr inbounds %main.S, ptr %2, i32 0, i32 0
|
||||
%45 = load %"github.com/goplus/llgo/internal/runtime.iface", ptr %44, align 8
|
||||
%46 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" %45)
|
||||
%47 = load ptr, ptr @_llgo_main.I, align 8
|
||||
%48 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %47, ptr %46)
|
||||
br i1 %48, label %_llgo_17, label %_llgo_18
|
||||
|
||||
_llgo_5: ; preds = %_llgo_17
|
||||
%49 = load ptr, ptr @_llgo_int, align 8
|
||||
%50 = inttoptr i64 %124 to ptr
|
||||
%51 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %49, 0
|
||||
%52 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %51, ptr %50, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %52)
|
||||
unreachable
|
||||
|
||||
_llgo_6: ; preds = %_llgo_17
|
||||
%53 = load %main.S, ptr %2, align 8
|
||||
%54 = extractvalue %main.S %53, 0
|
||||
%55 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" %54)
|
||||
%56 = load ptr, ptr @_llgo_main.I, align 8
|
||||
%57 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %56, ptr %55)
|
||||
br i1 %57, label %_llgo_19, label %_llgo_20
|
||||
|
||||
_llgo_7: ; preds = %_llgo_19
|
||||
%58 = load ptr, ptr @_llgo_int, align 8
|
||||
%59 = inttoptr i64 %140 to ptr
|
||||
%60 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %58, 0
|
||||
%61 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %60, ptr %59, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %61)
|
||||
unreachable
|
||||
|
||||
_llgo_8: ; preds = %_llgo_19
|
||||
%62 = getelementptr inbounds %main.S, ptr %2, i32 0, i32 0
|
||||
%63 = load %"github.com/goplus/llgo/internal/runtime.iface", ptr %62, align 8
|
||||
%64 = call ptr @"github.com/goplus/llgo/internal/runtime.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface" %63)
|
||||
%65 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %63, 0
|
||||
%66 = getelementptr ptr, ptr %65, i64 4
|
||||
%67 = load ptr, ptr %66, align 8
|
||||
%68 = insertvalue { ptr, ptr } undef, ptr %67, 0
|
||||
%69 = insertvalue { ptr, ptr } %68, ptr %64, 1
|
||||
%70 = extractvalue { ptr, ptr } %69, 1
|
||||
%71 = extractvalue { ptr, ptr } %69, 0
|
||||
%72 = call %"github.com/goplus/llgo/internal/runtime.String" %71(ptr %70)
|
||||
%73 = call i1 @"github.com/goplus/llgo/internal/runtime.StringEqual"(%"github.com/goplus/llgo/internal/runtime.String" %72, %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 3 })
|
||||
%74 = xor i1 %73, true
|
||||
br i1 %74, label %_llgo_9, label %_llgo_10
|
||||
|
||||
_llgo_9: ; preds = %_llgo_8
|
||||
%75 = load ptr, ptr @_llgo_string, align 8
|
||||
%76 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" %72, ptr %76, align 8
|
||||
%77 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %75, 0
|
||||
%78 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %77, ptr %76, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %78)
|
||||
unreachable
|
||||
|
||||
_llgo_10: ; preds = %_llgo_8
|
||||
%79 = load %main.S, ptr %2, align 8
|
||||
%80 = extractvalue %main.S %79, 0
|
||||
%81 = call ptr @"github.com/goplus/llgo/internal/runtime.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface" %80)
|
||||
%82 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %80, 0
|
||||
%83 = getelementptr ptr, ptr %82, i64 4
|
||||
%84 = load ptr, ptr %83, align 8
|
||||
%85 = insertvalue { ptr, ptr } undef, ptr %84, 0
|
||||
%86 = insertvalue { ptr, ptr } %85, ptr %81, 1
|
||||
%87 = extractvalue { ptr, ptr } %86, 1
|
||||
%88 = extractvalue { ptr, ptr } %86, 0
|
||||
%89 = call %"github.com/goplus/llgo/internal/runtime.String" %88(ptr %87)
|
||||
%90 = call i1 @"github.com/goplus/llgo/internal/runtime.StringEqual"(%"github.com/goplus/llgo/internal/runtime.String" %89, %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 3 })
|
||||
%91 = xor i1 %90, true
|
||||
br i1 %91, label %_llgo_11, label %_llgo_12
|
||||
|
||||
_llgo_11: ; preds = %_llgo_10
|
||||
%92 = load ptr, ptr @_llgo_string, align 8
|
||||
%93 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" %89, ptr %93, align 8
|
||||
%94 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %92, 0
|
||||
%95 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %94, ptr %93, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %95)
|
||||
unreachable
|
||||
|
||||
_llgo_12: ; preds = %_llgo_10
|
||||
%96 = getelementptr inbounds %main.S, ptr %2, i32 0, i32 0
|
||||
%97 = load %"github.com/goplus/llgo/internal/runtime.iface", ptr %96, align 8
|
||||
%98 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" %97)
|
||||
%99 = load ptr, ptr @_llgo_main.I, align 8
|
||||
%100 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %99, ptr %98)
|
||||
br i1 %100, label %_llgo_21, label %_llgo_22
|
||||
|
||||
_llgo_13: ; preds = %_llgo_21
|
||||
%101 = load ptr, ptr @_llgo_string, align 8
|
||||
%102 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" %156, ptr %102, align 8
|
||||
%103 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %101, 0
|
||||
%104 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %103, ptr %102, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %104)
|
||||
unreachable
|
||||
|
||||
_llgo_14: ; preds = %_llgo_21
|
||||
%105 = load %main.S, ptr %2, align 8
|
||||
%106 = extractvalue %main.S %105, 0
|
||||
%107 = call ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface" %106)
|
||||
%108 = load ptr, ptr @_llgo_main.I, align 8
|
||||
%109 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %108, ptr %107)
|
||||
br i1 %109, label %_llgo_23, label %_llgo_24
|
||||
|
||||
_llgo_15: ; preds = %_llgo_23
|
||||
%110 = load ptr, ptr @_llgo_string, align 8
|
||||
%111 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" %173, ptr %111, align 8
|
||||
%112 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %110, 0
|
||||
%113 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %112, ptr %111, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %113)
|
||||
unreachable
|
||||
|
||||
_llgo_16: ; preds = %_llgo_23
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @8, i64 4 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
ret i32 0
|
||||
|
||||
_llgo_17: ; preds = %_llgo_4
|
||||
%114 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %45, 1
|
||||
%115 = load ptr, ptr @"main.iface$zZ89tENb5h_KNjvpxf1TXPfaWFYn0IZrZwyVf42lRtA", align 8
|
||||
%116 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %115, ptr %46)
|
||||
%117 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %116, 0
|
||||
%118 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %117, ptr %114, 1
|
||||
%119 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
%120 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.iface" }, ptr %119, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %45, ptr %120, align 8
|
||||
%121 = insertvalue { ptr, ptr } { ptr @"main.one$bound", ptr undef }, ptr %119, 1
|
||||
%122 = extractvalue { ptr, ptr } %121, 1
|
||||
%123 = extractvalue { ptr, ptr } %121, 0
|
||||
%124 = call i64 %123(ptr %122)
|
||||
%125 = icmp ne i64 %124, 1
|
||||
br i1 %125, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_18: ; preds = %_llgo_4
|
||||
%126 = load ptr, ptr @_llgo_string, align 8
|
||||
%127 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 21 }, ptr %127, align 8
|
||||
%128 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %126, 0
|
||||
%129 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %128, ptr %127, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %129)
|
||||
unreachable
|
||||
|
||||
_llgo_19: ; preds = %_llgo_6
|
||||
%130 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %54, 1
|
||||
%131 = load ptr, ptr @"main.iface$zZ89tENb5h_KNjvpxf1TXPfaWFYn0IZrZwyVf42lRtA", align 8
|
||||
%132 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %131, ptr %55)
|
||||
%133 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %132, 0
|
||||
%134 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %133, ptr %130, 1
|
||||
%135 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
%136 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.iface" }, ptr %135, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %54, ptr %136, align 8
|
||||
%137 = insertvalue { ptr, ptr } { ptr @"main.one$bound", ptr undef }, ptr %135, 1
|
||||
%138 = extractvalue { ptr, ptr } %137, 1
|
||||
%139 = extractvalue { ptr, ptr } %137, 0
|
||||
%140 = call i64 %139(ptr %138)
|
||||
%141 = icmp ne i64 %140, 1
|
||||
br i1 %141, label %_llgo_7, label %_llgo_8
|
||||
|
||||
_llgo_20: ; preds = %_llgo_6
|
||||
%142 = load ptr, ptr @_llgo_string, align 8
|
||||
%143 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 21 }, ptr %143, align 8
|
||||
%144 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %142, 0
|
||||
%145 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %144, ptr %143, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %145)
|
||||
unreachable
|
||||
|
||||
_llgo_21: ; preds = %_llgo_12
|
||||
%146 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %97, 1
|
||||
%147 = load ptr, ptr @"main.iface$zZ89tENb5h_KNjvpxf1TXPfaWFYn0IZrZwyVf42lRtA", align 8
|
||||
%148 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %147, ptr %98)
|
||||
%149 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %148, 0
|
||||
%150 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %149, ptr %146, 1
|
||||
%151 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
%152 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.iface" }, ptr %151, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %97, ptr %152, align 8
|
||||
%153 = insertvalue { ptr, ptr } { ptr @"main.two$bound", ptr undef }, ptr %151, 1
|
||||
%154 = extractvalue { ptr, ptr } %153, 1
|
||||
%155 = extractvalue { ptr, ptr } %153, 0
|
||||
%156 = call %"github.com/goplus/llgo/internal/runtime.String" %155(ptr %154)
|
||||
%157 = call i1 @"github.com/goplus/llgo/internal/runtime.StringEqual"(%"github.com/goplus/llgo/internal/runtime.String" %156, %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 3 })
|
||||
%158 = xor i1 %157, true
|
||||
br i1 %158, label %_llgo_13, label %_llgo_14
|
||||
|
||||
_llgo_22: ; preds = %_llgo_12
|
||||
%159 = load ptr, ptr @_llgo_string, align 8
|
||||
%160 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 21 }, ptr %160, align 8
|
||||
%161 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %159, 0
|
||||
%162 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %161, ptr %160, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %162)
|
||||
unreachable
|
||||
|
||||
_llgo_23: ; preds = %_llgo_14
|
||||
%163 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %106, 1
|
||||
%164 = load ptr, ptr @"main.iface$zZ89tENb5h_KNjvpxf1TXPfaWFYn0IZrZwyVf42lRtA", align 8
|
||||
%165 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %164, ptr %107)
|
||||
%166 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %165, 0
|
||||
%167 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %166, ptr %163, 1
|
||||
%168 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
%169 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.iface" }, ptr %168, i32 0, i32 0
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %106, ptr %169, align 8
|
||||
%170 = insertvalue { ptr, ptr } { ptr @"main.two$bound", ptr undef }, ptr %168, 1
|
||||
%171 = extractvalue { ptr, ptr } %170, 1
|
||||
%172 = extractvalue { ptr, ptr } %170, 0
|
||||
%173 = call %"github.com/goplus/llgo/internal/runtime.String" %172(ptr %171)
|
||||
%174 = call i1 @"github.com/goplus/llgo/internal/runtime.StringEqual"(%"github.com/goplus/llgo/internal/runtime.String" %173, %"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 3 })
|
||||
%175 = xor i1 %174, true
|
||||
br i1 %175, label %_llgo_15, label %_llgo_16
|
||||
|
||||
_llgo_24: ; preds = %_llgo_14
|
||||
%176 = load ptr, ptr @_llgo_string, align 8
|
||||
%177 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/internal/runtime.String" { ptr @7, i64 21 }, ptr %177, align 8
|
||||
%178 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" undef, ptr %176, 0
|
||||
%179 = insertvalue %"github.com/goplus/llgo/internal/runtime.eface" %178, ptr %177, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %179)
|
||||
unreachable
|
||||
}
|
||||
|
||||
; 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.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface")
|
||||
|
||||
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 @1, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 4 }, i64 25, i64 0, i64 2, i64 2)
|
||||
store ptr %0, ptr @_llgo_main.impl, align 8
|
||||
%1 = load ptr, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
%2 = icmp eq ptr %1, null
|
||||
br i1 %2, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%4 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %3, 0
|
||||
%5 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %4, i64 0, 1
|
||||
%6 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %5, i64 0, 2
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, i64 0, %"github.com/goplus/llgo/internal/runtime.Slice" %6)
|
||||
store ptr %7, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%8 = load ptr, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
%9 = load ptr, ptr @_llgo_int, align 8
|
||||
%10 = icmp eq ptr %9, null
|
||||
br i1 %10, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_3: ; preds = %_llgo_2
|
||||
%11 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
||||
store ptr %11, ptr @_llgo_int, align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%12 = load ptr, ptr @_llgo_int, align 8
|
||||
%13 = load ptr, ptr @_llgo_int, align 8
|
||||
%14 = load ptr, ptr @"_llgo_func$ETeB8WwW04JEq0ztcm-XPTJtuYvtpkjIsAc0-2NT9zA", align 8
|
||||
%15 = icmp eq ptr %14, null
|
||||
br i1 %15, label %_llgo_5, label %_llgo_6
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4
|
||||
%16 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%17 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %16, 0
|
||||
%18 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %17, i64 0, 1
|
||||
%19 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %18, i64 0, 2
|
||||
%20 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%21 = getelementptr ptr, ptr %20, i64 0
|
||||
store ptr %13, ptr %21, align 8
|
||||
%22 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %20, 0
|
||||
%23 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %22, i64 1, 1
|
||||
%24 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %23, i64 1, 2
|
||||
%25 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %19, %"github.com/goplus/llgo/internal/runtime.Slice" %24, i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %25)
|
||||
store ptr %25, ptr @"_llgo_func$ETeB8WwW04JEq0ztcm-XPTJtuYvtpkjIsAc0-2NT9zA", align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
%26 = load ptr, ptr @"_llgo_func$ETeB8WwW04JEq0ztcm-XPTJtuYvtpkjIsAc0-2NT9zA", align 8
|
||||
%27 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 8 }, ptr undef, ptr undef, ptr undef }, ptr %26, 1
|
||||
%28 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %27, ptr @"main.(*impl).one", 2
|
||||
%29 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %28, ptr @"main.(*impl).one", 3
|
||||
%30 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 8 }, ptr undef, ptr undef, ptr undef }, ptr %26, 1
|
||||
%31 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %30, ptr @"main.(*impl).one", 2
|
||||
%32 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %31, ptr @main.impl.one, 3
|
||||
%33 = load ptr, ptr @_llgo_string, align 8
|
||||
%34 = icmp eq ptr %33, null
|
||||
br i1 %34, label %_llgo_7, label %_llgo_8
|
||||
|
||||
_llgo_7: ; preds = %_llgo_6
|
||||
%35 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
store ptr %35, ptr @_llgo_string, align 8
|
||||
br label %_llgo_8
|
||||
|
||||
_llgo_8: ; preds = %_llgo_7, %_llgo_6
|
||||
%36 = load ptr, ptr @_llgo_string, align 8
|
||||
%37 = load ptr, ptr @_llgo_string, align 8
|
||||
%38 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
%39 = icmp eq ptr %38, null
|
||||
br i1 %39, label %_llgo_9, label %_llgo_10
|
||||
|
||||
_llgo_9: ; preds = %_llgo_8
|
||||
%40 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%41 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %40, 0
|
||||
%42 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %41, i64 0, 1
|
||||
%43 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %42, i64 0, 2
|
||||
%44 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%45 = getelementptr ptr, ptr %44, i64 0
|
||||
store ptr %37, ptr %45, align 8
|
||||
%46 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %44, 0
|
||||
%47 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %46, i64 1, 1
|
||||
%48 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %47, i64 1, 2
|
||||
%49 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %43, %"github.com/goplus/llgo/internal/runtime.Slice" %48, i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %49)
|
||||
store ptr %49, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
br label %_llgo_10
|
||||
|
||||
_llgo_10: ; preds = %_llgo_9, %_llgo_8
|
||||
%50 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
%51 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 8 }, ptr undef, ptr undef, ptr undef }, ptr %50, 1
|
||||
%52 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %51, ptr @"main.(*impl).two", 2
|
||||
%53 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %52, ptr @"main.(*impl).two", 3
|
||||
%54 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 8 }, ptr undef, ptr undef, ptr undef }, ptr %50, 1
|
||||
%55 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %54, ptr @"main.(*impl).two", 2
|
||||
%56 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %55, ptr @main.impl.two, 3
|
||||
%57 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 80)
|
||||
%58 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %57, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %32, ptr %58, align 8
|
||||
%59 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %57, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %56, ptr %59, align 8
|
||||
%60 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %57, 0
|
||||
%61 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %60, i64 2, 1
|
||||
%62 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %61, i64 2, 2
|
||||
%63 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 80)
|
||||
%64 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %63, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %29, ptr %64, align 8
|
||||
%65 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %63, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %53, ptr %65, align 8
|
||||
%66 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %63, 0
|
||||
%67 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %66, i64 2, 1
|
||||
%68 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %67, i64 2, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %0, ptr %8, %"github.com/goplus/llgo/internal/runtime.Slice" %62, %"github.com/goplus/llgo/internal/runtime.Slice" %68)
|
||||
%69 = load ptr, ptr @"_llgo_func$ETeB8WwW04JEq0ztcm-XPTJtuYvtpkjIsAc0-2NT9zA", align 8
|
||||
%70 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
%71 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 8 }, ptr undef }, ptr %69, 1
|
||||
%72 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 8 }, ptr undef }, ptr %70, 1
|
||||
%73 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
|
||||
%74 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %73, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %71, ptr %74, align 8
|
||||
%75 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %73, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %72, ptr %75, align 8
|
||||
%76 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %73, 0
|
||||
%77 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %76, i64 2, 1
|
||||
%78 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %77, i64 2, 2
|
||||
%79 = call ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, %"github.com/goplus/llgo/internal/runtime.Slice" %78)
|
||||
store ptr %79, ptr @"main.iface$zZ89tENb5h_KNjvpxf1TXPfaWFYn0IZrZwyVf42lRtA", align 8
|
||||
%80 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 1 })
|
||||
%81 = load ptr, ptr @_llgo_main.I, align 8
|
||||
%82 = icmp eq ptr %81, null
|
||||
br i1 %82, label %_llgo_11, label %_llgo_12
|
||||
|
||||
_llgo_11: ; preds = %_llgo_10
|
||||
store ptr %80, ptr @_llgo_main.I, align 8
|
||||
br label %_llgo_12
|
||||
|
||||
_llgo_12: ; preds = %_llgo_11, %_llgo_10
|
||||
%83 = load ptr, ptr @"_llgo_func$ETeB8WwW04JEq0ztcm-XPTJtuYvtpkjIsAc0-2NT9zA", align 8
|
||||
%84 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8
|
||||
br i1 %82, label %_llgo_13, label %_llgo_14
|
||||
|
||||
_llgo_13: ; preds = %_llgo_12
|
||||
%85 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 8 }, ptr undef }, ptr %83, 1
|
||||
%86 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @5, i64 8 }, ptr undef }, ptr %84, 1
|
||||
%87 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
|
||||
%88 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %87, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %85, ptr %88, align 8
|
||||
%89 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %87, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %86, ptr %89, align 8
|
||||
%90 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %87, 0
|
||||
%91 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %90, i64 2, 1
|
||||
%92 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %91, i64 2, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr %80, %"github.com/goplus/llgo/internal/runtime.Slice" %92)
|
||||
br label %_llgo_14
|
||||
|
||||
_llgo_14: ; preds = %_llgo_13, %_llgo_12
|
||||
ret void
|
||||
}
|
||||
|
||||
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.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.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.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 void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.IfaceType"(%"github.com/goplus/llgo/internal/runtime.iface")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr, ptr)
|
||||
|
||||
define i64 @"main.one$bound"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { %"github.com/goplus/llgo/internal/runtime.iface" }, ptr %0, align 8
|
||||
%2 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface" } %1, 0
|
||||
%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
|
||||
%11 = call i64 %10(ptr %9)
|
||||
ret i64 %11
|
||||
}
|
||||
|
||||
declare i1 @"github.com/goplus/llgo/internal/runtime.StringEqual"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.String" @"main.two$bound"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = load { %"github.com/goplus/llgo/internal/runtime.iface" }, ptr %0, align 8
|
||||
%2 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface" } %1, 0
|
||||
%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 4
|
||||
%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
|
||||
%11 = call %"github.com/goplus/llgo/internal/runtime.String" %10(ptr %9)
|
||||
ret %"github.com/goplus/llgo/internal/runtime.String" %11
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
|
||||
140
compiler/cl/_testgo/indexerr/in.go
Normal file
140
compiler/cl/_testgo/indexerr/in.go
Normal file
@@ -0,0 +1,140 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
}
|
||||
|
||||
func init() {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
panic("array -1 must error")
|
||||
}
|
||||
}()
|
||||
array(-1)
|
||||
}
|
||||
|
||||
func init() {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
panic("array 2 must error")
|
||||
}
|
||||
}()
|
||||
array(2)
|
||||
}
|
||||
|
||||
func init() {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
panic("array2 must error")
|
||||
}
|
||||
}()
|
||||
array2(2)
|
||||
}
|
||||
|
||||
func init() {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
panic("slice -1 must error")
|
||||
}
|
||||
}()
|
||||
slice(-1)
|
||||
}
|
||||
|
||||
func init() {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
panic("slice 2 must error")
|
||||
}
|
||||
}()
|
||||
slice(2)
|
||||
}
|
||||
|
||||
func init() {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
panic("slice2 2 must error")
|
||||
}
|
||||
}()
|
||||
slice2(2)
|
||||
}
|
||||
|
||||
func init() {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
panic("2 must error")
|
||||
}
|
||||
}()
|
||||
a := [...]int{1, 2}
|
||||
var n = -1
|
||||
println(a[n])
|
||||
}
|
||||
|
||||
func init() {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
panic("-1 must error")
|
||||
}
|
||||
}()
|
||||
a := [...]int{1, 2}
|
||||
var n = 2
|
||||
println(a[n])
|
||||
}
|
||||
|
||||
func init() {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
panic("2 must error")
|
||||
}
|
||||
}()
|
||||
a := [...]int{1, 2}
|
||||
var n uint = 2
|
||||
println(a[n])
|
||||
}
|
||||
|
||||
func init() {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
panic("2 must error")
|
||||
}
|
||||
}()
|
||||
a := []int{1, 2}
|
||||
var n = -1
|
||||
println(a[n])
|
||||
}
|
||||
|
||||
func init() {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
panic("-1 must error")
|
||||
}
|
||||
}()
|
||||
a := []int{1, 2}
|
||||
var n = 2
|
||||
println(a[n])
|
||||
}
|
||||
|
||||
func init() {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
panic("2 must error")
|
||||
}
|
||||
}()
|
||||
a := []int{1, 2}
|
||||
var n uint = 2
|
||||
println(a[n])
|
||||
}
|
||||
|
||||
func array(n int) {
|
||||
println([...]int{1, 2}[n])
|
||||
}
|
||||
|
||||
func array2(n uint) {
|
||||
println([...]int{1, 2}[n])
|
||||
}
|
||||
|
||||
func slice(n int) {
|
||||
println([]int{1, 2}[n])
|
||||
}
|
||||
|
||||
func slice2(n int) {
|
||||
println([]int{1, 2}[n])
|
||||
}
|
||||
1
compiler/cl/_testgo/indexerr/out.ll
Normal file
1
compiler/cl/_testgo/indexerr/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
27
compiler/cl/_testgo/interface/in.go
Normal file
27
compiler/cl/_testgo/interface/in.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/compiler/cl/internal/foo"
|
||||
)
|
||||
|
||||
type Game1 struct {
|
||||
*foo.Game
|
||||
}
|
||||
|
||||
type Game2 struct {
|
||||
}
|
||||
|
||||
func (p *Game2) initGame() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
var g1 any = &Game1{&foo.Game{}}
|
||||
var g2 any = &Game2{}
|
||||
v1, ok := g1.(foo.Gamer)
|
||||
println("OK", v1, ok)
|
||||
if ok {
|
||||
v1.Load()
|
||||
}
|
||||
v2, ok := g2.(foo.Gamer)
|
||||
println("FAIL", v2, ok)
|
||||
}
|
||||
485
compiler/cl/_testgo/interface/out.ll
Normal file
485
compiler/cl/_testgo/interface/out.ll
Normal file
@@ -0,0 +1,485 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%main.Game1 = type { ptr }
|
||||
%"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/runtime.String" = type { ptr, i64 }
|
||||
%"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.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.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
|
||||
@_llgo_main.Game1 = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [4 x i8] c"main", align 1
|
||||
@1 = private unnamed_addr constant [5 x i8] c"Game1", align 1
|
||||
@"_llgo_github.com/goplus/llgo/cl/internal/foo.Game" = linkonce global ptr null, align 8
|
||||
@2 = private unnamed_addr constant [38 x i8] c"github.com/goplus/llgo/cl/internal/foo", align 1
|
||||
@3 = private unnamed_addr constant [4 x i8] c"Game", align 1
|
||||
@"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw" = linkonce global ptr null, align 8
|
||||
@4 = private unnamed_addr constant [4 x i8] c"Load", align 1
|
||||
@"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac" = linkonce global ptr null, align 8
|
||||
@5 = private unnamed_addr constant [8 x i8] c"initGame", align 1
|
||||
@6 = private unnamed_addr constant [47 x i8] c"github.com/goplus/llgo/cl/internal/foo.initGame", align 1
|
||||
@"*_llgo_github.com/goplus/llgo/cl/internal/foo.Game" = linkonce global ptr null, align 8
|
||||
@"_llgo_struct$cJmCzeVn0orHWafCrTGAnbbAF46F2A4Fms4bJBm8ITI" = linkonce global ptr null, align 8
|
||||
@"*_llgo_main.Game1" = linkonce global ptr null, align 8
|
||||
@_llgo_main.Game2 = linkonce global ptr null, align 8
|
||||
@7 = private unnamed_addr constant [5 x i8] c"Game2", align 1
|
||||
@8 = private unnamed_addr constant [13 x i8] c"main.initGame", align 1
|
||||
@"*_llgo_main.Game2" = linkonce global ptr null, align 8
|
||||
@"_llgo_github.com/goplus/llgo/cl/internal/foo.Gamer" = linkonce global ptr null, align 8
|
||||
@9 = private unnamed_addr constant [5 x i8] c"Gamer", align 1
|
||||
@"main.iface$sO8a1LvuUsjXwiwaC6sR9-L4DiYgiOnZi7iosyShJXg" = linkonce global ptr null, align 8
|
||||
@10 = private unnamed_addr constant [2 x i8] c"OK", align 1
|
||||
@11 = private unnamed_addr constant [4 x i8] c"FAIL", align 1
|
||||
|
||||
define void @main.Game1.Load(%main.Game1 %0) {
|
||||
_llgo_0:
|
||||
%1 = alloca %main.Game1, align 8
|
||||
call void @llvm.memset(ptr %1, i8 0, i64 8, i1 false)
|
||||
store %main.Game1 %0, ptr %1, align 8
|
||||
%2 = getelementptr inbounds %main.Game1, ptr %1, i32 0, i32 0
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
call void @"github.com/goplus/llgo/cl/internal/foo.(*Game).Load"(ptr %3)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.Game1.initGame(%main.Game1 %0) {
|
||||
_llgo_0:
|
||||
%1 = alloca %main.Game1, align 8
|
||||
call void @llvm.memset(ptr %1, i8 0, i64 8, i1 false)
|
||||
store %main.Game1 %0, ptr %1, align 8
|
||||
%2 = getelementptr inbounds %main.Game1, ptr %1, i32 0, i32 0
|
||||
%3 = load ptr, ptr %2, align 8
|
||||
call void @"github.com/goplus/llgo/cl/internal/foo.(*Game).initGame"(ptr %3)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.(*Game1).Load"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = getelementptr inbounds %main.Game1, ptr %0, i32 0, i32 0
|
||||
%2 = load ptr, ptr %1, align 8
|
||||
call void @"github.com/goplus/llgo/cl/internal/foo.(*Game).Load"(ptr %2)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.(*Game1).initGame"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = getelementptr inbounds %main.Game1, ptr %0, i32 0, i32 0
|
||||
%2 = load ptr, ptr %1, align 8
|
||||
call void @"github.com/goplus/llgo/cl/internal/foo.(*Game).initGame"(ptr %2)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"main.(*Game2).initGame"(ptr %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
|
||||
call void @"github.com/goplus/llgo/cl/internal/foo.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 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%3 = getelementptr inbounds %main.Game1, ptr %2, i32 0, i32 0
|
||||
%4 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 0)
|
||||
store ptr %4, ptr %3, align 8
|
||||
%5 = load ptr, ptr @_llgo_main.Game1, align 8
|
||||
%6 = load ptr, ptr @"*_llgo_main.Game1", 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 %2, 1
|
||||
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 0)
|
||||
%10 = load ptr, ptr @_llgo_main.Game2, align 8
|
||||
%11 = load ptr, ptr @"*_llgo_main.Game2", 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 %9, 1
|
||||
%14 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %8, 0
|
||||
%15 = load ptr, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Gamer", align 8
|
||||
%16 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %15, ptr %14)
|
||||
br i1 %16, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_1: ; preds = %_llgo_5
|
||||
%17 = call ptr @"github.com/goplus/llgo/internal/runtime.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface" %36)
|
||||
%18 = extractvalue %"github.com/goplus/llgo/internal/runtime.iface" %36, 0
|
||||
%19 = getelementptr ptr, ptr %18, i64 3
|
||||
%20 = load ptr, ptr %19, align 8
|
||||
%21 = insertvalue { ptr, ptr } undef, ptr %20, 0
|
||||
%22 = insertvalue { ptr, ptr } %21, ptr %17, 1
|
||||
%23 = extractvalue { ptr, ptr } %22, 1
|
||||
%24 = extractvalue { ptr, ptr } %22, 0
|
||||
call void %24(ptr %23)
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_5
|
||||
%25 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %13, 0
|
||||
%26 = load ptr, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Gamer", align 8
|
||||
%27 = call i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr %26, ptr %25)
|
||||
br i1 %27, label %_llgo_6, label %_llgo_7
|
||||
|
||||
_llgo_3: ; preds = %_llgo_0
|
||||
%28 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %8, 1
|
||||
%29 = load ptr, ptr @"main.iface$sO8a1LvuUsjXwiwaC6sR9-L4DiYgiOnZi7iosyShJXg", align 8
|
||||
%30 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %29, ptr %14)
|
||||
%31 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %30, 0
|
||||
%32 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %31, ptr %28, 1
|
||||
%33 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } undef, %"github.com/goplus/llgo/internal/runtime.iface" %32, 0
|
||||
%34 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %33, i1 true, 1
|
||||
br label %_llgo_5
|
||||
|
||||
_llgo_4: ; preds = %_llgo_0
|
||||
br label %_llgo_5
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4, %_llgo_3
|
||||
%35 = phi { %"github.com/goplus/llgo/internal/runtime.iface", i1 } [ %34, %_llgo_3 ], [ zeroinitializer, %_llgo_4 ]
|
||||
%36 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %35, 0
|
||||
%37 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %35, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @10, i64 2 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintIface"(%"github.com/goplus/llgo/internal/runtime.iface" %36)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %37)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
br i1 %37, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_6: ; preds = %_llgo_2
|
||||
%38 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %13, 1
|
||||
%39 = load ptr, ptr @"main.iface$sO8a1LvuUsjXwiwaC6sR9-L4DiYgiOnZi7iosyShJXg", align 8
|
||||
%40 = call ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr %39, ptr %25)
|
||||
%41 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" undef, ptr %40, 0
|
||||
%42 = insertvalue %"github.com/goplus/llgo/internal/runtime.iface" %41, ptr %38, 1
|
||||
%43 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } undef, %"github.com/goplus/llgo/internal/runtime.iface" %42, 0
|
||||
%44 = insertvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %43, i1 true, 1
|
||||
br label %_llgo_8
|
||||
|
||||
_llgo_7: ; preds = %_llgo_2
|
||||
br label %_llgo_8
|
||||
|
||||
_llgo_8: ; preds = %_llgo_7, %_llgo_6
|
||||
%45 = phi { %"github.com/goplus/llgo/internal/runtime.iface", i1 } [ %44, %_llgo_6 ], [ zeroinitializer, %_llgo_7 ]
|
||||
%46 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %45, 0
|
||||
%47 = extractvalue { %"github.com/goplus/llgo/internal/runtime.iface", i1 } %45, 1
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @11, i64 4 })
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintIface"(%"github.com/goplus/llgo/internal/runtime.iface" %46)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 %47)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
||||
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 @"github.com/goplus/llgo/cl/internal/foo.(*Game).Load"(ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/cl/internal/foo.(*Game).initGame"(ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/cl/internal/foo.init"()
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
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 @0, i64 4 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @1, i64 5 }, i64 25, i64 8, i64 2, i64 2)
|
||||
%1 = load ptr, ptr @_llgo_main.Game1, align 8
|
||||
%2 = icmp eq ptr %1, null
|
||||
br i1 %2, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %0)
|
||||
store ptr %0, ptr @_llgo_main.Game1, align 8
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 38 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 4 }, i64 25, i64 0, i64 0, i64 2)
|
||||
%4 = load ptr, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Game", align 8
|
||||
%5 = icmp eq ptr %4, null
|
||||
br i1 %5, label %_llgo_3, label %_llgo_4
|
||||
|
||||
_llgo_3: ; preds = %_llgo_2
|
||||
store ptr %3, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Game", align 8
|
||||
br label %_llgo_4
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
||||
%6 = load ptr, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", 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.AllocU"(i64 0)
|
||||
%9 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %8, 0
|
||||
%10 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %9, i64 0, 1
|
||||
%11 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %10, i64 0, 2
|
||||
%12 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @0, i64 4 }, i64 0, %"github.com/goplus/llgo/internal/runtime.Slice" %11)
|
||||
store ptr %12, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
br label %_llgo_6
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5, %_llgo_4
|
||||
%13 = load ptr, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
br i1 %5, label %_llgo_7, label %_llgo_8
|
||||
|
||||
_llgo_7: ; preds = %_llgo_6
|
||||
%14 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%15 = icmp eq ptr %14, null
|
||||
br i1 %15, label %_llgo_9, label %_llgo_10
|
||||
|
||||
_llgo_8: ; preds = %_llgo_10, %_llgo_6
|
||||
%16 = load ptr, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Game", align 8
|
||||
%17 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 38 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 4 }, i64 25, i64 0, i64 0, i64 2)
|
||||
%18 = load ptr, ptr @"*_llgo_github.com/goplus/llgo/cl/internal/foo.Game", align 8
|
||||
%19 = icmp eq ptr %18, null
|
||||
br i1 %19, label %_llgo_11, label %_llgo_12
|
||||
|
||||
_llgo_9: ; preds = %_llgo_7
|
||||
%20 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%21 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %20, 0
|
||||
%22 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %21, i64 0, 1
|
||||
%23 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %22, i64 0, 2
|
||||
%24 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0)
|
||||
%25 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %24, 0
|
||||
%26 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %25, i64 0, 1
|
||||
%27 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %26, i64 0, 2
|
||||
%28 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %23, %"github.com/goplus/llgo/internal/runtime.Slice" %27, i1 false)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %28)
|
||||
store ptr %28, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
br label %_llgo_10
|
||||
|
||||
_llgo_10: ; preds = %_llgo_9, %_llgo_7
|
||||
%29 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%30 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 4 }, ptr undef, ptr undef, ptr undef }, ptr %29, 1
|
||||
%31 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %30, ptr @"github.com/goplus/llgo/cl/internal/foo.(*Game).Load", 2
|
||||
%32 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %31, ptr @"github.com/goplus/llgo/cl/internal/foo.(*Game).Load", 3
|
||||
%33 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%34 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 47 }, ptr undef, ptr undef, ptr undef }, ptr %33, 1
|
||||
%35 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %34, ptr @"github.com/goplus/llgo/cl/internal/foo.(*Game).initGame", 2
|
||||
%36 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %35, ptr @"github.com/goplus/llgo/cl/internal/foo.(*Game).initGame", 3
|
||||
%37 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 80)
|
||||
%38 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %37, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %32, ptr %38, align 8
|
||||
%39 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %37, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %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
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %3, ptr %13, { ptr, i64, i64 } zeroinitializer, %"github.com/goplus/llgo/internal/runtime.Slice" %42)
|
||||
br label %_llgo_8
|
||||
|
||||
_llgo_11: ; preds = %_llgo_8
|
||||
%43 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %17)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %43)
|
||||
store ptr %43, ptr @"*_llgo_github.com/goplus/llgo/cl/internal/foo.Game", align 8
|
||||
br label %_llgo_12
|
||||
|
||||
_llgo_12: ; preds = %_llgo_11, %_llgo_8
|
||||
%44 = load ptr, ptr @"*_llgo_github.com/goplus/llgo/cl/internal/foo.Game", align 8
|
||||
%45 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 38 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @3, i64 4 }, i64 25, i64 0, i64 0, i64 2)
|
||||
%46 = load ptr, ptr @"_llgo_struct$cJmCzeVn0orHWafCrTGAnbbAF46F2A4Fms4bJBm8ITI", align 8
|
||||
%47 = icmp eq ptr %46, null
|
||||
br i1 %47, label %_llgo_13, label %_llgo_14
|
||||
|
||||
_llgo_13: ; preds = %_llgo_12
|
||||
%48 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %45)
|
||||
%49 = 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 4 }, ptr %48, i64 0, %"github.com/goplus/llgo/internal/runtime.String" zeroinitializer, i1 true)
|
||||
%50 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 56)
|
||||
%51 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %50, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.StructField" %49, ptr %51, align 8
|
||||
%52 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %50, 0
|
||||
%53 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %52, i64 1, 1
|
||||
%54 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %53, i64 1, 2
|
||||
%55 = 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" %54)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %55)
|
||||
store ptr %55, ptr @"_llgo_struct$cJmCzeVn0orHWafCrTGAnbbAF46F2A4Fms4bJBm8ITI", align 8
|
||||
br label %_llgo_14
|
||||
|
||||
_llgo_14: ; preds = %_llgo_13, %_llgo_12
|
||||
%56 = load ptr, ptr @"_llgo_struct$cJmCzeVn0orHWafCrTGAnbbAF46F2A4Fms4bJBm8ITI", align 8
|
||||
br i1 %2, label %_llgo_15, label %_llgo_16
|
||||
|
||||
_llgo_15: ; preds = %_llgo_14
|
||||
%57 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%58 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 4 }, ptr undef, ptr undef, ptr undef }, ptr %57, 1
|
||||
%59 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %58, ptr @"main.(*Game1).Load", 2
|
||||
%60 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %59, ptr @"main.(*Game1).Load", 3
|
||||
%61 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 4 }, ptr undef, ptr undef, ptr undef }, ptr %57, 1
|
||||
%62 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %61, ptr @"main.(*Game1).Load", 2
|
||||
%63 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %62, ptr @main.Game1.Load, 3
|
||||
%64 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%65 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 47 }, ptr undef, ptr undef, ptr undef }, ptr %64, 1
|
||||
%66 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %65, ptr @"github.com/goplus/llgo/cl/internal/foo.(*Game).initGame", 2
|
||||
%67 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %66, ptr @"github.com/goplus/llgo/cl/internal/foo.(*Game).initGame", 3
|
||||
%68 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
||||
%69 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %68, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %63, ptr %69, align 8
|
||||
%70 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %68, 0
|
||||
%71 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %70, i64 1, 1
|
||||
%72 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %71, i64 1, 2
|
||||
%73 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 80)
|
||||
%74 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %73, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %60, ptr %74, align 8
|
||||
%75 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %73, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %67, ptr %75, align 8
|
||||
%76 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %73, 0
|
||||
%77 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %76, i64 2, 1
|
||||
%78 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %77, i64 2, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %0, ptr %56, %"github.com/goplus/llgo/internal/runtime.Slice" %72, %"github.com/goplus/llgo/internal/runtime.Slice" %78)
|
||||
br label %_llgo_16
|
||||
|
||||
_llgo_16: ; preds = %_llgo_15, %_llgo_14
|
||||
%79 = 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 5 }, i64 25, i64 8, i64 2, i64 2)
|
||||
%80 = load ptr, ptr @"*_llgo_main.Game1", align 8
|
||||
%81 = icmp eq ptr %80, null
|
||||
br i1 %81, label %_llgo_17, label %_llgo_18
|
||||
|
||||
_llgo_17: ; preds = %_llgo_16
|
||||
%82 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %79)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %82)
|
||||
store ptr %82, ptr @"*_llgo_main.Game1", align 8
|
||||
br label %_llgo_18
|
||||
|
||||
_llgo_18: ; preds = %_llgo_17, %_llgo_16
|
||||
%83 = 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 @7, i64 5 }, i64 25, i64 0, i64 0, i64 1)
|
||||
%84 = load ptr, ptr @_llgo_main.Game2, align 8
|
||||
%85 = icmp eq ptr %84, null
|
||||
br i1 %85, label %_llgo_19, label %_llgo_20
|
||||
|
||||
_llgo_19: ; preds = %_llgo_18
|
||||
store ptr %83, ptr @_llgo_main.Game2, align 8
|
||||
br label %_llgo_20
|
||||
|
||||
_llgo_20: ; preds = %_llgo_19, %_llgo_18
|
||||
%86 = load ptr, ptr @"_llgo_struct$n1H8J_3prDN3firMwPxBLVTkE5hJ9Di-AqNvaC9jczw", align 8
|
||||
br i1 %85, label %_llgo_21, label %_llgo_22
|
||||
|
||||
_llgo_21: ; preds = %_llgo_20
|
||||
%87 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%88 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @8, i64 13 }, ptr undef, ptr undef, ptr undef }, ptr %87, 1
|
||||
%89 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %88, ptr @"main.(*Game2).initGame", 2
|
||||
%90 = insertvalue %"github.com/goplus/llgo/internal/abi.Method" %89, ptr @"main.(*Game2).initGame", 3
|
||||
%91 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40)
|
||||
%92 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %91, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Method" %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
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %83, ptr %86, { ptr, i64, i64 } zeroinitializer, %"github.com/goplus/llgo/internal/runtime.Slice" %95)
|
||||
br label %_llgo_22
|
||||
|
||||
_llgo_22: ; preds = %_llgo_21, %_llgo_20
|
||||
%96 = 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 @7, i64 5 }, i64 25, i64 0, i64 0, i64 1)
|
||||
%97 = load ptr, ptr @"*_llgo_main.Game2", align 8
|
||||
%98 = icmp eq ptr %97, null
|
||||
br i1 %98, label %_llgo_23, label %_llgo_24
|
||||
|
||||
_llgo_23: ; preds = %_llgo_22
|
||||
%99 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %96)
|
||||
call void @"github.com/goplus/llgo/internal/runtime.SetDirectIface"(ptr %99)
|
||||
store ptr %99, ptr @"*_llgo_main.Game2", align 8
|
||||
br label %_llgo_24
|
||||
|
||||
_llgo_24: ; preds = %_llgo_23, %_llgo_22
|
||||
%100 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String" { ptr @2, i64 38 }, %"github.com/goplus/llgo/internal/runtime.String" { ptr @9, i64 5 })
|
||||
%101 = load ptr, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Gamer", align 8
|
||||
%102 = icmp eq ptr %101, null
|
||||
br i1 %102, label %_llgo_25, label %_llgo_26
|
||||
|
||||
_llgo_25: ; preds = %_llgo_24
|
||||
store ptr %100, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Gamer", align 8
|
||||
br label %_llgo_26
|
||||
|
||||
_llgo_26: ; preds = %_llgo_25, %_llgo_24
|
||||
%103 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%104 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
br i1 %102, label %_llgo_27, label %_llgo_28
|
||||
|
||||
_llgo_27: ; preds = %_llgo_26
|
||||
%105 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 4 }, ptr undef }, ptr %103, 1
|
||||
%106 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 47 }, ptr undef }, ptr %104, 1
|
||||
%107 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
|
||||
%108 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %107, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %105, ptr %108, align 8
|
||||
%109 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %107, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %106, ptr %109, align 8
|
||||
%110 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %107, 0
|
||||
%111 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %110, i64 2, 1
|
||||
%112 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %111, i64 2, 2
|
||||
call void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr %100, %"github.com/goplus/llgo/internal/runtime.Slice" %112)
|
||||
br label %_llgo_28
|
||||
|
||||
_llgo_28: ; preds = %_llgo_27, %_llgo_26
|
||||
%113 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%114 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8
|
||||
%115 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @4, i64 4 }, ptr undef }, ptr %113, 1
|
||||
%116 = insertvalue %"github.com/goplus/llgo/internal/abi.Imethod" { %"github.com/goplus/llgo/internal/runtime.String" { ptr @6, i64 47 }, ptr undef }, ptr %114, 1
|
||||
%117 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 48)
|
||||
%118 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %117, i64 0
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %115, ptr %118, align 8
|
||||
%119 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %117, i64 1
|
||||
store %"github.com/goplus/llgo/internal/abi.Imethod" %116, ptr %119, align 8
|
||||
%120 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" undef, ptr %117, 0
|
||||
%121 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %120, i64 2, 1
|
||||
%122 = insertvalue %"github.com/goplus/llgo/internal/runtime.Slice" %121, i64 2, 2
|
||||
%123 = 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" %122)
|
||||
store ptr %123, ptr @"main.iface$sO8a1LvuUsjXwiwaC6sR9-L4DiYgiOnZi7iosyShJXg", 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 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.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 ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamedInterface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.InitNamedInterface"(ptr, %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare i1 @"github.com/goplus/llgo/internal/runtime.Implements"(ptr, ptr)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr, ptr)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintIface"(%"github.com/goplus/llgo/internal/runtime.iface")
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1)
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.IfacePtrData"(%"github.com/goplus/llgo/internal/runtime.iface")
|
||||
|
||||
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
|
||||
102
compiler/cl/_testgo/invoke/in.go
Normal file
102
compiler/cl/_testgo/invoke/in.go
Normal file
@@ -0,0 +1,102 @@
|
||||
package main
|
||||
|
||||
type T struct {
|
||||
s string
|
||||
}
|
||||
|
||||
func (t T) Invoke() int {
|
||||
println("invoke", t.s)
|
||||
return 0
|
||||
}
|
||||
|
||||
func (t *T) Method() {}
|
||||
|
||||
type T1 int
|
||||
|
||||
func (t T1) Invoke() int {
|
||||
println("invoke1", t)
|
||||
return 1
|
||||
}
|
||||
|
||||
type T2 float64
|
||||
|
||||
func (t T2) Invoke() int {
|
||||
println("invoke2", t)
|
||||
return 2
|
||||
}
|
||||
|
||||
type T3 int8
|
||||
|
||||
func (t *T3) Invoke() int {
|
||||
println("invoke3", *t)
|
||||
return 3
|
||||
}
|
||||
|
||||
type T4 [1]int
|
||||
|
||||
func (t T4) Invoke() int {
|
||||
println("invoke4", t[0])
|
||||
return 4
|
||||
}
|
||||
|
||||
type T5 struct {
|
||||
n int
|
||||
}
|
||||
|
||||
func (t T5) Invoke() int {
|
||||
println("invoke5", t.n)
|
||||
return 5
|
||||
}
|
||||
|
||||
type T6 func() int
|
||||
|
||||
func (t T6) Invoke() int {
|
||||
println("invoke6", t())
|
||||
return 6
|
||||
}
|
||||
|
||||
type I interface {
|
||||
Invoke() int
|
||||
}
|
||||
|
||||
func main() {
|
||||
var t = T{"hello"}
|
||||
var t1 = T1(100)
|
||||
var t2 = T2(100.1)
|
||||
var t3 = T3(127)
|
||||
var t4 = T4{200}
|
||||
var t5 = T5{300}
|
||||
var t6 = T6(func() int { return 400 })
|
||||
invoke(t)
|
||||
invoke(&t)
|
||||
invoke(t1)
|
||||
invoke(&t1)
|
||||
invoke(t2)
|
||||
invoke(&t2)
|
||||
invoke(&t3)
|
||||
invoke(t4)
|
||||
invoke(&t4)
|
||||
invoke(t5)
|
||||
invoke(&t5)
|
||||
invoke(t6)
|
||||
invoke(&t6)
|
||||
var m M
|
||||
var i I = m
|
||||
println(i, m)
|
||||
m = &t
|
||||
invoke(m)
|
||||
var a any = T{"world"}
|
||||
invoke(a.(I))
|
||||
invoke(a.(interface{}).(interface{ Invoke() int }))
|
||||
//panic
|
||||
//invoke(nil)
|
||||
}
|
||||
|
||||
func invoke(i I) {
|
||||
println(i.Invoke())
|
||||
}
|
||||
|
||||
type M interface {
|
||||
Invoke() int
|
||||
Method()
|
||||
}
|
||||
1089
compiler/cl/_testgo/invoke/out.ll
Normal file
1089
compiler/cl/_testgo/invoke/out.ll
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user