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);
// 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) {

View File

@ -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,

View File

@ -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: