cl: _testpy/math

This commit is contained in:
xushiwei
2024-05-11 15:12:42 +08:00
parent 97cb312386
commit 15499ddc14
2 changed files with 30 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
; ModuleID = 'math'
source_filename = "math"
@__llgo_py.math.sqrt = external global ptr
@"math.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
define void @math.init() {
_llgo_0:
%0 = load i1, ptr @"math.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
%1 = load ptr, ptr @__llgo_py.math, align 8
%2 = icmp ne ptr %1, null
br i1 %2, 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
br label %_llgo_2
}
declare ptr @PyImport_ImportModule(ptr)

View File

@@ -217,7 +217,7 @@ func (p *context) compileFuncDecl(pkg llssa.Package, f *ssa.Function) llssa.Func
if ftype == pyFunc {
// TODO(xsw): pyMod == ""
fn := pysymPrefix + p.pyMod + "." + name
pkg.NewVar(fn, types.Typ[types.Int], llssa.InC)
pkg.NewVar(fn, pkg.Prog.PyObjectPtrPtr().RawType(), llssa.InC)
}
return nil
}