From 1c820cfeb985c686a355dd48d612b2b80ae57d07 Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Fri, 20 May 2016 03:21:37 +0000 Subject: [PATCH] [lanai] Use Optional in LanaiTargetMachine. Follow r269988 and use Optional. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270176 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Lanai/LanaiSubtarget.cpp | 1 - lib/Target/Lanai/LanaiSubtarget.h | 4 ++-- lib/Target/Lanai/LanaiTargetMachine.cpp | 21 +++++++++++++-------- lib/Target/Lanai/LanaiTargetMachine.h | 3 ++- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/Target/Lanai/LanaiSubtarget.cpp b/lib/Target/Lanai/LanaiSubtarget.cpp index 98b934016310..bfe07170050f 100644 --- a/lib/Target/Lanai/LanaiSubtarget.cpp +++ b/lib/Target/Lanai/LanaiSubtarget.cpp @@ -40,7 +40,6 @@ LanaiSubtarget &LanaiSubtarget::initializeSubtargetDependencies(StringRef CPU, LanaiSubtarget::LanaiSubtarget(const Triple &TargetTriple, StringRef Cpu, StringRef FeatureString, const TargetMachine &TM, const TargetOptions &Options, - Reloc::Model RelocationModel, CodeModel::Model CodeModel, CodeGenOpt::Level OptLevel) : LanaiGenSubtargetInfo(TargetTriple, Cpu, FeatureString), diff --git a/lib/Target/Lanai/LanaiSubtarget.h b/lib/Target/Lanai/LanaiSubtarget.h index f50347682e22..2732ef3097ec 100644 --- a/lib/Target/Lanai/LanaiSubtarget.h +++ b/lib/Target/Lanai/LanaiSubtarget.h @@ -34,8 +34,8 @@ class LanaiSubtarget : public LanaiGenSubtargetInfo { // of the specified triple. LanaiSubtarget(const Triple &TargetTriple, StringRef Cpu, StringRef FeatureString, const TargetMachine &TM, - const TargetOptions &Options, Reloc::Model RelocationModel, - CodeModel::Model CodeModel, CodeGenOpt::Level OptLevel); + const TargetOptions &Options, CodeModel::Model CodeModel, + CodeGenOpt::Level OptLevel); // ParseSubtargetFeatures - Parses features string setting specified // subtarget options. Definition of function is auto generated by tblgen. diff --git a/lib/Target/Lanai/LanaiTargetMachine.cpp b/lib/Target/Lanai/LanaiTargetMachine.cpp index f89464826b3f..bb418f3110c9 100644 --- a/lib/Target/Lanai/LanaiTargetMachine.cpp +++ b/lib/Target/Lanai/LanaiTargetMachine.cpp @@ -47,18 +47,23 @@ static std::string computeDataLayout(const Triple &TT) { "-S64"; // 64 bit natural stack alignment } -LanaiTargetMachine::LanaiTargetMachine(const Target &TheTarget, - const Triple &TargetTriple, +static Reloc::Model getEffectiveRelocModel(const Triple &TT, + Optional RM) { + if (!RM.hasValue()) + return Reloc::Static; + return *RM; +} + +LanaiTargetMachine::LanaiTargetMachine(const Target &T, const Triple &TT, StringRef Cpu, StringRef FeatureString, const TargetOptions &Options, - Reloc::Model RelocationModel, + Optional RM, CodeModel::Model CodeModel, CodeGenOpt::Level OptLevel) - : LLVMTargetMachine(TheTarget, computeDataLayout(TargetTriple), - TargetTriple, Cpu, FeatureString, Options, - RelocationModel, CodeModel, OptLevel), - Subtarget(TargetTriple, Cpu, FeatureString, *this, Options, - RelocationModel, CodeModel, OptLevel), + : LLVMTargetMachine(T, computeDataLayout(TargetTriple), TT, Cpu, + FeatureString, Options, getEffectiveRelocModel(TT, RM), + CodeModel, OptLevel), + Subtarget(TT, Cpu, FeatureString, *this, Options, CodeModel, OptLevel), TLOF(new LanaiTargetObjectFile()) { initAsmInfo(); } diff --git a/lib/Target/Lanai/LanaiTargetMachine.h b/lib/Target/Lanai/LanaiTargetMachine.h index 9c911768e300..1f616085cdbe 100644 --- a/lib/Target/Lanai/LanaiTargetMachine.h +++ b/lib/Target/Lanai/LanaiTargetMachine.h @@ -32,7 +32,8 @@ class LanaiTargetMachine : public LLVMTargetMachine { public: LanaiTargetMachine(const Target &TheTarget, const Triple &TargetTriple, StringRef Cpu, StringRef FeatureString, - const TargetOptions &Options, Reloc::Model RelocationModel, + const TargetOptions &Options, + Optional RelocationModel, CodeModel::Model CodeModel, CodeGenOpt::Level OptLevel); const LanaiSubtarget *