From c19786bdfb80a69dcd37832b1d92e457ed708bed Mon Sep 17 00:00:00 2001 From: xushiwei Date: Wed, 22 May 2024 10:07:21 +0800 Subject: [PATCH 01/20] llgo/ssa: AfterInit/SliceLit/InterfaceData, unsafe.Slice; ssa/abi: Basic/Struct --- cl/_testgo/strucintf/in.go | 18 +++++++ cl/_testgo/strucintf/out.ll | 0 cl/compile.go | 4 +- cl/compile_test.go | 2 - cl/internal/foo/foo.go | 9 ++++ internal/abi/type.go | 4 +- internal/runtime/runtime2.go | 21 +++++--- internal/runtime/z_c.go | 4 +- internal/runtime/z_eface.go | 76 +++++++++++++++++++++++++++++ internal/runtime/z_iface.go | 94 ------------------------------------ internal/runtime/z_print.go | 4 +- ssa/{_abi => abi}/abi.go | 52 ++++++++++++++------ ssa/datastruct.go | 36 ++++++++------ ssa/decl.go | 39 ++++++++++----- ssa/expr.go | 36 ++++++++------ ssa/interface.go | 92 +++++++++++++++++++++++++++-------- ssa/package.go | 45 ++++++++++++----- ssa/type.go | 27 +++++++++-- 18 files changed, 361 insertions(+), 202 deletions(-) create mode 100644 cl/_testgo/strucintf/in.go create mode 100644 cl/_testgo/strucintf/out.ll create mode 100644 cl/internal/foo/foo.go create mode 100644 internal/runtime/z_eface.go delete mode 100644 internal/runtime/z_iface.go rename ssa/{_abi => abi}/abi.go (58%) diff --git a/cl/_testgo/strucintf/in.go b/cl/_testgo/strucintf/in.go new file mode 100644 index 00000000..ad3d0140 --- /dev/null +++ b/cl/_testgo/strucintf/in.go @@ -0,0 +1,18 @@ +package main + +import ( + "github.com/goplus/llgo/_demo/interf/foo" +) + +func main() { + if x, ok := foo.Bar().(struct{ V int }); ok { + println(x.V) + } else { + println("Bar: not ok") + } + if x, ok := foo.F().(struct{ v int }); ok { + println(x.v) + } else { + println("F: not ok") + } +} diff --git a/cl/_testgo/strucintf/out.ll b/cl/_testgo/strucintf/out.ll new file mode 100644 index 00000000..e69de29b diff --git a/cl/compile.go b/cl/compile.go index 6974ee81..d4ce3aa0 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -352,9 +352,9 @@ func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock, n int, do last = len(instrs) - 1 instrs = instrs[:last] } else { - // TODO(xsw): confirm pyMod don't need to call LoadPyModSyms + // TODO(xsw): confirm pyMod don't need to call AfterInit p.inits = append(p.inits, func() { - pkg.PyLoadModSyms(b, ret) + pkg.AfterInit(b, ret) }) } } else if doMainInit { diff --git a/cl/compile_test.go b/cl/compile_test.go index f1841da6..213da252 100644 --- a/cl/compile_test.go +++ b/cl/compile_test.go @@ -28,11 +28,9 @@ func testCompile(t *testing.T, src, expected string) { cltest.TestCompileEx(t, src, "foo.go", expected) } -/* func TestFromTestgo(t *testing.T) { cltest.FromDir(t, "strucintf", "./_testgo", false) } -*/ func TestFromTestpy(t *testing.T) { cltest.FromDir(t, "", "./_testpy", false) diff --git a/cl/internal/foo/foo.go b/cl/internal/foo/foo.go new file mode 100644 index 00000000..e385a31d --- /dev/null +++ b/cl/internal/foo/foo.go @@ -0,0 +1,9 @@ +package foo + +func Bar() any { + return struct{ V int }{1} +} + +func F() any { + return struct{ v int }{1} +} diff --git a/internal/abi/type.go b/internal/abi/type.go index 085a6475..21f90142 100644 --- a/internal/abi/type.go +++ b/internal/abi/type.go @@ -84,14 +84,12 @@ const ( UnsafePointer ) -/* const ( // TODO (khr, drchase) why aren't these in TFlag? Investigate, fix if possible. KindDirectIface = 1 << 5 KindGCProg = 1 << 6 // Type.gc points to GC program KindMask = (1 << 5) - 1 ) -*/ // TFlag is used by a Type to signal what extra type information is // available in the memory directly following the Type value. @@ -229,7 +227,7 @@ type Imethod struct { Typ TypeOff // .(*FuncType) underneath } -func (t *Type) Kind() Kind { return Kind(t.Kind_) } +func (t *Type) Kind() Kind { return Kind(t.Kind_ & KindMask) } // Size returns the size of data with type t. func (t *Type) Size() uintptr { return t.Size_ } diff --git a/internal/runtime/runtime2.go b/internal/runtime/runtime2.go index d0d8bea7..027c408f 100644 --- a/internal/runtime/runtime2.go +++ b/internal/runtime/runtime2.go @@ -8,21 +8,20 @@ import ( "unsafe" ) -type iface struct { - tab *itab - data unsafe.Pointer -} - -/* type eface struct { _type *_type data unsafe.Pointer } +/* func efaceOf(ep *any) *eface { return (*eface)(unsafe.Pointer(ep)) } -*/ + +type iface struct { + tab *itab + data unsafe.Pointer +} // layout of Itab known to compilers // allocated in non-garbage-collected memory @@ -35,3 +34,11 @@ type itab struct { _ [4]byte fun [1]uintptr // variable sized. fun[0]==0 means _type does not implement inter. } + +func MakeInterface(inter *InterfaceType, typ *Type, data unsafe.Pointer) Interface { + tab := &itab{inter: inter, _type: typ, hash: 0, fun: [1]uintptr{0}} + return Interface{ + tab: tab, data: data, + } +} +*/ diff --git a/internal/runtime/z_c.go b/internal/runtime/z_c.go index 1ea1efbd..2689b8cc 100644 --- a/internal/runtime/z_c.go +++ b/internal/runtime/z_c.go @@ -40,8 +40,8 @@ func Zeroinit(p c.Pointer, size uintptr) c.Pointer { } // TracePanic prints panic message. -func TracePanic(v Interface) { - kind := abi.Kind(v.tab._type.Kind_) +func TracePanic(v Eface) { + kind := abi.Kind(v._type.Kind_) switch { case kind == abi.String: stringTracef(c.Stderr, c.Str("panic: %s\n"), *(*String)(v.data)) diff --git a/internal/runtime/z_eface.go b/internal/runtime/z_eface.go new file mode 100644 index 00000000..03095088 --- /dev/null +++ b/internal/runtime/z_eface.go @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package runtime + +import ( + "unsafe" + + "github.com/goplus/llgo/internal/abi" +) + +type Eface = eface + +// ----------------------------------------------------------------------------- + +func MakeAnyIntptr(typ *Type, data uintptr) Eface { + return eface{ + _type: typ, data: unsafe.Pointer(data), + } +} + +func MakeAnyString(data string) Eface { + typ := basicTypes[abi.String] + return eface{ + _type: typ, data: unsafe.Pointer(&data), + } +} + +func MakeAny(typ *Type, data unsafe.Pointer) Eface { + return eface{ + _type: typ, data: data, + } +} + +func I2Int(v Eface, t *Type) uintptr { + if v._type == t { + return uintptr(v.data) + } + panic("I2Int: type mismatch") +} + +func CheckI2Int(v Eface, t *Type) (uintptr, bool) { + if v._type == t { + return uintptr(v.data), true + } + return 0, false +} + +func I2String(v Eface) string { + if v._type.Kind() == abi.String { + return *(*string)(v.data) + } + panic("I2String: type mismatch") +} + +func CheckI2String(v Eface) (string, bool) { + if v._type.Kind() == abi.String { + return *(*string)(v.data), true + } + return "", false +} + +// ----------------------------------------------------------------------------- diff --git a/internal/runtime/z_iface.go b/internal/runtime/z_iface.go deleted file mode 100644 index c64449ca..00000000 --- a/internal/runtime/z_iface.go +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package runtime - -import ( - "unsafe" - - "github.com/goplus/llgo/internal/abi" -) - -// ----------------------------------------------------------------------------- - -type InterfaceType = abi.InterfaceType - -var ( - TyAny = &InterfaceType{} -) - -// ----------------------------------------------------------------------------- - -type Interface = iface - -func MakeAnyIntptr(typ *Type, data uintptr) Interface { - tab := &itab{inter: TyAny, _type: typ, hash: 0, fun: [1]uintptr{0}} - return Interface{ - tab: tab, data: unsafe.Pointer(data), - } -} - -func MakeAnyString(data string) Interface { - typ := basicTypes[abi.String] - tab := &itab{inter: TyAny, _type: typ, hash: 0, fun: [1]uintptr{0}} - return Interface{ - tab: tab, data: unsafe.Pointer(&data), - } -} - -func MakeAny(typ *Type, data unsafe.Pointer) Interface { - tab := &itab{inter: TyAny, _type: typ, hash: 0, fun: [1]uintptr{0}} - return Interface{ - tab: tab, data: data, - } -} - -func MakeInterface(inter *InterfaceType, typ *Type, data unsafe.Pointer) Interface { - tab := &itab{inter: inter, _type: typ, hash: 0, fun: [1]uintptr{0}} - return Interface{ - tab: tab, data: data, - } -} - -func I2Int(v Interface, t *Type) uintptr { - if v.tab._type == t { - return uintptr(v.data) - } - panic("I2Int: type mismatch") -} - -func CheckI2Int(v Interface, t *Type) (uintptr, bool) { - if v.tab._type == t { - return uintptr(v.data), true - } - return 0, false -} - -func I2String(v Interface, t *Type) string { - if v.tab._type == t { - return *(*string)(v.data) - } - panic("I2String: type mismatch") -} - -func CheckI2String(v Interface, t *Type) (string, bool) { - if v.tab._type == t { - return *(*string)(v.data), true - } - return "", false -} - -// ----------------------------------------------------------------------------- diff --git a/internal/runtime/z_print.go b/internal/runtime/z_print.go index 4d4ea802..7aeca7f3 100644 --- a/internal/runtime/z_print.go +++ b/internal/runtime/z_print.go @@ -66,6 +66,6 @@ func PrintSlice(s Slice) { print("[", s.len, "/", s.cap, "]", s.data) } -func PrintIface(i Interface) { - print("(", i.tab, ",", i.data, ")") +func PrintEface(e Eface) { + print("(", e._type, ",", e.data, ")") } diff --git a/ssa/_abi/abi.go b/ssa/abi/abi.go similarity index 58% rename from ssa/_abi/abi.go rename to ssa/abi/abi.go index 65578218..3e9fb082 100644 --- a/ssa/_abi/abi.go +++ b/ssa/abi/abi.go @@ -28,46 +28,70 @@ import ( type Builder struct { h hash.Hash buf []byte + Pkg string } // New creates a new ABI type Builder. -func New() *Builder { - h := sha256.New() - buf := make([]byte, sha256.Size) - return &Builder{h, buf} +func New(pkg string) *Builder { + ret := new(Builder) + ret.Init(pkg) + return ret +} + +func (b *Builder) Init(pkg string) { + b.Pkg = pkg + b.h = sha256.New() + b.buf = make([]byte, sha256.Size) } // TypeName returns the ABI type name for the specified type. -func (b *Builder) TypeName(t types.Type) string { +func (b *Builder) TypeName(t types.Type) (ret string, private bool) { switch t := t.(type) { case *types.Basic: - return t.Name() + return BasicName(t), false case *types.Pointer: - return "*" + b.TypeName(t.Elem()) + ret, private = b.TypeName(t.Elem()) + return "*" + ret, private case *types.Struct: return b.StructName(t) } panic("todo") } -// StructName returns the ABI type name for the specified struct type. -func (b *Builder) StructName(t *types.Struct) string { - hash := b.structHash(t) - return "struct$" + base64.RawURLEncoding.EncodeToString(hash) +func BasicName(t *types.Basic) string { + return "_llgo_" + t.Name() } -func (b *Builder) structHash(t *types.Struct) []byte { +// StructName returns the ABI type name for the specified struct type. +func (b *Builder) StructName(t *types.Struct) (ret string, private bool) { + hash, private := b.structHash(t) + hashStr := base64.RawURLEncoding.EncodeToString(hash) + if private { + return b.Pkg + ".struct$" + hashStr, true + } + return "_llgo_struct$" + hashStr, false +} + +func (b *Builder) structHash(t *types.Struct) (ret []byte, private bool) { h := b.h h.Reset() n := t.NumFields() fmt.Fprintln(h, "struct", n) for i := 0; i < n; i++ { f := t.Field(i) + if !f.Exported() { + private = true + } name := f.Name() if f.Embedded() { name = "-" } - fmt.Fprintln(h, name, b.TypeName(f.Type())) + ft, fpriv := b.TypeName(f.Type()) + if fpriv { + private = true + } + fmt.Fprintln(h, name, ft) } - return h.Sum(b.buf[:0]) + ret = h.Sum(b.buf[:0]) + return } diff --git a/ssa/datastruct.go b/ssa/datastruct.go index 0ce70e97..c5ade5d7 100644 --- a/ssa/datastruct.go +++ b/ssa/datastruct.go @@ -70,9 +70,8 @@ func (b Builder) StringData(x Expr) Expr { if debugInstr { log.Printf("StringData %v\n", x.impl) } - prog := b.Prog ptr := llvm.CreateExtractValue(b.impl, x.impl, 0) - return Expr{ptr, prog.CStr()} + return Expr{ptr, b.Prog.CStr()} } // StringLen returns the length of a string. @@ -80,9 +79,8 @@ func (b Builder) StringLen(x Expr) Expr { if debugInstr { log.Printf("StringLen %v\n", x.impl) } - prog := b.Prog ptr := llvm.CreateExtractValue(b.impl, x.impl, 1) - return Expr{ptr, prog.Int()} + return Expr{ptr, b.Prog.Int()} } // SliceData returns the data pointer of a slice. @@ -90,9 +88,8 @@ func (b Builder) SliceData(x Expr) Expr { if debugInstr { log.Printf("SliceData %v\n", x.impl) } - prog := b.Prog ptr := llvm.CreateExtractValue(b.impl, x.impl, 0) - return Expr{ptr, prog.CStr()} + return Expr{ptr, b.Prog.VoidPtr()} } // SliceLen returns the length of a slice. @@ -100,9 +97,8 @@ func (b Builder) SliceLen(x Expr) Expr { if debugInstr { log.Printf("SliceLen %v\n", x.impl) } - prog := b.Prog ptr := llvm.CreateExtractValue(b.impl, x.impl, 1) - return Expr{ptr, prog.Int()} + return Expr{ptr, b.Prog.Int()} } // SliceCap returns the length of a slice cap. @@ -110,9 +106,8 @@ func (b Builder) SliceCap(x Expr) Expr { if debugInstr { log.Printf("SliceCap %v\n", x.impl) } - prog := b.Prog ptr := llvm.CreateExtractValue(b.impl, x.impl, 2) - return Expr{ptr, prog.Int()} + return Expr{ptr, b.Prog.Int()} } // The IndexAddr instruction yields the address of the element at @@ -188,7 +183,7 @@ func (b Builder) Index(x, idx Expr, addr func(Expr) Expr) Expr { if addr != nil { ptr = addr(x) } else { - size := b.SizeOf(telem, t.Len()) + size := SizeOf(prog, telem, t.Len()) ptr = b.Alloca(size) b.Store(ptr, x) } @@ -255,7 +250,7 @@ func (b Builder) Slice(x, low, high, max Expr) (ret Expr) { ret.impl = b.InlineCall(b.Pkg.rtFunc("NewStringSlice"), x, low, high).impl return case *types.Slice: - nEltSize = b.SizeOf(prog.Index(x.Type)) + nEltSize = SizeOf(prog, prog.Index(x.Type)) nCap = b.SliceCap(x) if high.IsNil() { high = b.SliceCap(x) @@ -268,7 +263,7 @@ func (b Builder) Slice(x, low, high, max Expr) (ret Expr) { case *types.Array: elem := prog.rawType(te.Elem()) ret.Type = prog.Slice(elem) - nEltSize = b.SizeOf(elem) + nEltSize = SizeOf(prog, elem) nCap = prog.IntVal(uint64(te.Len()), prog.Int()) if high.IsNil() { high = nCap @@ -283,6 +278,18 @@ func (b Builder) Slice(x, low, high, max Expr) (ret Expr) { return } +// SliceLit creates a new slice with the specified elements. +func (b Builder) SliceLit(t Type, elts ...Expr) Expr { + prog := b.Prog + telem := prog.Index(t) + ptr := b.AllocU(telem, int64(len(elts))) + for i, elt := range elts { + b.Store(b.Advance(ptr, prog.Val(i)), elt) + } + size := llvm.ConstInt(prog.tyInt(), uint64(len(elts)), false) + return b.unsafeSlice(ptr, size, size) +} + // ----------------------------------------------------------------------------- // The MakeMap instruction creates a new hash-table-based map object @@ -323,10 +330,11 @@ func (b Builder) MakeSlice(t Type, len, cap Expr) (ret Expr) { log.Printf("MakeSlice %v, %v, %v\n", t.RawType(), len.impl, cap.impl) } pkg := b.Pkg + prog := b.Prog if cap.IsNil() { cap = len } - elemSize := b.SizeOf(b.Prog.Index(t)) + elemSize := SizeOf(prog, prog.Index(t)) size := b.BinOp(token.MUL, cap, elemSize) ptr := b.InlineCall(pkg.rtFunc("AllocZ"), size) ret.impl = b.InlineCall(pkg.rtFunc("NewSlice"), ptr, len, cap).impl diff --git a/ssa/decl.go b/ssa/decl.go index 97856aa3..f859563f 100644 --- a/ssa/decl.go +++ b/ssa/decl.go @@ -58,6 +58,13 @@ type aNamedConst struct { // it augments with the name and position of its 'const' declaration. type NamedConst = *aNamedConst +/* +// NewConst creates a new named constant. +func (p Package) NewConst(name string, val constant.Value) NamedConst { + return &aNamedConst{} +} +*/ + // ----------------------------------------------------------------------------- type aGlobal struct { @@ -75,9 +82,21 @@ func (p Package) NewVar(name string, typ types.Type, bg Background) Global { return v } t := p.Prog.Type(typ, bg) + return p.doNewVar(name, t) +} + +// NewVarFrom creates a new global variable. +func (p Package) NewVarFrom(name string, t Type) Global { + if v, ok := p.vars[name]; ok { + return v + } + return p.doNewVar(name, t) +} + +func (p Package) doNewVar(name string, t Type) Global { var gbl llvm.Value var array bool - if t.kind == vkPtr && p.Prog.Elem(t).kind == vkArray { + if t.kind == vkPtr && p.Prog.Elem(t).kind == vkArray { // TODO(xsw): check this code typ := p.Prog.Elem(t).ll gbl = llvm.AddGlobal(p.mod, typ, name) gbl.SetInitializer(llvm.Undef(typ)) @@ -97,7 +116,7 @@ func (p Package) VarOf(name string) Global { // Init initializes the global variable with the given value. func (g Global) Init(v Expr) { - if g.array && v.kind == vkPtr { + if g.array && v.kind == vkPtr { // TODO(xsw): check this code return } g.impl.SetInitializer(v.impl) @@ -350,15 +369,14 @@ func (p Package) PyObjOf(name string) PyObjRef { return p.pyobjs[name] } -// PyLoadModSyms loads module symbols used in this package. -func (p Package) PyLoadModSyms(b Builder, ret BasicBlock) { - objs := p.pyobjs - n := len(objs) - if n == 0 { - return - } +func (p Package) pyHasModSyms() bool { + return len(p.pyobjs) > 0 +} - names := make([]string, 0, n) +// pyLoadModSyms loads module symbols used in this package. +func (p Package) pyLoadModSyms(b Builder) { + objs := p.pyobjs + names := make([]string, 0, len(objs)) for name := range objs { names = append(names, name) } @@ -376,7 +394,6 @@ func (p Package) PyLoadModSyms(b Builder, ret BasicBlock) { } } - b.SetBlockEx(ret, afterInit) for _, modName := range modNames { objs := mods[modName] b.PyLoadModSyms(modName, objs...) diff --git a/ssa/expr.go b/ssa/expr.go index 49ccc6d9..5a25085b 100644 --- a/ssa/expr.go +++ b/ssa/expr.go @@ -180,13 +180,6 @@ func (b Builder) Const(v constant.Value, typ Type) Expr { panic(fmt.Sprintf("unsupported Const: %v, %v", v, raw)) } -// SizeOf returns the size of a type. -func (b Builder) SizeOf(t Type, n ...int64) Expr { - prog := b.Prog - size := prog.SizeOf(t, n...) - return prog.IntVal(size, prog.Uintptr()) -} - // CStr returns a c-style string constant expression. func (b Builder) CStr(v string) Expr { return Expr{llvm.CreateGlobalStringPtr(b.impl, v), b.Prog.CStr()} @@ -200,10 +193,17 @@ func (b Builder) Str(v string) (ret Expr) { return Expr{aggregateValue(b.impl, prog.rtString(), data, size), prog.String()} } -// unsafe.String(data *byte, size int) string -func (b Builder) String(data, size Expr) Expr { +// unsafeString(data *byte, size int) string +func (b Builder) unsafeString(data, size llvm.Value) Expr { prog := b.Prog - return Expr{aggregateValue(b.impl, prog.rtString(), data.impl, size.impl), prog.String()} + return Expr{aggregateValue(b.impl, prog.rtString(), data, size), prog.String()} +} + +// unsafeSlice(data *T, size, cap int) []T +func (b Builder) unsafeSlice(data Expr, size, cap llvm.Value) Expr { + prog := b.Prog + tslice := prog.Slice(prog.Elem(data.Type)) + return Expr{aggregateValue(b.impl, prog.rtSlice(), data.impl, size, cap), tslice} } // ----------------------------------------------------------------------------- @@ -667,7 +667,7 @@ func (b Builder) Alloc(elem Type, heap bool) (ret Expr) { } prog := b.Prog pkg := b.Pkg - size := b.SizeOf(elem) + size := SizeOf(prog, elem) if heap { ret = b.InlineCall(pkg.rtFunc("AllocZ"), size) } else { @@ -683,9 +683,10 @@ func (b Builder) AllocU(elem Type, n ...int64) (ret Expr) { if debugInstr { log.Printf("AllocU %v, %v\n", elem.raw.Type, n) } - size := b.SizeOf(elem, n...) + prog := b.Prog + size := SizeOf(prog, elem, n...) ret = b.InlineCall(b.Pkg.rtFunc("AllocU"), size) - ret.Type = b.Prog.Pointer(elem) + ret.Type = prog.Pointer(elem) return } @@ -1035,8 +1036,8 @@ func (b Builder) BuiltinCall(fn string, args ...Expr) (ret Expr) { typ = prog.VoidPtr() case vkString: fn = "PrintString" - case vkInterface: - fn = "PrintIface" + case vkEface: + fn = "PrintEface" // case vkComplex: // fn = "PrintComplex" default: @@ -1067,7 +1068,10 @@ func (b Builder) BuiltinCall(fn string, args ...Expr) (ret Expr) { } } case "String": // unsafe.String - return b.String(args[0], args[1]) + return b.unsafeString(args[0].impl, args[1].impl) + case "Slice": // unsafe.Slice + size := args[1].impl + return b.unsafeSlice(args[0], size, size) } panic("todo: " + fn) } diff --git a/ssa/interface.go b/ssa/interface.go index 16004054..84f7fe04 100644 --- a/ssa/interface.go +++ b/ssa/interface.go @@ -21,31 +21,72 @@ import ( "go/types" "log" - "github.com/goplus/llgo/internal/abi" + "github.com/goplus/llgo/ssa/abi" "github.com/goplus/llvm" ) // ----------------------------------------------------------------------------- // abiBasic returns the abi type of the specified basic kind. -func (b Builder) abiBasic(kind types.BasicKind) Expr { - return b.InlineCall(b.Pkg.rtFunc("Basic"), b.Prog.Val(int(kind))) +func (b Builder) abiBasic(t *types.Basic) Expr { + name := abi.BasicName(t) + g := b.Pkg.NewVarFrom(name, b.Prog.AbiTypePtrPtr()) + return g.Expr } -/* // abiStruct returns the abi type of the specified struct type. func (b Builder) abiStruct(t *types.Struct) Expr { - // name := "__llgo_" + b.Prog.abi.StructName(t) + pkg := b.Pkg + name, _ := pkg.abi.StructName(t) + if v := pkg.VarOf(name); v != nil { + return v.Expr + } + prog := b.Prog + g := pkg.doNewVar(name, prog.AbiTypePtrPtr()) + g.Init(prog.Null(g.Type)) + pkg.abitys = append(pkg.abitys, func() { + b.structOf(t) + }) + return g.Expr } -*/ -// AbiType returns the abi type of the specified type. -func (b Builder) AbiType(t Type) Expr { - switch tx := t.raw.Type.(type) { +// func Struct(size uintptr, pkgPath string, fields []abi.StructField) *abi.Type +func (b Builder) structOf(t *types.Struct) Expr { + pkg := b.Pkg + prog := b.Prog + n := t.NumFields() + flds := make([]Expr, n) + strucAbi := pkg.rtFunc("Struct") + sfAbi := pkg.rtFunc("StructField") + typ := prog.rawType(t) + for i := 0; i < n; i++ { + f := t.Field(i) + off := uintptr(prog.OffsetOf(typ, i)) + flds[i] = b.structField(sfAbi, prog, f, off, t.Tag(i)) + } + pkgPath := prog.Val(pkg.abi.Pkg) + params := strucAbi.raw.Type.(*types.Signature).Params() + tSlice := prog.rawType(params.At(params.Len() - 1).Type().(*types.Slice)) + fldSlice := b.SliceLit(tSlice, flds...) + return b.Call(strucAbi, pkgPath, fldSlice) +} + +// func StructField(name string, typ *abi.Type, off uintptr, tag string, exported, embedded bool) abi.StructField +func (b Builder) structField(sfAbi Expr, prog Program, f *types.Var, offset uintptr, tag string) Expr { + name := prog.Val(f.Name()) + typ := b.abiType(f.Type()) + exported := prog.Val(f.Exported()) + embedded := prog.Val(f.Embedded()) + return b.Call(sfAbi, name, typ, prog.Val(offset), prog.Val(tag), exported, embedded) +} + +// abiType returns the abi type of the specified type. +func (b Builder) abiType(raw types.Type) Expr { + switch tx := raw.(type) { case *types.Basic: - return b.abiBasic(tx.Kind()) - //case *types.Struct: - // return b.abiStruct(tx) + return b.abiBasic(tx) + case *types.Struct: + return b.abiStruct(tx) } panic("todo") } @@ -94,14 +135,14 @@ func (b Builder) MakeInterface(tinter Type, x Expr) (ret Expr) { case kind == types.String: return Expr{b.InlineCall(b.Pkg.rtFunc("MakeAnyString"), x).impl, tinter} } - /* case *types.Struct: + case *types.Struct: size := int(prog.SizeOf(typ)) if size > prog.PointerSize() { return b.makeIntfAlloc(tinter, rawIntf, typ, x) } tv := prog.ctx.IntType(size * 8) iv := llvm.CreateBitCast(b.impl, x.impl, tv) - return b.makeIntfByIntptr(tinter, rawIntf, typ, iv) */ + return b.makeIntfByIntptr(tinter, rawIntf, typ, iv) } panic("todo") } @@ -114,7 +155,7 @@ func (b Builder) makeIntfAlloc(tinter Type, rawIntf *types.Interface, typ Type, func (b Builder) makeIntfByPtr(tinter Type, rawIntf *types.Interface, typ Type, vptr Expr) (ret Expr) { if rawIntf.Empty() { - ret = b.InlineCall(b.Pkg.rtFunc("MakeAny"), b.AbiType(typ), vptr) + ret = b.InlineCall(b.Pkg.rtFunc("MakeAny"), b.abiType(typ.raw.Type), vptr) ret.Type = tinter return } @@ -125,7 +166,7 @@ func (b Builder) makeIntfByIntptr(tinter Type, rawIntf *types.Interface, typ Typ if rawIntf.Empty() { tptr := b.Prog.Uintptr() x = llvm.CreateIntCast(b.impl, x, tptr.ll) - impl := b.InlineCall(b.Pkg.rtFunc("MakeAnyIntptr"), b.AbiType(typ), Expr{x, tptr}).impl + impl := b.InlineCall(b.Pkg.rtFunc("MakeAnyIntptr"), b.abiType(typ.raw.Type), Expr{x, tptr}).impl return Expr{impl, tinter} } panic("todo") @@ -183,13 +224,14 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) (ret Expr) { } fn := pkg.rtFunc(fnName) var kind types.BasicKind + var typ Expr switch t := assertedTyp.raw.Type.(type) { case *types.Basic: kind = t.Kind() + typ = b.abiBasic(t) default: panic("todo") } - typ := b.InlineCall(pkg.rtFunc("Basic"), b.Prog.Val(int(kind))) ret = b.InlineCall(fn, x, typ) if kind != types.Uintptr { conv := func(v llvm.Value) llvm.Value { @@ -226,11 +268,21 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) (ret Expr) { if commaOk { fnName = "CheckI2String" } - fn := pkg.rtFunc(fnName) - typ := b.InlineCall(pkg.rtFunc("Basic"), b.Prog.Val(int(abi.String))) - return b.InlineCall(fn, x, typ) + return b.InlineCall(pkg.rtFunc(fnName), x) + case vkStruct: } panic("todo") } // ----------------------------------------------------------------------------- + +// InterfaceData returns the data pointer of an interface. +func (b Builder) InterfaceData(x Expr) Expr { + if debugInstr { + log.Printf("InterfaceData %v\n", x.impl) + } + ptr := llvm.CreateExtractValue(b.impl, x.impl, 1) + return Expr{ptr, b.Prog.VoidPtr()} +} + +// ----------------------------------------------------------------------------- diff --git a/ssa/package.go b/ssa/package.go index 9e9356bb..e5960391 100644 --- a/ssa/package.go +++ b/ssa/package.go @@ -20,6 +20,7 @@ import ( "go/token" "go/types" + "github.com/goplus/llgo/ssa/abi" "github.com/goplus/llvm" "golang.org/x/tools/go/types/typeutil" ) @@ -99,7 +100,6 @@ type aProgram struct { ctx llvm.Context typs typeutil.Map // rawType -> Type gocvt goTypes - //abi *abi.Builder rt *types.Package rtget func() *types.Package @@ -144,6 +144,7 @@ type aProgram struct { u64Ty Type pyObjPtr Type pyObjPPtr Type + abiTyptr Type pyImpTy *types.Signature pyNewList *types.Signature @@ -184,7 +185,7 @@ func NewProgram(target *Target) Program { */ is32Bits := (td.PointerSize() == 4 || target.GOARCH == "x86") // TODO(xsw): remove temp code return &aProgram{ - ctx: ctx, gocvt: newGoTypes(), // abi: abi.New(), + ctx: ctx, gocvt: newGoTypes(), target: target, td: td, is32Bits: is32Bits, named: make(map[string]llvm.Type), } @@ -243,9 +244,9 @@ func (p Program) rtType(name string) Type { return p.rawType(p.rtNamed(name)) } -func (p Program) rtIface() llvm.Type { +func (p Program) rtEface() llvm.Type { if p.rtIfaceTy.IsNil() { - p.rtIfaceTy = p.rtType("Interface").ll + p.rtIfaceTy = p.rtType("Eface").ll } return p.rtIfaceTy } @@ -284,7 +285,23 @@ func (p Program) NewPackage(name, pkgPath string) Package { p.NeedRuntime = false // Don't need reset p.needPyInit here // p.needPyInit = false - return &aPackage{mod, gbls, fns, stubs, pyobjs, pymods, p} + ret := &aPackage{ + mod: mod, vars: gbls, fns: fns, stubs: stubs, + pyobjs: pyobjs, pymods: pymods, Prog: p} + return ret +} + +// AbiTypePtr returns *abi.Type. +func (p Program) AbiTypePtr() Type { + if p.abiTyptr == nil { + p.abiTyptr = p.rawType(types.NewPointer(p.rtNamed("Type"))) + } + return p.abiTyptr +} + +// AbiTypePtr returns **abi.Type. +func (p Program) AbiTypePtrPtr() Type { + return p.Pointer(p.AbiTypePtr()) } // PyObjectPtrPtr returns the **py.Object type. @@ -440,6 +457,8 @@ func (p Program) Uint64() Type { // and unspecified other things too. type aPackage struct { mod llvm.Module + abi abi.Builder + abitys []func() vars map[string]Global fns map[string]Function stubs map[string]Function @@ -450,13 +469,6 @@ type aPackage struct { type Package = *aPackage -/* -// NewConst creates a new named constant. -func (p Package) NewConst(name string, val constant.Value) NamedConst { - return &aNamedConst{} -} -*/ - func (p Package) rtFunc(fnName string) Expr { fn := p.Prog.runtime().Scope().Lookup(fnName).(*types.Func) name := FullName(fn.Pkg(), fnName) @@ -509,6 +521,15 @@ func (p Package) String() string { return p.mod.String() } +// AfterInit is called after the package is initialized (init all packages that depends on). +func (p Package) AfterInit(b Builder, ret BasicBlock) { + doAfterInit := p.pyHasModSyms() + if doAfterInit { + b.SetBlockEx(ret, afterInit) + p.pyLoadModSyms(b) + } +} + /* type CodeGenFileType = llvm.CodeGenFileType diff --git a/ssa/type.go b/ssa/type.go index b7307c39..391e95da 100644 --- a/ssa/type.go +++ b/ssa/type.go @@ -49,7 +49,9 @@ const ( vkSlice vkArray vkMap - vkInterface + vkEface + vkIface + vkStruct vkPhisExpr = -1 ) @@ -99,6 +101,22 @@ func (p Program) SizeOf(typ Type, n ...int64) uint64 { return size } +// OffsetOf returns the offset of a field in a struct. +func (p Program) OffsetOf(typ Type, i int) uint64 { + return p.td.ElementOffset(typ.ll, i) +} + +// SizeOf returns the size of a type. +func SizeOf(prog Program, t Type, n ...int64) Expr { + size := prog.SizeOf(t, n...) + return prog.IntVal(size, prog.Uintptr()) +} + +func OffsetOf(prog Program, t Type, i int) Expr { + offset := prog.OffsetOf(t, i) + return prog.IntVal(offset, prog.Uintptr()) +} + func (p Program) PointerSize() int { return p.td.PointerSize() } @@ -113,7 +131,6 @@ func (p Program) Pointer(typ Type) Type { func (p Program) Elem(typ Type) Type { elem := typ.raw.Type.(interface { - types.Type Elem() types.Type }).Elem() return p.rawType(elem) @@ -247,7 +264,9 @@ func (p Program) toType(raw types.Type) Type { elem := p.rawType(t.Elem()) return &aType{llvm.PointerType(elem.ll, 0), typ, vkPtr} case *types.Interface: - return &aType{p.rtIface(), typ, vkInterface} + if t.Empty() { + return &aType{p.rtEface(), typ, vkEface} + } case *types.Slice: return &aType{p.rtSlice(), typ, vkSlice} case *types.Map: @@ -283,6 +302,8 @@ func (p Program) toLLVMStruct(raw *types.Struct) (ret llvm.Type, kind valueKind) ret = p.ctx.StructType(fields, false) if isClosure(raw) { kind = vkClosure + } else { + kind = vkStruct } return } From 6442ab2f200d9294bd08506a2261f134e6e7e4d5 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Wed, 22 May 2024 13:47:21 +0800 Subject: [PATCH 02/20] llgo/ssa: unsafeEface --- internal/runtime/z_eface.go | 6 ------ ssa/interface.go | 30 +++++++++++++++++++----------- ssa/package.go | 25 +++++++++++++++++++------ 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/internal/runtime/z_eface.go b/internal/runtime/z_eface.go index 03095088..a0f96d03 100644 --- a/internal/runtime/z_eface.go +++ b/internal/runtime/z_eface.go @@ -39,12 +39,6 @@ func MakeAnyString(data string) Eface { } } -func MakeAny(typ *Type, data unsafe.Pointer) Eface { - return eface{ - _type: typ, data: data, - } -} - func I2Int(v Eface, t *Type) uintptr { if v._type == t { return uintptr(v.data) diff --git a/ssa/interface.go b/ssa/interface.go index 84f7fe04..e497cae9 100644 --- a/ssa/interface.go +++ b/ssa/interface.go @@ -31,23 +31,24 @@ import ( func (b Builder) abiBasic(t *types.Basic) Expr { name := abi.BasicName(t) g := b.Pkg.NewVarFrom(name, b.Prog.AbiTypePtrPtr()) - return g.Expr + return b.Load(g.Expr) } // abiStruct returns the abi type of the specified struct type. func (b Builder) abiStruct(t *types.Struct) Expr { pkg := b.Pkg name, _ := pkg.abi.StructName(t) - if v := pkg.VarOf(name); v != nil { - return v.Expr + g := pkg.VarOf(name) + if g == nil { + prog := b.Prog + g := pkg.doNewVar(name, prog.AbiTypePtrPtr()) + g.Init(prog.Null(g.Type)) } - prog := b.Prog - g := pkg.doNewVar(name, prog.AbiTypePtrPtr()) - g.Init(prog.Null(g.Type)) pkg.abitys = append(pkg.abitys, func() { - b.structOf(t) + tabi := b.structOf(t) + b.Store(g.Expr, tabi) }) - return g.Expr + return b.Load(g.Expr) } // func Struct(size uintptr, pkgPath string, fields []abi.StructField) *abi.Type @@ -91,6 +92,11 @@ func (b Builder) abiType(raw types.Type) Expr { panic("todo") } +// unsafeEface(t *abi.Type, data unsafe.Pointer) Eface +func (b Builder) unsafeEface(t, data llvm.Value) llvm.Value { + return aggregateValue(b.impl, b.Prog.rtEface(), t, data) +} + // ----------------------------------------------------------------------------- // MakeInterface constructs an instance of an interface type from a @@ -155,9 +161,7 @@ func (b Builder) makeIntfAlloc(tinter Type, rawIntf *types.Interface, typ Type, func (b Builder) makeIntfByPtr(tinter Type, rawIntf *types.Interface, typ Type, vptr Expr) (ret Expr) { if rawIntf.Empty() { - ret = b.InlineCall(b.Pkg.rtFunc("MakeAny"), b.abiType(typ.raw.Type), vptr) - ret.Type = tinter - return + return Expr{b.unsafeEface(b.abiType(typ.raw.Type).impl, vptr.impl), tinter} } panic("todo") } @@ -215,6 +219,10 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) (ret Expr) { if debugInstr { log.Printf("TypeAssert %v, %v, %v\n", x.impl, assertedTyp.raw.Type, commaOk) } + // TODO(xsw) + // if x.kind != vkEface { + // panic("todo: non empty interface") + // } switch assertedTyp.kind { case vkSigned, vkUnsigned, vkFloat, vkBool: pkg := b.Pkg diff --git a/ssa/package.go b/ssa/package.go index e5960391..879e38ee 100644 --- a/ssa/package.go +++ b/ssa/package.go @@ -122,7 +122,7 @@ type aProgram struct { voidPtrTy llvm.Type rtStringTy llvm.Type - rtIfaceTy llvm.Type + rtEfaceTy llvm.Type rtSliceTy llvm.Type rtMapTy llvm.Type @@ -145,6 +145,8 @@ type aProgram struct { pyObjPtr Type pyObjPPtr Type abiTyptr Type + abiTypptr Type + efaceTy Type pyImpTy *types.Signature pyNewList *types.Signature @@ -245,10 +247,10 @@ func (p Program) rtType(name string) Type { } func (p Program) rtEface() llvm.Type { - if p.rtIfaceTy.IsNil() { - p.rtIfaceTy = p.rtType("Eface").ll + if p.rtEfaceTy.IsNil() { + p.rtEfaceTy = p.rtType("Eface").ll } - return p.rtIfaceTy + return p.rtEfaceTy } func (p Program) rtMap() llvm.Type { @@ -291,6 +293,14 @@ func (p Program) NewPackage(name, pkgPath string) Package { return ret } +// Eface returns the empty interface type. +func (p Program) Eface() Type { + if p.efaceTy == nil { + p.efaceTy = p.rawType(tyAny) + } + return p.efaceTy +} + // AbiTypePtr returns *abi.Type. func (p Program) AbiTypePtr() Type { if p.abiTyptr == nil { @@ -299,9 +309,12 @@ func (p Program) AbiTypePtr() Type { return p.abiTyptr } -// AbiTypePtr returns **abi.Type. +// AbiTypePtrPtr returns **abi.Type. func (p Program) AbiTypePtrPtr() Type { - return p.Pointer(p.AbiTypePtr()) + if p.abiTypptr == nil { + p.abiTypptr = p.Pointer(p.AbiTypePtr()) + } + return p.abiTypptr } // PyObjectPtrPtr returns the **py.Object type. From a4c4324ba314d6d15064f69d33ea7d906a221674 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Thu, 23 May 2024 01:10:13 +0800 Subject: [PATCH 03/20] merge Field/Extract; prog.Tuple/Zero; TypeAssert refactor --- ssa/expr.go | 59 ++++++++++++-------- ssa/interface.go | 133 ++++++++++++++++++++++++++++++-------------- ssa/package.go | 19 +++++++ ssa/stmt_builder.go | 16 ++++++ ssa/type.go | 15 +++-- 5 files changed, 174 insertions(+), 68 deletions(-) diff --git a/ssa/expr.go b/ssa/expr.go index 5a25085b..9b69c4af 100644 --- a/ssa/expr.go +++ b/ssa/expr.go @@ -93,6 +93,40 @@ func phisExpr(t Type, phis []llvm.Value) Expr { // ----------------------------------------------------------------------------- +func (p Program) Zero(t Type) Expr { + var ret llvm.Value + switch u := t.raw.Type.Underlying().(type) { + case *types.Basic: + kind := u.Kind() + switch { + case kind >= types.Bool && kind <= types.Uintptr: + ret = llvm.ConstInt(p.rawType(u).ll, 0, false) + case kind == types.String: + ret = p.Zero(p.rtType("String")).impl + case kind == types.UnsafePointer: + ret = llvm.ConstPointerNull(p.tyVoidPtr()) + case kind <= types.Float64: + ret = llvm.ConstFloat(p.Float64().ll, 0) + case kind == types.Float32: + ret = llvm.ConstFloat(p.Float32().ll, 0) + default: + panic("todo") + } + case *types.Pointer: + return Expr{llvm.ConstNull(t.ll), t} + case *types.Struct: + n := u.NumFields() + flds := make([]llvm.Value, n) + for i := 0; i < n; i++ { + flds[i] = p.Zero(p.rawType(u.Field(i).Type())).impl + } + ret = llvm.ConstStruct(flds, false) + default: + log.Panicln("todo:", u) + } + return Expr{ret, t} +} + // Null returns a null constant expression. func (p Program) Null(t Type) Expr { return Expr{llvm.ConstNull(t.ll), t} @@ -125,12 +159,6 @@ func (p Program) FloatVal(v float64, t Type) Expr { return Expr{ret, t} } -func (p Program) ByteVal(v byte) Expr { - t := p.Byte() - ret := llvm.ConstInt(t.ll, uint64(v), false) - return Expr{ret, t} -} - // Val returns a constant expression. func (p Program) Val(v interface{}) Expr { switch v := v.(type) { @@ -941,21 +969,6 @@ func (b Builder) Call(fn Expr, args ...Expr) (ret Expr) { return } -// The Extract instruction yields component Index of Tuple. -// -// This is used to access the results of instructions with multiple -// return values, such as Call, TypeAssert, Next, UnOp(ARROW) and -// IndexExpr(Map). -// -// Example printed form: -// -// t1 = extract t0 #1 -func (b Builder) Extract(x Expr, index int) (ret Expr) { - ret.Type = b.Prog.toType(x.Type.raw.Type.(*types.Tuple).At(index).Type()) - ret.impl = llvm.CreateExtractValue(b.impl, x.impl, index) - return -} - // A Builtin represents a specific use of a built-in function, e.g. len. // // Builtins are immutable values. Builtins do not have addresses. @@ -1009,7 +1022,7 @@ func (b Builder) BuiltinCall(fn string, args ...Expr) (ret Expr) { ret.Type = prog.Void() for i, arg := range args { if ln && i > 0 { - b.InlineCall(b.Pkg.rtFunc("PrintByte"), prog.ByteVal(' ')) + b.InlineCall(b.Pkg.rtFunc("PrintByte"), prog.IntVal(' ', prog.Byte())) } var fn string typ := arg.Type @@ -1049,7 +1062,7 @@ func (b Builder) BuiltinCall(fn string, args ...Expr) (ret Expr) { b.InlineCall(b.Pkg.rtFunc(fn), arg) } if ln { - b.InlineCall(b.Pkg.rtFunc("PrintByte"), prog.ByteVal('\n')) + b.InlineCall(b.Pkg.rtFunc("PrintByte"), prog.IntVal('\n', prog.Byte())) } return case "copy": diff --git a/ssa/interface.go b/ssa/interface.go index e497cae9..5aebb33e 100644 --- a/ssa/interface.go +++ b/ssa/interface.go @@ -161,11 +161,13 @@ func (b Builder) makeIntfAlloc(tinter Type, rawIntf *types.Interface, typ Type, func (b Builder) makeIntfByPtr(tinter Type, rawIntf *types.Interface, typ Type, vptr Expr) (ret Expr) { if rawIntf.Empty() { - return Expr{b.unsafeEface(b.abiType(typ.raw.Type).impl, vptr.impl), tinter} + tabi := b.abiType(typ.raw.Type) + return Expr{b.unsafeEface(tabi.impl, vptr.impl), tinter} } panic("todo") } +// TODO(xsw): remove MakeAnyIntptr, MakeAnyString func (b Builder) makeIntfByIntptr(tinter Type, rawIntf *types.Interface, typ Type, x llvm.Value) (ret Expr) { if rawIntf.Empty() { tptr := b.Prog.Uintptr() @@ -176,45 +178,7 @@ func (b Builder) makeIntfByIntptr(tinter Type, rawIntf *types.Interface, typ Typ panic("todo") } -// The TypeAssert instruction tests whether interface value X has type -// AssertedType. -// -// If !CommaOk, on success it returns v, the result of the conversion -// (defined below); on failure it panics. -// -// If CommaOk: on success it returns a pair (v, true) where v is the -// result of the conversion; on failure it returns (z, false) where z -// is AssertedType's zero value. The components of the pair must be -// accessed using the Extract instruction. -// -// If Underlying: tests whether interface value X has the underlying -// type AssertedType. -// -// If AssertedType is a concrete type, TypeAssert checks whether the -// dynamic type in interface X is equal to it, and if so, the result -// of the conversion is a copy of the value in the interface. -// -// If AssertedType is an interface, TypeAssert checks whether the -// dynamic type of the interface is assignable to it, and if so, the -// result of the conversion is a copy of the interface value X. -// If AssertedType is a superinterface of X.Type(), the operation will -// fail iff the operand is nil. (Contrast with ChangeInterface, which -// performs no nil-check.) -// -// Type() reflects the actual type of the result, possibly a -// 2-types.Tuple; AssertedType is the asserted type. -// -// Depending on the TypeAssert's purpose, Pos may return: -// - the ast.CallExpr.Lparen of an explicit T(e) conversion; -// - the ast.TypeAssertExpr.Lparen of an explicit e.(T) operation; -// - the ast.CaseClause.Case of a case of a type-switch statement; -// - the Ident(m).NamePos of an interface method value i.m -// (for which TypeAssert may be used to effect the nil check). -// -// Example printed form: -// -// t1 = typeassert t0.(int) -// t3 = typeassert,ok t2.(T) +/* func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) (ret Expr) { if debugInstr { log.Printf("TypeAssert %v, %v, %v\n", x.impl, assertedTyp.raw.Type, commaOk) @@ -277,10 +241,89 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) (ret Expr) { fnName = "CheckI2String" } return b.InlineCall(pkg.rtFunc(fnName), x) - case vkStruct: } panic("todo") } +*/ + +// The TypeAssert instruction tests whether interface value X has type +// AssertedType. +// +// If !CommaOk, on success it returns v, the result of the conversion +// (defined below); on failure it panics. +// +// If CommaOk: on success it returns a pair (v, true) where v is the +// result of the conversion; on failure it returns (z, false) where z +// is AssertedType's zero value. The components of the pair must be +// accessed using the Extract instruction. +// +// If Underlying: tests whether interface value X has the underlying +// type AssertedType. +// +// If AssertedType is a concrete type, TypeAssert checks whether the +// dynamic type in interface X is equal to it, and if so, the result +// of the conversion is a copy of the value in the interface. +// +// If AssertedType is an interface, TypeAssert checks whether the +// dynamic type of the interface is assignable to it, and if so, the +// result of the conversion is a copy of the interface value X. +// If AssertedType is a superinterface of X.Type(), the operation will +// fail iff the operand is nil. (Contrast with ChangeInterface, which +// performs no nil-check.) +// +// Type() reflects the actual type of the result, possibly a +// 2-types.Tuple; AssertedType is the asserted type. +// +// Depending on the TypeAssert's purpose, Pos may return: +// - the ast.CallExpr.Lparen of an explicit T(e) conversion; +// - the ast.TypeAssertExpr.Lparen of an explicit e.(T) operation; +// - the ast.CaseClause.Case of a case of a type-switch statement; +// - the Ident(m).NamePos of an interface method value i.m +// (for which TypeAssert may be used to effect the nil check). +// +// Example printed form: +// +// t1 = typeassert t0.(int) +// t3 = typeassert,ok t2.(T) +func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) Expr { + if debugInstr { + log.Printf("TypeAssert %v, %v, %v\n", x.impl, assertedTyp.raw.Type, commaOk) + } + tx := b.faceAbiType(x) + tabi := b.abiType(assertedTyp.raw.Type) + eq := b.BinOp(token.EQL, tx, tabi) + if commaOk { + /* + prog := b.Prog + t := prog.Tuple(assertedTyp, prog.Bool()) + val := b.valFromData(assertedTyp, b.InterfaceData(x)) + zero := prog.Zero(assertedTyp) + valTrue := aggregateValue(b.impl, t.ll, val.impl, prog.BoolVal(true).impl) + valFalse := aggregateValue(b.impl, t.ll, zero.impl, prog.BoolVal(false).impl) + return Expr{llvm.CreateSelect(b.impl, eq.impl, valTrue, valFalse), t} + */ + panic("todo") + } + blks := b.Func.MakeBlocks(2) + b.If(eq, blks[0], blks[1]) + b.SetBlock(blks[1]) + b.Panic(b.Str("type assertion failed")) + b.SetBlock(blks[0]) + return b.valFromData(assertedTyp, b.InterfaceData(x)) +} + +func (b Builder) valFromData(t Type, data Expr) Expr { + switch u := t.raw.Type.Underlying().(type) { + case *types.Basic: + kind := u.Kind() + switch { + case kind >= types.Bool && kind <= types.Uintptr: + panic("todo") + } + } + _ = data + panic("todo") +} // ----------------------------------------------------------------------------- @@ -293,4 +336,12 @@ func (b Builder) InterfaceData(x Expr) Expr { return Expr{ptr, b.Prog.VoidPtr()} } +func (b Builder) faceAbiType(x Expr) Expr { + if x.kind == vkIface { + panic("todo") + } + typ := llvm.CreateExtractValue(b.impl, x.impl, 0) + return Expr{typ, b.Prog.AbiTypePtr()} +} + // ----------------------------------------------------------------------------- diff --git a/ssa/package.go b/ssa/package.go index 879e38ee..f7a967e9 100644 --- a/ssa/package.go +++ b/ssa/package.go @@ -137,6 +137,7 @@ type aProgram struct { intTy Type uintTy Type f64Ty Type + f32Ty Type byteTy Type i32Ty Type u32Ty Type @@ -293,6 +294,16 @@ func (p Program) NewPackage(name, pkgPath string) Package { return ret } +// Tuple returns a tuple type. +func (p Program) Tuple(typs ...Type) Type { + n := len(typs) + els := make([]*types.Var, n) + for i, t := range typs { + els[i] = types.NewParam(token.NoPos, nil, "", t.raw.Type) + } + return p.rawType(types.NewTuple(els...)) +} + // Eface returns the empty interface type. func (p Program) Eface() Type { if p.efaceTy == nil { @@ -418,6 +429,14 @@ func (p Program) Float64() Type { return p.f64Ty } +// Float32 returns float32 type. +func (p Program) Float32() Type { + if p.f32Ty == nil { + p.f32Ty = p.rawType(types.Typ[types.Float32]) + } + return p.f32Ty +} + // Byte returns byte type. func (p Program) Byte() Type { if p.byteTy == nil { diff --git a/ssa/stmt_builder.go b/ssa/stmt_builder.go index 2bbaf771..4ef42c9a 100644 --- a/ssa/stmt_builder.go +++ b/ssa/stmt_builder.go @@ -160,6 +160,22 @@ func (b Builder) Return(results ...Expr) { } } +// The Extract instruction yields component Index of Tuple. +// +// This is used to access the results of instructions with multiple +// return values, such as Call, TypeAssert, Next, UnOp(ARROW) and +// IndexExpr(Map). +// +// Example printed form: +// +// t1 = extract t0 #1 +func (b Builder) Extract(x Expr, i int) (ret Expr) { + if debugInstr { + log.Printf("Extract %v, %d\n", x.impl, i) + } + return b.getField(x, i) +} + // Jump emits a jump instruction. func (b Builder) Jump(jmpb BasicBlock) { if b.Func != jmpb.fn { diff --git a/ssa/type.go b/ssa/type.go index 391e95da..64314d6c 100644 --- a/ssa/type.go +++ b/ssa/type.go @@ -141,9 +141,14 @@ func (p Program) Index(typ Type) Type { } func (p Program) Field(typ Type, i int) Type { - tunder := typ.raw.Type.Underlying() - tfld := tunder.(*types.Struct).Field(i).Type() - return p.rawType(tfld) + var fld *types.Var + switch t := typ.raw.Type.(type) { + case *types.Tuple: + fld = t.At(i) + default: + fld = t.Underlying().(*types.Struct).Field(i) + } + return p.rawType(fld.Type()) } func (p Program) rawType(raw types.Type) Type { @@ -218,9 +223,11 @@ func (p Program) tyInt64() llvm.Type { return p.int64Type } +/* func (p Program) toTuple(typ *types.Tuple) Type { return &aType{p.toLLVMTuple(typ), rawType{typ}, vkTuple} } +*/ func (p Program) toType(raw types.Type) Type { typ := rawType{raw} @@ -385,7 +392,7 @@ func (p Program) toNamed(raw *types.Named) Type { switch t := raw.Underlying().(type) { case *types.Struct: name := NameOf(raw) - return &aType{p.toLLVMNamedStruct(name, t), rawType{raw}, vkInvalid} + return &aType{p.toLLVMNamedStruct(name, t), rawType{raw}, vkStruct} default: return p.rawType(t) } From 4986592dd7e68739229dc34be42dba02e37376f1 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Thu, 23 May 2024 01:34:48 +0800 Subject: [PATCH 04/20] TypeAssert refactor --- ssa/expr.go | 2 +- ssa/interface.go | 19 ++++++++----------- ssa/package.go | 4 ++-- ssa/type.go | 6 ++++-- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/ssa/expr.go b/ssa/expr.go index 9b69c4af..2c5c7770 100644 --- a/ssa/expr.go +++ b/ssa/expr.go @@ -425,7 +425,7 @@ func (b Builder) UnOp(op token.Token, x Expr) (ret Expr) { case token.MUL: return b.Load(x) case token.SUB: - switch t := x.Type.raw.Underlying().(type) { + switch t := x.raw.Type.Underlying().(type) { case *types.Basic: ret.Type = x.Type if t.Info()&types.IsInteger != 0 { diff --git a/ssa/interface.go b/ssa/interface.go index 5aebb33e..7b9c49dc 100644 --- a/ssa/interface.go +++ b/ssa/interface.go @@ -41,7 +41,7 @@ func (b Builder) abiStruct(t *types.Struct) Expr { g := pkg.VarOf(name) if g == nil { prog := b.Prog - g := pkg.doNewVar(name, prog.AbiTypePtrPtr()) + g = pkg.doNewVar(name, prog.AbiTypePtrPtr()) g.Init(prog.Null(g.Type)) } pkg.abitys = append(pkg.abitys, func() { @@ -293,16 +293,13 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) Expr { tabi := b.abiType(assertedTyp.raw.Type) eq := b.BinOp(token.EQL, tx, tabi) if commaOk { - /* - prog := b.Prog - t := prog.Tuple(assertedTyp, prog.Bool()) - val := b.valFromData(assertedTyp, b.InterfaceData(x)) - zero := prog.Zero(assertedTyp) - valTrue := aggregateValue(b.impl, t.ll, val.impl, prog.BoolVal(true).impl) - valFalse := aggregateValue(b.impl, t.ll, zero.impl, prog.BoolVal(false).impl) - return Expr{llvm.CreateSelect(b.impl, eq.impl, valTrue, valFalse), t} - */ - panic("todo") + prog := b.Prog + t := prog.Tuple(assertedTyp, prog.Bool()) + val := b.valFromData(assertedTyp, b.InterfaceData(x)) + zero := prog.Zero(assertedTyp) + valTrue := aggregateValue(b.impl, t.ll, val.impl, prog.BoolVal(true).impl) + valFalse := aggregateValue(b.impl, t.ll, zero.impl, prog.BoolVal(false).impl) + return Expr{llvm.CreateSelect(b.impl, eq.impl, valTrue, valFalse), t} } blks := b.Func.MakeBlocks(2) b.If(eq, blks[0], blks[1]) diff --git a/ssa/package.go b/ssa/package.go index f7a967e9..e7a47720 100644 --- a/ssa/package.go +++ b/ssa/package.go @@ -291,13 +291,13 @@ func (p Program) NewPackage(name, pkgPath string) Package { ret := &aPackage{ mod: mod, vars: gbls, fns: fns, stubs: stubs, pyobjs: pyobjs, pymods: pymods, Prog: p} + ret.abi.Init(pkgPath) return ret } // Tuple returns a tuple type. func (p Program) Tuple(typs ...Type) Type { - n := len(typs) - els := make([]*types.Var, n) + els := make([]*types.Var, len(typs)) for i, t := range typs { els[i] = types.NewParam(token.NoPos, nil, "", t.raw.Type) } diff --git a/ssa/type.go b/ssa/type.go index 64314d6c..d8ba01a7 100644 --- a/ssa/type.go +++ b/ssa/type.go @@ -75,7 +75,7 @@ func indexType(t types.Type) types.Type { // ----------------------------------------------------------------------------- type rawType struct { - types.Type + Type types.Type } type aType struct { @@ -285,12 +285,14 @@ func (p Program) toType(raw types.Type) Type { return p.toNamed(t) case *types.Signature: // represents a C function pointer in raw type return &aType{p.toLLVMFuncPtr(t), typ, vkFuncPtr} + case *types.Tuple: + return &aType{p.toLLVMTuple(t), typ, vkTuple} case *types.Array: elem := p.rawType(t.Elem()) return &aType{llvm.ArrayType(elem.ll, int(t.Len())), typ, vkArray} case *types.Chan: } - panic(fmt.Sprintf("toLLVMType: todo - %T\n", typ)) + panic(fmt.Sprintf("toLLVMType: todo - %T\n", raw)) } func (p Program) toLLVMNamedStruct(name string, raw *types.Struct) llvm.Type { From 176c0b2d361b2efcc648a24486128689f750e40f Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 00:36:51 +0800 Subject: [PATCH 05/20] abi.KindOf; llgo/ssa: valFromData --- ssa/abi/abi.go | 53 ++++++++++++++++ ssa/interface.go | 160 +++++++++++++++++++++++++---------------------- 2 files changed, 137 insertions(+), 76 deletions(-) diff --git a/ssa/abi/abi.go b/ssa/abi/abi.go index 3e9fb082..14775932 100644 --- a/ssa/abi/abi.go +++ b/ssa/abi/abi.go @@ -24,6 +24,57 @@ import ( "hash" ) +// ----------------------------------------------------------------------------- + +type Kind int + +const ( + Invalid Kind = iota + Indirect // allocate memory for the value + Pointer // store a pointer value directly in the interface value + Integer // store a integer value directly in the interface value + BitCast // store other value (need bitcast) directly in the interface value +) + +func KindOf(raw types.Type, is32Bits bool) (ret Kind) { + switch t := raw.Underlying().(type) { + case *types.Basic: + kind := t.Kind() + switch { + case types.Bool <= kind && kind <= types.Uintptr: + if is32Bits && (kind == types.Int64 || kind == types.Uint64) { + return Indirect + } + return Integer + case kind == types.Float32: + return BitCast + case kind == types.Float64 || kind == types.Complex64: + if is32Bits { + return Indirect + } + return BitCast + case kind == types.UnsafePointer: + return Pointer + } + case *types.Pointer, *types.Signature, *types.Map, *types.Chan: + return Pointer + case *types.Struct: + if t.NumFields() == 1 { + return KindOf(t.Field(0).Type(), is32Bits) + } + case *types.Interface, *types.Slice: + case *types.Array: + if t.Len() == 1 { + return KindOf(t.Elem(), is32Bits) + } + default: + panic("unkown type") + } + return Indirect +} + +// ----------------------------------------------------------------------------- + // Builder is a helper for constructing ABI types. type Builder struct { h hash.Hash @@ -95,3 +146,5 @@ func (b *Builder) structHash(t *types.Struct) (ret []byte, private bool) { ret = h.Sum(b.buf[:0]) return } + +// ----------------------------------------------------------------------------- diff --git a/ssa/interface.go b/ssa/interface.go index 7b9c49dc..51a7900b 100644 --- a/ssa/interface.go +++ b/ssa/interface.go @@ -178,6 +178,90 @@ func (b Builder) makeIntfByIntptr(tinter Type, rawIntf *types.Interface, typ Typ panic("todo") } +func (b Builder) valFromData(t Type, data Expr) Expr { + kind := abi.KindOf(t.raw.Type, b.Prog.is32Bits) + switch kind { + case abi.Indirect: + impl := b.impl + tll := t.ll + tptr := llvm.PointerType(tll, 0) + ptr := llvm.CreatePointerCast(impl, data.impl, tptr) + return Expr{llvm.CreateLoad(impl, tll, ptr), t} + case abi.Pointer: + return Expr{data.impl, t} + case abi.Integer: + x := castUintptr(b, data.impl, b.Prog.Uintptr()) + return Expr{castInt(b, x, t), t} + case abi.BitCast: + x := castUintptr(b, data.impl, b.Prog.Uintptr()) + return Expr{llvm.CreateBitCast(b.impl, x, t.ll), t} + } + panic("todo") +} + +// The TypeAssert instruction tests whether interface value X has type +// AssertedType. +// +// If !CommaOk, on success it returns v, the result of the conversion +// (defined below); on failure it panics. +// +// If CommaOk: on success it returns a pair (v, true) where v is the +// result of the conversion; on failure it returns (z, false) where z +// is AssertedType's zero value. The components of the pair must be +// accessed using the Extract instruction. +// +// If Underlying: tests whether interface value X has the underlying +// type AssertedType. +// +// If AssertedType is a concrete type, TypeAssert checks whether the +// dynamic type in interface X is equal to it, and if so, the result +// of the conversion is a copy of the value in the interface. +// +// If AssertedType is an interface, TypeAssert checks whether the +// dynamic type of the interface is assignable to it, and if so, the +// result of the conversion is a copy of the interface value X. +// If AssertedType is a superinterface of X.Type(), the operation will +// fail iff the operand is nil. (Contrast with ChangeInterface, which +// performs no nil-check.) +// +// Type() reflects the actual type of the result, possibly a +// 2-types.Tuple; AssertedType is the asserted type. +// +// Depending on the TypeAssert's purpose, Pos may return: +// - the ast.CallExpr.Lparen of an explicit T(e) conversion; +// - the ast.TypeAssertExpr.Lparen of an explicit e.(T) operation; +// - the ast.CaseClause.Case of a case of a type-switch statement; +// - the Ident(m).NamePos of an interface method value i.m +// (for which TypeAssert may be used to effect the nil check). +// +// Example printed form: +// +// t1 = typeassert t0.(int) +// t3 = typeassert,ok t2.(T) +func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) Expr { + if debugInstr { + log.Printf("TypeAssert %v, %v, %v\n", x.impl, assertedTyp.raw.Type, commaOk) + } + tx := b.faceAbiType(x) + tabi := b.abiType(assertedTyp.raw.Type) + eq := b.BinOp(token.EQL, tx, tabi) + if commaOk { + prog := b.Prog + t := prog.Tuple(assertedTyp, prog.Bool()) + val := b.valFromData(assertedTyp, b.InterfaceData(x)) + zero := prog.Zero(assertedTyp) + valTrue := aggregateValue(b.impl, t.ll, val.impl, prog.BoolVal(true).impl) + valFalse := aggregateValue(b.impl, t.ll, zero.impl, prog.BoolVal(false).impl) + return Expr{llvm.CreateSelect(b.impl, eq.impl, valTrue, valFalse), t} + } + blks := b.Func.MakeBlocks(2) + b.If(eq, blks[0], blks[1]) + b.SetBlock(blks[1]) + b.Panic(b.Str("type assertion failed")) + b.SetBlock(blks[0]) + return b.valFromData(assertedTyp, b.InterfaceData(x)) +} + /* func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) (ret Expr) { if debugInstr { @@ -246,82 +330,6 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) (ret Expr) { } */ -// The TypeAssert instruction tests whether interface value X has type -// AssertedType. -// -// If !CommaOk, on success it returns v, the result of the conversion -// (defined below); on failure it panics. -// -// If CommaOk: on success it returns a pair (v, true) where v is the -// result of the conversion; on failure it returns (z, false) where z -// is AssertedType's zero value. The components of the pair must be -// accessed using the Extract instruction. -// -// If Underlying: tests whether interface value X has the underlying -// type AssertedType. -// -// If AssertedType is a concrete type, TypeAssert checks whether the -// dynamic type in interface X is equal to it, and if so, the result -// of the conversion is a copy of the value in the interface. -// -// If AssertedType is an interface, TypeAssert checks whether the -// dynamic type of the interface is assignable to it, and if so, the -// result of the conversion is a copy of the interface value X. -// If AssertedType is a superinterface of X.Type(), the operation will -// fail iff the operand is nil. (Contrast with ChangeInterface, which -// performs no nil-check.) -// -// Type() reflects the actual type of the result, possibly a -// 2-types.Tuple; AssertedType is the asserted type. -// -// Depending on the TypeAssert's purpose, Pos may return: -// - the ast.CallExpr.Lparen of an explicit T(e) conversion; -// - the ast.TypeAssertExpr.Lparen of an explicit e.(T) operation; -// - the ast.CaseClause.Case of a case of a type-switch statement; -// - the Ident(m).NamePos of an interface method value i.m -// (for which TypeAssert may be used to effect the nil check). -// -// Example printed form: -// -// t1 = typeassert t0.(int) -// t3 = typeassert,ok t2.(T) -func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) Expr { - if debugInstr { - log.Printf("TypeAssert %v, %v, %v\n", x.impl, assertedTyp.raw.Type, commaOk) - } - tx := b.faceAbiType(x) - tabi := b.abiType(assertedTyp.raw.Type) - eq := b.BinOp(token.EQL, tx, tabi) - if commaOk { - prog := b.Prog - t := prog.Tuple(assertedTyp, prog.Bool()) - val := b.valFromData(assertedTyp, b.InterfaceData(x)) - zero := prog.Zero(assertedTyp) - valTrue := aggregateValue(b.impl, t.ll, val.impl, prog.BoolVal(true).impl) - valFalse := aggregateValue(b.impl, t.ll, zero.impl, prog.BoolVal(false).impl) - return Expr{llvm.CreateSelect(b.impl, eq.impl, valTrue, valFalse), t} - } - blks := b.Func.MakeBlocks(2) - b.If(eq, blks[0], blks[1]) - b.SetBlock(blks[1]) - b.Panic(b.Str("type assertion failed")) - b.SetBlock(blks[0]) - return b.valFromData(assertedTyp, b.InterfaceData(x)) -} - -func (b Builder) valFromData(t Type, data Expr) Expr { - switch u := t.raw.Type.Underlying().(type) { - case *types.Basic: - kind := u.Kind() - switch { - case kind >= types.Bool && kind <= types.Uintptr: - panic("todo") - } - } - _ = data - panic("todo") -} - // ----------------------------------------------------------------------------- // InterfaceData returns the data pointer of an interface. From 2628ee98f3501c63c3f57a27c319fe5de01577f6 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 01:18:18 +0800 Subject: [PATCH 06/20] llgo/ssa: valFromData, buildVal --- cl/_testgo/strucintf/out.ll | 150 ++++++++++++++++++++++++++++++++++++ ssa/abi/abi.go | 22 +++--- ssa/interface.go | 51 ++++++++---- 3 files changed, 198 insertions(+), 25 deletions(-) diff --git a/cl/_testgo/strucintf/out.ll b/cl/_testgo/strucintf/out.ll index e69de29b..de0f7f58 100644 --- a/cl/_testgo/strucintf/out.ll +++ b/cl/_testgo/strucintf/out.ll @@ -0,0 +1,150 @@ +; ModuleID = 'main' +source_filename = "main" + +%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr } +%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 } + +@"main.init$guard" = global ptr null +@__llgo_argc = global ptr null +@__llgo_argv = global ptr null +@"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk" = global ptr null +@"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88" = global ptr null +@0 = private unnamed_addr constant [12 x i8] c"Bar: not ok\00", align 1 +@1 = private unnamed_addr constant [10 x i8] c"F: not ok\00", align 1 + +define void @main.init() { +_llgo_0: + %0 = load i1, ptr @"main.init$guard", align 1 + br i1 %0, label %_llgo_2, label %_llgo_1 + +_llgo_1: ; preds = %_llgo_0 + store i1 true, ptr @"main.init$guard", align 1 + call void @"github.com/goplus/llgo/_demo/interf/foo.init"() + br label %_llgo_2 + +_llgo_2: ; preds = %_llgo_1, %_llgo_0 + ret void +} + +define i32 @main(i32 %0, ptr %1) { +_llgo_0: + store i32 %0, ptr @__llgo_argc, align 4 + store ptr %1, ptr @__llgo_argv, align 8 + call void @"github.com/goplus/llgo/internal/runtime.init"() + call void @main.init() + %2 = alloca { i64 }, align 8 + %3 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %2, i64 8) + %4 = call %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/_demo/interf/foo.Bar"() + %5 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %4, 0 + %6 = load ptr, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 + %7 = icmp eq ptr %5, %6 + %8 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %4, 1 + %9 = ptrtoint ptr %8 to i64 + %10 = alloca { i64 }, align 8 + %11 = getelementptr inbounds { i64 }, ptr %10, i32 0, i32 0 + store i64 %9, ptr %11, align 4 + %12 = load { i64 }, ptr %10, align 4 + %13 = alloca { { i64 }, i1 }, align 8 + %14 = getelementptr inbounds { { i64 }, i1 }, ptr %13, i32 0, i32 0 + store { i64 } %12, ptr %14, align 4 + %15 = getelementptr inbounds { { i64 }, i1 }, ptr %13, i32 0, i32 1 + store i1 true, ptr %15, align 1 + %16 = load { { i64 }, i1 }, ptr %13, align 4 + %17 = alloca { { i64 }, i1 }, align 8 + %18 = getelementptr inbounds { { i64 }, i1 }, ptr %17, i32 0, i32 0 + store { i64 } zeroinitializer, ptr %18, align 4 + %19 = getelementptr inbounds { { i64 }, i1 }, ptr %17, i32 0, i32 1 + store i1 false, ptr %19, align 1 + %20 = load { { i64 }, i1 }, ptr %17, align 4 + %21 = select i1 %7, { { i64 }, i1 } %16, { { i64 }, i1 } %20 + %22 = extractvalue { { i64 }, i1 } %21, 0 + store { i64 } %22, ptr %3, align 4 + %23 = extractvalue { { i64 }, i1 } %21, 1 + br i1 %23, label %_llgo_1, label %_llgo_3 + +_llgo_1: ; preds = %_llgo_0 + %24 = getelementptr inbounds { i64 }, ptr %3, i32 0, i32 0 + %25 = load i64, ptr %24, align 4 + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %25) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) + br label %_llgo_2 + +_llgo_2: ; preds = %_llgo_3, %_llgo_1 + %26 = alloca { i64 }, align 8 + %27 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %26, i64 8) + %28 = call %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/_demo/interf/foo.F"() + %29 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %28, 0 + %30 = load ptr, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8 + %31 = icmp eq ptr %29, %30 + %32 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %28, 1 + %33 = ptrtoint ptr %32 to i64 + %34 = alloca { i64 }, align 8 + %35 = getelementptr inbounds { i64 }, ptr %34, i32 0, i32 0 + store i64 %33, ptr %35, align 4 + %36 = load { i64 }, ptr %34, align 4 + %37 = alloca { { i64 }, i1 }, align 8 + %38 = getelementptr inbounds { { i64 }, i1 }, ptr %37, i32 0, i32 0 + store { i64 } %36, ptr %38, align 4 + %39 = getelementptr inbounds { { i64 }, i1 }, ptr %37, i32 0, i32 1 + store i1 true, ptr %39, align 1 + %40 = load { { i64 }, i1 }, ptr %37, align 4 + %41 = alloca { { i64 }, i1 }, align 8 + %42 = getelementptr inbounds { { i64 }, i1 }, ptr %41, i32 0, i32 0 + store { i64 } zeroinitializer, ptr %42, align 4 + %43 = getelementptr inbounds { { i64 }, i1 }, ptr %41, i32 0, i32 1 + store i1 false, ptr %43, align 1 + %44 = load { { i64 }, i1 }, ptr %41, align 4 + %45 = select i1 %31, { { i64 }, i1 } %40, { { i64 }, i1 } %44 + %46 = extractvalue { { i64 }, i1 } %45, 0 + store { i64 } %46, ptr %27, align 4 + %47 = extractvalue { { i64 }, i1 } %45, 1 + br i1 %47, label %_llgo_4, label %_llgo_6 + +_llgo_3: ; preds = %_llgo_0 + %48 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %49 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %48, i32 0, i32 0 + store ptr @0, ptr %49, align 8 + %50 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %48, i32 0, i32 1 + store i64 11, ptr %50, align 4 + %51 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %48, align 8 + call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %51) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) + br label %_llgo_2 + +_llgo_4: ; preds = %_llgo_2 + %52 = getelementptr inbounds { i64 }, ptr %27, i32 0, i32 0 + %53 = load i64, ptr %52, align 4 + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %53) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) + br label %_llgo_5 + +_llgo_5: ; preds = %_llgo_6, %_llgo_4 + ret i32 0 + +_llgo_6: ; preds = %_llgo_2 + %54 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %55 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %54, i32 0, i32 0 + store ptr @1, ptr %55, align 8 + %56 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %54, i32 0, i32 1 + store i64 9, ptr %56, align 4 + %57 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %54, align 8 + call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %57) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) + br label %_llgo_5 +} + +declare void @"github.com/goplus/llgo/_demo/interf/foo.init"() + +declare void @"github.com/goplus/llgo/internal/runtime.init"() + +declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64) + +declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/_demo/interf/foo.Bar"() + +declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64) + +declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8) + +declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/_demo/interf/foo.F"() + +declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String") diff --git a/ssa/abi/abi.go b/ssa/abi/abi.go index 14775932..05b09df6 100644 --- a/ssa/abi/abi.go +++ b/ssa/abi/abi.go @@ -36,41 +36,41 @@ const ( BitCast // store other value (need bitcast) directly in the interface value ) -func KindOf(raw types.Type, is32Bits bool) (ret Kind) { +func KindOf(raw types.Type, lvl int, is32Bits bool) (Kind, types.Type, int) { switch t := raw.Underlying().(type) { case *types.Basic: kind := t.Kind() switch { case types.Bool <= kind && kind <= types.Uintptr: if is32Bits && (kind == types.Int64 || kind == types.Uint64) { - return Indirect + return Indirect, raw, lvl } - return Integer + return Integer, raw, lvl case kind == types.Float32: - return BitCast + return BitCast, raw, lvl case kind == types.Float64 || kind == types.Complex64: if is32Bits { - return Indirect + return Indirect, raw, lvl } - return BitCast + return BitCast, raw, lvl case kind == types.UnsafePointer: - return Pointer + return Pointer, raw, lvl } case *types.Pointer, *types.Signature, *types.Map, *types.Chan: - return Pointer + return Pointer, raw, lvl case *types.Struct: if t.NumFields() == 1 { - return KindOf(t.Field(0).Type(), is32Bits) + return KindOf(t.Field(0).Type(), lvl+1, is32Bits) } case *types.Interface, *types.Slice: case *types.Array: if t.Len() == 1 { - return KindOf(t.Elem(), is32Bits) + return KindOf(t.Elem(), lvl+1, is32Bits) } default: panic("unkown type") } - return Indirect + return Indirect, raw, lvl } // ----------------------------------------------------------------------------- diff --git a/ssa/interface.go b/ssa/interface.go index 51a7900b..ea06e88f 100644 --- a/ssa/interface.go +++ b/ssa/interface.go @@ -178,23 +178,43 @@ func (b Builder) makeIntfByIntptr(tinter Type, rawIntf *types.Interface, typ Typ panic("todo") } -func (b Builder) valFromData(t Type, data Expr) Expr { - kind := abi.KindOf(t.raw.Type, b.Prog.is32Bits) +func (b Builder) valFromData(typ Type, data llvm.Value) Expr { + prog := b.Prog + kind, real, lvl := abi.KindOf(typ.raw.Type, 0, prog.is32Bits) switch kind { case abi.Indirect: impl := b.impl - tll := t.ll + tll := typ.ll tptr := llvm.PointerType(tll, 0) - ptr := llvm.CreatePointerCast(impl, data.impl, tptr) - return Expr{llvm.CreateLoad(impl, tll, ptr), t} + ptr := llvm.CreatePointerCast(impl, data, tptr) + return Expr{llvm.CreateLoad(impl, tll, ptr), typ} case abi.Pointer: - return Expr{data.impl, t} + return Expr{data, typ} + } + t := typ + if lvl > 0 { + t = prog.rawType(real) + } + switch kind { case abi.Integer: - x := castUintptr(b, data.impl, b.Prog.Uintptr()) - return Expr{castInt(b, x, t), t} + x := castUintptr(b, data, prog.Uintptr()) + return b.buildVal(typ, castInt(b, x, t), lvl) case abi.BitCast: - x := castUintptr(b, data.impl, b.Prog.Uintptr()) - return Expr{llvm.CreateBitCast(b.impl, x, t.ll), t} + x := castUintptr(b, data, prog.Uintptr()) + return b.buildVal(typ, llvm.CreateBitCast(b.impl, x, t.ll), lvl) + } + panic("todo") +} + +func (b Builder) buildVal(typ Type, val llvm.Value, lvl int) Expr { + if lvl == 0 { + return Expr{val, typ} + } + switch t := typ.raw.Type.Underlying().(type) { + case *types.Struct: + telem := b.Prog.rawType(t.Field(0).Type()) + elem := b.buildVal(telem, val, lvl-1) + return Expr{aggregateValue(b.impl, typ.ll, elem.impl), typ} } panic("todo") } @@ -248,7 +268,7 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) Expr { if commaOk { prog := b.Prog t := prog.Tuple(assertedTyp, prog.Bool()) - val := b.valFromData(assertedTyp, b.InterfaceData(x)) + val := b.valFromData(assertedTyp, b.faceData(x.impl)) zero := prog.Zero(assertedTyp) valTrue := aggregateValue(b.impl, t.ll, val.impl, prog.BoolVal(true).impl) valFalse := aggregateValue(b.impl, t.ll, zero.impl, prog.BoolVal(false).impl) @@ -259,7 +279,7 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) Expr { b.SetBlock(blks[1]) b.Panic(b.Str("type assertion failed")) b.SetBlock(blks[0]) - return b.valFromData(assertedTyp, b.InterfaceData(x)) + return b.valFromData(assertedTyp, b.faceData(x.impl)) } /* @@ -337,8 +357,11 @@ func (b Builder) InterfaceData(x Expr) Expr { if debugInstr { log.Printf("InterfaceData %v\n", x.impl) } - ptr := llvm.CreateExtractValue(b.impl, x.impl, 1) - return Expr{ptr, b.Prog.VoidPtr()} + return Expr{b.faceData(x.impl), b.Prog.VoidPtr()} +} + +func (b Builder) faceData(x llvm.Value) llvm.Value { + return llvm.CreateExtractValue(b.impl, x, 1) } func (b Builder) faceAbiType(x Expr) Expr { From b195656900a6e1b9c54780af6551d9545fa17e70 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 01:45:41 +0800 Subject: [PATCH 07/20] llgo/ssa: MakeInterface --- ssa/interface.go | 90 +++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 55 deletions(-) diff --git a/ssa/interface.go b/ssa/interface.go index ea06e88f..33cf27ec 100644 --- a/ssa/interface.go +++ b/ssa/interface.go @@ -120,62 +120,33 @@ func (b Builder) MakeInterface(tinter Type, x Expr) (ret Expr) { } prog := b.Prog typ := x.Type - switch tx := typ.raw.Type.Underlying().(type) { - case *types.Basic: - kind := tx.Kind() - switch { - case kind >= types.Bool && kind <= types.Uintptr: - if prog.is32Bits && (kind == types.Int64 || kind == types.Uint64) { - return b.makeIntfAlloc(tinter, rawIntf, typ, x) - } - return b.makeIntfByIntptr(tinter, rawIntf, typ, x.impl) - case kind == types.Float32: - i32 := llvm.CreateBitCast(b.impl, x.impl, prog.tyInt32()) - return b.makeIntfByIntptr(tinter, rawIntf, typ, i32) - case kind == types.Float64: - if prog.is32Bits { - return b.makeIntfAlloc(tinter, rawIntf, typ, x) - } - i64 := llvm.CreateBitCast(b.impl, x.impl, prog.tyInt64()) - return b.makeIntfByIntptr(tinter, rawIntf, typ, i64) - case kind == types.String: - return Expr{b.InlineCall(b.Pkg.rtFunc("MakeAnyString"), x).impl, tinter} - } - case *types.Struct: - size := int(prog.SizeOf(typ)) - if size > prog.PointerSize() { - return b.makeIntfAlloc(tinter, rawIntf, typ, x) - } - tv := prog.ctx.IntType(size * 8) - iv := llvm.CreateBitCast(b.impl, x.impl, tv) - return b.makeIntfByIntptr(tinter, rawIntf, typ, iv) - } - panic("todo") -} - -func (b Builder) makeIntfAlloc(tinter Type, rawIntf *types.Interface, typ Type, x Expr) (ret Expr) { - vptr := b.AllocU(typ) - b.Store(vptr, x) - return b.makeIntfByPtr(tinter, rawIntf, typ, vptr) -} - -func (b Builder) makeIntfByPtr(tinter Type, rawIntf *types.Interface, typ Type, vptr Expr) (ret Expr) { - if rawIntf.Empty() { - tabi := b.abiType(typ.raw.Type) + tabi := b.abiType(typ.raw.Type) + kind, _, lvl := abi.KindOf(typ.raw.Type, 0, prog.is32Bits) + switch kind { + case abi.Indirect: + vptr := b.AllocU(typ) + b.Store(vptr, x) return Expr{b.unsafeEface(tabi.impl, vptr.impl), tinter} } - panic("todo") -} - -// TODO(xsw): remove MakeAnyIntptr, MakeAnyString -func (b Builder) makeIntfByIntptr(tinter Type, rawIntf *types.Interface, typ Type, x llvm.Value) (ret Expr) { - if rawIntf.Empty() { - tptr := b.Prog.Uintptr() - x = llvm.CreateIntCast(b.impl, x, tptr.ll) - impl := b.InlineCall(b.Pkg.rtFunc("MakeAnyIntptr"), b.abiType(typ.raw.Type), Expr{x, tptr}).impl - return Expr{impl, tinter} + ximpl := x.impl + if lvl > 0 { + ximpl = extractVal(b.impl, ximpl, lvl) } - panic("todo") + var u llvm.Value + switch kind { + case abi.Pointer: + return Expr{b.unsafeEface(tabi.impl, ximpl), tinter} + case abi.Integer: + tu := prog.Uintptr() + u = llvm.CreateIntCast(b.impl, ximpl, tu.ll) + case abi.BitCast: + tu := prog.Uintptr() + u = llvm.CreateBitCast(b.impl, ximpl, tu.ll) + default: + panic("todo") + } + data := llvm.CreateIntToPtr(b.impl, u, prog.tyVoidPtr()) + return Expr{b.unsafeEface(tabi.impl, data), tinter} } func (b Builder) valFromData(typ Type, data llvm.Value) Expr { @@ -188,14 +159,14 @@ func (b Builder) valFromData(typ Type, data llvm.Value) Expr { tptr := llvm.PointerType(tll, 0) ptr := llvm.CreatePointerCast(impl, data, tptr) return Expr{llvm.CreateLoad(impl, tll, ptr), typ} - case abi.Pointer: - return Expr{data, typ} } t := typ if lvl > 0 { t = prog.rawType(real) } switch kind { + case abi.Pointer: + return b.buildVal(typ, data, lvl) case abi.Integer: x := castUintptr(b, data, prog.Uintptr()) return b.buildVal(typ, castInt(b, x, t), lvl) @@ -206,6 +177,15 @@ func (b Builder) valFromData(typ Type, data llvm.Value) Expr { panic("todo") } +func extractVal(b llvm.Builder, val llvm.Value, lvl int) llvm.Value { + for lvl > 0 { + // TODO(xsw): check array support + val = llvm.CreateExtractValue(b, val, 0) + lvl-- + } + return val +} + func (b Builder) buildVal(typ Type, val llvm.Value, lvl int) Expr { if lvl == 0 { return Expr{val, typ} From b66827998d9d3448add8920b998eb4ac13f986f0 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 02:09:57 +0800 Subject: [PATCH 08/20] llgo/ssa: AfterInit --- cl/_testgo/strucintf/out.ll | 86 ++++++++++++++++++++++++++++++++++++- ssa/interface.go | 15 ++++--- ssa/package.go | 7 ++- 3 files changed, 97 insertions(+), 11 deletions(-) diff --git a/cl/_testgo/strucintf/out.ll b/cl/_testgo/strucintf/out.ll index de0f7f58..2bfabedd 100644 --- a/cl/_testgo/strucintf/out.ll +++ b/cl/_testgo/strucintf/out.ll @@ -3,14 +3,24 @@ 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/abi.StructField" = type { %"github.com/goplus/llgo/internal/abi.Name", ptr, i64 } +%"github.com/goplus/llgo/internal/abi.Name" = type { ptr } +%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 } @"main.init$guard" = global ptr null @__llgo_argc = global ptr null @__llgo_argv = global ptr null -@"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk" = global ptr null -@"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88" = global ptr null +@"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk" = linkonce global ptr null +@"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88" = linkonce global ptr null @0 = private unnamed_addr constant [12 x i8] c"Bar: not ok\00", align 1 @1 = private unnamed_addr constant [10 x i8] c"F: not ok\00", align 1 +@2 = private unnamed_addr constant [2 x i8] c"V\00", align 1 +@_llgo_int = external global ptr +@3 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@4 = private unnamed_addr constant [5 x i8] c"main\00", align 1 +@5 = private unnamed_addr constant [2 x i8] c"v\00", align 1 +@6 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@7 = private unnamed_addr constant [5 x i8] c"main\00", align 1 define void @main.init() { _llgo_0: @@ -131,6 +141,72 @@ _llgo_6: ; preds = %_llgo_2 call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %57) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) br label %_llgo_5 + %58 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %59 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %58, i32 0, i32 0 + store ptr @2, ptr %59, align 8 + %60 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %58, i32 0, i32 1 + store i64 1, ptr %60, align 4 + %61 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %58, align 8 + %62 = load ptr, ptr @_llgo_int, align 8 + %63 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %64 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %63, i32 0, i32 0 + store ptr @3, ptr %64, align 8 + %65 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %63, i32 0, i32 1 + store i64 0, ptr %65, align 4 + %66 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %63, align 8 + %67 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %61, ptr %62, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %66, i1 true, i1 false) + %68 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %69 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %68, i32 0, i32 0 + store ptr @4, ptr %69, align 8 + %70 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %68, i32 0, i32 1 + store i64 4, ptr %70, align 4 + %71 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %68, align 8 + %72 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24) + %73 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %72, i64 0 + store %"github.com/goplus/llgo/internal/abi.StructField" %67, ptr %73, align 8 + %74 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %75 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %74, i32 0, i32 0 + store ptr %72, ptr %75, align 8 + %76 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %74, i32 0, i32 1 + store i64 1, ptr %76, align 4 + %77 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %74, i32 0, i32 2 + store i64 1, ptr %77, align 4 + %78 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %74, align 8 + %79 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %71, %"github.com/goplus/llgo/internal/runtime.Slice" %78) + store ptr %79, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 + %80 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %81 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %80, i32 0, i32 0 + store ptr @5, ptr %81, align 8 + %82 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %80, i32 0, i32 1 + store i64 1, ptr %82, align 4 + %83 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %80, align 8 + %84 = load ptr, ptr @_llgo_int, align 8 + %85 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %86 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %85, i32 0, i32 0 + store ptr @6, ptr %86, align 8 + %87 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %85, i32 0, i32 1 + store i64 0, ptr %87, align 4 + %88 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %85, align 8 + %89 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %83, ptr %84, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %88, i1 false, i1 false) + %90 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %91 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %90, i32 0, i32 0 + store ptr @7, ptr %91, align 8 + %92 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %90, i32 0, i32 1 + store i64 4, ptr %92, align 4 + %93 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %90, align 8 + %94 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24) + %95 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %94, i64 0 + store %"github.com/goplus/llgo/internal/abi.StructField" %89, ptr %95, align 8 + %96 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %97 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %96, i32 0, i32 0 + store ptr %94, ptr %97, align 8 + %98 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %96, i32 0, i32 1 + store i64 1, ptr %98, align 4 + %99 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %96, i32 0, i32 2 + store i64 1, ptr %99, align 4 + %100 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %96, align 8 + %101 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %93, %"github.com/goplus/llgo/internal/runtime.Slice" %100) + store ptr %101, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8 } declare void @"github.com/goplus/llgo/_demo/interf/foo.init"() @@ -148,3 +224,9 @@ declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8) declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/_demo/interf/foo.F"() declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String") + +declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(i64, %"github.com/goplus/llgo/internal/runtime.String", %"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, i1) + +declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) diff --git a/ssa/interface.go b/ssa/interface.go index 33cf27ec..374ce102 100644 --- a/ssa/interface.go +++ b/ssa/interface.go @@ -43,11 +43,12 @@ func (b Builder) abiStruct(t *types.Struct) Expr { prog := b.Prog g = pkg.doNewVar(name, prog.AbiTypePtrPtr()) g.Init(prog.Null(g.Type)) + g.impl.SetLinkage(llvm.LinkOnceAnyLinkage) + pkg.ainits = append(pkg.ainits, func() { + tabi := b.structOf(t) + b.Store(g.Expr, tabi) + }) } - pkg.abitys = append(pkg.abitys, func() { - tabi := b.structOf(t) - b.Store(g.Expr, tabi) - }) return b.Load(g.Expr) } @@ -65,7 +66,7 @@ func (b Builder) structOf(t *types.Struct) Expr { off := uintptr(prog.OffsetOf(typ, i)) flds[i] = b.structField(sfAbi, prog, f, off, t.Tag(i)) } - pkgPath := prog.Val(pkg.abi.Pkg) + pkgPath := b.Str(pkg.abi.Pkg) params := strucAbi.raw.Type.(*types.Signature).Params() tSlice := prog.rawType(params.At(params.Len() - 1).Type().(*types.Slice)) fldSlice := b.SliceLit(tSlice, flds...) @@ -74,11 +75,11 @@ func (b Builder) structOf(t *types.Struct) Expr { // func StructField(name string, typ *abi.Type, off uintptr, tag string, exported, embedded bool) abi.StructField func (b Builder) structField(sfAbi Expr, prog Program, f *types.Var, offset uintptr, tag string) Expr { - name := prog.Val(f.Name()) + name := b.Str(f.Name()) typ := b.abiType(f.Type()) exported := prog.Val(f.Exported()) embedded := prog.Val(f.Embedded()) - return b.Call(sfAbi, name, typ, prog.Val(offset), prog.Val(tag), exported, embedded) + return b.Call(sfAbi, name, typ, prog.Val(offset), b.Str(tag), exported, embedded) } // abiType returns the abi type of the specified type. diff --git a/ssa/package.go b/ssa/package.go index e7a47720..905fa966 100644 --- a/ssa/package.go +++ b/ssa/package.go @@ -490,7 +490,7 @@ func (p Program) Uint64() Type { type aPackage struct { mod llvm.Module abi abi.Builder - abitys []func() + ainits []func() vars map[string]Global fns map[string]Function stubs map[string]Function @@ -555,9 +555,12 @@ func (p Package) String() string { // AfterInit is called after the package is initialized (init all packages that depends on). func (p Package) AfterInit(b Builder, ret BasicBlock) { - doAfterInit := p.pyHasModSyms() + doAfterInit := len(p.ainits) > 0 || p.pyHasModSyms() if doAfterInit { b.SetBlockEx(ret, afterInit) + for _, afterInit := range p.ainits { + afterInit() + } p.pyLoadModSyms(b) } } From 418c37dd52d7ffb6402e6346be4412b539dd234d Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 02:42:10 +0800 Subject: [PATCH 09/20] AfterInit bugfix: add param Builder --- cl/_testgo/strucintf/out.ll | 1 + ssa/decl.go | 7 +++++++ ssa/interface.go | 4 +++- ssa/package.go | 7 ++++--- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cl/_testgo/strucintf/out.ll b/cl/_testgo/strucintf/out.ll index 2bfabedd..b8dd18f3 100644 --- a/cl/_testgo/strucintf/out.ll +++ b/cl/_testgo/strucintf/out.ll @@ -110,6 +110,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1 %47 = extractvalue { { i64 }, i1 } %45, 1 br i1 %47, label %_llgo_4, label %_llgo_6 + _llgo_3: ; preds = %_llgo_0 %48 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %49 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %48, i32 0, i32 0 diff --git a/ssa/decl.go b/ssa/decl.go index f859563f..2243e975 100644 --- a/ssa/decl.go +++ b/ssa/decl.go @@ -238,6 +238,13 @@ func newParams(fn Type, prog Program) (params []Type, hasVArg bool) { return } +/* +// Name returns the function's name. +func (p Function) Name() string { + return p.impl.Name() +} +*/ + // Params returns the function's ith parameter. func (p Function) Param(i int) Expr { i += p.base // skip if hasFreeVars diff --git a/ssa/interface.go b/ssa/interface.go index 374ce102..14ffe0fa 100644 --- a/ssa/interface.go +++ b/ssa/interface.go @@ -20,6 +20,7 @@ import ( "go/token" "go/types" "log" + "unsafe" "github.com/goplus/llgo/ssa/abi" "github.com/goplus/llvm" @@ -44,7 +45,8 @@ func (b Builder) abiStruct(t *types.Struct) Expr { g = pkg.doNewVar(name, prog.AbiTypePtrPtr()) g.Init(prog.Null(g.Type)) g.impl.SetLinkage(llvm.LinkOnceAnyLinkage) - pkg.ainits = append(pkg.ainits, func() { + pkg.ainits = append(pkg.ainits, func(param unsafe.Pointer) { + b := Builder(param) tabi := b.structOf(t) b.Store(g.Expr, tabi) }) diff --git a/ssa/package.go b/ssa/package.go index 905fa966..03d0ff26 100644 --- a/ssa/package.go +++ b/ssa/package.go @@ -19,6 +19,7 @@ package ssa import ( "go/token" "go/types" + "unsafe" "github.com/goplus/llgo/ssa/abi" "github.com/goplus/llvm" @@ -490,7 +491,7 @@ func (p Program) Uint64() Type { type aPackage struct { mod llvm.Module abi abi.Builder - ainits []func() + ainits []func(b unsafe.Pointer) // b Builder vars map[string]Global fns map[string]Function stubs map[string]Function @@ -558,8 +559,8 @@ func (p Package) AfterInit(b Builder, ret BasicBlock) { doAfterInit := len(p.ainits) > 0 || p.pyHasModSyms() if doAfterInit { b.SetBlockEx(ret, afterInit) - for _, afterInit := range p.ainits { - afterInit() + for _, fnAfterInit := range p.ainits { + fnAfterInit(unsafe.Pointer(b)) } p.pyLoadModSyms(b) } From 1162a5f916780b80b0f985bd6b2b473e5fd5bf17 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 03:22:10 +0800 Subject: [PATCH 10/20] AfterInit: init --- cl/_testgo/strucintf/in.go | 9 +- cl/_testgo/strucintf/out.ll | 260 ++++++++++++++++++------------------ cl/compile_test.go | 2 +- ssa/interface.go | 33 ++++- ssa/package.go | 22 ++- 5 files changed, 176 insertions(+), 150 deletions(-) diff --git a/cl/_testgo/strucintf/in.go b/cl/_testgo/strucintf/in.go index ad3d0140..c2822448 100644 --- a/cl/_testgo/strucintf/in.go +++ b/cl/_testgo/strucintf/in.go @@ -2,17 +2,18 @@ package main import ( "github.com/goplus/llgo/_demo/interf/foo" + "github.com/goplus/llgo/c" ) func main() { if x, ok := foo.Bar().(struct{ V int }); ok { - println(x.V) + c.Printf(c.Str("%d\n"), x.V) } else { - println("Bar: not ok") + c.Printf(c.Str("Bar: not ok\n")) } if x, ok := foo.F().(struct{ v int }); ok { - println(x.v) + c.Printf(c.Str("%d\n"), x.v) } else { - println("F: not ok") + c.Printf(c.Str("F: not ok\n")) } } diff --git a/cl/_testgo/strucintf/out.ll b/cl/_testgo/strucintf/out.ll index b8dd18f3..c042d4ac 100644 --- a/cl/_testgo/strucintf/out.ll +++ b/cl/_testgo/strucintf/out.ll @@ -11,16 +11,17 @@ source_filename = "main" @__llgo_argc = global ptr null @__llgo_argv = global ptr null @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk" = linkonce global ptr null -@"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88" = linkonce global ptr null -@0 = private unnamed_addr constant [12 x i8] c"Bar: not ok\00", align 1 -@1 = private unnamed_addr constant [10 x i8] c"F: not ok\00", align 1 -@2 = private unnamed_addr constant [2 x i8] c"V\00", align 1 -@_llgo_int = external global ptr -@3 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 -@4 = private unnamed_addr constant [5 x i8] c"main\00", align 1 -@5 = private unnamed_addr constant [2 x i8] c"v\00", align 1 -@6 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 -@7 = private unnamed_addr constant [5 x i8] c"main\00", align 1 +@0 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 +@"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88" = global ptr null +@1 = private unnamed_addr constant [13 x i8] c"Bar: not ok\0A\00", align 1 +@2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 +@3 = private unnamed_addr constant [11 x i8] c"F: not ok\0A\00", align 1 +@4 = private unnamed_addr constant [2 x i8] c"V\00", align 1 +@5 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@6 = private unnamed_addr constant [5 x i8] c"main\00", align 1 +@7 = private unnamed_addr constant [2 x i8] c"v\00", align 1 +@8 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@9 = private unnamed_addr constant [5 x i8] c"main\00", align 1 define void @main.init() { _llgo_0: @@ -30,6 +31,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 call void @"github.com/goplus/llgo/_demo/interf/foo.init"() + call void @"main.init$abi"() br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 @@ -75,139 +77,56 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 %24 = getelementptr inbounds { i64 }, ptr %3, i32 0, i32 0 %25 = load i64, ptr %24, align 4 - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %25) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) + %26 = call i32 (ptr, ...) @printf(ptr @0, i64 %25) br label %_llgo_2 _llgo_2: ; preds = %_llgo_3, %_llgo_1 - %26 = alloca { i64 }, align 8 - %27 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %26, i64 8) - %28 = call %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/_demo/interf/foo.F"() - %29 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %28, 0 - %30 = load ptr, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8 - %31 = icmp eq ptr %29, %30 - %32 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %28, 1 - %33 = ptrtoint ptr %32 to i64 - %34 = alloca { i64 }, align 8 - %35 = getelementptr inbounds { i64 }, ptr %34, i32 0, i32 0 - store i64 %33, ptr %35, align 4 - %36 = load { i64 }, ptr %34, align 4 - %37 = alloca { { i64 }, i1 }, align 8 - %38 = getelementptr inbounds { { i64 }, i1 }, ptr %37, i32 0, i32 0 - store { i64 } %36, ptr %38, align 4 - %39 = getelementptr inbounds { { i64 }, i1 }, ptr %37, i32 0, i32 1 - store i1 true, ptr %39, align 1 - %40 = load { { i64 }, i1 }, ptr %37, align 4 - %41 = alloca { { i64 }, i1 }, align 8 - %42 = getelementptr inbounds { { i64 }, i1 }, ptr %41, i32 0, i32 0 - store { i64 } zeroinitializer, ptr %42, align 4 - %43 = getelementptr inbounds { { i64 }, i1 }, ptr %41, i32 0, i32 1 - store i1 false, ptr %43, align 1 - %44 = load { { i64 }, i1 }, ptr %41, align 4 - %45 = select i1 %31, { { i64 }, i1 } %40, { { i64 }, i1 } %44 - %46 = extractvalue { { i64 }, i1 } %45, 0 - store { i64 } %46, ptr %27, align 4 - %47 = extractvalue { { i64 }, i1 } %45, 1 - br i1 %47, label %_llgo_4, label %_llgo_6 - + %27 = alloca { i64 }, align 8 + %28 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %27, i64 8) + %29 = call %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/_demo/interf/foo.F"() + %30 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %29, 0 + %31 = load ptr, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8 + %32 = icmp eq ptr %30, %31 + %33 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %29, 1 + %34 = ptrtoint ptr %33 to i64 + %35 = alloca { i64 }, align 8 + %36 = getelementptr inbounds { i64 }, ptr %35, i32 0, i32 0 + store i64 %34, ptr %36, align 4 + %37 = load { i64 }, ptr %35, align 4 + %38 = alloca { { i64 }, i1 }, align 8 + %39 = getelementptr inbounds { { i64 }, i1 }, ptr %38, i32 0, i32 0 + store { i64 } %37, ptr %39, align 4 + %40 = getelementptr inbounds { { i64 }, i1 }, ptr %38, i32 0, i32 1 + store i1 true, ptr %40, align 1 + %41 = load { { i64 }, i1 }, ptr %38, align 4 + %42 = alloca { { i64 }, i1 }, align 8 + %43 = getelementptr inbounds { { i64 }, i1 }, ptr %42, i32 0, i32 0 + store { i64 } zeroinitializer, ptr %43, align 4 + %44 = getelementptr inbounds { { i64 }, i1 }, ptr %42, i32 0, i32 1 + store i1 false, ptr %44, align 1 + %45 = load { { i64 }, i1 }, ptr %42, align 4 + %46 = select i1 %32, { { i64 }, i1 } %41, { { i64 }, i1 } %45 + %47 = extractvalue { { i64 }, i1 } %46, 0 + store { i64 } %47, ptr %28, align 4 + %48 = extractvalue { { i64 }, i1 } %46, 1 + br i1 %48, label %_llgo_4, label %_llgo_6 _llgo_3: ; preds = %_llgo_0 - %48 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %49 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %48, i32 0, i32 0 - store ptr @0, ptr %49, align 8 - %50 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %48, i32 0, i32 1 - store i64 11, ptr %50, align 4 - %51 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %48, align 8 - call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %51) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) + %49 = call i32 (ptr, ...) @printf(ptr @1) br label %_llgo_2 _llgo_4: ; preds = %_llgo_2 - %52 = getelementptr inbounds { i64 }, ptr %27, i32 0, i32 0 - %53 = load i64, ptr %52, align 4 - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %53) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) + %50 = getelementptr inbounds { i64 }, ptr %28, i32 0, i32 0 + %51 = load i64, ptr %50, align 4 + %52 = call i32 (ptr, ...) @printf(ptr @2, i64 %51) br label %_llgo_5 _llgo_5: ; preds = %_llgo_6, %_llgo_4 ret i32 0 _llgo_6: ; preds = %_llgo_2 - %54 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %55 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %54, i32 0, i32 0 - store ptr @1, ptr %55, align 8 - %56 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %54, i32 0, i32 1 - store i64 9, ptr %56, align 4 - %57 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %54, align 8 - call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %57) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) + %53 = call i32 (ptr, ...) @printf(ptr @3) br label %_llgo_5 - %58 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %59 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %58, i32 0, i32 0 - store ptr @2, ptr %59, align 8 - %60 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %58, i32 0, i32 1 - store i64 1, ptr %60, align 4 - %61 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %58, align 8 - %62 = load ptr, ptr @_llgo_int, align 8 - %63 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %64 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %63, i32 0, i32 0 - store ptr @3, ptr %64, align 8 - %65 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %63, i32 0, i32 1 - store i64 0, ptr %65, align 4 - %66 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %63, align 8 - %67 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %61, ptr %62, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %66, i1 true, i1 false) - %68 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %69 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %68, i32 0, i32 0 - store ptr @4, ptr %69, align 8 - %70 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %68, i32 0, i32 1 - store i64 4, ptr %70, align 4 - %71 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %68, align 8 - %72 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24) - %73 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %72, i64 0 - store %"github.com/goplus/llgo/internal/abi.StructField" %67, ptr %73, align 8 - %74 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %75 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %74, i32 0, i32 0 - store ptr %72, ptr %75, align 8 - %76 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %74, i32 0, i32 1 - store i64 1, ptr %76, align 4 - %77 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %74, i32 0, i32 2 - store i64 1, ptr %77, align 4 - %78 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %74, align 8 - %79 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %71, %"github.com/goplus/llgo/internal/runtime.Slice" %78) - store ptr %79, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 - %80 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %81 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %80, i32 0, i32 0 - store ptr @5, ptr %81, align 8 - %82 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %80, i32 0, i32 1 - store i64 1, ptr %82, align 4 - %83 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %80, align 8 - %84 = load ptr, ptr @_llgo_int, align 8 - %85 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %86 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %85, i32 0, i32 0 - store ptr @6, ptr %86, align 8 - %87 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %85, i32 0, i32 1 - store i64 0, ptr %87, align 4 - %88 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %85, align 8 - %89 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %83, ptr %84, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %88, i1 false, i1 false) - %90 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %91 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %90, i32 0, i32 0 - store ptr @7, ptr %91, align 8 - %92 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %90, i32 0, i32 1 - store i64 4, ptr %92, align 4 - %93 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %90, align 8 - %94 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24) - %95 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %94, i64 0 - store %"github.com/goplus/llgo/internal/abi.StructField" %89, ptr %95, align 8 - %96 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %97 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %96, i32 0, i32 0 - store ptr %94, ptr %97, align 8 - %98 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %96, i32 0, i32 1 - store i64 1, ptr %98, align 4 - %99 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %96, i32 0, i32 2 - store i64 1, ptr %99, align 4 - %100 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %96, align 8 - %101 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %93, %"github.com/goplus/llgo/internal/runtime.Slice" %100) - store ptr %101, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8 } declare void @"github.com/goplus/llgo/_demo/interf/foo.init"() @@ -218,16 +137,93 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64) declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/_demo/interf/foo.Bar"() -declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64) - -declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8) +declare i32 @printf(ptr, ...) declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/_demo/interf/foo.F"() -declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String") +define void @"main.init$abi"() { +_llgo_0: + %0 = load ptr, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 + %1 = icmp eq ptr %0, null + br i1 %1, label %_llgo_1, label %_llgo_2 + +_llgo_1: ; preds = %_llgo_0 + %2 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i32 0, i32 0 + store ptr @4, ptr %3, align 8 + %4 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i32 0, i32 1 + store i64 1, ptr %4, align 4 + %5 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %2, align 8 + %6 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %7 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %8 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %7, i32 0, i32 0 + store ptr @5, ptr %8, align 8 + %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %7, i32 0, i32 1 + store i64 0, ptr %9, align 4 + %10 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %7, align 8 + %11 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %5, ptr %6, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %10, i1 true, i1 false) + %12 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %13 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %12, i32 0, i32 0 + store ptr @6, ptr %13, align 8 + %14 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %12, i32 0, i32 1 + store i64 4, ptr %14, align 4 + %15 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %12, align 8 + %16 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24) + %17 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %16, i64 0 + store %"github.com/goplus/llgo/internal/abi.StructField" %11, ptr %17, align 8 + %18 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %18, i32 0, i32 0 + store ptr %16, ptr %19, align 8 + %20 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %18, i32 0, i32 1 + store i64 1, ptr %20, align 4 + %21 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %18, i32 0, i32 2 + store i64 1, ptr %21, align 4 + %22 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %18, align 8 + %23 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %15, %"github.com/goplus/llgo/internal/runtime.Slice" %22) + store ptr %23, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 + br label %_llgo_2 + +_llgo_2: ; preds = %_llgo_1, %_llgo_0 + %24 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %25 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %24, i32 0, i32 0 + store ptr @7, ptr %25, align 8 + %26 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %24, i32 0, i32 1 + store i64 1, ptr %26, align 4 + %27 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %24, align 8 + %28 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %29 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %30 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %29, i32 0, i32 0 + store ptr @8, ptr %30, align 8 + %31 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %29, i32 0, i32 1 + store i64 0, ptr %31, align 4 + %32 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %29, align 8 + %33 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %27, ptr %28, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %32, i1 false, i1 false) + %34 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %35 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %34, i32 0, i32 0 + store ptr @9, ptr %35, align 8 + %36 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %34, i32 0, i32 1 + store i64 4, ptr %36, align 4 + %37 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %34, align 8 + %38 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24) + %39 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %38, i64 0 + store %"github.com/goplus/llgo/internal/abi.StructField" %33, ptr %39, align 8 + %40 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %41 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, i32 0, i32 0 + store ptr %38, ptr %41, align 8 + %42 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, i32 0, i32 1 + store i64 1, ptr %42, align 4 + %43 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, i32 0, i32 2 + store i64 1, ptr %43, align 4 + %44 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, align 8 + %45 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %37, %"github.com/goplus/llgo/internal/runtime.Slice" %44) + store ptr %45, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8 + ret void +} declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(i64, %"github.com/goplus/llgo/internal/runtime.String", %"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, i1) +declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) + declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) diff --git a/cl/compile_test.go b/cl/compile_test.go index 213da252..48639cf5 100644 --- a/cl/compile_test.go +++ b/cl/compile_test.go @@ -29,7 +29,7 @@ func testCompile(t *testing.T, src, expected string) { } func TestFromTestgo(t *testing.T) { - cltest.FromDir(t, "strucintf", "./_testgo", false) + cltest.FromDir(t, "", "./_testgo", false) } func TestFromTestpy(t *testing.T) { diff --git a/ssa/interface.go b/ssa/interface.go index 14ffe0fa..75958cbb 100644 --- a/ssa/interface.go +++ b/ssa/interface.go @@ -30,25 +30,44 @@ import ( // abiBasic returns the abi type of the specified basic kind. func (b Builder) abiBasic(t *types.Basic) Expr { - name := abi.BasicName(t) - g := b.Pkg.NewVarFrom(name, b.Prog.AbiTypePtrPtr()) - return b.Load(g.Expr) + /* + TODO(xsw): + name := abi.BasicName(t) + g := b.Pkg.NewVarFrom(name, b.Prog.AbiTypePtrPtr()) + return b.Load(g.Expr) + */ + return b.InlineCall(b.Pkg.rtFunc("Basic"), b.Prog.Val(int(t.Kind()))) } // abiStruct returns the abi type of the specified struct type. func (b Builder) abiStruct(t *types.Struct) Expr { pkg := b.Pkg - name, _ := pkg.abi.StructName(t) + name, private := pkg.abi.StructName(t) g := pkg.VarOf(name) if g == nil { prog := b.Prog g = pkg.doNewVar(name, prog.AbiTypePtrPtr()) g.Init(prog.Null(g.Type)) - g.impl.SetLinkage(llvm.LinkOnceAnyLinkage) - pkg.ainits = append(pkg.ainits, func(param unsafe.Pointer) { + pub := !private + if pub { + g.impl.SetLinkage(llvm.LinkOnceAnyLinkage) + } + pkg.abiini = append(pkg.abiini, func(param unsafe.Pointer) { b := Builder(param) + expr := g.Expr + var blks []BasicBlock + if pub { + eq := b.BinOp(token.EQL, b.Load(expr), b.Prog.Null(expr.Type)) + blks = b.Func.MakeBlocks(2) + b.If(eq, blks[0], blks[1]) + b.SetBlock(blks[0]) + } tabi := b.structOf(t) - b.Store(g.Expr, tabi) + b.Store(expr, tabi) + if pub { + b.Jump(blks[1]) + b.SetBlock(blks[1]) + } }) } return b.Load(g.Expr) diff --git a/ssa/package.go b/ssa/package.go index 03d0ff26..25900f92 100644 --- a/ssa/package.go +++ b/ssa/package.go @@ -491,7 +491,7 @@ func (p Program) Uint64() Type { type aPackage struct { mod llvm.Module abi abi.Builder - ainits []func(b unsafe.Pointer) // b Builder + abiini []func(b unsafe.Pointer) // b Builder vars map[string]Global fns map[string]Function stubs map[string]Function @@ -556,13 +556,23 @@ func (p Package) String() string { // AfterInit is called after the package is initialized (init all packages that depends on). func (p Package) AfterInit(b Builder, ret BasicBlock) { - doAfterInit := len(p.ainits) > 0 || p.pyHasModSyms() - if doAfterInit { + doAbiInit := len(p.abiini) > 0 + doPyLoadModSyms := p.pyHasModSyms() + if doAbiInit || doPyLoadModSyms { b.SetBlockEx(ret, afterInit) - for _, fnAfterInit := range p.ainits { - fnAfterInit(unsafe.Pointer(b)) + if doAbiInit { + sigAbiInit := types.NewSignatureType(nil, nil, nil, nil, nil, false) + fn := p.NewFunc(p.abi.Pkg+".init$abi", sigAbiInit, InC) + fnb := fn.MakeBody(1) + for _, abiInit := range p.abiini { + abiInit(unsafe.Pointer(fnb)) + } + fnb.Return() + b.Call(fn.Expr) + } + if doPyLoadModSyms { + p.pyLoadModSyms(b) } - p.pyLoadModSyms(b) } } From 88004cac7620c977e762a279d62bdfc93a7bb084 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 07:51:41 +0800 Subject: [PATCH 11/20] abiBasic fix --- cl/_testdata/print/out.ll | 821 +++++++++++++++++------- cl/_testdata/vargs/out.ll | 77 ++- cl/_testrt/{gotypes => _gotypes}/in.go | 0 cl/_testrt/{gotypes => _gotypes}/out.ll | 0 cl/_testrt/any/out.ll | 49 +- cl/_testrt/builtin/out.ll | 137 ++-- cl/_testrt/cast/out.ll | 182 ++++-- cl/_testrt/panic/out.ll | 20 +- internal/abi/llgo_autogen.lla | Bin 5187 -> 5351 bytes internal/runtime/llgo_autogen.lla | Bin 5811 -> 5744 bytes ssa/abi/abi.go | 15 + ssa/interface.go | 3 +- 12 files changed, 924 insertions(+), 380 deletions(-) rename cl/_testrt/{gotypes => _gotypes}/in.go (100%) rename cl/_testrt/{gotypes => _gotypes}/out.ll (100%) diff --git a/cl/_testdata/print/out.ll b/cl/_testdata/print/out.ll index 0e4003b5..3288ef27 100644 --- a/cl/_testdata/print/out.ll +++ b/cl/_testdata/print/out.ll @@ -5,7 +5,7 @@ source_filename = "main" %"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 } %main.stringStruct = type { ptr, i64 } %main.slice = type { ptr, i64, i64 } -%"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr } +%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr } @"main.init$guard" = global ptr null @main.minhexdigits = global ptr null @@ -104,127 +104,251 @@ _llgo_0: call void @main.prinfsub(double 1.001000e+02) call void @main.printnl() %6 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13) - %7 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %6, i64 1315859240) - call void @main.printany(%"github.com/goplus/llgo/internal/runtime.iface" %7) + %7 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %8 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %7, i32 0, i32 0 + store ptr %6, ptr %8, align 8 + %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %7, i32 0, i32 1 + store ptr inttoptr (i32 1315859240 to ptr), ptr %9, align 8 + %10 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %7, align 8 + call void @main.printany(%"github.com/goplus/llgo/internal/runtime.eface" %10) call void @main.printnl() - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) - %9 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %8, i64 4746175415993761792) - call void @main.printany(%"github.com/goplus/llgo/internal/runtime.iface" %9) + %11 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) + %12 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %13 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %12, i32 0, i32 0 + store ptr %11, ptr %13, align 8 + %14 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %12, i32 0, i32 1 + store ptr inttoptr (i64 4746175415993761792 to ptr), ptr %14, align 8 + %15 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %12, align 8 + call void @main.printany(%"github.com/goplus/llgo/internal/runtime.eface" %15) call void @main.printnl() br i1 true, label %_llgo_3, label %_llgo_2 _llgo_1: ; preds = %_llgo_3 - %10 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32) - %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %10, i64 0 - %12 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %13 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %12, i32 0, i32 0 - store ptr @2, ptr %13, align 8 - %14 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %12, i32 0, i32 1 - store i64 10, ptr %14, align 4 - %15 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %12, align 8 - %16 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %15) - store %"github.com/goplus/llgo/internal/runtime.iface" %16, ptr %11, align 8 - %17 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %10, i64 1 - %18 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) - %19 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %18, i64 -1) - store %"github.com/goplus/llgo/internal/runtime.iface" %19, ptr %17, align 8 - %20 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %10, i64 16, i64 2, i64 0, i64 2, i64 2) - call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %20) + %16 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32) + %17 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %16, i64 0 + %18 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %18, i32 0, i32 0 + store ptr @2, ptr %19, align 8 + %20 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %18, i32 0, i32 1 + store i64 10, ptr %20, align 4 + %21 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %18, align 8 + %22 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %23 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %21, ptr %23, align 8 + %24 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %25 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %24, i32 0, i32 0 + store ptr %22, ptr %25, align 8 + %26 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %24, i32 0, i32 1 + store ptr %23, ptr %26, align 8 + %27 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %24, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %27, ptr %17, align 8 + %28 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %16, i64 1 + %29 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %30 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %31 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %30, i32 0, i32 0 + store ptr %29, ptr %31, align 8 + %32 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %30, i32 0, i32 1 + store ptr inttoptr (i64 -1 to ptr), ptr %32, align 8 + %33 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %30, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %33, ptr %28, align 8 + %34 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %16, i64 16, i64 2, i64 0, i64 2, i64 2) + call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %34) br label %_llgo_2 _llgo_2: ; preds = %_llgo_3, %_llgo_1, %_llgo_0 - %21 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 48) - %22 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %21, i64 0 - %23 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %24 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %23, i32 0, i32 0 - store ptr @3, ptr %24, align 8 - %25 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %23, i32 0, i32 1 - store i64 8, ptr %25, align 4 - %26 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %23, align 8 - %27 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %26) - store %"github.com/goplus/llgo/internal/runtime.iface" %27, ptr %22, align 8 - %28 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %21, i64 1 - %29 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) - %30 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %29, i64 -1) - store %"github.com/goplus/llgo/internal/runtime.iface" %30, ptr %28, align 8 - %31 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %21, i64 2 - %32 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) - %33 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %32, i64 -1) - store %"github.com/goplus/llgo/internal/runtime.iface" %33, ptr %31, align 8 - %34 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %21, i64 16, i64 3, i64 0, i64 3, i64 3) - call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %34) - %35 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 256) - %36 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 0 - %37 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) - %38 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %37, i64 -1) - store %"github.com/goplus/llgo/internal/runtime.iface" %38, ptr %36, align 8 - %39 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 1 - %40 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) - %41 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %40, i64 0) - store %"github.com/goplus/llgo/internal/runtime.iface" %41, ptr %39, align 8 - %42 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 2 - %43 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) - %44 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %43, i64 97) - store %"github.com/goplus/llgo/internal/runtime.iface" %44, ptr %42, align 8 - %45 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 3 - %46 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) - %47 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %46, i64 65) - store %"github.com/goplus/llgo/internal/runtime.iface" %47, ptr %45, align 8 - %48 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 4 - %49 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) - %50 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %49, i64 20013) - store %"github.com/goplus/llgo/internal/runtime.iface" %50, ptr %48, align 8 - %51 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 5 - %52 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3) - %53 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %52, i64 1) - store %"github.com/goplus/llgo/internal/runtime.iface" %53, ptr %51, align 8 - %54 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 6 - %55 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4) - %56 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %55, i64 2) - store %"github.com/goplus/llgo/internal/runtime.iface" %56, ptr %54, align 8 - %57 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 7 - %58 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) - %59 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %58, i64 3) - store %"github.com/goplus/llgo/internal/runtime.iface" %59, ptr %57, align 8 - %60 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 8 - %61 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) - %62 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %61, i64 4) - store %"github.com/goplus/llgo/internal/runtime.iface" %62, ptr %60, align 8 - %63 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 9 - %64 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %65 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %64, i64 5) - store %"github.com/goplus/llgo/internal/runtime.iface" %65, ptr %63, align 8 - %66 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 10 - %67 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8) - %68 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %67, i64 1) - store %"github.com/goplus/llgo/internal/runtime.iface" %68, ptr %66, align 8 - %69 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 11 - %70 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9) - %71 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %70, i64 2) - store %"github.com/goplus/llgo/internal/runtime.iface" %71, ptr %69, align 8 - %72 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 12 - %73 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10) - %74 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %73, i64 3) - store %"github.com/goplus/llgo/internal/runtime.iface" %74, ptr %72, align 8 - %75 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 13 - %76 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11) - %77 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %76, i64 4) - store %"github.com/goplus/llgo/internal/runtime.iface" %77, ptr %75, align 8 - %78 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 14 - %79 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12) - %80 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %79, i64 5) - store %"github.com/goplus/llgo/internal/runtime.iface" %80, ptr %78, align 8 - %81 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %35, i64 15 - %82 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %83 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %82, i32 0, i32 0 - store ptr @4, ptr %83, align 8 - %84 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %82, i32 0, i32 1 - store i64 4, ptr %84, align 4 - %85 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %82, align 8 - %86 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %85) - store %"github.com/goplus/llgo/internal/runtime.iface" %86, ptr %81, align 8 - %87 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %35, i64 16, i64 16, i64 0, i64 16, i64 16) - call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %87) + %35 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 48) + %36 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %35, i64 0 + %37 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %38 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %37, i32 0, i32 0 + store ptr @3, ptr %38, align 8 + %39 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %37, i32 0, i32 1 + store i64 8, ptr %39, align 4 + %40 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %37, align 8 + %41 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %42 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %40, ptr %42, align 8 + %43 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %44 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %43, i32 0, i32 0 + store ptr %41, ptr %44, align 8 + %45 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %43, i32 0, i32 1 + store ptr %42, ptr %45, align 8 + %46 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %43, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %46, ptr %36, align 8 + %47 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %35, i64 1 + %48 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %49 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %50 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %49, i32 0, i32 0 + store ptr %48, ptr %50, align 8 + %51 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %49, i32 0, i32 1 + store ptr inttoptr (i64 -1 to ptr), ptr %51, align 8 + %52 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %49, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %52, ptr %47, align 8 + %53 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %35, i64 2 + %54 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %55 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %56 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %55, i32 0, i32 0 + store ptr %54, ptr %56, align 8 + %57 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %55, i32 0, i32 1 + store ptr inttoptr (i64 -1 to ptr), ptr %57, align 8 + %58 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %55, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %58, ptr %53, align 8 + %59 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %35, i64 16, i64 3, i64 0, i64 3, i64 3) + call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %59) + %60 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 256) + %61 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 0 + %62 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %63 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %64 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %63, i32 0, i32 0 + store ptr %62, ptr %64, align 8 + %65 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %63, i32 0, i32 1 + store ptr inttoptr (i64 -1 to ptr), ptr %65, align 8 + %66 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %63, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %66, ptr %61, align 8 + %67 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 1 + %68 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %69 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %70 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %69, i32 0, i32 0 + store ptr %68, ptr %70, align 8 + %71 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %69, i32 0, i32 1 + store ptr null, ptr %71, align 8 + %72 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %69, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %72, ptr %67, align 8 + %73 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 2 + %74 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %75 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %76 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %75, i32 0, i32 0 + store ptr %74, ptr %76, align 8 + %77 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %75, i32 0, i32 1 + store ptr inttoptr (i64 97 to ptr), ptr %77, align 8 + %78 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %75, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %78, ptr %73, align 8 + %79 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 3 + %80 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %81 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %82 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %81, i32 0, i32 0 + store ptr %80, ptr %82, align 8 + %83 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %81, i32 0, i32 1 + store ptr inttoptr (i64 65 to ptr), ptr %83, align 8 + %84 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %81, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %84, ptr %79, align 8 + %85 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 4 + %86 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %87 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %88 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %87, i32 0, i32 0 + store ptr %86, ptr %88, align 8 + %89 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %87, i32 0, i32 1 + store ptr inttoptr (i64 20013 to ptr), ptr %89, align 8 + %90 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %87, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %90, ptr %85, align 8 + %91 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 5 + %92 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3) + %93 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %94 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %93, i32 0, i32 0 + store ptr %92, ptr %94, align 8 + %95 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %93, i32 0, i32 1 + store ptr inttoptr (i64 1 to ptr), ptr %95, align 8 + %96 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %93, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %96, ptr %91, align 8 + %97 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 6 + %98 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4) + %99 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %100 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %99, i32 0, i32 0 + store ptr %98, ptr %100, align 8 + %101 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %99, i32 0, i32 1 + store ptr inttoptr (i64 2 to ptr), ptr %101, align 8 + %102 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %99, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %102, ptr %97, align 8 + %103 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 7 + %104 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %105 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %106 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %105, i32 0, i32 0 + store ptr %104, ptr %106, align 8 + %107 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %105, i32 0, i32 1 + store ptr inttoptr (i64 3 to ptr), ptr %107, align 8 + %108 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %105, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %108, ptr %103, align 8 + %109 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 8 + %110 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) + %111 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %112 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %111, i32 0, i32 0 + store ptr %110, ptr %112, align 8 + %113 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %111, i32 0, i32 1 + store ptr inttoptr (i64 4 to ptr), ptr %113, align 8 + %114 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %111, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %114, ptr %109, align 8 + %115 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 9 + %116 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %117 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %118 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %117, i32 0, i32 0 + store ptr %116, ptr %118, align 8 + %119 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %117, i32 0, i32 1 + store ptr inttoptr (i64 5 to ptr), ptr %119, align 8 + %120 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %117, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %120, ptr %115, align 8 + %121 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 10 + %122 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8) + %123 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %124 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %123, i32 0, i32 0 + store ptr %122, ptr %124, align 8 + %125 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %123, i32 0, i32 1 + store ptr inttoptr (i64 1 to ptr), ptr %125, align 8 + %126 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %123, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %126, ptr %121, align 8 + %127 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 11 + %128 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9) + %129 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %130 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %129, i32 0, i32 0 + store ptr %128, ptr %130, align 8 + %131 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %129, i32 0, i32 1 + store ptr inttoptr (i64 2 to ptr), ptr %131, align 8 + %132 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %129, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %132, ptr %127, align 8 + %133 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 12 + %134 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10) + %135 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %136 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %135, i32 0, i32 0 + store ptr %134, ptr %136, align 8 + %137 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %135, i32 0, i32 1 + store ptr inttoptr (i64 3 to ptr), ptr %137, align 8 + %138 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %135, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %138, ptr %133, align 8 + %139 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 13 + %140 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11) + %141 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %142 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %141, i32 0, i32 0 + store ptr %140, ptr %142, align 8 + %143 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %141, i32 0, i32 1 + store ptr inttoptr (i64 4 to ptr), ptr %143, align 8 + %144 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %141, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %144, ptr %139, align 8 + %145 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 14 + %146 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12) + %147 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %148 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %147, i32 0, i32 0 + store ptr %146, ptr %148, align 8 + %149 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %147, i32 0, i32 1 + store ptr inttoptr (i64 5 to ptr), ptr %149, align 8 + %150 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %147, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %150, ptr %145, align 8 + %151 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 15 + %152 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %153 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %152, i32 0, i32 0 + store ptr @4, ptr %153, align 8 + %154 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %152, i32 0, i32 1 + store i64 4, ptr %154, align 4 + %155 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %152, align 8 + %156 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %157 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %155, ptr %157, align 8 + %158 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %159 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %158, i32 0, i32 0 + store ptr %156, ptr %159, align 8 + %160 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %158, i32 0, i32 1 + store ptr %157, ptr %160, align 8 + %161 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %158, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %161, ptr %151, align 8 + %162 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %60, i64 16, i64 16, i64 0, i64 16, i64 16) + call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %162) ret i32 0 _llgo_3: ; preds = %_llgo_0 @@ -245,190 +369,429 @@ _llgo_0: ret void } -define void @main.printany(%"github.com/goplus/llgo/internal/runtime.iface" %0) { +define void @main.printany(%"github.com/goplus/llgo/internal/runtime.eface" %0) { _llgo_0: - %1 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) - %2 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %1) - %3 = extractvalue { i64, i1 } %2, 0 - %4 = trunc i64 %3 to i1 - %5 = extractvalue { i64, i1 } %2, 1 - br i1 %5, label %_llgo_2, label %_llgo_3 + %1 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %3 = icmp eq ptr %1, %2 + %4 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %5 = ptrtoint ptr %4 to i64 + %6 = trunc i64 %5 to i1 + %7 = alloca { i1, i1 }, align 8 + %8 = getelementptr inbounds { i1, i1 }, ptr %7, i32 0, i32 0 + store i1 %6, ptr %8, align 1 + %9 = getelementptr inbounds { i1, i1 }, ptr %7, i32 0, i32 1 + store i1 true, ptr %9, align 1 + %10 = load { i1, i1 }, ptr %7, align 1 + %11 = alloca { i1, i1 }, align 8 + %12 = getelementptr inbounds { i1, i1 }, ptr %11, i32 0, i32 0 + store i1 false, ptr %12, align 1 + %13 = getelementptr inbounds { i1, i1 }, ptr %11, i32 0, i32 1 + store i1 false, ptr %13, align 1 + %14 = load { i1, i1 }, ptr %11, align 1 + %15 = select i1 %3, { i1, i1 } %10, { i1, i1 } %14 + %16 = extractvalue { i1, i1 } %15, 0 + %17 = extractvalue { i1, i1 } %15, 1 + br i1 %17, label %_llgo_2, label %_llgo_3 _llgo_1: ; preds = %_llgo_30, %_llgo_29, %_llgo_28, %_llgo_26, %_llgo_24, %_llgo_22, %_llgo_20, %_llgo_18, %_llgo_16, %_llgo_14, %_llgo_12, %_llgo_10, %_llgo_8, %_llgo_6, %_llgo_4, %_llgo_2 ret void _llgo_2: ; preds = %_llgo_0 - call void @main.printbool(i1 %4) + call void @main.printbool(i1 %16) br label %_llgo_1 _llgo_3: ; preds = %_llgo_0 - %6 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %7 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %6) - %8 = extractvalue { i64, i1 } %7, 0 - %9 = extractvalue { i64, i1 } %7, 1 - br i1 %9, label %_llgo_4, label %_llgo_5 + %18 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %19 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %20 = icmp eq ptr %18, %19 + %21 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %22 = ptrtoint ptr %21 to i64 + %23 = alloca { i64, i1 }, align 8 + %24 = getelementptr inbounds { i64, i1 }, ptr %23, i32 0, i32 0 + store i64 %22, ptr %24, align 4 + %25 = getelementptr inbounds { i64, i1 }, ptr %23, i32 0, i32 1 + store i1 true, ptr %25, align 1 + %26 = load { i64, i1 }, ptr %23, align 4 + %27 = alloca { i64, i1 }, align 8 + %28 = getelementptr inbounds { i64, i1 }, ptr %27, i32 0, i32 0 + store i64 0, ptr %28, align 4 + %29 = getelementptr inbounds { i64, i1 }, ptr %27, i32 0, i32 1 + store i1 false, ptr %29, align 1 + %30 = load { i64, i1 }, ptr %27, align 4 + %31 = select i1 %20, { i64, i1 } %26, { i64, i1 } %30 + %32 = extractvalue { i64, i1 } %31, 0 + %33 = extractvalue { i64, i1 } %31, 1 + br i1 %33, label %_llgo_4, label %_llgo_5 _llgo_4: ; preds = %_llgo_3 - call void @main.printint(i64 %8) + call void @main.printint(i64 %32) br label %_llgo_1 _llgo_5: ; preds = %_llgo_3 - %10 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3) - %11 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %10) - %12 = extractvalue { i64, i1 } %11, 0 - %13 = trunc i64 %12 to i8 - %14 = extractvalue { i64, i1 } %11, 1 - br i1 %14, label %_llgo_6, label %_llgo_7 + %34 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %35 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3) + %36 = icmp eq ptr %34, %35 + %37 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %38 = ptrtoint ptr %37 to i64 + %39 = trunc i64 %38 to i8 + %40 = alloca { i8, i1 }, align 8 + %41 = getelementptr inbounds { i8, i1 }, ptr %40, i32 0, i32 0 + store i8 %39, ptr %41, align 1 + %42 = getelementptr inbounds { i8, i1 }, ptr %40, i32 0, i32 1 + store i1 true, ptr %42, align 1 + %43 = load { i8, i1 }, ptr %40, align 1 + %44 = alloca { i8, i1 }, align 8 + %45 = getelementptr inbounds { i8, i1 }, ptr %44, i32 0, i32 0 + store i8 0, ptr %45, align 1 + %46 = getelementptr inbounds { i8, i1 }, ptr %44, i32 0, i32 1 + store i1 false, ptr %46, align 1 + %47 = load { i8, i1 }, ptr %44, align 1 + %48 = select i1 %36, { i8, i1 } %43, { i8, i1 } %47 + %49 = extractvalue { i8, i1 } %48, 0 + %50 = extractvalue { i8, i1 } %48, 1 + br i1 %50, label %_llgo_6, label %_llgo_7 _llgo_6: ; preds = %_llgo_5 - %15 = sext i8 %13 to i64 - call void @main.printint(i64 %15) + %51 = sext i8 %49 to i64 + call void @main.printint(i64 %51) br label %_llgo_1 _llgo_7: ; preds = %_llgo_5 - %16 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4) - %17 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %16) - %18 = extractvalue { i64, i1 } %17, 0 - %19 = trunc i64 %18 to i16 - %20 = extractvalue { i64, i1 } %17, 1 - br i1 %20, label %_llgo_8, label %_llgo_9 + %52 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %53 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4) + %54 = icmp eq ptr %52, %53 + %55 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %56 = ptrtoint ptr %55 to i64 + %57 = trunc i64 %56 to i16 + %58 = alloca { i16, i1 }, align 8 + %59 = getelementptr inbounds { i16, i1 }, ptr %58, i32 0, i32 0 + store i16 %57, ptr %59, align 2 + %60 = getelementptr inbounds { i16, i1 }, ptr %58, i32 0, i32 1 + store i1 true, ptr %60, align 1 + %61 = load { i16, i1 }, ptr %58, align 2 + %62 = alloca { i16, i1 }, align 8 + %63 = getelementptr inbounds { i16, i1 }, ptr %62, i32 0, i32 0 + store i16 0, ptr %63, align 2 + %64 = getelementptr inbounds { i16, i1 }, ptr %62, i32 0, i32 1 + store i1 false, ptr %64, align 1 + %65 = load { i16, i1 }, ptr %62, align 2 + %66 = select i1 %54, { i16, i1 } %61, { i16, i1 } %65 + %67 = extractvalue { i16, i1 } %66, 0 + %68 = extractvalue { i16, i1 } %66, 1 + br i1 %68, label %_llgo_8, label %_llgo_9 _llgo_8: ; preds = %_llgo_7 - %21 = sext i16 %19 to i64 - call void @main.printint(i64 %21) + %69 = sext i16 %67 to i64 + call void @main.printint(i64 %69) br label %_llgo_1 _llgo_9: ; preds = %_llgo_7 - %22 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) - %23 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %22) - %24 = extractvalue { i64, i1 } %23, 0 - %25 = trunc i64 %24 to i32 - %26 = extractvalue { i64, i1 } %23, 1 - br i1 %26, label %_llgo_10, label %_llgo_11 + %70 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %71 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %72 = icmp eq ptr %70, %71 + %73 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %74 = ptrtoint ptr %73 to i64 + %75 = trunc i64 %74 to i32 + %76 = alloca { i32, i1 }, align 8 + %77 = getelementptr inbounds { i32, i1 }, ptr %76, i32 0, i32 0 + store i32 %75, ptr %77, align 4 + %78 = getelementptr inbounds { i32, i1 }, ptr %76, i32 0, i32 1 + store i1 true, ptr %78, align 1 + %79 = load { i32, i1 }, ptr %76, align 4 + %80 = alloca { i32, i1 }, align 8 + %81 = getelementptr inbounds { i32, i1 }, ptr %80, i32 0, i32 0 + store i32 0, ptr %81, align 4 + %82 = getelementptr inbounds { i32, i1 }, ptr %80, i32 0, i32 1 + store i1 false, ptr %82, align 1 + %83 = load { i32, i1 }, ptr %80, align 4 + %84 = select i1 %72, { i32, i1 } %79, { i32, i1 } %83 + %85 = extractvalue { i32, i1 } %84, 0 + %86 = extractvalue { i32, i1 } %84, 1 + br i1 %86, label %_llgo_10, label %_llgo_11 _llgo_10: ; preds = %_llgo_9 - %27 = sext i32 %25 to i64 - call void @main.printint(i64 %27) + %87 = sext i32 %85 to i64 + call void @main.printint(i64 %87) br label %_llgo_1 _llgo_11: ; preds = %_llgo_9 - %28 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) - %29 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %28) - %30 = extractvalue { i64, i1 } %29, 0 - %31 = extractvalue { i64, i1 } %29, 1 - br i1 %31, label %_llgo_12, label %_llgo_13 + %88 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %89 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) + %90 = icmp eq ptr %88, %89 + %91 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %92 = ptrtoint ptr %91 to i64 + %93 = alloca { i64, i1 }, align 8 + %94 = getelementptr inbounds { i64, i1 }, ptr %93, i32 0, i32 0 + store i64 %92, ptr %94, align 4 + %95 = getelementptr inbounds { i64, i1 }, ptr %93, i32 0, i32 1 + store i1 true, ptr %95, align 1 + %96 = load { i64, i1 }, ptr %93, align 4 + %97 = alloca { i64, i1 }, align 8 + %98 = getelementptr inbounds { i64, i1 }, ptr %97, i32 0, i32 0 + store i64 0, ptr %98, align 4 + %99 = getelementptr inbounds { i64, i1 }, ptr %97, i32 0, i32 1 + store i1 false, ptr %99, align 1 + %100 = load { i64, i1 }, ptr %97, align 4 + %101 = select i1 %90, { i64, i1 } %96, { i64, i1 } %100 + %102 = extractvalue { i64, i1 } %101, 0 + %103 = extractvalue { i64, i1 } %101, 1 + br i1 %103, label %_llgo_12, label %_llgo_13 _llgo_12: ; preds = %_llgo_11 - call void @main.printint(i64 %30) + call void @main.printint(i64 %102) br label %_llgo_1 _llgo_13: ; preds = %_llgo_11 - %32 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 7) - %33 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %32) - %34 = extractvalue { i64, i1 } %33, 0 - %35 = extractvalue { i64, i1 } %33, 1 - br i1 %35, label %_llgo_14, label %_llgo_15 + %104 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %105 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 7) + %106 = icmp eq ptr %104, %105 + %107 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %108 = ptrtoint ptr %107 to i64 + %109 = alloca { i64, i1 }, align 8 + %110 = getelementptr inbounds { i64, i1 }, ptr %109, i32 0, i32 0 + store i64 %108, ptr %110, align 4 + %111 = getelementptr inbounds { i64, i1 }, ptr %109, i32 0, i32 1 + store i1 true, ptr %111, align 1 + %112 = load { i64, i1 }, ptr %109, align 4 + %113 = alloca { i64, i1 }, align 8 + %114 = getelementptr inbounds { i64, i1 }, ptr %113, i32 0, i32 0 + store i64 0, ptr %114, align 4 + %115 = getelementptr inbounds { i64, i1 }, ptr %113, i32 0, i32 1 + store i1 false, ptr %115, align 1 + %116 = load { i64, i1 }, ptr %113, align 4 + %117 = select i1 %106, { i64, i1 } %112, { i64, i1 } %116 + %118 = extractvalue { i64, i1 } %117, 0 + %119 = extractvalue { i64, i1 } %117, 1 + br i1 %119, label %_llgo_14, label %_llgo_15 _llgo_14: ; preds = %_llgo_13 - call void @main.printuint(i64 %34) + call void @main.printuint(i64 %118) br label %_llgo_1 _llgo_15: ; preds = %_llgo_13 - %36 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8) - %37 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %36) - %38 = extractvalue { i64, i1 } %37, 0 - %39 = trunc i64 %38 to i8 - %40 = extractvalue { i64, i1 } %37, 1 - br i1 %40, label %_llgo_16, label %_llgo_17 + %120 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %121 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8) + %122 = icmp eq ptr %120, %121 + %123 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %124 = ptrtoint ptr %123 to i64 + %125 = trunc i64 %124 to i8 + %126 = alloca { i8, i1 }, align 8 + %127 = getelementptr inbounds { i8, i1 }, ptr %126, i32 0, i32 0 + store i8 %125, ptr %127, align 1 + %128 = getelementptr inbounds { i8, i1 }, ptr %126, i32 0, i32 1 + store i1 true, ptr %128, align 1 + %129 = load { i8, i1 }, ptr %126, align 1 + %130 = alloca { i8, i1 }, align 8 + %131 = getelementptr inbounds { i8, i1 }, ptr %130, i32 0, i32 0 + store i8 0, ptr %131, align 1 + %132 = getelementptr inbounds { i8, i1 }, ptr %130, i32 0, i32 1 + store i1 false, ptr %132, align 1 + %133 = load { i8, i1 }, ptr %130, align 1 + %134 = select i1 %122, { i8, i1 } %129, { i8, i1 } %133 + %135 = extractvalue { i8, i1 } %134, 0 + %136 = extractvalue { i8, i1 } %134, 1 + br i1 %136, label %_llgo_16, label %_llgo_17 _llgo_16: ; preds = %_llgo_15 - %41 = zext i8 %39 to i64 - call void @main.printuint(i64 %41) + %137 = zext i8 %135 to i64 + call void @main.printuint(i64 %137) br label %_llgo_1 _llgo_17: ; preds = %_llgo_15 - %42 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9) - %43 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %42) - %44 = extractvalue { i64, i1 } %43, 0 - %45 = trunc i64 %44 to i16 - %46 = extractvalue { i64, i1 } %43, 1 - br i1 %46, label %_llgo_18, label %_llgo_19 + %138 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %139 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9) + %140 = icmp eq ptr %138, %139 + %141 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %142 = ptrtoint ptr %141 to i64 + %143 = trunc i64 %142 to i16 + %144 = alloca { i16, i1 }, align 8 + %145 = getelementptr inbounds { i16, i1 }, ptr %144, i32 0, i32 0 + store i16 %143, ptr %145, align 2 + %146 = getelementptr inbounds { i16, i1 }, ptr %144, i32 0, i32 1 + store i1 true, ptr %146, align 1 + %147 = load { i16, i1 }, ptr %144, align 2 + %148 = alloca { i16, i1 }, align 8 + %149 = getelementptr inbounds { i16, i1 }, ptr %148, i32 0, i32 0 + store i16 0, ptr %149, align 2 + %150 = getelementptr inbounds { i16, i1 }, ptr %148, i32 0, i32 1 + store i1 false, ptr %150, align 1 + %151 = load { i16, i1 }, ptr %148, align 2 + %152 = select i1 %140, { i16, i1 } %147, { i16, i1 } %151 + %153 = extractvalue { i16, i1 } %152, 0 + %154 = extractvalue { i16, i1 } %152, 1 + br i1 %154, label %_llgo_18, label %_llgo_19 _llgo_18: ; preds = %_llgo_17 - %47 = zext i16 %45 to i64 - call void @main.printuint(i64 %47) + %155 = zext i16 %153 to i64 + call void @main.printuint(i64 %155) br label %_llgo_1 _llgo_19: ; preds = %_llgo_17 - %48 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10) - %49 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %48) - %50 = extractvalue { i64, i1 } %49, 0 - %51 = trunc i64 %50 to i32 - %52 = extractvalue { i64, i1 } %49, 1 - br i1 %52, label %_llgo_20, label %_llgo_21 + %156 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %157 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10) + %158 = icmp eq ptr %156, %157 + %159 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %160 = ptrtoint ptr %159 to i64 + %161 = trunc i64 %160 to i32 + %162 = alloca { i32, i1 }, align 8 + %163 = getelementptr inbounds { i32, i1 }, ptr %162, i32 0, i32 0 + store i32 %161, ptr %163, align 4 + %164 = getelementptr inbounds { i32, i1 }, ptr %162, i32 0, i32 1 + store i1 true, ptr %164, align 1 + %165 = load { i32, i1 }, ptr %162, align 4 + %166 = alloca { i32, i1 }, align 8 + %167 = getelementptr inbounds { i32, i1 }, ptr %166, i32 0, i32 0 + store i32 0, ptr %167, align 4 + %168 = getelementptr inbounds { i32, i1 }, ptr %166, i32 0, i32 1 + store i1 false, ptr %168, align 1 + %169 = load { i32, i1 }, ptr %166, align 4 + %170 = select i1 %158, { i32, i1 } %165, { i32, i1 } %169 + %171 = extractvalue { i32, i1 } %170, 0 + %172 = extractvalue { i32, i1 } %170, 1 + br i1 %172, label %_llgo_20, label %_llgo_21 _llgo_20: ; preds = %_llgo_19 - %53 = zext i32 %51 to i64 - call void @main.printuint(i64 %53) + %173 = zext i32 %171 to i64 + call void @main.printuint(i64 %173) br label %_llgo_1 _llgo_21: ; preds = %_llgo_19 - %54 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11) - %55 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %54) - %56 = extractvalue { i64, i1 } %55, 0 - %57 = extractvalue { i64, i1 } %55, 1 - br i1 %57, label %_llgo_22, label %_llgo_23 + %174 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %175 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11) + %176 = icmp eq ptr %174, %175 + %177 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %178 = ptrtoint ptr %177 to i64 + %179 = alloca { i64, i1 }, align 8 + %180 = getelementptr inbounds { i64, i1 }, ptr %179, i32 0, i32 0 + store i64 %178, ptr %180, align 4 + %181 = getelementptr inbounds { i64, i1 }, ptr %179, i32 0, i32 1 + store i1 true, ptr %181, align 1 + %182 = load { i64, i1 }, ptr %179, align 4 + %183 = alloca { i64, i1 }, align 8 + %184 = getelementptr inbounds { i64, i1 }, ptr %183, i32 0, i32 0 + store i64 0, ptr %184, align 4 + %185 = getelementptr inbounds { i64, i1 }, ptr %183, i32 0, i32 1 + store i1 false, ptr %185, align 1 + %186 = load { i64, i1 }, ptr %183, align 4 + %187 = select i1 %176, { i64, i1 } %182, { i64, i1 } %186 + %188 = extractvalue { i64, i1 } %187, 0 + %189 = extractvalue { i64, i1 } %187, 1 + br i1 %189, label %_llgo_22, label %_llgo_23 _llgo_22: ; preds = %_llgo_21 - call void @main.printuint(i64 %56) + call void @main.printuint(i64 %188) br label %_llgo_1 _llgo_23: ; preds = %_llgo_21 - %58 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12) - %59 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %58) - %60 = extractvalue { i64, i1 } %59, 0 - %61 = extractvalue { i64, i1 } %59, 1 - br i1 %61, label %_llgo_24, label %_llgo_25 + %190 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %191 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12) + %192 = icmp eq ptr %190, %191 + %193 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %194 = ptrtoint ptr %193 to i64 + %195 = alloca { i64, i1 }, align 8 + %196 = getelementptr inbounds { i64, i1 }, ptr %195, i32 0, i32 0 + store i64 %194, ptr %196, align 4 + %197 = getelementptr inbounds { i64, i1 }, ptr %195, i32 0, i32 1 + store i1 true, ptr %197, align 1 + %198 = load { i64, i1 }, ptr %195, align 4 + %199 = alloca { i64, i1 }, align 8 + %200 = getelementptr inbounds { i64, i1 }, ptr %199, i32 0, i32 0 + store i64 0, ptr %200, align 4 + %201 = getelementptr inbounds { i64, i1 }, ptr %199, i32 0, i32 1 + store i1 false, ptr %201, align 1 + %202 = load { i64, i1 }, ptr %199, align 4 + %203 = select i1 %192, { i64, i1 } %198, { i64, i1 } %202 + %204 = extractvalue { i64, i1 } %203, 0 + %205 = extractvalue { i64, i1 } %203, 1 + br i1 %205, label %_llgo_24, label %_llgo_25 _llgo_24: ; preds = %_llgo_23 - call void @main.printuint(i64 %60) + call void @main.printuint(i64 %204) br label %_llgo_1 _llgo_25: ; preds = %_llgo_23 - %62 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13) - %63 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %62) - %64 = extractvalue { i64, i1 } %63, 0 - %65 = trunc i64 %64 to i32 - %66 = bitcast i32 %65 to float - %67 = extractvalue { i64, i1 } %63, 1 - br i1 %67, label %_llgo_26, label %_llgo_27 + %206 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %207 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13) + %208 = icmp eq ptr %206, %207 + %209 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %210 = ptrtoint ptr %209 to i64 + %211 = bitcast i64 %210 to float + %212 = alloca { float, i1 }, align 8 + %213 = getelementptr inbounds { float, i1 }, ptr %212, i32 0, i32 0 + store float %211, ptr %213, align 4 + %214 = getelementptr inbounds { float, i1 }, ptr %212, i32 0, i32 1 + store i1 true, ptr %214, align 1 + %215 = load { float, i1 }, ptr %212, align 4 + %216 = alloca { float, i1 }, align 8 + %217 = getelementptr inbounds { float, i1 }, ptr %216, i32 0, i32 0 + store double 0.000000e+00, ptr %217, align 8 + %218 = getelementptr inbounds { float, i1 }, ptr %216, i32 0, i32 1 + store i1 false, ptr %218, align 1 + %219 = load { float, i1 }, ptr %216, align 4 + %220 = select i1 %208, { float, i1 } %215, { float, i1 } %219 + %221 = extractvalue { float, i1 } %220, 0 + %222 = extractvalue { float, i1 } %220, 1 + br i1 %222, label %_llgo_26, label %_llgo_27 _llgo_26: ; preds = %_llgo_25 - %68 = fpext float %66 to double - call void @main.printfloat(double %68) + %223 = fpext float %221 to double + call void @main.printfloat(double %223) br label %_llgo_1 _llgo_27: ; preds = %_llgo_25 - %69 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) - %70 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %69) - %71 = extractvalue { i64, i1 } %70, 0 - %72 = bitcast i64 %71 to double - %73 = extractvalue { i64, i1 } %70, 1 - br i1 %73, label %_llgo_28, label %_llgo_29 + %224 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %225 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) + %226 = icmp eq ptr %224, %225 + %227 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %228 = ptrtoint ptr %227 to i64 + %229 = bitcast i64 %228 to double + %230 = alloca { double, i1 }, align 8 + %231 = getelementptr inbounds { double, i1 }, ptr %230, i32 0, i32 0 + store double %229, ptr %231, align 8 + %232 = getelementptr inbounds { double, i1 }, ptr %230, i32 0, i32 1 + store i1 true, ptr %232, align 1 + %233 = load { double, i1 }, ptr %230, align 8 + %234 = alloca { double, i1 }, align 8 + %235 = getelementptr inbounds { double, i1 }, ptr %234, i32 0, i32 0 + store double 0.000000e+00, ptr %235, align 8 + %236 = getelementptr inbounds { double, i1 }, ptr %234, i32 0, i32 1 + store i1 false, ptr %236, align 1 + %237 = load { double, i1 }, ptr %234, align 8 + %238 = select i1 %226, { double, i1 } %233, { double, i1 } %237 + %239 = extractvalue { double, i1 } %238, 0 + %240 = extractvalue { double, i1 } %238, 1 + br i1 %240, label %_llgo_28, label %_llgo_29 _llgo_28: ; preds = %_llgo_27 - call void @main.printfloat(double %72) + call void @main.printfloat(double %239) br label %_llgo_1 _llgo_29: ; preds = %_llgo_27 - %74 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) - %75 = call { %"github.com/goplus/llgo/internal/runtime.String", i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2String"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %74) - %76 = extractvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } %75, 0 - %77 = extractvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } %75, 1 - br i1 %77, label %_llgo_30, label %_llgo_1 + %241 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %242 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %243 = icmp eq ptr %241, %242 + %244 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %245 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %244, align 8 + %246 = alloca { %"github.com/goplus/llgo/internal/runtime.String", i1 }, align 8 + %247 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %246, i32 0, i32 0 + store %"github.com/goplus/llgo/internal/runtime.String" %245, ptr %247, align 8 + %248 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %246, i32 0, i32 1 + store i1 true, ptr %248, align 1 + %249 = load { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %246, align 8 + %250 = alloca { %"github.com/goplus/llgo/internal/runtime.String", i1 }, align 8 + %251 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %250, i32 0, i32 0 + store { ptr, i64 } zeroinitializer, ptr %251, align 8 + %252 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %250, i32 0, i32 1 + store i1 false, ptr %252, align 1 + %253 = load { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %250, align 8 + %254 = select i1 %243, { %"github.com/goplus/llgo/internal/runtime.String", i1 } %249, { %"github.com/goplus/llgo/internal/runtime.String", i1 } %253 + %255 = extractvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } %254, 0 + %256 = extractvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } %254, 1 + br i1 %256, label %_llgo_30, label %_llgo_1 _llgo_30: ; preds = %_llgo_29 - call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %76) + call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %255) br label %_llgo_1 } @@ -756,8 +1119,8 @@ _llgo_2: ; preds = %_llgo_1 %5 = icmp slt i64 %3, 0 call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %5) %6 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 0 - %7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %6, i64 %3 - %8 = load %"github.com/goplus/llgo/internal/runtime.iface", ptr %7, align 8 + %7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %6, i64 %3 + %8 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %7, align 8 %9 = icmp ne i64 %3, 0 br i1 %9, label %_llgo_4, label %_llgo_5 @@ -776,7 +1139,7 @@ _llgo_4: ; preds = %_llgo_2 br label %_llgo_5 _llgo_5: ; preds = %_llgo_4, %_llgo_2 - call void @main.printany(%"github.com/goplus/llgo/internal/runtime.iface" %8) + call void @main.printany(%"github.com/goplus/llgo/internal/runtime.eface" %8) br label %_llgo_1 } @@ -869,16 +1232,10 @@ declare i32 @printf(ptr, ...) declare void @"github.com/goplus/llgo/internal/runtime.init"() -declare %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr, i64) - declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) -declare %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String") +declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr, i64, i64, i64, i64, i64) -declare { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface", ptr) - -declare { %"github.com/goplus/llgo/internal/runtime.String", i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2String"(%"github.com/goplus/llgo/internal/runtime.iface", ptr) - declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1) diff --git a/cl/_testdata/vargs/out.ll b/cl/_testdata/vargs/out.ll index 86c098c9..dbb7eda8 100644 --- a/cl/_testdata/vargs/out.ll +++ b/cl/_testdata/vargs/out.ll @@ -1,13 +1,15 @@ ; ModuleID = 'main' source_filename = "main" -%"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr } +%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr } %"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 ptr null @__llgo_argc = global ptr null @__llgo_argv = global ptr null @0 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 +@1 = private unnamed_addr constant [22 x i8] c"type assertion failed\00", align 1 define void @main.init() { _llgo_0: @@ -29,20 +31,35 @@ _llgo_0: 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.iface", ptr %2, i64 0 + %3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i64 0 %4 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %5 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %4, i64 1) - store %"github.com/goplus/llgo/internal/runtime.iface" %5, ptr %3, align 8 - %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %2, i64 1 - %7 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %8 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %7, i64 2) - store %"github.com/goplus/llgo/internal/runtime.iface" %8, ptr %6, align 8 - %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %2, i64 2 + %5 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %5, i32 0, i32 0 + store ptr %4, ptr %6, align 8 + %7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %5, i32 0, i32 1 + store ptr inttoptr (i64 1 to ptr), ptr %7, align 8 + %8 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %5, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %8, ptr %3, align 8 + %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i64 1 %10 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %11 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %10, i64 3) - store %"github.com/goplus/llgo/internal/runtime.iface" %11, ptr %9, align 8 - %12 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %2, i64 16, i64 3, i64 0, i64 3, i64 3) - call void @main.test(%"github.com/goplus/llgo/internal/runtime.Slice" %12) + %11 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %11, i32 0, i32 0 + store ptr %10, ptr %12, align 8 + %13 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %11, i32 0, i32 1 + store ptr inttoptr (i64 2 to ptr), ptr %13, align 8 + %14 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %11, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %14, ptr %9, align 8 + %15 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i64 2 + %16 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %17 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %18 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %17, i32 0, i32 0 + store ptr %16, ptr %18, align 8 + %19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %17, i32 0, i32 1 + store ptr inttoptr (i64 3 to ptr), ptr %19, align 8 + %20 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %17, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %20, ptr %15, align 8 + %21 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %2, i64 16, i64 3, i64 0, i64 3, i64 3) + call void @main.test(%"github.com/goplus/llgo/internal/runtime.Slice" %21) ret i32 0 } @@ -51,7 +68,7 @@ _llgo_0: %1 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 1 br label %_llgo_1 -_llgo_1: ; preds = %_llgo_2, %_llgo_0 +_llgo_1: ; preds = %_llgo_4, %_llgo_0 %2 = phi i64 [ -1, %_llgo_0 ], [ %3, %_llgo_2 ] %3 = add i64 %2, 1 %4 = icmp slt i64 %3, %1 @@ -61,29 +78,43 @@ _llgo_2: ; preds = %_llgo_1 %5 = icmp slt i64 %3, 0 call void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1 %5) %6 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 0 - %7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %6, i64 %3 - %8 = load %"github.com/goplus/llgo/internal/runtime.iface", ptr %7, align 8 - %9 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %10 = call i64 @"github.com/goplus/llgo/internal/runtime.I2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %8, ptr %9) - %11 = call i32 (ptr, ...) @printf(ptr @0, i64 %10) - br label %_llgo_1 + %7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %6, i64 %3 + %8 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %7, align 8 + %9 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %8, 0 + %10 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %11 = icmp eq ptr %9, %10 + br i1 %11, label %_llgo_4, label %_llgo_5 _llgo_3: ; preds = %_llgo_1 ret void + +_llgo_4: ; preds = %_llgo_2 + %12 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %8, 1 + %13 = ptrtoint ptr %12 to i64 + %14 = call i32 (ptr, ...) @printf(ptr @0, i64 %13) + br label %_llgo_1 + +_llgo_5: ; preds = %_llgo_2 + %15 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %16 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %15, i32 0, i32 0 + store ptr @1, ptr %16, align 8 + %17 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %15, i32 0, i32 1 + store i64 21, ptr %17, align 4 + %18 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %15, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.String" %18) + unreachable } declare void @"github.com/goplus/llgo/internal/runtime.init"() declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64) -declare %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr, i64) - declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr, i64, i64, i64, i64, i64) declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1) -declare i64 @"github.com/goplus/llgo/internal/runtime.I2Int"(%"github.com/goplus/llgo/internal/runtime.iface", ptr) +declare void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface") declare i32 @printf(ptr, ...) diff --git a/cl/_testrt/gotypes/in.go b/cl/_testrt/_gotypes/in.go similarity index 100% rename from cl/_testrt/gotypes/in.go rename to cl/_testrt/_gotypes/in.go diff --git a/cl/_testrt/gotypes/out.ll b/cl/_testrt/_gotypes/out.ll similarity index 100% rename from cl/_testrt/gotypes/out.ll rename to cl/_testrt/_gotypes/out.ll diff --git a/cl/_testrt/any/out.ll b/cl/_testrt/any/out.ll index fbf58289..207fc6d3 100644 --- a/cl/_testrt/any/out.ll +++ b/cl/_testrt/any/out.ll @@ -1,19 +1,37 @@ ; ModuleID = 'main' source_filename = "main" -%"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr } +%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr } +%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 } @"main.init$guard" = global ptr null +@0 = private unnamed_addr constant [22 x i8] c"type assertion failed\00", align 1 @__llgo_argc = global ptr null @__llgo_argv = global ptr null -@0 = private unnamed_addr constant [10 x i8] c"Hello %d\0A\00", align 1 +@1 = private unnamed_addr constant [10 x i8] c"Hello %d\0A\00", align 1 -define i64 @main.incVal(%"github.com/goplus/llgo/internal/runtime.iface" %0) { +define i64 @main.incVal(%"github.com/goplus/llgo/internal/runtime.eface" %0) { _llgo_0: - %1 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %2 = call i64 @"github.com/goplus/llgo/internal/runtime.I2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %1) - %3 = add i64 %2, 1 - ret i64 %3 + %1 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %3 = icmp eq ptr %1, %2 + br i1 %3, label %_llgo_1, label %_llgo_2 + +_llgo_1: ; preds = %_llgo_0 + %4 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %5 = ptrtoint ptr %4 to i64 + %6 = add i64 %5, 1 + ret i64 %6 + +_llgo_2: ; preds = %_llgo_0 + %7 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %8 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %7, i32 0, i32 0 + store ptr @0, ptr %8, align 8 + %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %7, i32 0, i32 1 + store i64 21, ptr %9, align 4 + %10 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %7, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.String" %10) + unreachable } define void @main.init() { @@ -36,18 +54,21 @@ _llgo_0: call void @"github.com/goplus/llgo/internal/runtime.init"() call void @main.init() %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %3 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %2, i64 100) - %4 = call i64 @main.incVal(%"github.com/goplus/llgo/internal/runtime.iface" %3) - %5 = call i32 (ptr, ...) @printf(ptr @0, i64 %4) + %3 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %4 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %3, i32 0, i32 0 + store ptr %2, ptr %4, align 8 + %5 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %3, i32 0, i32 1 + store ptr inttoptr (i64 100 to ptr), ptr %5, align 8 + %6 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %3, align 8 + %7 = call i64 @main.incVal(%"github.com/goplus/llgo/internal/runtime.eface" %6) + %8 = call i32 (ptr, ...) @printf(ptr @1, i64 %7) ret i32 0 } -declare i64 @"github.com/goplus/llgo/internal/runtime.I2Int"(%"github.com/goplus/llgo/internal/runtime.iface", ptr) - declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) +declare void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface") + declare void @"github.com/goplus/llgo/internal/runtime.init"() -declare %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr, i64) - declare i32 @printf(ptr, ...) diff --git a/cl/_testrt/builtin/out.ll b/cl/_testrt/builtin/out.ll index c921f898..9ff25dda 100644 --- a/cl/_testrt/builtin/out.ll +++ b/cl/_testrt/builtin/out.ll @@ -3,7 +3,7 @@ source_filename = "main" %"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 } %"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 } -%"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr } +%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr } @main.a = global ptr null @main.b = global ptr null @@ -242,10 +242,15 @@ _llgo_0: call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) %107 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16) %108 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %109 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr %108, i64 100) - store %"github.com/goplus/llgo/internal/runtime.iface" %109, ptr %107, align 8 - %110 = load %"github.com/goplus/llgo/internal/runtime.iface", ptr %107, align 8 - %111 = ptrtoint ptr %107 to i64 + %109 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %110 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %109, i32 0, i32 0 + store ptr %108, ptr %110, align 8 + %111 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %109, i32 0, i32 1 + store ptr inttoptr (i64 100 to ptr), ptr %111, align 8 + %112 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %109, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %112, ptr %107, align 8 + %113 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %107, align 8 + %114 = ptrtoint ptr %107 to i64 call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 true) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 0) @@ -262,83 +267,83 @@ _llgo_0: call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double 1.005000e+02) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintIface"(%"github.com/goplus/llgo/internal/runtime.iface" %110) + call void @"github.com/goplus/llgo/internal/runtime.PrintEface"(%"github.com/goplus/llgo/internal/runtime.eface" %113) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %107) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %111) + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %114) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) - %112 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 3) - %113 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8) - %114 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %112, i64 1, i64 3, i64 0, i64 3, i64 3) - %115 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %106, 0 - %116 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %106, 1 - %117 = call i64 @"github.com/goplus/llgo/internal/runtime.SliceCopy"(%"github.com/goplus/llgo/internal/runtime.Slice" %114, ptr %115, i64 %116, i64 1) - store i64 %117, ptr %113, align 4 - %118 = load i64, ptr %113, align 4 - %119 = getelementptr inbounds i8, ptr %112, i64 0 - %120 = load i8, ptr %119, align 1 - %121 = getelementptr inbounds i8, ptr %112, i64 1 - %122 = load i8, ptr %121, align 1 - %123 = getelementptr inbounds i8, ptr %112, i64 2 - %124 = load i8, ptr %123, align 1 - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %118) + %115 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 3) + %116 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8) + %117 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %115, i64 1, i64 3, i64 0, i64 3, i64 3) + %118 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %106, 0 + %119 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %106, 1 + %120 = call i64 @"github.com/goplus/llgo/internal/runtime.SliceCopy"(%"github.com/goplus/llgo/internal/runtime.Slice" %117, ptr %118, i64 %119, i64 1) + store i64 %120, ptr %116, align 4 + %121 = load i64, ptr %116, align 4 + %122 = getelementptr inbounds i8, ptr %115, i64 0 + %123 = load i8, ptr %122, align 1 + %124 = getelementptr inbounds i8, ptr %115, i64 1 + %125 = load i8, ptr %124, align 1 + %126 = getelementptr inbounds i8, ptr %115, i64 2 + %127 = load i8, ptr %126, align 1 + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %121) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %125 = zext i8 %120 to i64 - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %125) + %128 = zext i8 %123 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %128) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %126 = zext i8 %122 to i64 - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %126) + %129 = zext i8 %125 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %129) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %127 = zext i8 %124 to i64 - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %127) + %130 = zext i8 %127 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %130) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) - %128 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %112, i64 1, i64 3, i64 1, i64 3, i64 3) - %129 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %130 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %129, i32 0, i32 0 - store ptr @5, ptr %130, align 8 - %131 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %129, i32 0, i32 1 - store i64 4, ptr %131, align 4 - %132 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %129, align 8 - %133 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %132, 0 - %134 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %132, 1 - %135 = call i64 @"github.com/goplus/llgo/internal/runtime.SliceCopy"(%"github.com/goplus/llgo/internal/runtime.Slice" %128, ptr %133, i64 %134, i64 1) - store i64 %135, ptr %113, align 4 - %136 = load i64, ptr %113, align 4 - %137 = getelementptr inbounds i8, ptr %112, i64 0 - %138 = load i8, ptr %137, align 1 - %139 = getelementptr inbounds i8, ptr %112, i64 1 - %140 = load i8, ptr %139, align 1 - %141 = getelementptr inbounds i8, ptr %112, i64 2 - %142 = load i8, ptr %141, align 1 - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %136) + %131 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %115, i64 1, i64 3, i64 1, i64 3, i64 3) + %132 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %133 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %132, i32 0, i32 0 + store ptr @5, ptr %133, align 8 + %134 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %132, i32 0, i32 1 + store i64 4, ptr %134, align 4 + %135 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %132, align 8 + %136 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %135, 0 + %137 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %135, 1 + %138 = call i64 @"github.com/goplus/llgo/internal/runtime.SliceCopy"(%"github.com/goplus/llgo/internal/runtime.Slice" %131, ptr %136, i64 %137, i64 1) + store i64 %138, ptr %116, align 4 + %139 = load i64, ptr %116, align 4 + %140 = getelementptr inbounds i8, ptr %115, i64 0 + %141 = load i8, ptr %140, align 1 + %142 = getelementptr inbounds i8, ptr %115, i64 1 + %143 = load i8, ptr %142, align 1 + %144 = getelementptr inbounds i8, ptr %115, i64 2 + %145 = load i8, ptr %144, align 1 + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %139) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %143 = zext i8 %138 to i64 - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %143) + %146 = zext i8 %141 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %146) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %144 = zext i8 %140 to i64 - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %144) + %147 = zext i8 %143 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %147) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %145 = zext i8 %142 to i64 - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %145) + %148 = zext i8 %145 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %148) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) - %146 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) - %147 = getelementptr inbounds { ptr }, ptr %146, i32 0, i32 0 - store ptr %113, ptr %147, align 8 - %148 = alloca { ptr, ptr }, align 8 - %149 = getelementptr inbounds { ptr, ptr }, ptr %148, i32 0, i32 0 - store ptr @"main.main$2", ptr %149, align 8 - %150 = getelementptr inbounds { ptr, ptr }, ptr %148, i32 0, i32 1 - store ptr %146, ptr %150, align 8 - %151 = load { ptr, ptr }, ptr %148, align 8 + %149 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) + %150 = getelementptr inbounds { ptr }, ptr %149, i32 0, i32 0 + store ptr %116, ptr %150, align 8 + %151 = alloca { ptr, ptr }, align 8 + %152 = getelementptr inbounds { ptr, ptr }, ptr %151, i32 0, i32 0 + store ptr @"main.main$2", ptr %152, align 8 + %153 = getelementptr inbounds { ptr, ptr }, ptr %151, i32 0, i32 1 + store ptr %149, ptr %153, align 8 + %154 = load { ptr, ptr }, ptr %151, align 8 call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr @main.demo) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr @main.demo) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr @"main.main$1") call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %152 = extractvalue { ptr, ptr } %151, 0 - call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %152) + %155 = extractvalue { ptr, ptr } %154, 0 + call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %155) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) ret i32 0 } @@ -361,8 +366,6 @@ declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.SliceAppend"(%"github.com/goplus/llgo/internal/runtime.Slice", ptr, i64, i64) -declare %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyIntptr"(ptr, i64) - declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) declare void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1) @@ -371,7 +374,7 @@ declare void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64) declare void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double) -declare void @"github.com/goplus/llgo/internal/runtime.PrintIface"(%"github.com/goplus/llgo/internal/runtime.iface") +declare void @"github.com/goplus/llgo/internal/runtime.PrintEface"(%"github.com/goplus/llgo/internal/runtime.eface") declare void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr) diff --git a/cl/_testrt/cast/out.ll b/cl/_testrt/cast/out.ll index b6739dbb..794eea9e 100644 --- a/cl/_testrt/cast/out.ll +++ b/cl/_testrt/cast/out.ll @@ -2,7 +2,7 @@ source_filename = "main" %"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 } -%"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr } +%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr } @"main.init$guard" = global ptr null @0 = private unnamed_addr constant [6 x i8] c"error\00", align 1 @@ -34,8 +34,16 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %7) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %8) + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 + %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 0 + store ptr %8, ptr %11, align 8 + %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 1 + store ptr %9, ptr %12, align 8 + %13 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %13) unreachable _llgo_2: ; preds = %_llgo_0 @@ -55,8 +63,16 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %7) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %8) + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 + %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 0 + store ptr %8, ptr %11, align 8 + %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 1 + store ptr %9, ptr %12, align 8 + %13 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %13) unreachable _llgo_2: ; preds = %_llgo_0 @@ -76,8 +92,16 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %7) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %8) + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 + %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 0 + store ptr %8, ptr %11, align 8 + %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 1 + store ptr %9, ptr %12, align 8 + %13 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %13) unreachable _llgo_2: ; preds = %_llgo_0 @@ -97,8 +121,16 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %7) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %8) + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 + %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 0 + store ptr %8, ptr %11, align 8 + %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 1 + store ptr %9, ptr %12, align 8 + %13 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %13) unreachable _llgo_2: ; preds = %_llgo_0 @@ -118,8 +150,16 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %7) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %8) + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 + %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 0 + store ptr %8, ptr %11, align 8 + %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 1 + store ptr %9, ptr %12, align 8 + %13 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %13) unreachable _llgo_2: ; preds = %_llgo_0 @@ -139,8 +179,16 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %7) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %8) + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 + %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 0 + store ptr %8, ptr %11, align 8 + %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 1 + store ptr %9, ptr %12, align 8 + %13 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %13) unreachable _llgo_2: ; preds = %_llgo_0 @@ -160,8 +208,16 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %7) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %8) + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 + %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 0 + store ptr %8, ptr %11, align 8 + %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 1 + store ptr %9, ptr %12, align 8 + %13 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %13) unreachable _llgo_2: ; preds = %_llgo_0 @@ -181,8 +237,16 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %7) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %8) + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 + %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 0 + store ptr %8, ptr %11, align 8 + %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 1 + store ptr %9, ptr %12, align 8 + %13 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %13) unreachable _llgo_2: ; preds = %_llgo_0 @@ -202,8 +266,16 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %7) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %8) + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 + %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 0 + store ptr %8, ptr %11, align 8 + %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 1 + store ptr %9, ptr %12, align 8 + %13 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %13) unreachable _llgo_2: ; preds = %_llgo_0 @@ -223,8 +295,16 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %7) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %8) + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 + %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 0 + store ptr %8, ptr %11, align 8 + %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 1 + store ptr %9, ptr %12, align 8 + %13 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %13) unreachable _llgo_2: ; preds = %_llgo_0 @@ -244,8 +324,16 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %7) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %8) + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 + %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 0 + store ptr %8, ptr %11, align 8 + %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 1 + store ptr %9, ptr %12, align 8 + %13 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %13) unreachable _llgo_2: ; preds = %_llgo_0 @@ -265,24 +353,40 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %7) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %8) + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 + %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 0 + store ptr %8, ptr %11, align 8 + %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, i32 0, i32 1 + store ptr %9, ptr %12, align 8 + %13 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %13) unreachable _llgo_2: ; preds = %_llgo_0 - %9 = trunc i64 %1 to i32 - %10 = icmp ne i32 %9, %0 - br i1 %10, label %_llgo_3, label %_llgo_4 + %14 = trunc i64 %1 to i32 + %15 = icmp ne i32 %14, %0 + br i1 %15, label %_llgo_3, label %_llgo_4 _llgo_3: ; preds = %_llgo_2 - %11 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %11, i32 0, i32 0 - store ptr @12, ptr %12, align 8 - %13 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %11, i32 0, i32 1 - store i64 5, ptr %13, align 4 - %14 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %11, align 8 - %15 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %14) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %15) + %16 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %17 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %16, i32 0, i32 0 + store ptr @12, ptr %17, align 8 + %18 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %16, i32 0, i32 1 + store i64 5, ptr %18, align 4 + %19 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %16, align 8 + %20 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %21 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %19, ptr %21, align 8 + %22 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %23 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %22, i32 0, i32 0 + store ptr %20, ptr %23, align 8 + %24 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %22, i32 0, i32 1 + store ptr %21, ptr %24, align 8 + %25 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %22, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %25) unreachable _llgo_4: ; preds = %_llgo_2 @@ -366,8 +470,10 @@ _llgo_0: ret i32 0 } -declare %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String") +declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) -declare void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface") +declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) + +declare void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface") declare void @"github.com/goplus/llgo/internal/runtime.init"() diff --git a/cl/_testrt/panic/out.ll b/cl/_testrt/panic/out.ll index f8923d33..362b3bb2 100644 --- a/cl/_testrt/panic/out.ll +++ b/cl/_testrt/panic/out.ll @@ -2,7 +2,7 @@ source_filename = "main" %"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 } -%"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr } +%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr } @"main.init$guard" = global ptr null @__llgo_argc = global ptr null @@ -34,13 +34,23 @@ _llgo_0: %4 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i32 0, i32 1 store i64 13, ptr %4, align 4 %5 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %2, align 8 - %6 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %5) - call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface" %6) + %6 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %5, ptr %7, align 8 + %8 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %8, i32 0, i32 0 + store ptr %6, ptr %9, align 8 + %10 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %8, i32 0, i32 1 + store ptr %7, ptr %10, align 8 + %11 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %8, align 8 + call void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface" %11) unreachable } declare void @"github.com/goplus/llgo/internal/runtime.init"() -declare %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String") +declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) -declare void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.iface") +declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) + +declare void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface") diff --git a/internal/abi/llgo_autogen.lla b/internal/abi/llgo_autogen.lla index 505458a89fc15cdac8298a11db7a0a2e357b38b4..def779e5aea1f92b8df31ea7c8398bb8ebc0ca54 100644 GIT binary patch delta 5255 zcmV;26nN{yDCa3TP)h>@6aWAK2ms|8xLBh_3w$#a000U8000jF8~|)=XK!C&b#!lM zWo|BPY*kbV00W+vPiCK&Pmwtte;OZLN7TDg6iAw;xZtiu(e&;^dqtq^Dr=!@t#4PG zCN1*cPb5W(q_naqapZJQrO6gVG8R;$!lzk1dD@V)v+BLDvi-(;n6KXtnJ?Y>-?R9K*h{1{!~OZ>;%Y>}JPI_}}`Ye^jS@OEET#ch85 zYF#YqHjV8HDZlLj8Tb*ee=4`OeMEnjEL<$6vm+X+w8$S(n8ypNJGFG)Wpz1~ zQchr_XQ9oWMfVrxf2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LMIadQ-#awyH}pi=i(ZFUa%Xc8(?SyGqn!s}qiTY`Hx0pF@_ zwgDwx)o8M#o??| Date: Fri, 24 May 2024 08:23:01 +0800 Subject: [PATCH 12/20] llgo/ssa.Slice optimize speed --- internal/abi/llgo_autogen.lla | Bin 5351 -> 5351 bytes internal/runtime/llgo_autogen.lla | Bin 5744 -> 5745 bytes ssa/datastruct.go | 6 +++++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/abi/llgo_autogen.lla b/internal/abi/llgo_autogen.lla index def779e5aea1f92b8df31ea7c8398bb8ebc0ca54..68590077d52dabc484c7e975af9f4fc6618105a5 100644 GIT binary patch delta 2457 zcmV;K31;@^Dd#CTP)h>@6aWAK2mr4>xLEb_?Eo_r000U8000jF8~|)=XK!C&b#!lM zWo|BPY*kbV00a8gPiFhpu{a(Je=!WrmWO0oNzbq<{EHTaBAuP{-9B~qO1A44+A5dh z6j4f~+_fR-tYE&vaX3(pn8tZ-cijTCAxLQmv;Oi{KDr8_sdAla+w!LD#rdgrxAGsd z63e4*BX9?>$nDE*o-J;&H*1T>V7<=D<1~*G@ud;jAH<6%Jq{sW$(ZZ(e<)cdc?d2c z>URk}Ydh3EfQ^OT;0|@Jk;;-LfOqN*?NIl)jgoh$d&WD|J$dV<@1Fi_?4{F|N9b(q zTieI(1MFk>hxV~QP1#e*=`{c+)gRi%&U`~(-o)-3Z({f5na`ia^qEPcKaHsP)HwQ) zE#J_e=w({;4Slw^#h1;cf1gP;v4#G0tl2< zYK`FN!D^4`8wTirZ)lVmf;djW!~@4fBYti)f^Gx~CT1J#D=L^^(}+)|>CNGH{3fOz zG%FN{`DTi%#(vWlc2*_~LaYHda5T^7n3(hL+oHcF+n;%;xR* z21;xK3YDVBX4hg-e~JRkEJ9j~bOI>EM}R`ISvkb&wb{~CA3jYur-}gYZDP{f_)6+` zSkXz#|^`je-u+Oh>#F_2 zl*O`gvShLm;{TwH>70hppCKZ4WFi^}o$v#SQ8S;k-Z+sAe%h4#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pKh#iq!F|e~mi!{3a{!=~vY4e^=PsugFT)LV7T^Pj-@4cGLtBoqQcu@&JXnDMrcq zFvQIH=|z|xr0F7@^dg*ENjpMsvUPhP_JkBD_~4bClu}L7VI@-uy}}Q6gAYB;;&o9* zomfuy7{Mroi&EPha=!ycrAe}1GxD``Ne z5Ji1R`vTG`vdO`uBxXrMR42p4L7gE$cX&9%6Yx^U#NI%i)bx{+dViE`_F?hdzxJ>g z!Zx3ch{oCocJX~ZT0VD}|6qp0?=c*K5gzvh6HkTaSiJoOn&$Wt%_*YJ-R8>Z*;EjE zCe*}ijR>NG8mxizg8!cee+x8fJ0c#bNHOY_;;BJco$xED*oA*>v7=)$2DEIs1iw4D zF1Om$?=UwN2FWM`_%BtEB2`5$)zf=Du_E)@OdSrTK++mtMKy4;JEnhTw z7RDF$*=nC{m*?Wl-bj`jE9gj?HOXoc`XQ&*tlUlq`gOoaT-#I&8kJD zTnK7aBrKkp?QXXGjkq`B7)eRE?h82jcEpAS9BD$Zb;ZpEZpxJO>d$ug63>_AGJpSL zR<7!4h@=#|WMN0cf9xJEPwsJezAl7o>6&ZW*GVXTD$Px>CDE9#KS5S;4uOeGWirpu`^(q36Ixd`E| zlIikga$kj6%YRl|K3it9Rw$Jp^EO6li%|J&>B+8~Lrt(SA6%aO4^T@10v-bt00008 X0OcCESffP?e3OtAE&`sHlfV=wBWbU+ diff --git a/internal/runtime/llgo_autogen.lla b/internal/runtime/llgo_autogen.lla index d0d0e4d2a2cf3c691f44d546dba4ba6268bf24a9..f358a32c5dfec0f6dd2a6a3b59aaeb23f4d35268 100644 GIT binary patch delta 3409 zcmV-X4X*O=Eb%NjP)h>@6aWAK2mrS}xLAmR2`0T2003m^000jF8~|)=XK!C&b#!lM zWo|BPY*kbV00RowPi70(u{hKNea&Bj`(;MiG_+;YNCKgy*vg;Rm4W&*vQIA}$WjD>=OBV0f4GRCiwL@i zpo<9lG(^x(;XYE_VIswG2H^!O=dw2rNbP+ii$|l;4$mZeq)O00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ZeYangikm*zV3~jt5nF^Q{3xn? zw@cTH8~el*I^R>d1TGlF#jmC82UbeP+u|-G}W$@R>f;Af$yUVSM0?mErFix%-@3ryQgo3Tl%|+pn*kdae8+6oc0#*$=rtFi5 zH0VfpgeXPBB&qK(+&}GDCr?QI1N_5-3AOYIgLtg+fTrSQJhLP1#v&(upX!SC>a1&E z+WL*i-5w`y+A3*L+3J7l8DU6^D^D~zlU#|2Nx?KYoNMb6WvK+qP-1^w4oX^MQG3wfd}fkw?|5%t4(ls>Oii7b zFH@QYx59ggU+ZUDk7|1~b5_5zceT0k Date: Fri, 24 May 2024 09:20:58 +0800 Subject: [PATCH 13/20] llgo/ssa.Phi: AddIncoming fix --- cl/_testdata/print/out.ll | 426 ++++++++++++++++++---------------- cl/_testdata/vargs/out.ll | 15 +- cl/_testrt/builtin/out.ll | 471 ++++++++++++++++++++------------------ cl/_testrt/concat/out.ll | 25 +- cl/_testrt/sum/out.ll | 15 +- cl/compile.go | 4 +- ssa/decl.go | 6 +- ssa/expr.go | 20 +- ssa/interface.go | 10 +- ssa/package.go | 4 +- ssa/ssa_test.go | 2 +- ssa/stmt_builder.go | 27 ++- 12 files changed, 555 insertions(+), 470 deletions(-) diff --git a/cl/_testdata/print/out.ll b/cl/_testdata/print/out.ll index 3288ef27..4b2285c6 100644 --- a/cl/_testdata/print/out.ll +++ b/cl/_testdata/print/out.ll @@ -151,204 +151,225 @@ _llgo_1: ; preds = %_llgo_3 store ptr inttoptr (i64 -1 to ptr), ptr %32, align 8 %33 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %30, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %33, ptr %28, align 8 - %34 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %16, i64 16, i64 2, i64 0, i64 2, i64 2) - call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %34) + %34 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %35 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %34, i32 0, i32 0 + store ptr %16, ptr %35, align 8 + %36 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %34, i32 0, i32 1 + store i64 2, ptr %36, align 4 + %37 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %34, i32 0, i32 2 + store i64 2, ptr %37, align 4 + %38 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %34, align 8 + call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %38) br label %_llgo_2 _llgo_2: ; preds = %_llgo_3, %_llgo_1, %_llgo_0 - %35 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 48) - %36 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %35, i64 0 - %37 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %38 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %37, i32 0, i32 0 - store ptr @3, ptr %38, align 8 - %39 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %37, i32 0, i32 1 - store i64 8, ptr %39, align 4 - %40 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %37, align 8 - %41 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) - %42 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) - store %"github.com/goplus/llgo/internal/runtime.String" %40, ptr %42, align 8 - %43 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %44 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %43, i32 0, i32 0 - store ptr %41, ptr %44, align 8 - %45 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %43, i32 0, i32 1 - store ptr %42, ptr %45, align 8 - %46 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %43, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %46, ptr %36, align 8 - %47 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %35, i64 1 - %48 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) - %49 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %50 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %49, i32 0, i32 0 - store ptr %48, ptr %50, align 8 - %51 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %49, i32 0, i32 1 - store ptr inttoptr (i64 -1 to ptr), ptr %51, align 8 - %52 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %49, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %52, ptr %47, align 8 - %53 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %35, i64 2 - %54 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) - %55 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %56 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %55, i32 0, i32 0 - store ptr %54, ptr %56, align 8 - %57 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %55, i32 0, i32 1 - store ptr inttoptr (i64 -1 to ptr), ptr %57, align 8 - %58 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %55, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %58, ptr %53, align 8 - %59 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %35, i64 16, i64 3, i64 0, i64 3, i64 3) - call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %59) - %60 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 256) - %61 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 0 - %62 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) - %63 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %64 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %63, i32 0, i32 0 - store ptr %62, ptr %64, align 8 - %65 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %63, i32 0, i32 1 - store ptr inttoptr (i64 -1 to ptr), ptr %65, align 8 - %66 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %63, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %66, ptr %61, align 8 - %67 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 1 - %68 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) - %69 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %70 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %69, i32 0, i32 0 - store ptr %68, ptr %70, align 8 - %71 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %69, i32 0, i32 1 - store ptr null, ptr %71, align 8 - %72 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %69, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %72, ptr %67, align 8 - %73 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 2 - %74 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) - %75 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %76 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %75, i32 0, i32 0 - store ptr %74, ptr %76, align 8 - %77 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %75, i32 0, i32 1 - store ptr inttoptr (i64 97 to ptr), ptr %77, align 8 - %78 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %75, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %78, ptr %73, align 8 - %79 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 3 - %80 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) - %81 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %82 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %81, i32 0, i32 0 - store ptr %80, ptr %82, align 8 - %83 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %81, i32 0, i32 1 - store ptr inttoptr (i64 65 to ptr), ptr %83, align 8 - %84 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %81, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %84, ptr %79, align 8 - %85 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 4 - %86 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) - %87 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %88 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %87, i32 0, i32 0 - store ptr %86, ptr %88, align 8 - %89 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %87, i32 0, i32 1 - store ptr inttoptr (i64 20013 to ptr), ptr %89, align 8 - %90 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %87, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %90, ptr %85, align 8 - %91 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 5 - %92 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3) - %93 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %94 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %93, i32 0, i32 0 - store ptr %92, ptr %94, align 8 - %95 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %93, i32 0, i32 1 - store ptr inttoptr (i64 1 to ptr), ptr %95, align 8 - %96 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %93, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %96, ptr %91, align 8 - %97 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 6 - %98 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4) - %99 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %100 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %99, i32 0, i32 0 - store ptr %98, ptr %100, align 8 - %101 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %99, i32 0, i32 1 - store ptr inttoptr (i64 2 to ptr), ptr %101, align 8 - %102 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %99, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %102, ptr %97, align 8 - %103 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 7 - %104 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) - %105 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %106 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %105, i32 0, i32 0 - store ptr %104, ptr %106, align 8 - %107 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %105, i32 0, i32 1 - store ptr inttoptr (i64 3 to ptr), ptr %107, align 8 - %108 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %105, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %108, ptr %103, align 8 - %109 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 8 - %110 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) - %111 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %112 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %111, i32 0, i32 0 - store ptr %110, ptr %112, align 8 - %113 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %111, i32 0, i32 1 - store ptr inttoptr (i64 4 to ptr), ptr %113, align 8 - %114 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %111, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %114, ptr %109, align 8 - %115 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 9 - %116 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %117 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %118 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %117, i32 0, i32 0 - store ptr %116, ptr %118, align 8 - %119 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %117, i32 0, i32 1 - store ptr inttoptr (i64 5 to ptr), ptr %119, align 8 - %120 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %117, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %120, ptr %115, align 8 - %121 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 10 - %122 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8) - %123 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %124 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %123, i32 0, i32 0 - store ptr %122, ptr %124, align 8 - %125 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %123, i32 0, i32 1 - store ptr inttoptr (i64 1 to ptr), ptr %125, align 8 - %126 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %123, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %126, ptr %121, align 8 - %127 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 11 - %128 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9) - %129 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %130 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %129, i32 0, i32 0 - store ptr %128, ptr %130, align 8 - %131 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %129, i32 0, i32 1 - store ptr inttoptr (i64 2 to ptr), ptr %131, align 8 - %132 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %129, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %132, ptr %127, align 8 - %133 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 12 - %134 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10) - %135 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %136 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %135, i32 0, i32 0 - store ptr %134, ptr %136, align 8 - %137 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %135, i32 0, i32 1 - store ptr inttoptr (i64 3 to ptr), ptr %137, align 8 - %138 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %135, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %138, ptr %133, align 8 - %139 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 13 - %140 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11) - %141 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %142 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %141, i32 0, i32 0 - store ptr %140, ptr %142, align 8 - %143 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %141, i32 0, i32 1 - store ptr inttoptr (i64 4 to ptr), ptr %143, align 8 - %144 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %141, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %144, ptr %139, align 8 - %145 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 14 - %146 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12) - %147 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %148 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %147, i32 0, i32 0 - store ptr %146, ptr %148, align 8 - %149 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %147, i32 0, i32 1 - store ptr inttoptr (i64 5 to ptr), ptr %149, align 8 - %150 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %147, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %150, ptr %145, align 8 - %151 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %60, i64 15 - %152 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %153 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %152, i32 0, i32 0 - store ptr @4, ptr %153, align 8 - %154 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %152, i32 0, i32 1 - store i64 4, ptr %154, align 4 - %155 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %152, align 8 - %156 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) - %157 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) - store %"github.com/goplus/llgo/internal/runtime.String" %155, ptr %157, align 8 - %158 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %159 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %158, i32 0, i32 0 - store ptr %156, ptr %159, align 8 - %160 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %158, i32 0, i32 1 - store ptr %157, ptr %160, align 8 - %161 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %158, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %161, ptr %151, align 8 - %162 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %60, i64 16, i64 16, i64 0, i64 16, i64 16) - call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %162) + %39 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 48) + %40 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %39, i64 0 + %41 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %42 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %41, i32 0, i32 0 + store ptr @3, ptr %42, align 8 + %43 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %41, i32 0, i32 1 + store i64 8, ptr %43, align 4 + %44 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %41, align 8 + %45 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %46 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %44, ptr %46, align 8 + %47 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %48 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %47, i32 0, i32 0 + store ptr %45, ptr %48, align 8 + %49 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %47, i32 0, i32 1 + store ptr %46, ptr %49, align 8 + %50 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %47, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %50, ptr %40, align 8 + %51 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %39, i64 1 + %52 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %53 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %54 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %53, i32 0, i32 0 + store ptr %52, ptr %54, align 8 + %55 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %53, i32 0, i32 1 + store ptr inttoptr (i64 -1 to ptr), ptr %55, align 8 + %56 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %53, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %56, ptr %51, align 8 + %57 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %39, i64 2 + %58 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %59 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %60 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %59, i32 0, i32 0 + store ptr %58, ptr %60, align 8 + %61 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %59, i32 0, i32 1 + store ptr inttoptr (i64 -1 to ptr), ptr %61, align 8 + %62 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %59, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %62, ptr %57, align 8 + %63 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %64 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %63, i32 0, i32 0 + store ptr %39, ptr %64, align 8 + %65 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %63, i32 0, i32 1 + store i64 3, ptr %65, align 4 + %66 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %63, i32 0, i32 2 + store i64 3, ptr %66, align 4 + %67 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %63, align 8 + call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %67) + %68 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 256) + %69 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 0 + %70 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %71 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %72 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %71, i32 0, i32 0 + store ptr %70, ptr %72, align 8 + %73 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %71, i32 0, i32 1 + store ptr inttoptr (i64 -1 to ptr), ptr %73, align 8 + %74 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %71, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %74, ptr %69, align 8 + %75 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 1 + %76 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %77 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %78 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %77, i32 0, i32 0 + store ptr %76, ptr %78, align 8 + %79 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %77, i32 0, i32 1 + store ptr null, ptr %79, align 8 + %80 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %77, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %80, ptr %75, align 8 + %81 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 2 + %82 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %83 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %84 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %83, i32 0, i32 0 + store ptr %82, ptr %84, align 8 + %85 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %83, i32 0, i32 1 + store ptr inttoptr (i64 97 to ptr), ptr %85, align 8 + %86 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %83, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %86, ptr %81, align 8 + %87 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 3 + %88 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %89 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %90 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %89, i32 0, i32 0 + store ptr %88, ptr %90, align 8 + %91 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %89, i32 0, i32 1 + store ptr inttoptr (i64 65 to ptr), ptr %91, align 8 + %92 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %89, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %92, ptr %87, align 8 + %93 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 4 + %94 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %95 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %96 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %95, i32 0, i32 0 + store ptr %94, ptr %96, align 8 + %97 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %95, i32 0, i32 1 + store ptr inttoptr (i64 20013 to ptr), ptr %97, align 8 + %98 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %95, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %98, ptr %93, align 8 + %99 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 5 + %100 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3) + %101 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %102 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %101, i32 0, i32 0 + store ptr %100, ptr %102, align 8 + %103 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %101, i32 0, i32 1 + store ptr inttoptr (i64 1 to ptr), ptr %103, align 8 + %104 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %101, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %104, ptr %99, align 8 + %105 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 6 + %106 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4) + %107 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %108 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %107, i32 0, i32 0 + store ptr %106, ptr %108, align 8 + %109 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %107, i32 0, i32 1 + store ptr inttoptr (i64 2 to ptr), ptr %109, align 8 + %110 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %107, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %110, ptr %105, align 8 + %111 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 7 + %112 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %113 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %114 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %113, i32 0, i32 0 + store ptr %112, ptr %114, align 8 + %115 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %113, i32 0, i32 1 + store ptr inttoptr (i64 3 to ptr), ptr %115, align 8 + %116 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %113, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %116, ptr %111, align 8 + %117 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 8 + %118 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) + %119 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %120 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %119, i32 0, i32 0 + store ptr %118, ptr %120, align 8 + %121 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %119, i32 0, i32 1 + store ptr inttoptr (i64 4 to ptr), ptr %121, align 8 + %122 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %119, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %122, ptr %117, align 8 + %123 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 9 + %124 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %125 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %126 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %125, i32 0, i32 0 + store ptr %124, ptr %126, align 8 + %127 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %125, i32 0, i32 1 + store ptr inttoptr (i64 5 to ptr), ptr %127, align 8 + %128 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %125, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %128, ptr %123, align 8 + %129 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 10 + %130 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8) + %131 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %132 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %131, i32 0, i32 0 + store ptr %130, ptr %132, align 8 + %133 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %131, i32 0, i32 1 + store ptr inttoptr (i64 1 to ptr), ptr %133, align 8 + %134 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %131, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %134, ptr %129, align 8 + %135 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 11 + %136 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9) + %137 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %138 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %137, i32 0, i32 0 + store ptr %136, ptr %138, align 8 + %139 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %137, i32 0, i32 1 + store ptr inttoptr (i64 2 to ptr), ptr %139, align 8 + %140 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %137, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %140, ptr %135, align 8 + %141 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 12 + %142 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10) + %143 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %144 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %143, i32 0, i32 0 + store ptr %142, ptr %144, align 8 + %145 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %143, i32 0, i32 1 + store ptr inttoptr (i64 3 to ptr), ptr %145, align 8 + %146 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %143, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %146, ptr %141, align 8 + %147 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 13 + %148 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11) + %149 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %150 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %149, i32 0, i32 0 + store ptr %148, ptr %150, align 8 + %151 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %149, i32 0, i32 1 + store ptr inttoptr (i64 4 to ptr), ptr %151, align 8 + %152 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %149, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %152, ptr %147, align 8 + %153 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 14 + %154 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12) + %155 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %156 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %155, i32 0, i32 0 + store ptr %154, ptr %156, align 8 + %157 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %155, i32 0, i32 1 + store ptr inttoptr (i64 5 to ptr), ptr %157, align 8 + %158 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %155, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %158, ptr %153, align 8 + %159 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 15 + %160 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %161 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %160, i32 0, i32 0 + store ptr @4, ptr %161, align 8 + %162 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %160, i32 0, i32 1 + store i64 4, ptr %162, align 4 + %163 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %160, align 8 + %164 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %165 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) + store %"github.com/goplus/llgo/internal/runtime.String" %163, ptr %165, align 8 + %166 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %167 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %166, i32 0, i32 0 + store ptr %164, ptr %167, align 8 + %168 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %166, i32 0, i32 1 + store ptr %165, ptr %168, align 8 + %169 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %166, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %169, ptr %159, align 8 + %170 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %171 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %170, i32 0, i32 0 + store ptr %68, ptr %171, align 8 + %172 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %170, i32 0, i32 1 + store i64 16, ptr %172, align 4 + %173 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %170, i32 0, i32 2 + store i64 16, ptr %173, align 4 + %174 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %170, align 8 + call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %174) ret i32 0 _llgo_3: ; preds = %_llgo_0 @@ -1021,8 +1042,15 @@ _llgo_29: ; preds = %_llgo_28, %_llgo_26 %86 = add i8 %85, 48 %87 = getelementptr inbounds i8, ptr %20, i64 13 store i8 %86, ptr %87, align 1 - %88 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %20, i64 1, i64 14, i64 0, i64 14, i64 14) - call void @main.gwrite(%"github.com/goplus/llgo/internal/runtime.Slice" %88) + %88 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %89 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %88, i32 0, i32 0 + store ptr %20, ptr %89, align 8 + %90 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %88, i32 0, i32 1 + store i64 14, ptr %90, align 4 + %91 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %88, i32 0, i32 2 + store i64 14, ptr %91, align 4 + %92 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %88, align 8 + call void @main.gwrite(%"github.com/goplus/llgo/internal/runtime.Slice" %92) ret void } @@ -1236,6 +1264,6 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) -declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr, i64, i64, i64, i64, i64) - declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1) + +declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr, i64, i64, i64, i64, i64) diff --git a/cl/_testdata/vargs/out.ll b/cl/_testdata/vargs/out.ll index dbb7eda8..9d9d841e 100644 --- a/cl/_testdata/vargs/out.ll +++ b/cl/_testdata/vargs/out.ll @@ -58,8 +58,15 @@ _llgo_0: store ptr inttoptr (i64 3 to ptr), ptr %19, align 8 %20 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %17, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %20, ptr %15, align 8 - %21 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %2, i64 16, i64 3, i64 0, i64 3, i64 3) - call void @main.test(%"github.com/goplus/llgo/internal/runtime.Slice" %21) + %21 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %22 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %21, i32 0, i32 0 + store ptr %2, ptr %22, align 8 + %23 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %21, i32 0, i32 1 + store i64 3, ptr %23, align 4 + %24 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %21, i32 0, i32 2 + store i64 3, ptr %24, align 4 + %25 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %21, align 8 + call void @main.test(%"github.com/goplus/llgo/internal/runtime.Slice" %25) ret i32 0 } @@ -69,7 +76,7 @@ _llgo_0: br label %_llgo_1 _llgo_1: ; preds = %_llgo_4, %_llgo_0 - %2 = phi i64 [ -1, %_llgo_0 ], [ %3, %_llgo_2 ] + %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 @@ -111,8 +118,6 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64) declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) -declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr, i64, i64, i64, i64, i64) - declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1) declare void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface") diff --git a/cl/_testrt/builtin/out.ll b/cl/_testrt/builtin/out.ll index 9ff25dda..d6c806f3 100644 --- a/cl/_testrt/builtin/out.ll +++ b/cl/_testrt/builtin/out.ll @@ -55,33 +55,40 @@ _llgo_0: store i64 3, ptr %5, align 4 %6 = getelementptr inbounds i64, ptr %2, i64 3 store i64 4, ptr %6, align 4 - %7 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %2, i64 8, i64 4, i64 0, i64 4, i64 4) - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32) - %9 = getelementptr inbounds i64, ptr %8, i64 0 - %10 = getelementptr inbounds i64, ptr %8, i64 1 - %11 = getelementptr inbounds i64, ptr %8, i64 2 - %12 = getelementptr inbounds i64, ptr %8, i64 3 - store i64 1, ptr %9, align 4 - store i64 2, ptr %10, align 4 - store i64 3, ptr %11, align 4 - store i64 4, ptr %12, align 4 - %13 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 10) - %14 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %13, i64 1, i64 10, i64 0, i64 4, i64 10) - %15 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 1 - %16 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 2 - call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %7) + %7 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %8 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %7, i32 0, i32 0 + store ptr %2, ptr %8, align 8 + %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %7, i32 0, i32 1 + store i64 4, ptr %9, align 4 + %10 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %7, i32 0, i32 2 + store i64 4, ptr %10, align 4 + %11 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %7, align 8 + %12 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32) + %13 = getelementptr inbounds i64, ptr %12, i64 0 + %14 = getelementptr inbounds i64, ptr %12, i64 1 + %15 = getelementptr inbounds i64, ptr %12, i64 2 + %16 = getelementptr inbounds i64, ptr %12, i64 3 + store i64 1, ptr %13, align 4 + store i64 2, ptr %14, align 4 + store i64 3, ptr %15, align 4 + store i64 4, ptr %16, align 4 + %17 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 10) + %18 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %17, i64 1, i64 10, i64 0, i64 4, i64 10) + %19 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 1 + %20 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 2 + call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %11) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %15) + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %19) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %16) + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %20) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) - %17 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %14, 1 - %18 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %14, 2 - call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %14) + %21 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %18, 1 + %22 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %18, 2 + call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %18) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %17) + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %21) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %18) + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %22) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 4) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) @@ -91,166 +98,187 @@ _llgo_0: 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) - %19 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32) - %20 = getelementptr inbounds i64, ptr %19, i64 0 - store i64 1, ptr %20, align 4 - %21 = getelementptr inbounds i64, ptr %19, i64 1 - store i64 2, ptr %21, align 4 - %22 = getelementptr inbounds i64, ptr %19, i64 2 - store i64 3, ptr %22, align 4 - %23 = getelementptr inbounds i64, ptr %19, i64 3 - store i64 4, ptr %23, align 4 - %24 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %19, i64 8, i64 4, i64 0, i64 4, i64 4) - %25 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %24, 1 - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %25) + %23 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32) + %24 = getelementptr inbounds i64, ptr %23, i64 0 + store i64 1, ptr %24, align 4 + %25 = getelementptr inbounds i64, ptr %23, i64 1 + store i64 2, ptr %25, align 4 + %26 = getelementptr inbounds i64, ptr %23, i64 2 + store i64 3, ptr %26, align 4 + %27 = getelementptr inbounds i64, ptr %23, i64 3 + store i64 4, ptr %27, align 4 + %28 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %29 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %28, i32 0, i32 0 + store ptr %23, ptr %29, align 8 + %30 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %28, i32 0, i32 1 + store i64 4, ptr %30, align 4 + %31 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %28, i32 0, i32 2 + store i64 4, ptr %31, align 4 + %32 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %28, align 8 + %33 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %32, 1 + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %33) 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) - %26 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 2 - %27 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 2 - %28 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 0 - %29 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %28, i64 8, i64 %26, i64 1, i64 %27, i64 %26) - %30 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %29, 1 - %31 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 2 - %32 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 2 - %33 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 0 - %34 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %33, i64 8, i64 %31, i64 1, i64 %32, i64 %31) - %35 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %34, 2 - %36 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 2 - %37 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 0 - %38 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %37, i64 8, i64 %36, i64 1, i64 2, i64 %36) - %39 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %38, 1 - %40 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 2 - %41 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 0 - %42 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %41, i64 8, i64 %40, i64 1, i64 2, i64 %40) + %34 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 2 + %35 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 2 + %36 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 0 + %37 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %36, i64 32, i64 %34, i64 1, i64 %35, i64 %34) + %38 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %37, 1 + %39 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 2 + %40 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 2 + %41 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 0 + %42 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %41, i64 32, i64 %39, i64 1, i64 %40, i64 %39) %43 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %42, 2 - %44 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 2 - %45 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 0 - %46 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %45, i64 8, i64 %44, i64 1, i64 2, i64 2) + %44 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 2 + %45 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 0 + %46 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %45, i64 32, i64 %44, i64 1, i64 2, i64 %44) %47 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %46, 1 - %48 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 2 - %49 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %7, 0 - %50 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %49, i64 8, i64 %48, i64 1, i64 2, i64 2) + %48 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 2 + %49 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 0 + %50 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %49, i64 32, i64 %48, i64 1, i64 2, i64 %48) %51 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %50, 2 - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %30) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %35) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %39) + %52 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 2 + %53 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 0 + %54 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %53, i64 32, i64 %52, i64 1, i64 2, i64 2) + %55 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %54, 1 + %56 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 2 + %57 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %11, 0 + %58 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %57, i64 32, i64 %56, i64 1, i64 2, i64 2) + %59 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %58, 2 + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %38) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %43) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %47) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %51) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) - %52 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %8, i64 8, i64 4, i64 1, i64 4, i64 4) - %53 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %52, 1 - %54 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %8, i64 8, i64 4, i64 1, i64 4, i64 4) - %55 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %54, 2 - %56 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %8, i64 8, i64 4, i64 1, i64 2, i64 4) - %57 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %56, 1 - %58 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %8, i64 8, i64 4, i64 1, i64 2, i64 4) - %59 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %58, 2 - %60 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %8, i64 8, i64 4, i64 1, i64 2, i64 2) - %61 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %60, 1 - %62 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %8, i64 8, i64 4, i64 1, i64 2, i64 2) - %63 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %62, 2 - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %53) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %55) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %57) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %59) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) + %60 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %12, i64 8, i64 4, i64 1, i64 4, i64 4) + %61 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %60, 1 + %62 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %12, i64 8, i64 4, i64 1, i64 4, i64 4) + %63 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %62, 2 + %64 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %12, i64 8, i64 4, i64 1, i64 2, i64 4) + %65 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %64, 1 + %66 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %12, i64 8, i64 4, i64 1, i64 2, i64 4) + %67 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %66, 2 + %68 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %12, i64 8, i64 4, i64 1, i64 2, i64 2) + %69 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %68, 1 + %70 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %12, i64 8, i64 4, i64 1, i64 2, i64 2) + %71 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %70, 2 call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %61) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %63) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) - %64 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %65 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %64, i32 0, i32 0 - store ptr @0, ptr %65, align 8 - %66 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %64, i32 0, i32 1 - store i64 5, ptr %66, align 4 - %67 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %64, align 8 - %68 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %67, 1 - %69 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewStringSlice"(%"github.com/goplus/llgo/internal/runtime.String" %67, i64 1, i64 %68) - %70 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %71 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %70, i32 0, i32 0 - store ptr @1, ptr %71, align 8 - %72 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %70, i32 0, i32 1 - store i64 5, ptr %72, align 4 - %73 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %70, align 8 - %74 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewStringSlice"(%"github.com/goplus/llgo/internal/runtime.String" %73, i64 1, i64 2) - %75 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %76 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %75, i32 0, i32 0 - store ptr @2, ptr %76, align 8 - %77 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %75, i32 0, i32 1 - store i64 5, ptr %77, align 4 - %78 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %75, align 8 - %79 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %78, 1 - %80 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewStringSlice"(%"github.com/goplus/llgo/internal/runtime.String" %78, i64 5, i64 %79) - %81 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %80, 1 - %82 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %83 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %82, i32 0, i32 0 - store ptr @3, ptr %83, align 8 - %84 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %82, i32 0, i32 1 - store i64 5, ptr %84, align 4 - %85 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %82, align 8 - call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %85) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %69) + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %65) 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" %74) + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %67) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %81) + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %69) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %71) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) - %86 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32) - %87 = getelementptr inbounds i64, ptr %86, i64 0 - store i64 5, ptr %87, align 4 - %88 = getelementptr inbounds i64, ptr %86, i64 1 - store i64 6, ptr %88, align 4 - %89 = getelementptr inbounds i64, ptr %86, i64 2 - store i64 7, ptr %89, align 4 - %90 = getelementptr inbounds i64, ptr %86, i64 3 - store i64 8, ptr %90, align 4 - %91 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %86, i64 8, i64 4, i64 0, i64 4, i64 4) - %92 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %91, 0 - %93 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %91, 1 - %94 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.SliceAppend"(%"github.com/goplus/llgo/internal/runtime.Slice" %7, ptr %92, i64 %93, i64 8) - call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %94) + %72 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %73 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %72, i32 0, i32 0 + store ptr @0, ptr %73, align 8 + %74 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %72, i32 0, i32 1 + store i64 5, ptr %74, align 4 + %75 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %72, align 8 + %76 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %75, 1 + %77 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewStringSlice"(%"github.com/goplus/llgo/internal/runtime.String" %75, i64 1, i64 %76) + %78 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %79 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %78, i32 0, i32 0 + store ptr @1, ptr %79, align 8 + %80 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %78, i32 0, i32 1 + store i64 5, ptr %80, align 4 + %81 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %78, align 8 + %82 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewStringSlice"(%"github.com/goplus/llgo/internal/runtime.String" %81, i64 1, i64 2) + %83 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %84 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %83, i32 0, i32 0 + store ptr @2, ptr %84, align 8 + %85 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %83, i32 0, i32 1 + store i64 5, ptr %85, align 4 + %86 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %83, align 8 + %87 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %86, 1 + %88 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewStringSlice"(%"github.com/goplus/llgo/internal/runtime.String" %86, i64 5, i64 %87) + %89 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %88, 1 + %90 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %91 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %90, i32 0, i32 0 + store ptr @3, ptr %91, align 8 + %92 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %90, i32 0, i32 1 + store i64 5, ptr %92, align 4 + %93 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %90, align 8 + call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %93) + 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" %77) + 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" %82) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %89) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) - %95 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 3) - %96 = getelementptr inbounds i8, ptr %95, i64 0 - store i8 97, ptr %96, align 1 - %97 = getelementptr inbounds i8, ptr %95, i64 1 - store i8 98, ptr %97, align 1 - %98 = getelementptr inbounds i8, ptr %95, i64 2 - store i8 99, ptr %98, align 1 - %99 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %95, i64 1, i64 3, i64 0, i64 3, i64 3) - %100 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %101 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %100, i32 0, i32 0 - store ptr @4, ptr %101, align 8 - %102 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %100, i32 0, i32 1 - store i64 3, ptr %102, align 4 - %103 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %100, align 8 - %104 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %103, 0 - %105 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %103, 1 - %106 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.SliceAppend"(%"github.com/goplus/llgo/internal/runtime.Slice" %99, ptr %104, i64 %105, i64 1) + %94 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32) + %95 = getelementptr inbounds i64, ptr %94, i64 0 + store i64 5, ptr %95, align 4 + %96 = getelementptr inbounds i64, ptr %94, i64 1 + store i64 6, ptr %96, align 4 + %97 = getelementptr inbounds i64, ptr %94, i64 2 + store i64 7, ptr %97, align 4 + %98 = getelementptr inbounds i64, ptr %94, i64 3 + store i64 8, ptr %98, align 4 + %99 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %100 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %99, i32 0, i32 0 + store ptr %94, ptr %100, align 8 + %101 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %99, i32 0, i32 1 + store i64 4, ptr %101, align 4 + %102 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %99, i32 0, i32 2 + store i64 4, ptr %102, align 4 + %103 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %99, align 8 + %104 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %103, 0 + %105 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %103, 1 + %106 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.SliceAppend"(%"github.com/goplus/llgo/internal/runtime.Slice" %11, ptr %104, i64 %105, i64 32) call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %106) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) - %107 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16) - %108 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %109 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %110 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %109, i32 0, i32 0 - store ptr %108, ptr %110, align 8 - %111 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %109, i32 0, i32 1 - store ptr inttoptr (i64 100 to ptr), ptr %111, align 8 - %112 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %109, align 8 - store %"github.com/goplus/llgo/internal/runtime.eface" %112, ptr %107, align 8 - %113 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %107, align 8 - %114 = ptrtoint ptr %107 to i64 + %107 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 3) + %108 = getelementptr inbounds i8, ptr %107, i64 0 + store i8 97, ptr %108, align 1 + %109 = getelementptr inbounds i8, ptr %107, i64 1 + store i8 98, ptr %109, align 1 + %110 = getelementptr inbounds i8, ptr %107, i64 2 + store i8 99, ptr %110, align 1 + %111 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %112 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %111, i32 0, i32 0 + store ptr %107, ptr %112, align 8 + %113 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %111, i32 0, i32 1 + store i64 3, ptr %113, align 4 + %114 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %111, i32 0, i32 2 + store i64 3, ptr %114, align 4 + %115 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %111, align 8 + %116 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %117 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %116, i32 0, i32 0 + store ptr @4, ptr %117, align 8 + %118 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %116, i32 0, i32 1 + store i64 3, ptr %118, align 4 + %119 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %116, align 8 + %120 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %119, 0 + %121 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %119, 1 + %122 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.SliceAppend"(%"github.com/goplus/llgo/internal/runtime.Slice" %115, ptr %120, i64 %121, i64 1) + call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %122) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) + %123 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16) + %124 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %125 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %126 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %125, i32 0, i32 0 + store ptr %124, ptr %126, align 8 + %127 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %125, i32 0, i32 1 + store ptr inttoptr (i64 100 to ptr), ptr %127, align 8 + %128 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %125, align 8 + store %"github.com/goplus/llgo/internal/runtime.eface" %128, ptr %123, align 8 + %129 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %123, align 8 + %130 = ptrtoint ptr %123 to i64 call void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1 true) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 0) @@ -267,83 +295,90 @@ _llgo_0: call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double 1.005000e+02) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintEface"(%"github.com/goplus/llgo/internal/runtime.eface" %113) + call void @"github.com/goplus/llgo/internal/runtime.PrintEface"(%"github.com/goplus/llgo/internal/runtime.eface" %129) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %107) + call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %123) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %114) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) - %115 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 3) - %116 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8) - %117 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %115, i64 1, i64 3, i64 0, i64 3, i64 3) - %118 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %106, 0 - %119 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %106, 1 - %120 = call i64 @"github.com/goplus/llgo/internal/runtime.SliceCopy"(%"github.com/goplus/llgo/internal/runtime.Slice" %117, ptr %118, i64 %119, i64 1) - store i64 %120, ptr %116, align 4 - %121 = load i64, ptr %116, align 4 - %122 = getelementptr inbounds i8, ptr %115, i64 0 - %123 = load i8, ptr %122, align 1 - %124 = getelementptr inbounds i8, ptr %115, i64 1 - %125 = load i8, ptr %124, align 1 - %126 = getelementptr inbounds i8, ptr %115, i64 2 - %127 = load i8, ptr %126, align 1 - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %121) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %128 = zext i8 %123 to i64 - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %128) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %129 = zext i8 %125 to i64 - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %129) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %130 = zext i8 %127 to i64 call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %130) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) - %131 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %115, i64 1, i64 3, i64 1, i64 3, i64 3) - %132 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %133 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %132, i32 0, i32 0 - store ptr @5, ptr %133, align 8 - %134 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %132, i32 0, i32 1 - store i64 4, ptr %134, align 4 - %135 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %132, align 8 - %136 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %135, 0 - %137 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %135, 1 - %138 = call i64 @"github.com/goplus/llgo/internal/runtime.SliceCopy"(%"github.com/goplus/llgo/internal/runtime.Slice" %131, ptr %136, i64 %137, i64 1) - store i64 %138, ptr %116, align 4 - %139 = load i64, ptr %116, align 4 - %140 = getelementptr inbounds i8, ptr %115, i64 0 - %141 = load i8, ptr %140, align 1 - %142 = getelementptr inbounds i8, ptr %115, i64 1 + %131 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 3) + %132 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8) + %133 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %134 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %133, i32 0, i32 0 + store ptr %131, ptr %134, align 8 + %135 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %133, i32 0, i32 1 + store i64 3, ptr %135, align 4 + %136 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %133, i32 0, i32 2 + store i64 3, ptr %136, align 4 + %137 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %133, align 8 + %138 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %122, 0 + %139 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %122, 1 + %140 = call i64 @"github.com/goplus/llgo/internal/runtime.SliceCopy"(%"github.com/goplus/llgo/internal/runtime.Slice" %137, ptr %138, i64 %139, i64 3) + store i64 %140, ptr %132, align 4 + %141 = load i64, ptr %132, align 4 + %142 = getelementptr inbounds i8, ptr %131, i64 0 %143 = load i8, ptr %142, align 1 - %144 = getelementptr inbounds i8, ptr %115, i64 2 + %144 = getelementptr inbounds i8, ptr %131, i64 1 %145 = load i8, ptr %144, align 1 - call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %139) + %146 = getelementptr inbounds i8, ptr %131, i64 2 + %147 = load i8, ptr %146, align 1 + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %141) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %146 = zext i8 %141 to i64 - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %146) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %147 = zext i8 %143 to i64 - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %147) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %148 = zext i8 %145 to i64 + %148 = zext i8 %143 to i64 call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %148) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) + %149 = zext i8 %145 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %149) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) + %150 = zext i8 %147 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %150) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) - %149 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) - %150 = getelementptr inbounds { ptr }, ptr %149, i32 0, i32 0 - store ptr %116, ptr %150, align 8 - %151 = alloca { ptr, ptr }, align 8 - %152 = getelementptr inbounds { ptr, ptr }, ptr %151, i32 0, i32 0 - store ptr @"main.main$2", ptr %152, align 8 - %153 = getelementptr inbounds { ptr, ptr }, ptr %151, i32 0, i32 1 - store ptr %149, ptr %153, align 8 - %154 = load { ptr, ptr }, ptr %151, align 8 + %151 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %131, i64 1, i64 3, i64 1, i64 3, i64 3) + %152 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %153 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %152, i32 0, i32 0 + store ptr @5, ptr %153, align 8 + %154 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %152, i32 0, i32 1 + store i64 4, ptr %154, align 4 + %155 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %152, align 8 + %156 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %155, 0 + %157 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %155, 1 + %158 = call i64 @"github.com/goplus/llgo/internal/runtime.SliceCopy"(%"github.com/goplus/llgo/internal/runtime.Slice" %151, ptr %156, i64 %157, i64 1) + store i64 %158, ptr %132, align 4 + %159 = load i64, ptr %132, align 4 + %160 = getelementptr inbounds i8, ptr %131, i64 0 + %161 = load i8, ptr %160, align 1 + %162 = getelementptr inbounds i8, ptr %131, i64 1 + %163 = load i8, ptr %162, align 1 + %164 = getelementptr inbounds i8, ptr %131, i64 2 + %165 = load i8, ptr %164, align 1 + call void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64 %159) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) + %166 = zext i8 %161 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %166) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) + %167 = zext i8 %163 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %167) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) + %168 = zext i8 %165 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %168) + call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) + %169 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) + %170 = getelementptr inbounds { ptr }, ptr %169, i32 0, i32 0 + store ptr %132, ptr %170, align 8 + %171 = alloca { ptr, ptr }, align 8 + %172 = getelementptr inbounds { ptr, ptr }, ptr %171, i32 0, i32 0 + store ptr @"main.main$2", ptr %172, align 8 + %173 = getelementptr inbounds { ptr, ptr }, ptr %171, i32 0, i32 1 + store ptr %169, ptr %173, align 8 + %174 = load { ptr, ptr }, ptr %171, align 8 call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr @main.demo) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr @main.demo) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr @"main.main$1") call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %155 = extractvalue { ptr, ptr } %154, 0 - call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %155) + %175 = extractvalue { ptr, ptr } %174, 0 + call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %175) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) ret i32 0 } diff --git a/cl/_testrt/concat/out.ll b/cl/_testrt/concat/out.ll index 845d1d0c..f850807f 100644 --- a/cl/_testrt/concat/out.ll +++ b/cl/_testrt/concat/out.ll @@ -121,14 +121,21 @@ _llgo_0: store i64 5, ptr %16, align 4 %17 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %14, align 8 store %"github.com/goplus/llgo/internal/runtime.String" %17, ptr %13, align 8 - %18 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %2, i64 16, i64 3, i64 0, i64 3, i64 3) - %19 = call %"github.com/goplus/llgo/internal/runtime.String" @main.concat(%"github.com/goplus/llgo/internal/runtime.Slice" %18) - %20 = load ptr, ptr @__stderrp, align 8 - %21 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %19, 1 - %22 = add i64 %21, 1 - %23 = alloca i8, i64 %22, align 1 - %24 = call ptr @"github.com/goplus/llgo/internal/runtime.CStrCopy"(ptr %23, %"github.com/goplus/llgo/internal/runtime.String" %19) - %25 = call i32 (ptr, ptr, ...) @fprintf(ptr %20, ptr @6, ptr %24) + %18 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %18, i32 0, i32 0 + store ptr %2, ptr %19, align 8 + %20 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %18, i32 0, i32 1 + store i64 3, ptr %20, align 4 + %21 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %18, i32 0, i32 2 + store i64 3, ptr %21, align 4 + %22 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %18, align 8 + %23 = call %"github.com/goplus/llgo/internal/runtime.String" @main.concat(%"github.com/goplus/llgo/internal/runtime.Slice" %22) + %24 = load ptr, ptr @__stderrp, align 8 + %25 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %23, 1 + %26 = add i64 %25, 1 + %27 = alloca i8, i64 %26, align 1 + %28 = call ptr @"github.com/goplus/llgo/internal/runtime.CStrCopy"(ptr %27, %"github.com/goplus/llgo/internal/runtime.String" %23) + %29 = call i32 (ptr, ptr, ...) @fprintf(ptr %24, ptr @6, ptr %28) ret i32 0 } @@ -140,8 +147,6 @@ declare void @"github.com/goplus/llgo/internal/runtime.init"() declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64) -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.CStrCopy"(ptr, %"github.com/goplus/llgo/internal/runtime.String") declare i32 @fprintf(ptr, ptr, ...) diff --git a/cl/_testrt/sum/out.ll b/cl/_testrt/sum/out.ll index e13b24a2..c36f08d1 100644 --- a/cl/_testrt/sum/out.ll +++ b/cl/_testrt/sum/out.ll @@ -36,9 +36,16 @@ _llgo_0: store i64 3, ptr %5, align 4 %6 = getelementptr inbounds i64, ptr %2, i64 3 store i64 4, ptr %6, align 4 - %7 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %2, i64 8, i64 4, i64 0, i64 4, i64 4) - %8 = call i64 @main.sum(%"github.com/goplus/llgo/internal/runtime.Slice" %7) - %9 = call i32 (ptr, ...) @printf(ptr @0, i64 %8) + %7 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %8 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %7, i32 0, i32 0 + store ptr %2, ptr %8, align 8 + %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %7, i32 0, i32 1 + store i64 4, ptr %9, align 4 + %10 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %7, i32 0, i32 2 + store i64 4, ptr %10, align 4 + %11 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %7, align 8 + %12 = call i64 @main.sum(%"github.com/goplus/llgo/internal/runtime.Slice" %11) + %13 = call i32 (ptr, ...) @printf(ptr @0, i64 %12) ret i32 0 } @@ -71,8 +78,6 @@ declare void @"github.com/goplus/llgo/internal/runtime.init"() declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64) -declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr, i64, i64, i64, i64, i64) - declare i32 @printf(ptr, ...) declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1) diff --git a/cl/compile.go b/cl/compile.go index d4ce3aa0..1b23d3b8 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -381,7 +381,7 @@ func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock, n int, do cond := b.BinOp(token.NEQ, mod, prog.Null(mod.Type)) newBlk := p.fn.MakeBlock() b.If(cond, jumpTo, newBlk) - b.SetBlock(newBlk) + b.SetBlockEx(newBlk, llssa.AtEnd, false) b.Store(modPtr, b.PyImportMod(modPath)) b.Jump(jumpTo) } @@ -508,7 +508,7 @@ func isPhi(i ssa.Instruction) bool { func (p *context) compilePhis(b llssa.Builder, block *ssa.BasicBlock) int { ret := p.fn.Block(block.Index) - b.SetBlockEx(ret, llssa.AtEnd) + b.SetBlockEx(ret, llssa.AtEnd, false) if ninstr := len(block.Instrs); ninstr > 0 { if isPhi(block.Instrs[0]) { n := 1 diff --git a/ssa/decl.go b/ssa/decl.go index 2243e975..a4b64db1 100644 --- a/ssa/decl.go +++ b/ssa/decl.go @@ -274,7 +274,7 @@ func (p Function) NewBuilder() Builder { b := prog.ctx.NewBuilder() // TODO(xsw): Finalize may cause panic, so comment it. // b.Finalize() - return &aBuilder{b, p, p.Pkg, prog} + return &aBuilder{b, nil, p, p.Pkg, prog} } // HasBody reports whether the function has a body. @@ -287,7 +287,7 @@ func (p Function) HasBody() bool { func (p Function) MakeBody(nblk int) Builder { p.MakeBlocks(nblk) b := p.NewBuilder() - b.impl.SetInsertPointAtEnd(p.blks[0].impl) + b.impl.SetInsertPointAtEnd(p.blks[0].last) return b } @@ -306,7 +306,7 @@ func (p Function) MakeBlocks(nblk int) []BasicBlock { func (p Function) addBlock(idx int) BasicBlock { label := "_llgo_" + strconv.Itoa(idx) blk := llvm.AddBasicBlock(p.impl, label) - ret := &aBasicBlock{blk, p, idx} + ret := &aBasicBlock{blk, blk, p, idx} p.blks = append(p.blks, ret) return ret } diff --git a/ssa/expr.go b/ssa/expr.go index 2c5c7770..6fce4fbe 100644 --- a/ssa/expr.go +++ b/ssa/expr.go @@ -517,10 +517,10 @@ func llvmDelayValues(f func(i int) Expr, n int) []llvm.Value { return ret } -func llvmBlocks(bblks []BasicBlock) []llvm.BasicBlock { - ret := make([]llvm.BasicBlock, len(bblks)) - for i, v := range bblks { - ret[i] = v.impl +func llvmPredBlocks(preds []BasicBlock) []llvm.BasicBlock { + ret := make([]llvm.BasicBlock, len(preds)) + for i, v := range preds { + ret[i] = v.last } return ret } @@ -531,24 +531,24 @@ type Phi struct { } // AddIncoming adds incoming values to a phi node. -func (p Phi) AddIncoming(b Builder, bblks []BasicBlock, f func(i int) Expr) { - bs := llvmBlocks(bblks) +func (p Phi) AddIncoming(b Builder, preds []BasicBlock, f func(i int) Expr) { + bs := llvmPredBlocks(preds) if p.kind != vkPhisExpr { // normal phi node - vs := llvmDelayValues(f, len(bblks)) + vs := llvmDelayValues(f, len(preds)) p.impl.AddIncoming(vs, bs) return } e := p.raw.Type.(*phisExprTy) phis := e.phis vals := make([][]llvm.Value, len(phis)) - for iblk, blk := range bblks { - last := blk.impl.LastInstruction() + for iblk, blk := range preds { + last := blk.last.LastInstruction() b.impl.SetInsertPointBefore(last) impl := b.impl val := f(iblk).impl for i := range phis { if iblk == 0 { - vals[i] = make([]llvm.Value, len(bblks)) + vals[i] = make([]llvm.Value, len(preds)) } vals[i][iblk] = llvm.CreateExtractValue(impl, val, i) } diff --git a/ssa/interface.go b/ssa/interface.go index bc4fb6e2..c336dfe8 100644 --- a/ssa/interface.go +++ b/ssa/interface.go @@ -61,13 +61,14 @@ func (b Builder) abiStruct(t *types.Struct) Expr { eq := b.BinOp(token.EQL, b.Load(expr), b.Prog.Null(expr.Type)) blks = b.Func.MakeBlocks(2) b.If(eq, blks[0], blks[1]) - b.SetBlock(blks[0]) + b.SetBlockEx(blks[0], AtEnd, false) } tabi := b.structOf(t) b.Store(expr, tabi) if pub { b.Jump(blks[1]) - b.SetBlock(blks[1]) + b.SetBlockEx(blks[1], AtEnd, false) + b.blk.last = blks[1].last } }) } @@ -279,9 +280,10 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) Expr { } blks := b.Func.MakeBlocks(2) b.If(eq, blks[0], blks[1]) - b.SetBlock(blks[1]) + b.SetBlockEx(blks[1], AtEnd, false) b.Panic(b.Str("type assertion failed")) - b.SetBlock(blks[0]) + b.SetBlockEx(blks[0], AtEnd, false) + b.blk.last = blks[0].last return b.valFromData(assertedTyp, b.faceData(x.impl)) } diff --git a/ssa/package.go b/ssa/package.go index 25900f92..da180b66 100644 --- a/ssa/package.go +++ b/ssa/package.go @@ -559,7 +559,7 @@ func (p Package) AfterInit(b Builder, ret BasicBlock) { doAbiInit := len(p.abiini) > 0 doPyLoadModSyms := p.pyHasModSyms() if doAbiInit || doPyLoadModSyms { - b.SetBlockEx(ret, afterInit) + b.SetBlockEx(ret, afterInit, false) if doAbiInit { sigAbiInit := types.NewSignatureType(nil, nil, nil, nil, nil, false) fn := p.NewFunc(p.abi.Pkg+".init$abi", sigAbiInit, InC) @@ -743,7 +743,7 @@ func (p Program) tyGetAttrString() *types.Signature { func (p Package) PyInit() bool { if fn := p.FuncOf("main"); fn != nil { b := fn.NewBuilder() - b.SetBlockEx(fn.Block(0), AtStart).callPyInit() + b.SetBlockEx(fn.Block(0), AtStart, false).callPyInit() b.Dispose() return true } diff --git a/ssa/ssa_test.go b/ssa/ssa_test.go index 103ee79e..cd686c7b 100644 --- a/ssa/ssa_test.go +++ b/ssa/ssa_test.go @@ -52,7 +52,7 @@ func TestSetBlockEx(t *testing.T) { }() fn := &aFunction{} b := &aBuilder{Func: fn} - b.SetBlockEx(&aBasicBlock{fn: fn}, -1) + b.SetBlockEx(&aBasicBlock{fn: fn}, -1, false) } func TestSetPython(t *testing.T) { diff --git a/ssa/stmt_builder.go b/ssa/stmt_builder.go index 4ef42c9a..93c462a4 100644 --- a/ssa/stmt_builder.go +++ b/ssa/stmt_builder.go @@ -29,9 +29,10 @@ import ( // ----------------------------------------------------------------------------- type aBasicBlock struct { - impl llvm.BasicBlock - fn Function - idx int + first llvm.BasicBlock + last llvm.BasicBlock + fn Function + idx int } // BasicBlock represents a basic block in a function. @@ -51,6 +52,7 @@ func (p BasicBlock) Index() int { type aBuilder struct { impl llvm.Builder + blk BasicBlock Func Function Pkg Package Prog Program @@ -64,12 +66,12 @@ func (b Builder) Dispose() { b.impl.Dispose() } -// SetBlock means SetBlockEx(blk, AtEnd). +// SetBlock means SetBlockEx(blk, AtEnd, true). func (b Builder) SetBlock(blk BasicBlock) Builder { if debugInstr { log.Printf("Block _llgo_%v:\n", blk.idx) } - b.SetBlockEx(blk, AtEnd) + b.SetBlockEx(blk, AtEnd, true) return b } @@ -82,20 +84,23 @@ const ( ) // SetBlockEx sets blk as current basic block and pos as its insert point. -func (b Builder) SetBlockEx(blk BasicBlock, pos InsertPoint) Builder { +func (b Builder) SetBlockEx(blk BasicBlock, pos InsertPoint, setBlk bool) Builder { if b.Func != blk.fn { panic("mismatched function") } switch pos { case AtEnd: - b.impl.SetInsertPointAtEnd(blk.impl) + b.impl.SetInsertPointAtEnd(blk.last) case AtStart: - b.impl.SetInsertPointBefore(blk.impl.FirstInstruction()) + b.impl.SetInsertPointBefore(blk.first.FirstInstruction()) case afterInit: - b.impl.SetInsertPointBefore(instrAfterInit(blk.impl)) + b.impl.SetInsertPointBefore(instrAfterInit(blk.first)) default: panic("SetBlockEx: invalid pos") } + if setBlk { + b.blk = blk + } return b } @@ -184,7 +189,7 @@ func (b Builder) Jump(jmpb BasicBlock) { if debugInstr { log.Printf("Jump _llgo_%v\n", jmpb.idx) } - b.impl.CreateBr(jmpb.impl) + b.impl.CreateBr(jmpb.first) } // If emits an if instruction. @@ -195,7 +200,7 @@ func (b Builder) If(cond Expr, thenb, elseb BasicBlock) { if debugInstr { log.Printf("If %v, _llgo_%v, _llgo_%v\n", cond.impl, thenb.idx, elseb.idx) } - b.impl.CreateCondBr(cond.impl, thenb.impl, elseb.impl) + b.impl.CreateCondBr(cond.impl, thenb.first, elseb.first) } // The MapUpdate instruction updates the association of Map[Key] to From 77eeea95c7cdf0f2a0f94fd981b0216370e2ac0b Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 09:30:16 +0800 Subject: [PATCH 14/20] valFromData BitCast bugfix --- cl/_testdata/print/out.ll | 129 +++++++++++++++++++------------------- ssa/interface.go | 3 + 2 files changed, 68 insertions(+), 64 deletions(-) diff --git a/cl/_testdata/print/out.ll b/cl/_testdata/print/out.ll index 4b2285c6..27462d72 100644 --- a/cl/_testdata/print/out.ll +++ b/cl/_testdata/print/out.ll @@ -737,82 +737,83 @@ _llgo_25: ; preds = %_llgo_23 %208 = icmp eq ptr %206, %207 %209 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 %210 = ptrtoint ptr %209 to i64 - %211 = bitcast i64 %210 to float - %212 = alloca { float, i1 }, align 8 - %213 = getelementptr inbounds { float, i1 }, ptr %212, i32 0, i32 0 - store float %211, ptr %213, align 4 - %214 = getelementptr inbounds { float, i1 }, ptr %212, i32 0, i32 1 - store i1 true, ptr %214, align 1 - %215 = load { float, i1 }, ptr %212, align 4 - %216 = alloca { float, i1 }, align 8 - %217 = getelementptr inbounds { float, i1 }, ptr %216, i32 0, i32 0 - store double 0.000000e+00, ptr %217, align 8 - %218 = getelementptr inbounds { float, i1 }, ptr %216, i32 0, i32 1 - store i1 false, ptr %218, align 1 - %219 = load { float, i1 }, ptr %216, align 4 - %220 = select i1 %208, { float, i1 } %215, { float, i1 } %219 - %221 = extractvalue { float, i1 } %220, 0 - %222 = extractvalue { float, i1 } %220, 1 - br i1 %222, label %_llgo_26, label %_llgo_27 + %211 = trunc i64 %210 to i32 + %212 = bitcast i32 %211 to float + %213 = alloca { float, i1 }, align 8 + %214 = getelementptr inbounds { float, i1 }, ptr %213, i32 0, i32 0 + store float %212, ptr %214, align 4 + %215 = getelementptr inbounds { float, i1 }, ptr %213, i32 0, i32 1 + store i1 true, ptr %215, align 1 + %216 = load { float, i1 }, ptr %213, align 4 + %217 = alloca { float, i1 }, align 8 + %218 = getelementptr inbounds { float, i1 }, ptr %217, i32 0, i32 0 + store double 0.000000e+00, ptr %218, align 8 + %219 = getelementptr inbounds { float, i1 }, ptr %217, i32 0, i32 1 + store i1 false, ptr %219, align 1 + %220 = load { float, i1 }, ptr %217, align 4 + %221 = select i1 %208, { float, i1 } %216, { float, i1 } %220 + %222 = extractvalue { float, i1 } %221, 0 + %223 = extractvalue { float, i1 } %221, 1 + br i1 %223, label %_llgo_26, label %_llgo_27 _llgo_26: ; preds = %_llgo_25 - %223 = fpext float %221 to double - call void @main.printfloat(double %223) + %224 = fpext float %222 to double + call void @main.printfloat(double %224) br label %_llgo_1 _llgo_27: ; preds = %_llgo_25 - %224 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %225 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) - %226 = icmp eq ptr %224, %225 - %227 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 - %228 = ptrtoint ptr %227 to i64 - %229 = bitcast i64 %228 to double - %230 = alloca { double, i1 }, align 8 - %231 = getelementptr inbounds { double, i1 }, ptr %230, i32 0, i32 0 - store double %229, ptr %231, align 8 - %232 = getelementptr inbounds { double, i1 }, ptr %230, i32 0, i32 1 - store i1 true, ptr %232, align 1 - %233 = load { double, i1 }, ptr %230, align 8 - %234 = alloca { double, i1 }, align 8 - %235 = getelementptr inbounds { double, i1 }, ptr %234, i32 0, i32 0 - store double 0.000000e+00, ptr %235, align 8 - %236 = getelementptr inbounds { double, i1 }, ptr %234, i32 0, i32 1 - store i1 false, ptr %236, align 1 - %237 = load { double, i1 }, ptr %234, align 8 - %238 = select i1 %226, { double, i1 } %233, { double, i1 } %237 - %239 = extractvalue { double, i1 } %238, 0 - %240 = extractvalue { double, i1 } %238, 1 - br i1 %240, label %_llgo_28, label %_llgo_29 + %225 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %226 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) + %227 = icmp eq ptr %225, %226 + %228 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %229 = ptrtoint ptr %228 to i64 + %230 = bitcast i64 %229 to double + %231 = alloca { double, i1 }, align 8 + %232 = getelementptr inbounds { double, i1 }, ptr %231, i32 0, i32 0 + store double %230, ptr %232, align 8 + %233 = getelementptr inbounds { double, i1 }, ptr %231, i32 0, i32 1 + store i1 true, ptr %233, align 1 + %234 = load { double, i1 }, ptr %231, align 8 + %235 = alloca { double, i1 }, align 8 + %236 = getelementptr inbounds { double, i1 }, ptr %235, i32 0, i32 0 + store double 0.000000e+00, ptr %236, align 8 + %237 = getelementptr inbounds { double, i1 }, ptr %235, i32 0, i32 1 + store i1 false, ptr %237, align 1 + %238 = load { double, i1 }, ptr %235, align 8 + %239 = select i1 %227, { double, i1 } %234, { double, i1 } %238 + %240 = extractvalue { double, i1 } %239, 0 + %241 = extractvalue { double, i1 } %239, 1 + br i1 %241, label %_llgo_28, label %_llgo_29 _llgo_28: ; preds = %_llgo_27 - call void @main.printfloat(double %239) + call void @main.printfloat(double %240) br label %_llgo_1 _llgo_29: ; preds = %_llgo_27 - %241 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %242 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) - %243 = icmp eq ptr %241, %242 - %244 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 - %245 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %244, align 8 - %246 = alloca { %"github.com/goplus/llgo/internal/runtime.String", i1 }, align 8 - %247 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %246, i32 0, i32 0 - store %"github.com/goplus/llgo/internal/runtime.String" %245, ptr %247, align 8 - %248 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %246, i32 0, i32 1 - store i1 true, ptr %248, align 1 - %249 = load { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %246, align 8 - %250 = alloca { %"github.com/goplus/llgo/internal/runtime.String", i1 }, align 8 - %251 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %250, i32 0, i32 0 - store { ptr, i64 } zeroinitializer, ptr %251, align 8 - %252 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %250, i32 0, i32 1 - store i1 false, ptr %252, align 1 - %253 = load { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %250, align 8 - %254 = select i1 %243, { %"github.com/goplus/llgo/internal/runtime.String", i1 } %249, { %"github.com/goplus/llgo/internal/runtime.String", i1 } %253 - %255 = extractvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } %254, 0 - %256 = extractvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } %254, 1 - br i1 %256, label %_llgo_30, label %_llgo_1 + %242 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 + %243 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %244 = icmp eq ptr %242, %243 + %245 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 1 + %246 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %245, align 8 + %247 = alloca { %"github.com/goplus/llgo/internal/runtime.String", i1 }, align 8 + %248 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %247, i32 0, i32 0 + store %"github.com/goplus/llgo/internal/runtime.String" %246, ptr %248, align 8 + %249 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %247, i32 0, i32 1 + store i1 true, ptr %249, align 1 + %250 = load { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %247, align 8 + %251 = alloca { %"github.com/goplus/llgo/internal/runtime.String", i1 }, align 8 + %252 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %251, i32 0, i32 0 + store { ptr, i64 } zeroinitializer, ptr %252, align 8 + %253 = getelementptr inbounds { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %251, i32 0, i32 1 + store i1 false, ptr %253, align 1 + %254 = load { %"github.com/goplus/llgo/internal/runtime.String", i1 }, ptr %251, align 8 + %255 = select i1 %244, { %"github.com/goplus/llgo/internal/runtime.String", i1 } %250, { %"github.com/goplus/llgo/internal/runtime.String", i1 } %254 + %256 = extractvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } %255, 0 + %257 = extractvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } %255, 1 + br i1 %257, label %_llgo_30, label %_llgo_1 _llgo_30: ; preds = %_llgo_29 - call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %255) + call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %256) br label %_llgo_1 } diff --git a/ssa/interface.go b/ssa/interface.go index c336dfe8..c1104663 100644 --- a/ssa/interface.go +++ b/ssa/interface.go @@ -196,6 +196,9 @@ func (b Builder) valFromData(typ Type, data llvm.Value) Expr { return b.buildVal(typ, castInt(b, x, t), lvl) case abi.BitCast: x := castUintptr(b, data, prog.Uintptr()) + if int(prog.SizeOf(t)) != prog.PointerSize() { + x = castInt(b, x, prog.Int32()) + } return b.buildVal(typ, llvm.CreateBitCast(b.impl, x, t.ll), lvl) } panic("todo") From d2e5bb99ef277e64d58c6241db15b4cb285cd98e Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 09:41:40 +0800 Subject: [PATCH 15/20] gentests; MakeBody fix --- chore/gentests/gentests.go | 1 + ssa/decl.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/chore/gentests/gentests.go b/chore/gentests/gentests.go index 2a8c2214..2eb83129 100644 --- a/chore/gentests/gentests.go +++ b/chore/gentests/gentests.go @@ -33,6 +33,7 @@ func main() { llgenDir(dir + "/cl/_testlibc") llgenDir(dir + "/cl/_testrt") + llgenDir(dir + "/cl/_testgo") llgenDir(dir+"/cl/_testpy", "") llgenDir(dir+"/cl/_testdata", "") } diff --git a/ssa/decl.go b/ssa/decl.go index a4b64db1..2ff49cde 100644 --- a/ssa/decl.go +++ b/ssa/decl.go @@ -287,7 +287,8 @@ func (p Function) HasBody() bool { func (p Function) MakeBody(nblk int) Builder { p.MakeBlocks(nblk) b := p.NewBuilder() - b.impl.SetInsertPointAtEnd(p.blks[0].last) + b.blk = p.blks[0] + b.impl.SetInsertPointAtEnd(b.blk.last) return b } From f399dd34986cea64c2cf64bc173cffb587e16291 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 09:46:29 +0800 Subject: [PATCH 16/20] TestAny --- cl/_testgo/strucintf/in.go | 2 +- cl/_testgo/strucintf/out.ll | 12 ++++++------ ssa/ssa_test.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cl/_testgo/strucintf/in.go b/cl/_testgo/strucintf/in.go index c2822448..ba17fc6b 100644 --- a/cl/_testgo/strucintf/in.go +++ b/cl/_testgo/strucintf/in.go @@ -1,8 +1,8 @@ package main import ( - "github.com/goplus/llgo/_demo/interf/foo" "github.com/goplus/llgo/c" + "github.com/goplus/llgo/cl/internal/foo" ) func main() { diff --git a/cl/_testgo/strucintf/out.ll b/cl/_testgo/strucintf/out.ll index c042d4ac..080533a6 100644 --- a/cl/_testgo/strucintf/out.ll +++ b/cl/_testgo/strucintf/out.ll @@ -30,7 +30,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 - call void @"github.com/goplus/llgo/_demo/interf/foo.init"() + call void @"github.com/goplus/llgo/cl/internal/foo.init"() call void @"main.init$abi"() br label %_llgo_2 @@ -46,7 +46,7 @@ _llgo_0: call void @main.init() %2 = alloca { i64 }, align 8 %3 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %2, i64 8) - %4 = call %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/_demo/interf/foo.Bar"() + %4 = call %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.Bar"() %5 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %4, 0 %6 = load ptr, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 %7 = icmp eq ptr %5, %6 @@ -83,7 +83,7 @@ _llgo_1: ; preds = %_llgo_0 _llgo_2: ; preds = %_llgo_3, %_llgo_1 %27 = alloca { i64 }, align 8 %28 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %27, i64 8) - %29 = call %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/_demo/interf/foo.F"() + %29 = call %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.F"() %30 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %29, 0 %31 = load ptr, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8 %32 = icmp eq ptr %30, %31 @@ -129,17 +129,17 @@ _llgo_6: ; preds = %_llgo_2 br label %_llgo_5 } -declare void @"github.com/goplus/llgo/_demo/interf/foo.init"() +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.Zeroinit"(ptr, i64) -declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/_demo/interf/foo.Bar"() +declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.Bar"() declare i32 @printf(ptr, ...) -declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/_demo/interf/foo.F"() +declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.F"() define void @"main.init$abi"() { _llgo_0: diff --git a/ssa/ssa_test.go b/ssa/ssa_test.go index cd686c7b..3e23e756 100644 --- a/ssa/ssa_test.go +++ b/ssa/ssa_test.go @@ -130,7 +130,7 @@ func TestAny(t *testing.T) { prog.SetRuntime(func() *types.Package { ret := types.NewPackage("runtime", "runtime") scope := ret.Scope() - name := types.NewTypeName(0, ret, "Interface", nil) + name := types.NewTypeName(0, ret, "Eface", nil) types.NewNamed(name, types.NewStruct(nil, nil), nil) scope.Insert(name) return ret From f0f973eb0026a292ffa69de9a2bcbbdaaa8c92d1 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 09:50:51 +0800 Subject: [PATCH 17/20] TestAbi --- internal/abi/llgo_autogen.lla | Bin 5351 -> 5463 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/internal/abi/llgo_autogen.lla b/internal/abi/llgo_autogen.lla index 68590077d52dabc484c7e975af9f4fc6618105a5..7fed635085121ecda4a72c47e157e2957316114f 100644 GIT binary patch delta 5428 zcmV-470c@9Dc350P)h>@6aWAK2mnw{xLA%xyQHHO002D!0RRsG8~|)=XK!C&b#!lM zWo|BPY*kbV00U_9PiATIPiA#^3jhHG^#K3?1QY-O0PS6EkJ~m9{=UCLSai|uVY?Oe zW+_F1q-lx^?phR0?>@9w1d6SAg?i;ZTTYu6{qHA|;;UqTttfJ|-d+y4O>Ikjc{nqi zXGjh|_rBS#4x8fTSKb%i$Lq4bIlQ@EZf`$ZZ|^pT{b!radiz;f)y1yLH=pHi%8$?X z+rw^Iynb75iYmV?n)l8}ymx+fb}{C;>u0-N{{Dyecg1;Aa^3vv{o##!le~20-PODH zPnksCpChY()oN^By=wo2LGve7|NjTC#ru<0MxG0U(KSB5$t&xAnso8&L$$Q2utW*@ zGrGc;_`}RQDxHWswbQ&!xwr=uz;tFr!ReaLqNyY*)KCf^YBtHWk<_SA2_yxW!U z^1AR26`s&muk+Pv=PkF@zRs)K`zcDi-x}Tc*;}61H-*aDjf z-xc0}`|ZKYyBzZbhLZg<(d-2AsxNHC(11#fP( ztv)So@9Ov7o@l7nqHsiE0WYlS)XIC8H|5k?IgyK=#V&i6++SFb@xq847QbRqeBu$G zrrvJ7&9+)U@w9>$BgBQ5dwqSay`GL}SK8lyt~y^IZ&qg2tg}_|wyX+bAD*6n@;4(l z?eh8=F6R6btWy{MrT53#Yy9|Y|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754Tkf3lLbkRFWflbxiM9W_BjCtrt^JU}6CiczvY3^8+ldJ(1vX}Sm}y$GjP z(vHxZY~3D+Js|}OK6oW3rBsu2SjkjEukeH2;6qQdcwLlH=hk!jv1cXU2oWEW0=k2< zkPH;5sWQ~#o~e~|ASr2#Q5xtGiysu}um|a&AL-Cae;N=fL{T5ozJRofY;rIuiCK~m z)yXh%P-h6x9Uji`1iaKSu{TgBHT~qI-XA5KeONsAuRSb=u+3*9qOmrDU3_1Umd_pL zKbYb0dkjZlgvUL>#8aU;7H@xnra8VubBd^Qx4ANUHWh@P2{kcWBZ8=)25TU_;Qyz= z0*%^^e~3paQjB_~cxn(P%dIx`J54*=IqgEcx*i+M zi}nh!vZ^*j!im+y@6>;Z{S~j69+_SlcbH}mP@Bn5%NI?ah4F=bw%TXg<+(VsH|6I?uQe;sQ%rrn0gb-9o$a?nYlVP%ATso%sP z3Hd_>R9JdU{)tbsWBSq?Zs!Hmc_U!1C9&4E@8!izvuY737lK+935#cDyPGY4Bkqkj zMp6>4`vQ)>9kF2nN1709U2$`Pn=&Q6`m-Ir#Pemj%-{c*m8*IhA}Pf#S=iAqyNAn@ ze|sFBuM6Q?x+WeV=H+Br|B)*(1`-k!4JHz2WrVE6n%lr2OUZlXe1W|7?l$0YK>j5U z%h?)KoCUo@fmkv}6v|@}^^8T=fDr4pSZCX@vvO~$8`84Nwx~%!f1j_is(6>b zx+&gP7;B-xlfDP(iaMk+1gCm^$ppXYPjae^v{#l)E<(7gWV(Er+*e`N@}Jd~&z9M& z6-wpDyp2)XB2+$Gda^6$P!lZ72bX9615ir=0v-bt000080Ixo{SoQMl05cQ-015s8 VlLr+i0{YgIFcl#Nd=vlx008w5H=h6i From 7c003e9e7a7bd6d0f133ccad7f1c23d47f2e7f29 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 09:52:46 +0800 Subject: [PATCH 18/20] TestMakeInterface --- ssa/cl_test.go | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/ssa/cl_test.go b/ssa/cl_test.go index c89a0958..e046abfa 100644 --- a/ssa/cl_test.go +++ b/ssa/cl_test.go @@ -56,26 +56,34 @@ func TestMakeInterface(t *testing.T) { ssatest.Assert(t, pkg, `; ModuleID = 'foo' source_filename = "foo" -%"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr } +%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr } define void @main() { _llgo_0: - %0 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) - store i64 100, ptr %0, align 4 - %1 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) - %2 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAny"(ptr %1, ptr %0) - %3 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) - store double 1.000000e+02, ptr %3, align 8 - %4 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) - %5 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAny"(ptr %4, ptr %3) + %0 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) + %1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) + store i64 100, ptr %1, align 4 + %2 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i32 0, i32 0 + store ptr %0, ptr %3, align 8 + %4 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i32 0, i32 1 + store ptr %1, ptr %4, align 8 + %5 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, align 8 + %6 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) + %7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) + store double 1.000000e+02, ptr %7, align 8 + %8 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 + %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %8, i32 0, i32 0 + store ptr %6, ptr %9, align 8 + %10 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %8, i32 0, i32 1 + store ptr %7, ptr %10, align 8 + %11 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %8, align 8 ret void } -declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) - -declare %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAny"(ptr, ptr) - declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) + +declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) `) } From 937e55eb4645e67d56ab6dc6f91145505dc5e4b9 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 10:01:41 +0800 Subject: [PATCH 19/20] TestFromTestgo --- cl/compile_test.go | 4 ---- ssa/cl_test.go | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cl/compile_test.go b/cl/compile_test.go index 48639cf5..2d601ae2 100644 --- a/cl/compile_test.go +++ b/cl/compile_test.go @@ -28,10 +28,6 @@ func testCompile(t *testing.T, src, expected string) { cltest.TestCompileEx(t, src, "foo.go", expected) } -func TestFromTestgo(t *testing.T) { - cltest.FromDir(t, "", "./_testgo", false) -} - func TestFromTestpy(t *testing.T) { cltest.FromDir(t, "", "./_testpy", false) } diff --git a/ssa/cl_test.go b/ssa/cl_test.go index e046abfa..513944c1 100644 --- a/ssa/cl_test.go +++ b/ssa/cl_test.go @@ -25,6 +25,10 @@ import ( "github.com/goplus/llgo/ssa/ssatest" ) +func TestFromTestgo(t *testing.T) { + cltest.FromDir(t, "", "../cl/_testgo", false) +} + func TestFromTestpy(t *testing.T) { cltest.FromDir(t, "", "../cl/_testpy", false) } From 9b4701fed71d85b78987a1b06a6a676a27be3c10 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 24 May 2024 10:30:56 +0800 Subject: [PATCH 20/20] runtime.Struct: temp disable abi.NewName --- cl/_testgo/strucintf/in.go | 3 ++- cl/_testgo/strucintf/out.ll | 18 +++++++++--------- internal/runtime/llgo_autogen.lla | Bin 5745 -> 5677 bytes internal/runtime/z_type.go | 7 ++++--- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/cl/_testgo/strucintf/in.go b/cl/_testgo/strucintf/in.go index ba17fc6b..1af4b02d 100644 --- a/cl/_testgo/strucintf/in.go +++ b/cl/_testgo/strucintf/in.go @@ -6,7 +6,8 @@ import ( ) func main() { - if x, ok := foo.Bar().(struct{ V int }); ok { + bar := foo.Bar() + if x, ok := bar.(struct{ V int }); ok { c.Printf(c.Str("%d\n"), x.V) } else { c.Printf(c.Str("Bar: not ok\n")) diff --git a/cl/_testgo/strucintf/out.ll b/cl/_testgo/strucintf/out.ll index 080533a6..57492612 100644 --- a/cl/_testgo/strucintf/out.ll +++ b/cl/_testgo/strucintf/out.ll @@ -44,13 +44,13 @@ _llgo_0: store ptr %1, ptr @__llgo_argv, align 8 call void @"github.com/goplus/llgo/internal/runtime.init"() call void @main.init() - %2 = alloca { i64 }, align 8 - %3 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %2, i64 8) - %4 = call %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.Bar"() - %5 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %4, 0 + %2 = call %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.Bar"() + %3 = alloca { i64 }, align 8 + %4 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %3, i64 8) + %5 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %2, 0 %6 = load ptr, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 %7 = icmp eq ptr %5, %6 - %8 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %4, 1 + %8 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %2, 1 %9 = ptrtoint ptr %8 to i64 %10 = alloca { i64 }, align 8 %11 = getelementptr inbounds { i64 }, ptr %10, i32 0, i32 0 @@ -70,12 +70,12 @@ _llgo_0: %20 = load { { i64 }, i1 }, ptr %17, align 4 %21 = select i1 %7, { { i64 }, i1 } %16, { { i64 }, i1 } %20 %22 = extractvalue { { i64 }, i1 } %21, 0 - store { i64 } %22, ptr %3, align 4 + store { i64 } %22, ptr %4, align 4 %23 = extractvalue { { i64 }, i1 } %21, 1 br i1 %23, label %_llgo_1, label %_llgo_3 _llgo_1: ; preds = %_llgo_0 - %24 = getelementptr inbounds { i64 }, ptr %3, i32 0, i32 0 + %24 = getelementptr inbounds { i64 }, ptr %4, i32 0, i32 0 %25 = load i64, ptr %24, align 4 %26 = call i32 (ptr, ...) @printf(ptr @0, i64 %25) br label %_llgo_2 @@ -133,10 +133,10 @@ 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.Zeroinit"(ptr, i64) - declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.Bar"() +declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64) + declare i32 @printf(ptr, ...) declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.F"() diff --git a/internal/runtime/llgo_autogen.lla b/internal/runtime/llgo_autogen.lla index f358a32c5dfec0f6dd2a6a3b59aaeb23f4d35268..a5c5b75bc81fc925cd674fcc15e25965e95a45cc 100644 GIT binary patch delta 5663 zcmV+)7U1deEUhemP)h>@6aWAK2mp*zxL9Vgk>`08007zL000jF8~|)=XK!C&b#!lM zWo|BPY*kbV00T$+Pi9H`PiA#^3jhHG^#K3?1QY-O0PP)VZ`(%pyMF~?tWc|~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>XmE@N6PuY>qoKzS)$Ju{ju$_pe+%FE4yKC(arX7=SAXeeo6JgaWg zFdz*svx)(<7oKbf^XuiCrS5E0<3Yn_qLupuN|QVjnTHOLO4)=$Y-X|WS7$zYiztb6 zk-)#H(w!Z99o~EuRc9PL&W4?G7I^C@e`tPJi9Hf0Rf4C`Y#R(@DCpb0R92JfCB%2r~gBR5&oMB|1Tn}B#VIf Q?>Wprq4rNl#QS&q4;jDxX#fBK diff --git a/internal/runtime/z_type.go b/internal/runtime/z_type.go index f9915453..a4860621 100644 --- a/internal/runtime/z_type.go +++ b/internal/runtime/z_type.go @@ -97,15 +97,16 @@ func StructField(name string, typ *Type, off uintptr, tag string, exported, embe // Struct returns a struct type. func Struct(size uintptr, pkgPath string, fields ...abi.StructField) *Type { - npkg := abi.NewName(pkgPath, "", false, false) + // TODO(xsw): pkgPath + // npkg := abi.NewName(pkgPath, "", false, false) ret := &abi.StructType{ Type: Type{ Size_: size, Hash: uint32(abi.Struct), // TODO(xsw): hash Kind_: uint8(abi.Struct), }, - PkgPath: npkg, - Fields: fields, + // PkgPath: npkg, + Fields: fields, } return &ret.Type }