diff options
author | Dylan Noblesmith <nobled@dreamwidth.org> | 2011-12-12 04:20:36 +0000 |
---|---|---|
committer | Dylan Noblesmith <nobled@dreamwidth.org> | 2011-12-12 04:20:36 +0000 |
commit | 9ea47179e647e806a2c67639bfead9d254514e59 (patch) | |
tree | 47f423d3a96aab3f5187f8c0222f4b61916e9a73 /lib/ExecutionEngine/ExecutionEngine.cpp | |
parent | d93e4c34963e83befbe67370fa39b66530b5e193 (diff) |
ExecutionEngine: refactor interface
The OptLevel is now redundant with the TargetMachine*.
And selectTarget() isn't really JIT-specific and could probably
get refactored into one of the lower level libraries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146355 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/ExecutionEngine.cpp')
-rw-r--r-- | lib/ExecutionEngine/ExecutionEngine.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 26b0584840..7829a2986b 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/Host.h" +#include "llvm/Support/TargetRegistry.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include <cmath> @@ -41,14 +42,12 @@ ExecutionEngine *(*ExecutionEngine::JITCtor)( Module *M, std::string *ErrorStr, JITMemoryManager *JMM, - CodeGenOpt::Level OptLevel, bool GVsWithCode, TargetMachine *TM) = 0; ExecutionEngine *(*ExecutionEngine::MCJITCtor)( Module *M, std::string *ErrorStr, JITMemoryManager *JMM, - CodeGenOpt::Level OptLevel, bool GVsWithCode, TargetMachine *TM) = 0; ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M, @@ -436,13 +435,14 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M, StringRef MCPU = ""; SmallVector<std::string, 1> MAttrs; + Triple TT(M->getTargetTriple()); // TODO: permit custom TargetOptions here TargetMachine *TM = - EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, TargetOptions(), RM, + EngineBuilder::selectTarget(TT, MArch, MCPU, MAttrs, TargetOptions(), RM, CMM, OL, ErrorStr); if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0; - return ExecutionEngine::JITCtor(M, ErrorStr, JMM, OL, GVsWithCode, TM); + return ExecutionEngine::JITCtor(M, ErrorStr, JMM, GVsWithCode, TM); } ExecutionEngine *EngineBuilder::create() { @@ -467,18 +467,25 @@ ExecutionEngine *EngineBuilder::create() { // Unless the interpreter was explicitly selected or the JIT is not linked, // try making a JIT. if (WhichEngine & EngineKind::JIT) { - if (TargetMachine *TM = EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, + Triple TT(M->getTargetTriple()); + if (TargetMachine *TM = EngineBuilder::selectTarget(TT, MArch, MCPU, MAttrs, Options, RelocModel, CMModel, OptLevel, ErrorStr)) { + if (!TM->getTarget().hasJIT()) { + errs() << "WARNING: This target JIT is not designed for the host" + << " you are running. If bad things happen, please choose" + << " a different -march switch.\n"; + } + if (UseMCJIT && ExecutionEngine::MCJITCtor) { ExecutionEngine *EE = - ExecutionEngine::MCJITCtor(M, ErrorStr, JMM, OptLevel, + ExecutionEngine::MCJITCtor(M, ErrorStr, JMM, AllocateGVsWithCode, TM); if (EE) return EE; } else if (ExecutionEngine::JITCtor) { ExecutionEngine *EE = - ExecutionEngine::JITCtor(M, ErrorStr, JMM, OptLevel, + ExecutionEngine::JITCtor(M, ErrorStr, JMM, AllocateGVsWithCode, TM); if (EE) return EE; } |