forked from OSchip/llvm-project
ExecutionEngine: push TargetMachine creation into clients (v2)
In particular, into EngineBuilder. This should only impact the private API between the EE and EB classes, not external clients, since JITCtor and MCJITCtor are both protected members. llvm-svn: 131317
This commit is contained in:
parent
1756faa472
commit
8418fdcd59
|
@ -135,20 +135,14 @@ protected:
|
||||||
JITMemoryManager *JMM,
|
JITMemoryManager *JMM,
|
||||||
CodeGenOpt::Level OptLevel,
|
CodeGenOpt::Level OptLevel,
|
||||||
bool GVsWithCode,
|
bool GVsWithCode,
|
||||||
CodeModel::Model CMM,
|
TargetMachine *TM);
|
||||||
StringRef MArch,
|
|
||||||
StringRef MCPU,
|
|
||||||
const SmallVectorImpl<std::string>& MAttrs);
|
|
||||||
static ExecutionEngine *(*MCJITCtor)(
|
static ExecutionEngine *(*MCJITCtor)(
|
||||||
Module *M,
|
Module *M,
|
||||||
std::string *ErrorStr,
|
std::string *ErrorStr,
|
||||||
JITMemoryManager *JMM,
|
JITMemoryManager *JMM,
|
||||||
CodeGenOpt::Level OptLevel,
|
CodeGenOpt::Level OptLevel,
|
||||||
bool GVsWithCode,
|
bool GVsWithCode,
|
||||||
CodeModel::Model CMM,
|
TargetMachine *TM);
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "llvm/Support/DynamicLibrary.h"
|
#include "llvm/Support/DynamicLibrary.h"
|
||||||
#include "llvm/Support/Host.h"
|
#include "llvm/Support/Host.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
@ -42,20 +43,14 @@ ExecutionEngine *(*ExecutionEngine::JITCtor)(
|
||||||
JITMemoryManager *JMM,
|
JITMemoryManager *JMM,
|
||||||
CodeGenOpt::Level OptLevel,
|
CodeGenOpt::Level OptLevel,
|
||||||
bool GVsWithCode,
|
bool GVsWithCode,
|
||||||
CodeModel::Model CMM,
|
TargetMachine *TM) = 0;
|
||||||
StringRef MArch,
|
|
||||||
StringRef MCPU,
|
|
||||||
const SmallVectorImpl<std::string>& MAttrs) = 0;
|
|
||||||
ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
|
ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
|
||||||
Module *M,
|
Module *M,
|
||||||
std::string *ErrorStr,
|
std::string *ErrorStr,
|
||||||
JITMemoryManager *JMM,
|
JITMemoryManager *JMM,
|
||||||
CodeGenOpt::Level OptLevel,
|
CodeGenOpt::Level OptLevel,
|
||||||
bool GVsWithCode,
|
bool GVsWithCode,
|
||||||
CodeModel::Model CMM,
|
TargetMachine *TM) = 0;
|
||||||
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;
|
||||||
|
|
||||||
|
@ -441,18 +436,21 @@ 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 (UseMCJIT && ExecutionEngine::MCJITCtor) {
|
if (TargetMachine *TM =
|
||||||
ExecutionEngine *EE =
|
EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr)) {
|
||||||
ExecutionEngine::MCJITCtor(M, ErrorStr, JMM, OptLevel,
|
TM->setCodeModel(CMModel);
|
||||||
AllocateGVsWithCode, CMModel,
|
|
||||||
MArch, MCPU, MAttrs);
|
if (UseMCJIT && ExecutionEngine::MCJITCtor) {
|
||||||
if (EE) return EE;
|
ExecutionEngine *EE =
|
||||||
} else if (ExecutionEngine::JITCtor) {
|
ExecutionEngine::MCJITCtor(M, ErrorStr, JMM, OptLevel,
|
||||||
ExecutionEngine *EE =
|
AllocateGVsWithCode, TM);
|
||||||
ExecutionEngine::JITCtor(M, ErrorStr, JMM, OptLevel,
|
if (EE) return EE;
|
||||||
AllocateGVsWithCode, CMModel,
|
} else if (ExecutionEngine::JITCtor) {
|
||||||
MArch, MCPU, MAttrs);
|
ExecutionEngine *EE =
|
||||||
if (EE) return EE;
|
ExecutionEngine::JITCtor(M, ErrorStr, JMM, OptLevel,
|
||||||
|
AllocateGVsWithCode, TM);
|
||||||
|
if (EE) return EE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,8 +214,12 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M,
|
||||||
StringRef MArch = "";
|
StringRef MArch = "";
|
||||||
StringRef MCPU = "";
|
StringRef MCPU = "";
|
||||||
SmallVector<std::string, 1> MAttrs;
|
SmallVector<std::string, 1> MAttrs;
|
||||||
return JIT::createJIT(M, ErrorStr, JMM, OptLevel, GVsWithCode, CMM,
|
TargetMachine *TM =
|
||||||
MArch, MCPU, MAttrs);
|
EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr);
|
||||||
|
if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
|
||||||
|
TM->setCodeModel(CMM);
|
||||||
|
|
||||||
|
return JIT::createJIT(M, ErrorStr, JMM, OptLevel, GVsWithCode, TM);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutionEngine *JIT::createJIT(Module *M,
|
ExecutionEngine *JIT::createJIT(Module *M,
|
||||||
|
@ -223,25 +227,12 @@ ExecutionEngine *JIT::createJIT(Module *M,
|
||||||
JITMemoryManager *JMM,
|
JITMemoryManager *JMM,
|
||||||
CodeGenOpt::Level OptLevel,
|
CodeGenOpt::Level OptLevel,
|
||||||
bool GVsWithCode,
|
bool GVsWithCode,
|
||||||
CodeModel::Model CMM,
|
TargetMachine *TM) {
|
||||||
StringRef MArch,
|
|
||||||
StringRef MCPU,
|
|
||||||
const SmallVectorImpl<std::string>& MAttrs) {
|
|
||||||
// Try to register the program as a source of symbols to resolve against.
|
// Try to register the program as a source of symbols to resolve against.
|
||||||
//
|
//
|
||||||
// FIXME: Don't do this here.
|
// FIXME: Don't do this here.
|
||||||
sys::DynamicLibrary::LoadLibraryPermanently(0, NULL);
|
sys::DynamicLibrary::LoadLibraryPermanently(0, NULL);
|
||||||
|
|
||||||
// Pick a target either via -march or by guessing the native arch.
|
|
||||||
//
|
|
||||||
// FIXME: This should be lifted out of here, it isn't something which should
|
|
||||||
// be part of the JIT policy, rather the burden for this selection should be
|
|
||||||
// pushed to clients.
|
|
||||||
TargetMachine *TM =
|
|
||||||
EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr);
|
|
||||||
if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
|
|
||||||
TM->setCodeModel(CMM);
|
|
||||||
|
|
||||||
// If the target supports JIT code generation, create the JIT.
|
// If the target supports JIT code generation, create the JIT.
|
||||||
if (TargetJITInfo *TJ = TM->getJITInfo()) {
|
if (TargetJITInfo *TJ = TM->getJITInfo()) {
|
||||||
return new JIT(M, *TM, *TJ, JMM, OptLevel, GVsWithCode);
|
return new JIT(M, *TM, *TJ, JMM, OptLevel, GVsWithCode);
|
||||||
|
|
|
@ -186,10 +186,7 @@ public:
|
||||||
JITMemoryManager *JMM,
|
JITMemoryManager *JMM,
|
||||||
CodeGenOpt::Level OptLevel,
|
CodeGenOpt::Level OptLevel,
|
||||||
bool GVsWithCode,
|
bool GVsWithCode,
|
||||||
CodeModel::Model CMM,
|
TargetMachine *TM);
|
||||||
StringRef MArch,
|
|
||||||
StringRef MCPU,
|
|
||||||
const SmallVectorImpl<std::string>& MAttrs);
|
|
||||||
|
|
||||||
// Run the JIT on F and return information about the generated code
|
// Run the JIT on F and return information about the generated code
|
||||||
void runJITOnFunction(Function *F, MachineCodeInfo *MCI = 0);
|
void runJITOnFunction(Function *F, MachineCodeInfo *MCI = 0);
|
||||||
|
|
|
@ -38,25 +38,12 @@ ExecutionEngine *MCJIT::createJIT(Module *M,
|
||||||
JITMemoryManager *JMM,
|
JITMemoryManager *JMM,
|
||||||
CodeGenOpt::Level OptLevel,
|
CodeGenOpt::Level OptLevel,
|
||||||
bool GVsWithCode,
|
bool GVsWithCode,
|
||||||
CodeModel::Model CMM,
|
TargetMachine *TM) {
|
||||||
StringRef MArch,
|
|
||||||
StringRef MCPU,
|
|
||||||
const SmallVectorImpl<std::string>& MAttrs) {
|
|
||||||
// Try to register the program as a source of symbols to resolve against.
|
// Try to register the program as a source of symbols to resolve against.
|
||||||
//
|
//
|
||||||
// FIXME: Don't do this here.
|
// FIXME: Don't do this here.
|
||||||
sys::DynamicLibrary::LoadLibraryPermanently(0, NULL);
|
sys::DynamicLibrary::LoadLibraryPermanently(0, NULL);
|
||||||
|
|
||||||
// Pick a target either via -march or by guessing the native arch.
|
|
||||||
//
|
|
||||||
// FIXME: This should be lifted out of here, it isn't something which should
|
|
||||||
// be part of the JIT policy, rather the burden for this selection should be
|
|
||||||
// pushed to clients.
|
|
||||||
TargetMachine *TM =
|
|
||||||
EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr);
|
|
||||||
if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
|
|
||||||
TM->setCodeModel(CMM);
|
|
||||||
|
|
||||||
// If the target supports JIT code generation, create the JIT.
|
// If the target supports JIT code generation, create the JIT.
|
||||||
if (TargetJITInfo *TJ = TM->getJITInfo())
|
if (TargetJITInfo *TJ = TM->getJITInfo())
|
||||||
return new MCJIT(M, TM, *TJ, new MCJITMemoryManager(JMM, M), OptLevel,
|
return new MCJIT(M, TM, *TJ, new MCJITMemoryManager(JMM, M), OptLevel,
|
||||||
|
|
|
@ -81,10 +81,7 @@ public:
|
||||||
JITMemoryManager *JMM,
|
JITMemoryManager *JMM,
|
||||||
CodeGenOpt::Level OptLevel,
|
CodeGenOpt::Level OptLevel,
|
||||||
bool GVsWithCode,
|
bool GVsWithCode,
|
||||||
CodeModel::Model CMM,
|
TargetMachine *TM);
|
||||||
StringRef MArch,
|
|
||||||
StringRef MCPU,
|
|
||||||
const SmallVectorImpl<std::string>& MAttrs);
|
|
||||||
|
|
||||||
// @}
|
// @}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue