diff --git a/include/xo/jit/Jit.hpp b/include/xo/jit/Jit.hpp index 57e8cf9e..43a289d4 100644 --- a/include/xo/jit/Jit.hpp +++ b/include/xo/jit/Jit.hpp @@ -75,6 +75,17 @@ namespace xo { static llvm::Expected> make_aux(); static xo::ref::rp make(); + // ----- module access ----- + + /** target triple = string describing target host for codegen **/ + const std::string & target_triple() const; + /** append function names defined in attached module to *p_v **/ + std::vector get_function_name_v(); + + /** write state of execution session (all the associated dynamic libraries) **/ + void dump_execution_session(); + + // ----- jit code generation ----- llvm::Value * codegen_constant(ref::brw expr); llvm::Function * codegen_primitive(ref::brw expr); diff --git a/include/xo/jit/KaleidoscopeJit.hpp b/include/xo/jit/KaleidoscopeJit.hpp index 3094c076..89f1a724 100644 --- a/include/xo/jit/KaleidoscopeJit.hpp +++ b/include/xo/jit/KaleidoscopeJit.hpp @@ -50,6 +50,7 @@ namespace xo { using SelfExecutorProcessControl = llvm::orc::SelfExecutorProcessControl; private: + /* execution session - represents a currenlty-running jit program */ std::unique_ptr ES; DataLayout DL; @@ -118,6 +119,11 @@ namespace xo { llvm::Expected lookup(StringRef Name) { return ES->lookup({&MainJD}, Mangle(Name.str())); } + + /* dump */ + void dump_execution_session() { + ES->dump(llvm::errs()); + } }; } // end namespace jit diff --git a/src/jit/Jit.cpp b/src/jit/Jit.cpp index 6a2d43a5..4591fadf 100644 --- a/src/jit/Jit.cpp +++ b/src/jit/Jit.cpp @@ -127,6 +127,23 @@ namespace xo { jit_object_layer_.setAutoClaimResponsibilityForObjectSymbols(true); } #endif + const std::string & + Jit::target_triple() const { + return llvm_module_->getTargetTriple(); + } + + std::vector + Jit::get_function_name_v() { + std::vector retval; + for (const auto & fn_name : *llvm_module_) + retval.push_back(fn_name.getName().str()); + + return retval; + } /*get_function_names*/ + + void + Jit::dump_execution_session() { + kal_jit_->dump_execution_session(); } llvm::Value *