summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/ExecutionEngine/ExecutionEngine.h22
-rw-r--r--lib/ExecutionEngine/ExecutionEngine.cpp18
-rw-r--r--tools/lli/lli.cpp8
3 files changed, 45 insertions, 3 deletions
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h
index 0e51271c6f..ce80d1c676 100644
--- a/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -126,8 +126,8 @@ protected:
virtual char *getMemoryForGV(const GlobalVariable *GV);
// To avoid having libexecutionengine depend on the JIT and interpreter
- // libraries, the JIT and Interpreter set these functions to ctor pointers at
- // startup time if they are linked in.
+ // libraries, the execution engine implementations set these functions to ctor
+ // pointers at startup time if they are linked in.
static ExecutionEngine *(*JITCtor)(
Module *M,
std::string *ErrorStr,
@@ -138,6 +138,16 @@ protected:
StringRef MArch,
StringRef MCPU,
const SmallVectorImpl<std::string>& MAttrs);
+ static ExecutionEngine *(*MCJITCtor)(
+ Module *M,
+ std::string *ErrorStr,
+ JITMemoryManager *JMM,
+ CodeGenOpt::Level OptLevel,
+ bool GVsWithCode,
+ CodeModel::Model CMM,
+ StringRef MArch,
+ StringRef MCPU,
+ const SmallVectorImpl<std::string>& MAttrs);
static ExecutionEngine *(*InterpCtor)(Module *M,
std::string *ErrorStr);
@@ -447,6 +457,7 @@ private:
std::string MArch;
std::string MCPU;
SmallVector<std::string, 4> MAttrs;
+ bool UseMCJIT;
/// InitEngine - Does the common initialization of default options.
void InitEngine() {
@@ -456,6 +467,7 @@ private:
JMM = NULL;
AllocateGVsWithCode = false;
CMModel = CodeModel::Default;
+ UseMCJIT = false;
}
public:
@@ -526,6 +538,12 @@ public:
return *this;
}
+ /// setUseMCJIT - Set whether the MC-JIT implementation should be used
+ /// (experimental).
+ void setUseMCJIT(bool Value) {
+ UseMCJIT = Value;
+ }
+
/// setMAttrs - Set cpu-specific attributes.
template<typename StringSequence>
EngineBuilder &setMAttrs(const StringSequence &mattrs) {
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp
index fc5cb926e3..91d68fb1e2 100644
--- a/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -46,6 +46,16 @@ ExecutionEngine *(*ExecutionEngine::JITCtor)(
StringRef MArch,
StringRef MCPU,
const SmallVectorImpl<std::string>& MAttrs) = 0;
+ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
+ Module *M,
+ std::string *ErrorStr,
+ JITMemoryManager *JMM,
+ CodeGenOpt::Level OptLevel,
+ bool GVsWithCode,
+ CodeModel::Model CMM,
+ StringRef MArch,
+ StringRef MCPU,
+ const SmallVectorImpl<std::string>& MAttrs) = 0;
ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M,
std::string *ErrorStr) = 0;
@@ -430,7 +440,13 @@ ExecutionEngine *EngineBuilder::create() {
// Unless the interpreter was explicitly selected or the JIT is not linked,
// try making a JIT.
if (WhichEngine & EngineKind::JIT) {
- if (ExecutionEngine::JITCtor) {
+ if (UseMCJIT && ExecutionEngine::MCJITCtor) {
+ ExecutionEngine *EE =
+ ExecutionEngine::MCJITCtor(M, ErrorStr, JMM, OptLevel,
+ AllocateGVsWithCode, CMModel,
+ MArch, MCPU, MAttrs);
+ if (EE) return EE;
+ } else if (ExecutionEngine::JITCtor) {
ExecutionEngine *EE =
ExecutionEngine::JITCtor(M, ErrorStr, JMM, OptLevel,
AllocateGVsWithCode, CMModel,
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index fa2de76062..507e38d920 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -55,6 +55,10 @@ namespace {
cl::desc("Force interpretation: disable JIT"),
cl::init(false));
+ cl::opt<bool> UseMCJIT(
+ "use-mcjit", cl::desc("Enable use of the MC-based JIT (if available)"),
+ cl::init(false));
+
// Determine optimization level.
cl::opt<char>
OptLevel("O",
@@ -167,6 +171,10 @@ int main(int argc, char **argv, char * const *envp) {
if (!TargetTriple.empty())
Mod->setTargetTriple(Triple::normalize(TargetTriple));
+ // Enable MCJIT, if desired.
+ if (UseMCJIT)
+ builder.setUseMCJIT(true);
+
CodeGenOpt::Level OLvl = CodeGenOpt::Default;
switch (OptLevel) {
default: