1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

lli: Add stub -use-mcjit option, which doesn't currently do anything.

llvm-svn: 119508
This commit is contained in:
Daniel Dunbar 2010-11-17 16:06:37 +00:00
parent c84443a206
commit 7817c0b45f
3 changed files with 45 additions and 3 deletions

View File

@ -126,8 +126,8 @@ protected:
virtual char *getMemoryForGV(const GlobalVariable *GV); virtual char *getMemoryForGV(const GlobalVariable *GV);
// To avoid having libexecutionengine depend on the JIT and interpreter // To avoid having libexecutionengine depend on the JIT and interpreter
// libraries, the JIT and Interpreter set these functions to ctor pointers at // libraries, the execution engine implementations set these functions to ctor
// startup time if they are linked in. // pointers at startup time if they are linked in.
static ExecutionEngine *(*JITCtor)( static ExecutionEngine *(*JITCtor)(
Module *M, Module *M,
std::string *ErrorStr, std::string *ErrorStr,
@ -138,6 +138,16 @@ protected:
StringRef MArch, StringRef MArch,
StringRef MCPU, StringRef MCPU,
const SmallVectorImpl<std::string>& MAttrs); 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, static ExecutionEngine *(*InterpCtor)(Module *M,
std::string *ErrorStr); std::string *ErrorStr);
@ -447,6 +457,7 @@ private:
std::string MArch; std::string MArch;
std::string MCPU; std::string MCPU;
SmallVector<std::string, 4> MAttrs; SmallVector<std::string, 4> MAttrs;
bool UseMCJIT;
/// InitEngine - Does the common initialization of default options. /// InitEngine - Does the common initialization of default options.
void InitEngine() { void InitEngine() {
@ -456,6 +467,7 @@ private:
JMM = NULL; JMM = NULL;
AllocateGVsWithCode = false; AllocateGVsWithCode = false;
CMModel = CodeModel::Default; CMModel = CodeModel::Default;
UseMCJIT = false;
} }
public: public:
@ -526,6 +538,12 @@ public:
return *this; return *this;
} }
/// setUseMCJIT - Set whether the MC-JIT implementation should be used
/// (experimental).
void setUseMCJIT(bool Value) {
UseMCJIT = Value;
}
/// setMAttrs - Set cpu-specific attributes. /// setMAttrs - Set cpu-specific attributes.
template<typename StringSequence> template<typename StringSequence>
EngineBuilder &setMAttrs(const StringSequence &mattrs) { EngineBuilder &setMAttrs(const StringSequence &mattrs) {

View File

@ -46,6 +46,16 @@ ExecutionEngine *(*ExecutionEngine::JITCtor)(
StringRef MArch, StringRef MArch,
StringRef MCPU, StringRef MCPU,
const SmallVectorImpl<std::string>& MAttrs) = 0; 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, ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M,
std::string *ErrorStr) = 0; std::string *ErrorStr) = 0;
@ -430,7 +440,13 @@ ExecutionEngine *EngineBuilder::create() {
// Unless the interpreter was explicitly selected or the JIT is not linked, // Unless the interpreter was explicitly selected or the JIT is not linked,
// try making a JIT. // try making a JIT.
if (WhichEngine & EngineKind::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 *EE =
ExecutionEngine::JITCtor(M, ErrorStr, JMM, OptLevel, ExecutionEngine::JITCtor(M, ErrorStr, JMM, OptLevel,
AllocateGVsWithCode, CMModel, AllocateGVsWithCode, CMModel,

View File

@ -55,6 +55,10 @@ namespace {
cl::desc("Force interpretation: disable JIT"), cl::desc("Force interpretation: disable JIT"),
cl::init(false)); 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. // Determine optimization level.
cl::opt<char> cl::opt<char>
OptLevel("O", OptLevel("O",
@ -167,6 +171,10 @@ int main(int argc, char **argv, char * const *envp) {
if (!TargetTriple.empty()) if (!TargetTriple.empty())
Mod->setTargetTriple(Triple::normalize(TargetTriple)); Mod->setTargetTriple(Triple::normalize(TargetTriple));
// Enable MCJIT, if desired.
if (UseMCJIT)
builder.setUseMCJIT(true);
CodeGenOpt::Level OLvl = CodeGenOpt::Default; CodeGenOpt::Level OLvl = CodeGenOpt::Default;
switch (OptLevel) { switch (OptLevel) {
default: default: