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

Add ability to set code model within the execution engine builders

and creation interfaces.

llvm-svn: 89151
This commit is contained in:
Eric Christopher 2009-11-17 21:58:16 +00:00
parent f96b51a084
commit 7a90b50fc6
4 changed files with 29 additions and 10 deletions

View File

@ -113,7 +113,8 @@ protected:
std::string *ErrorStr, std::string *ErrorStr,
JITMemoryManager *JMM, JITMemoryManager *JMM,
CodeGenOpt::Level OptLevel, CodeGenOpt::Level OptLevel,
bool GVsWithCode); bool GVsWithCode,
CodeModel::Model CMM);
static ExecutionEngine *(*InterpCtor)(ModuleProvider *MP, static ExecutionEngine *(*InterpCtor)(ModuleProvider *MP,
std::string *ErrorStr); std::string *ErrorStr);
@ -173,7 +174,9 @@ public:
JITMemoryManager *JMM = 0, JITMemoryManager *JMM = 0,
CodeGenOpt::Level OptLevel = CodeGenOpt::Level OptLevel =
CodeGenOpt::Default, CodeGenOpt::Default,
bool GVsWithCode = true); bool GVsWithCode = true,
CodeModel::Model CMM =
CodeModel::Default);
/// addModuleProvider - Add a ModuleProvider to the list of modules that we /// addModuleProvider - Add a ModuleProvider to the list of modules that we
/// can JIT from. Note that this takes ownership of the ModuleProvider: when /// can JIT from. Note that this takes ownership of the ModuleProvider: when
@ -425,6 +428,7 @@ class EngineBuilder {
CodeGenOpt::Level OptLevel; CodeGenOpt::Level OptLevel;
JITMemoryManager *JMM; JITMemoryManager *JMM;
bool AllocateGVsWithCode; bool AllocateGVsWithCode;
CodeModel::Model CMModel;
/// InitEngine - Does the common initialization of default options. /// InitEngine - Does the common initialization of default options.
/// ///
@ -434,6 +438,7 @@ class EngineBuilder {
OptLevel = CodeGenOpt::Default; OptLevel = CodeGenOpt::Default;
JMM = NULL; JMM = NULL;
AllocateGVsWithCode = false; AllocateGVsWithCode = false;
CMModel = CodeModel::Default;
} }
public: public:
@ -478,6 +483,13 @@ class EngineBuilder {
return *this; return *this;
} }
/// setCodeModel - Set the CodeModel that the ExecutionEngine target
/// data is using. Defaults to target specific default "CodeModel::Default".
EngineBuilder &setCodeModel(CodeModel::Model M) {
CMModel = M;
return *this;
}
/// setAllocateGVsWithCode - Sets whether global values should be allocated /// setAllocateGVsWithCode - Sets whether global values should be allocated
/// into the same buffer as code. For most applications this should be set /// into the same buffer as code. For most applications this should be set
/// to false. Allocating globals with code breaks freeMachineCodeForFunction /// to false. Allocating globals with code breaks freeMachineCodeForFunction

View File

@ -40,7 +40,8 @@ ExecutionEngine *(*ExecutionEngine::JITCtor)(ModuleProvider *MP,
std::string *ErrorStr, std::string *ErrorStr,
JITMemoryManager *JMM, JITMemoryManager *JMM,
CodeGenOpt::Level OptLevel, CodeGenOpt::Level OptLevel,
bool GVsWithCode) = 0; bool GVsWithCode,
CodeModel::Model CMM) = 0;
ExecutionEngine *(*ExecutionEngine::InterpCtor)(ModuleProvider *MP, ExecutionEngine *(*ExecutionEngine::InterpCtor)(ModuleProvider *MP,
std::string *ErrorStr) = 0; std::string *ErrorStr) = 0;
ExecutionEngine::EERegisterFn ExecutionEngine::ExceptionTableRegister = 0; ExecutionEngine::EERegisterFn ExecutionEngine::ExceptionTableRegister = 0;
@ -444,7 +445,7 @@ ExecutionEngine *EngineBuilder::create() {
if (ExecutionEngine::JITCtor) { if (ExecutionEngine::JITCtor) {
ExecutionEngine *EE = ExecutionEngine *EE =
ExecutionEngine::JITCtor(MP, ErrorStr, JMM, OptLevel, ExecutionEngine::JITCtor(MP, ErrorStr, JMM, OptLevel,
AllocateGVsWithCode); AllocateGVsWithCode, CMModel);
if (EE) return EE; if (EE) return EE;
} }
} }

View File

@ -198,15 +198,17 @@ ExecutionEngine *ExecutionEngine::createJIT(ModuleProvider *MP,
std::string *ErrorStr, std::string *ErrorStr,
JITMemoryManager *JMM, JITMemoryManager *JMM,
CodeGenOpt::Level OptLevel, CodeGenOpt::Level OptLevel,
bool GVsWithCode) { bool GVsWithCode,
return JIT::createJIT(MP, ErrorStr, JMM, OptLevel, GVsWithCode); CodeModel::Model CMM) {
return JIT::createJIT(MP, ErrorStr, JMM, OptLevel, GVsWithCode, CMM);
} }
ExecutionEngine *JIT::createJIT(ModuleProvider *MP, ExecutionEngine *JIT::createJIT(ModuleProvider *MP,
std::string *ErrorStr, std::string *ErrorStr,
JITMemoryManager *JMM, JITMemoryManager *JMM,
CodeGenOpt::Level OptLevel, CodeGenOpt::Level OptLevel,
bool GVsWithCode) { bool GVsWithCode,
CodeModel::Model CMM) {
// Make sure we can resolve symbols in the program as well. The zero arg // Make sure we can resolve symbols in the program as well. The zero arg
// to the function tells DynamicLibrary to load the program, not a library. // to the function tells DynamicLibrary to load the program, not a library.
if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr)) if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr))
@ -215,6 +217,7 @@ ExecutionEngine *JIT::createJIT(ModuleProvider *MP,
// Pick a target either via -march or by guessing the native arch. // Pick a target either via -march or by guessing the native arch.
TargetMachine *TM = JIT::selectTarget(MP, ErrorStr); TargetMachine *TM = JIT::selectTarget(MP, ErrorStr);
if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0; if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
TM->setCodeModel(CMM);
// If the target supports JIT code generation, create a the JIT. // If the target supports JIT code generation, create a the JIT.
if (TargetJITInfo *TJ = TM->getJITInfo()) { if (TargetJITInfo *TJ = TM->getJITInfo()) {

View File

@ -85,8 +85,10 @@ public:
JITMemoryManager *JMM, JITMemoryManager *JMM,
CodeGenOpt::Level OptLevel = CodeGenOpt::Level OptLevel =
CodeGenOpt::Default, CodeGenOpt::Default,
bool GVsWithCode = true) { bool GVsWithCode = true,
return ExecutionEngine::createJIT(MP, Err, JMM, OptLevel, GVsWithCode); CodeModel::Model CMM = CodeModel::Default) {
return ExecutionEngine::createJIT(MP, Err, JMM, OptLevel, GVsWithCode,
CMM);
} }
virtual void addModuleProvider(ModuleProvider *MP); virtual void addModuleProvider(ModuleProvider *MP);
@ -175,7 +177,8 @@ public:
std::string *ErrorStr, std::string *ErrorStr,
JITMemoryManager *JMM, JITMemoryManager *JMM,
CodeGenOpt::Level OptLevel, CodeGenOpt::Level OptLevel,
bool GVsWithCode); bool GVsWithCode,
CodeModel::Model CMM);
// 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);