diff options
| author | Reid Kleckner <reid@kleckner.net> | 2009-07-18 00:42:18 +0000 |
|---|---|---|
| committer | Reid Kleckner <reid@kleckner.net> | 2009-07-18 00:42:18 +0000 |
| commit | fc8a2d5a8390952029e1c47a623e046b744f44d4 (patch) | |
| tree | 628f6fa3e2de0310edd1fed1e72a666dc19bf884 /llvm/lib/ExecutionEngine/JIT/JIT.cpp | |
| parent | 91ff94d6d9befda562a1384f43ecde6e43b9db99 (diff) | |
| download | bcm5719-llvm-fc8a2d5a8390952029e1c47a623e046b744f44d4.tar.gz bcm5719-llvm-fc8a2d5a8390952029e1c47a623e046b744f44d4.zip | |
Add EngineBuilder to ExecutionEngine in favor of the five optional argument EE::create().
Also a test commit.
llvm-svn: 76276
Diffstat (limited to 'llvm/lib/ExecutionEngine/JIT/JIT.cpp')
| -rw-r--r-- | llvm/lib/ExecutionEngine/JIT/JIT.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/JIT.cpp b/llvm/lib/ExecutionEngine/JIT/JIT.cpp index 58ff71b8460..81be38bce51 100644 --- a/llvm/lib/ExecutionEngine/JIT/JIT.cpp +++ b/llvm/lib/ExecutionEngine/JIT/JIT.cpp @@ -199,14 +199,31 @@ ExecutionEngine *ExecutionEngine::createJIT(ModuleProvider *MP, JITMemoryManager *JMM, CodeGenOpt::Level OptLevel, bool GVsWithCode) { - ExecutionEngine *EE = JIT::createJIT(MP, ErrorStr, JMM, OptLevel, - GVsWithCode); - if (!EE) return 0; - + return JIT::createJIT(MP, ErrorStr, JMM, OptLevel, GVsWithCode); +} + +ExecutionEngine *JIT::createJIT(ModuleProvider *MP, + std::string *ErrorStr, + JITMemoryManager *JMM, + CodeGenOpt::Level OptLevel, + bool GVsWithCode) { // 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; + if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr)) + return 0; + + // Pick a target either via -march or by guessing the native arch. + TargetMachine *TM = JIT::selectTarget(MP, ErrorStr); + if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0; + + // If the target supports JIT code generation, create a the JIT. + if (TargetJITInfo *TJ = TM->getJITInfo()) { + return new JIT(MP, *TM, *TJ, JMM, OptLevel, GVsWithCode); + } else { + if (ErrorStr) + *ErrorStr = "target does not support JIT code generation"; + return 0; + } } JIT::JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji, |

