From 6f4f06f1b1f69734438d201da9abfb1660b31c37 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 5 Jul 2024 13:52:03 -0400 Subject: [PATCH 1/2] xo-pyjit: + reflect fyunction type so can declare vars w/ that type --- src/pyjit/pyjit.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pyjit/pyjit.cpp b/src/pyjit/pyjit.cpp index 184fb309..04cfd968 100644 --- a/src/pyjit/pyjit.cpp +++ b/src/pyjit/pyjit.cpp @@ -17,6 +17,7 @@ namespace xo { using xo::ast::llvmintrinsic; using xo::pyutil::pycaller_base; using xo::pyutil::pycaller; + using xo::reflect::Reflect; using xo::ref::rp; //using xo::ref::Refcount; using xo::ref::unowned_ptr; @@ -54,6 +55,11 @@ namespace xo { { using caller_type = pycaller; + /* we want native function type reflected; + * need this so we can declare function-valued variables + */ + Reflect::require(); + caller_type::declare_once(m, pycaller_id_str); /* factory function takes function pointer of type From a0d748ef9f506597132a9859fb37221d707dbb64 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 5 Jul 2024 13:52:31 -0400 Subject: [PATCH 2/2] xo-pyjit: fix: MachPipeline::codegen_toplevel() instead of codegen() --- src/pyjit/pyjit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyjit/pyjit.cpp b/src/pyjit/pyjit.cpp index 04cfd968..527cfe1a 100644 --- a/src/pyjit/pyjit.cpp +++ b/src/pyjit/pyjit.cpp @@ -156,7 +156,7 @@ namespace xo { py::doc("write to console with state of all jit-owned dynamic libraries")) .def("codegen", [](MachPipeline & jit, const rp & expr) { - return jit.codegen(expr.borrow()); + return jit.codegen_toplevel(expr.borrow()); }, py::arg("x"), py::doc("generate llvm (IR) code for Expression x"),