diff options
Diffstat (limited to 'contrib/llvm/tools/lli/OrcLazyJIT.h')
-rw-r--r-- | contrib/llvm/tools/lli/OrcLazyJIT.h | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/contrib/llvm/tools/lli/OrcLazyJIT.h b/contrib/llvm/tools/lli/OrcLazyJIT.h index fe86adb..bb4da33 100644 --- a/contrib/llvm/tools/lli/OrcLazyJIT.h +++ b/contrib/llvm/tools/lli/OrcLazyJIT.h @@ -23,39 +23,36 @@ #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h" #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" #include "llvm/ExecutionEngine/RTDyldMemoryManager.h" -#include "llvm/IR/LLVMContext.h" namespace llvm { class OrcLazyJIT { public: - typedef orc::JITCompileCallbackManagerBase CompileCallbackMgr; + typedef orc::JITCompileCallbackManager CompileCallbackMgr; typedef orc::ObjectLinkingLayer<> ObjLayerT; typedef orc::IRCompileLayer<ObjLayerT> CompileLayerT; typedef std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)> TransformFtor; typedef orc::IRTransformLayer<CompileLayerT, TransformFtor> IRDumpLayerT; typedef orc::CompileOnDemandLayer<IRDumpLayerT, CompileCallbackMgr> CODLayerT; + typedef CODLayerT::IndirectStubsManagerBuilderT + IndirectStubsManagerBuilder; typedef CODLayerT::ModuleSetHandleT ModuleHandleT; - typedef std::function< - std::unique_ptr<CompileCallbackMgr>(IRDumpLayerT&, - RuntimeDyld::MemoryManager&, - LLVMContext&)> - CallbackManagerBuilder; - - static CallbackManagerBuilder createCallbackManagerBuilder(Triple T); - - OrcLazyJIT(std::unique_ptr<TargetMachine> TM, LLVMContext &Context, - CallbackManagerBuilder &BuildCallbackMgr) - : TM(std::move(TM)), - ObjectLayer(), - CompileLayer(ObjectLayer, orc::SimpleCompiler(*this->TM)), - IRDumpLayer(CompileLayer, createDebugDumper()), - CCMgr(BuildCallbackMgr(IRDumpLayer, CCMgrMemMgr, Context)), - CODLayer(IRDumpLayer, *CCMgr, false), - CXXRuntimeOverrides([this](const std::string &S) { return mangle(S); }) {} + OrcLazyJIT(std::unique_ptr<TargetMachine> TM, + std::unique_ptr<CompileCallbackMgr> CCMgr, + IndirectStubsManagerBuilder IndirectStubsMgrBuilder, + bool InlineStubs) + : TM(std::move(TM)), DL(this->TM->createDataLayout()), + CCMgr(std::move(CCMgr)), + ObjectLayer(), + CompileLayer(ObjectLayer, orc::SimpleCompiler(*this->TM)), + IRDumpLayer(CompileLayer, createDebugDumper()), + CODLayer(IRDumpLayer, extractSingleFunction, *this->CCMgr, + std::move(IndirectStubsMgrBuilder), InlineStubs), + CXXRuntimeOverrides( + [this](const std::string &S) { return mangle(S); }) {} ~OrcLazyJIT() { // Run any destructors registered with __cxa_atexit. @@ -65,15 +62,13 @@ public: DtorRunner.runViaLayer(CODLayer); } - template <typename PtrTy> - static PtrTy fromTargetAddress(orc::TargetAddress Addr) { - return reinterpret_cast<PtrTy>(static_cast<uintptr_t>(Addr)); - } + static std::unique_ptr<CompileCallbackMgr> createCompileCallbackMgr(Triple T); + static IndirectStubsManagerBuilder createIndirectStubsMgrBuilder(Triple T); ModuleHandleT addModule(std::unique_ptr<Module> M) { // Attach a data-layout if one isn't already present. if (M->getDataLayout().isDefault()) - M->setDataLayout(*TM->getDataLayout()); + M->setDataLayout(DL); // Record the static constructors and destructors. We have to do this before // we hand over ownership of the module to the JIT. @@ -136,20 +131,27 @@ private: std::string MangledName; { raw_string_ostream MangledNameStream(MangledName); - Mangler::getNameWithPrefix(MangledNameStream, Name, *TM->getDataLayout()); + Mangler::getNameWithPrefix(MangledNameStream, Name, DL); } return MangledName; } + static std::set<Function*> extractSingleFunction(Function &F) { + std::set<Function*> Partition; + Partition.insert(&F); + return Partition; + } + static TransformFtor createDebugDumper(); std::unique_ptr<TargetMachine> TM; + DataLayout DL; SectionMemoryManager CCMgrMemMgr; + std::unique_ptr<CompileCallbackMgr> CCMgr; ObjLayerT ObjectLayer; CompileLayerT CompileLayer; IRDumpLayerT IRDumpLayer; - std::unique_ptr<CompileCallbackMgr> CCMgr; CODLayerT CODLayer; orc::LocalCXXRuntimeOverrides CXXRuntimeOverrides; |