vkPyFunc => vkPyFuncRef
This commit is contained in:
@@ -40,12 +40,14 @@ _llgo_0:
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call ptr @PyFloat_FromDouble(double 2.000000e+00)
|
||||
%3 = call ptr @PyObject_CallOneArg(ptr @__llgo_py.math.sqrt, ptr %2)
|
||||
%4 = call ptr @PyObject_CallNoArgs(ptr @__llgo_py.os.getcwd)
|
||||
%5 = call double @PyFloat_AsDouble()
|
||||
%6 = call i32 (ptr, ...) @printf(ptr @0, double %5)
|
||||
%7 = call ptr @PyBytes_AsString()
|
||||
%8 = call i32 (ptr, ...) @printf(ptr @1, ptr %7)
|
||||
%3 = load ptr, ptr @__llgo_py.math.sqrt, align 8
|
||||
%4 = call ptr @PyObject_CallOneArg(ptr %3, ptr %2)
|
||||
%5 = load ptr, ptr @__llgo_py.os.getcwd, align 8
|
||||
%6 = call ptr @PyObject_CallNoArgs(ptr %5)
|
||||
%7 = call double @PyFloat_AsDouble()
|
||||
%8 = call i32 (ptr, ...) @printf(ptr @0, double %7)
|
||||
%9 = call ptr @PyBytes_AsString()
|
||||
%10 = call i32 (ptr, ...) @printf(ptr @1, ptr %9)
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,34 @@
|
||||
; ModuleID = 'math'
|
||||
source_filename = "math"
|
||||
; ModuleID = 'command-line-arguments'
|
||||
source_filename = "command-line-arguments"
|
||||
|
||||
@__llgo_py.math.sqrt = external global ptr
|
||||
@"math.init$guard" = global ptr null
|
||||
@"command-line-arguments.init$guard" = global ptr null
|
||||
@__llgo_py.math = linkonce global ptr null
|
||||
@0 = private unnamed_addr constant [5 x i8] c"math\00", align 1
|
||||
@1 = private unnamed_addr constant [5 x i8] c"sqrt\00", align 1
|
||||
|
||||
define void @math.init() {
|
||||
define void @command-line-arguments.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"math.init$guard", align 1
|
||||
%0 = load i1, ptr @"command-line-arguments.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"math.init$guard", align 1
|
||||
store i1 true, ptr @"command-line-arguments.init$guard", align 1
|
||||
%1 = load ptr, ptr @__llgo_py.math, align 8
|
||||
%2 = icmp ne ptr %1, null
|
||||
br i1 %2, label %_llgo_2, label %_llgo_3
|
||||
call void (ptr, ...) @llgoLoadPyModSyms(ptr %1, ptr @1, ptr @__llgo_py.math.sqrt, ptr null)
|
||||
%2 = load ptr, ptr @__llgo_py.math, align 8
|
||||
%3 = icmp ne ptr %2, null
|
||||
br i1 %3, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_3, %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
%3 = call ptr @PyImport_ImportModule(ptr @0)
|
||||
store ptr %3, ptr @__llgo_py.math, align 8
|
||||
%4 = call ptr @PyImport_ImportModule(ptr @0)
|
||||
store ptr %4, ptr @__llgo_py.math, align 8
|
||||
br label %_llgo_2
|
||||
}
|
||||
|
||||
declare ptr @PyImport_ImportModule(ptr)
|
||||
|
||||
declare void @llgoLoadPyModSyms(ptr, ...)
|
||||
|
||||
@@ -211,7 +211,7 @@ var (
|
||||
argvTy = types.NewPointer(types.NewPointer(types.Typ[types.Int8]))
|
||||
)
|
||||
|
||||
func (p *context) compileFuncDecl(pkg llssa.Package, f *ssa.Function, call bool) (llssa.Function, llssa.PyObject, int) {
|
||||
func (p *context) compileFuncDecl(pkg llssa.Package, f *ssa.Function, call bool) (llssa.Function, llssa.PyObjRef, int) {
|
||||
pkgTypes, name, ftype := p.funcName(f, true)
|
||||
if ftype != goFunc {
|
||||
if ftype == pyFunc {
|
||||
@@ -283,7 +283,7 @@ func (p *context) compileFuncDecl(pkg llssa.Package, f *ssa.Function, call bool)
|
||||
|
||||
// funcOf returns a function by name and set ftype = goFunc, cFunc, etc.
|
||||
// or returns nil and set ftype = llgoCstr, llgoAlloca, llgoUnreachable, etc.
|
||||
func (p *context) funcOf(fn *ssa.Function) (aFn llssa.Function, pyFn llssa.PyObject, ftype int) {
|
||||
func (p *context) funcOf(fn *ssa.Function) (aFn llssa.Function, pyFn llssa.PyObjRef, ftype int) {
|
||||
pkgTypes, name, ftype := p.funcName(fn, false)
|
||||
switch ftype {
|
||||
case pyFunc:
|
||||
@@ -350,7 +350,7 @@ func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock, n int, do
|
||||
}
|
||||
p.inits = append(p.inits, func() {
|
||||
if objs := pkg.PyObjs(); len(objs) > 0 {
|
||||
mods := make(map[string][]llssa.PyObject)
|
||||
mods := make(map[string][]llssa.PyObjRef)
|
||||
for name, obj := range objs {
|
||||
modName := modOf(name)
|
||||
mods[modName] = append(mods[modName], obj)
|
||||
@@ -782,7 +782,7 @@ func (p *context) compileInstr(b llssa.Builder, instr ssa.Instruction) {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *context) compileFunction(v *ssa.Function) (goFn llssa.Function, pyFn llssa.PyObject, kind int) {
|
||||
func (p *context) compileFunction(v *ssa.Function) (goFn llssa.Function, pyFn llssa.PyObjRef, kind int) {
|
||||
// v.Pkg == nil: means auto generated function?
|
||||
if v.Pkg == p.goPkg || v.Pkg == nil {
|
||||
// function in this package
|
||||
|
||||
Reference in New Issue
Block a user