mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 23:31:37 +00:00
EngineBuilder: support for custom TargetOptions. Fixes the
ExceptionDemo example. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146108 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0c89f7fda2
commit
d40e103ea5
@ -2005,7 +2005,8 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If not set, exception handling will not be turned on
|
// If not set, exception handling will not be turned on
|
||||||
llvm::JITExceptionHandling = true;
|
llvm::TargetOptions Opts;
|
||||||
|
Opts.JITExceptionHandling = true;
|
||||||
|
|
||||||
llvm::InitializeNativeTarget();
|
llvm::InitializeNativeTarget();
|
||||||
llvm::LLVMContext &context = llvm::getGlobalContext();
|
llvm::LLVMContext &context = llvm::getGlobalContext();
|
||||||
@ -2018,6 +2019,7 @@ int main(int argc, char *argv[]) {
|
|||||||
llvm::EngineBuilder factory(module);
|
llvm::EngineBuilder factory(module);
|
||||||
factory.setEngineKind(llvm::EngineKind::JIT);
|
factory.setEngineKind(llvm::EngineKind::JIT);
|
||||||
factory.setAllocateGVsWithCode(false);
|
factory.setAllocateGVsWithCode(false);
|
||||||
|
factory.setTargetOptions(Opts);
|
||||||
llvm::ExecutionEngine *executionEngine = factory.create();
|
llvm::ExecutionEngine *executionEngine = factory.create();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "llvm/Support/ValueHandle.h"
|
#include "llvm/Support/ValueHandle.h"
|
||||||
#include "llvm/Support/Mutex.h"
|
#include "llvm/Support/Mutex.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
|
#include "llvm/Target/TargetOptions.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
@ -462,6 +463,7 @@ private:
|
|||||||
CodeGenOpt::Level OptLevel;
|
CodeGenOpt::Level OptLevel;
|
||||||
JITMemoryManager *JMM;
|
JITMemoryManager *JMM;
|
||||||
bool AllocateGVsWithCode;
|
bool AllocateGVsWithCode;
|
||||||
|
TargetOptions Options;
|
||||||
Reloc::Model RelocModel;
|
Reloc::Model RelocModel;
|
||||||
CodeModel::Model CMModel;
|
CodeModel::Model CMModel;
|
||||||
std::string MArch;
|
std::string MArch;
|
||||||
@ -475,6 +477,7 @@ private:
|
|||||||
ErrorStr = NULL;
|
ErrorStr = NULL;
|
||||||
OptLevel = CodeGenOpt::Default;
|
OptLevel = CodeGenOpt::Default;
|
||||||
JMM = NULL;
|
JMM = NULL;
|
||||||
|
Options = TargetOptions();
|
||||||
AllocateGVsWithCode = false;
|
AllocateGVsWithCode = false;
|
||||||
RelocModel = Reloc::Default;
|
RelocModel = Reloc::Default;
|
||||||
CMModel = CodeModel::JITDefault;
|
CMModel = CodeModel::JITDefault;
|
||||||
@ -518,6 +521,13 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// setTargetOptions - Set the target options that the ExecutionEngine
|
||||||
|
/// target is using. Defaults to TargetOptions().
|
||||||
|
EngineBuilder &setTargetOptions(const TargetOptions &Opts) {
|
||||||
|
Options = Opts;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/// setRelocationModel - Set the relocation model that the ExecutionEngine
|
/// setRelocationModel - Set the relocation model that the ExecutionEngine
|
||||||
/// target is using. Defaults to target specific default "Reloc::Default".
|
/// target is using. Defaults to target specific default "Reloc::Default".
|
||||||
EngineBuilder &setRelocationModel(Reloc::Model RM) {
|
EngineBuilder &setRelocationModel(Reloc::Model RM) {
|
||||||
@ -578,6 +588,7 @@ public:
|
|||||||
StringRef MArch,
|
StringRef MArch,
|
||||||
StringRef MCPU,
|
StringRef MCPU,
|
||||||
const SmallVectorImpl<std::string>& MAttrs,
|
const SmallVectorImpl<std::string>& MAttrs,
|
||||||
|
const TargetOptions &Options,
|
||||||
Reloc::Model RM,
|
Reloc::Model RM,
|
||||||
CodeModel::Model CM,
|
CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL,
|
CodeGenOpt::Level OL,
|
||||||
|
@ -436,8 +436,10 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M,
|
|||||||
StringRef MCPU = "";
|
StringRef MCPU = "";
|
||||||
SmallVector<std::string, 1> MAttrs;
|
SmallVector<std::string, 1> MAttrs;
|
||||||
|
|
||||||
|
// TODO: permit custom TargetOptions here
|
||||||
TargetMachine *TM =
|
TargetMachine *TM =
|
||||||
EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, RM, CMM, OL, ErrorStr);
|
EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, TargetOptions(), RM,
|
||||||
|
CMM, OL, ErrorStr);
|
||||||
if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
|
if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
|
||||||
|
|
||||||
return ExecutionEngine::JITCtor(M, ErrorStr, JMM, OL, GVsWithCode, TM);
|
return ExecutionEngine::JITCtor(M, ErrorStr, JMM, OL, GVsWithCode, TM);
|
||||||
@ -466,6 +468,7 @@ ExecutionEngine *EngineBuilder::create() {
|
|||||||
// try making a JIT.
|
// try making a JIT.
|
||||||
if (WhichEngine & EngineKind::JIT) {
|
if (WhichEngine & EngineKind::JIT) {
|
||||||
if (TargetMachine *TM = EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs,
|
if (TargetMachine *TM = EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs,
|
||||||
|
Options,
|
||||||
RelocModel, CMModel,
|
RelocModel, CMModel,
|
||||||
OptLevel, ErrorStr)) {
|
OptLevel, ErrorStr)) {
|
||||||
if (UseMCJIT && ExecutionEngine::MCJITCtor) {
|
if (UseMCJIT && ExecutionEngine::MCJITCtor) {
|
||||||
|
@ -30,6 +30,7 @@ TargetMachine *EngineBuilder::selectTarget(Module *Mod,
|
|||||||
StringRef MArch,
|
StringRef MArch,
|
||||||
StringRef MCPU,
|
StringRef MCPU,
|
||||||
const SmallVectorImpl<std::string>& MAttrs,
|
const SmallVectorImpl<std::string>& MAttrs,
|
||||||
|
const TargetOptions &Options,
|
||||||
Reloc::Model RM,
|
Reloc::Model RM,
|
||||||
CodeModel::Model CM,
|
CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL,
|
CodeGenOpt::Level OL,
|
||||||
@ -86,7 +87,6 @@ TargetMachine *EngineBuilder::selectTarget(Module *Mod,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a target...
|
// Allocate a target...
|
||||||
TargetOptions Options;
|
|
||||||
TargetMachine *Target = TheTarget->createTargetMachine(TheTriple.getTriple(),
|
TargetMachine *Target = TheTarget->createTargetMachine(TheTriple.getTriple(),
|
||||||
MCPU, FeaturesStr,
|
MCPU, FeaturesStr,
|
||||||
Options,
|
Options,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user