diff options
author | Chris Lattner <sabre@nondot.org> | 2007-12-06 01:34:04 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-12-06 01:34:04 +0000 |
commit | 4db98aafcd5e4a7e80933110cd64d4cc79300a0a (patch) | |
tree | ab136b7e1e199a68e9fe6ab59846e27cb8fce91e /lib/ExecutionEngine | |
parent | e44be00866df2aee43292cf3aed21f08ffc2b2eb (diff) | |
download | external_llvm-4db98aafcd5e4a7e80933110cd64d4cc79300a0a.zip external_llvm-4db98aafcd5e4a7e80933110cd64d4cc79300a0a.tar.gz external_llvm-4db98aafcd5e4a7e80933110cd64d4cc79300a0a.tar.bz2 |
add a new ExecutionEngine::createJIT which can be used if you only want
to create a JIT. This lets you specify JIT-specific configuration items
like the JITMemoryManager to use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44647 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine')
-rw-r--r-- | lib/ExecutionEngine/JIT/JIT.cpp | 21 | ||||
-rw-r--r-- | lib/ExecutionEngine/JIT/JIT.h | 11 | ||||
-rw-r--r-- | lib/ExecutionEngine/JIT/TargetSelect.cpp | 9 |
3 files changed, 33 insertions, 8 deletions
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index b599497..d6267d5 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -61,12 +61,29 @@ namespace llvm { } } -JIT::JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji) +/// createJIT - This is the factory method for creating a JIT for the current +/// machine, it does not fall back to the interpreter. This takes ownership +/// of the module provider. +ExecutionEngine *ExecutionEngine::createJIT(ModuleProvider *MP, + std::string *ErrorStr, + JITMemoryManager *JMM) { + ExecutionEngine *EE = JIT::createJIT(MP, ErrorStr, JMM); + if (!EE) return 0; + + + // Make sure we can resolve symbols in the program as well. The zero arg + // to the function tells DynamicLibrary to load the program, not a library. + sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr); + return EE; +} + +JIT::JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji, + JITMemoryManager *JMM) : ExecutionEngine(MP), TM(tm), TJI(tji), jitstate(MP) { setTargetData(TM.getTargetData()); // Initialize MCE - MCE = createEmitter(*this, 0); + MCE = createEmitter(*this, JMM); // Add target data MutexGuard locked(lock); diff --git a/lib/ExecutionEngine/JIT/JIT.h b/lib/ExecutionEngine/JIT/JIT.h index 6453740..789bbbb 100644 --- a/lib/ExecutionEngine/JIT/JIT.h +++ b/lib/ExecutionEngine/JIT/JIT.h @@ -56,7 +56,8 @@ class JIT : public ExecutionEngine { JITState jitstate; - JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji); + JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji, + JITMemoryManager *JMM); public: ~JIT(); @@ -71,7 +72,9 @@ public: /// create - Create an return a new JIT compiler if there is one available /// for the current target. Otherwise, return null. /// - static ExecutionEngine *create(ModuleProvider *MP, std::string* = 0); + static ExecutionEngine *create(ModuleProvider *MP, std::string *Err) { + return createJIT(MP, Err, 0); + } /// run - Start execution with the specified function and arguments. /// @@ -120,6 +123,10 @@ public: /// getCodeEmitter - Return the code emitter this JIT is emitting into. MachineCodeEmitter *getCodeEmitter() const { return MCE; } + + static ExecutionEngine *createJIT(ModuleProvider *MP, std::string *Err, + JITMemoryManager *JMM); + private: static MachineCodeEmitter *createEmitter(JIT &J, JITMemoryManager *JMM); void runJITOnFunction (Function *F); diff --git a/lib/ExecutionEngine/JIT/TargetSelect.cpp b/lib/ExecutionEngine/JIT/TargetSelect.cpp index 14e0a5f..e659850 100644 --- a/lib/ExecutionEngine/JIT/TargetSelect.cpp +++ b/lib/ExecutionEngine/JIT/TargetSelect.cpp @@ -36,10 +36,11 @@ MAttrs("mattr", cl::desc("Target specific attributes (-mattr=help for details)"), cl::value_desc("a1,+a2,-a3,...")); -/// create - Create an return a new JIT compiler if there is one available -/// for the current target. Otherwise, return null. +/// createInternal - Create an return a new JIT compiler if there is one +/// available for the current target. Otherwise, return null. /// -ExecutionEngine *JIT::create(ModuleProvider *MP, std::string *ErrorStr) { +ExecutionEngine *JIT::createJIT(ModuleProvider *MP, std::string *ErrorStr, + JITMemoryManager *JMM) { const TargetMachineRegistry::entry *TheArch = MArch; if (TheArch == 0) { std::string Error; @@ -71,7 +72,7 @@ ExecutionEngine *JIT::create(ModuleProvider *MP, std::string *ErrorStr) { // If the target supports JIT code generation, return a new JIT now. if (TargetJITInfo *TJ = Target->getJITInfo()) - return new JIT(MP, *Target, *TJ); + return new JIT(MP, *Target, *TJ, JMM); if (ErrorStr) *ErrorStr = "target does not support JIT code generation"; |