mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 16:24:23 +00:00
Move the DataLayout to the generic TargetMachine, making it mandatory.
Summary: I don't know why every singled backend had to redeclare its own DataLayout. There was a virtual getDataLayout() on the common base TargetMachine, the default implementation returned nullptr. It was not clear from this that we could assume at call site that a DataLayout will be available with each Target. Now getDataLayout() is no longer virtual and return a pointer to the DataLayout member of the common base TargetMachine. I plan to turn it into a reference in a future patch. The only backend that didn't have a DataLayout previsouly was the CPPBackend. It now initializes the default DataLayout. This commit is NFC for all the other backends. Test Plan: clang+llvm ninja check-all Reviewers: echristo Subscribers: jfb, jholewinski, llvm-commits Differential Revision: http://reviews.llvm.org/D8243 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231987 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -15,6 +15,7 @@
|
|||||||
#define LLVM_TARGET_TARGETMACHINE_H
|
#define LLVM_TARGET_TARGETMACHINE_H
|
||||||
|
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
|
#include "llvm/IR/DataLayout.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Support/CodeGen.h"
|
#include "llvm/Support/CodeGen.h"
|
||||||
#include "llvm/Target/TargetOptions.h"
|
#include "llvm/Target/TargetOptions.h"
|
||||||
@ -62,12 +63,16 @@ class TargetMachine {
|
|||||||
TargetMachine(const TargetMachine &) = delete;
|
TargetMachine(const TargetMachine &) = delete;
|
||||||
void operator=(const TargetMachine &) = delete;
|
void operator=(const TargetMachine &) = delete;
|
||||||
protected: // Can only create subclasses.
|
protected: // Can only create subclasses.
|
||||||
TargetMachine(const Target &T, StringRef TargetTriple,
|
TargetMachine(const Target &T, StringRef DataLayoutString,
|
||||||
StringRef CPU, StringRef FS, const TargetOptions &Options);
|
StringRef TargetTriple, StringRef CPU, StringRef FS,
|
||||||
|
const TargetOptions &Options);
|
||||||
|
|
||||||
/// TheTarget - The Target that this machine was created for.
|
/// TheTarget - The Target that this machine was created for.
|
||||||
const Target &TheTarget;
|
const Target &TheTarget;
|
||||||
|
|
||||||
|
/// DataLayout - For ABI type size and alignment.
|
||||||
|
const DataLayout DL;
|
||||||
|
|
||||||
/// TargetTriple, TargetCPU, TargetFS - Triple string, CPU name, and target
|
/// TargetTriple, TargetCPU, TargetFS - Triple string, CPU name, and target
|
||||||
/// feature strings the TargetMachine instance is created with.
|
/// feature strings the TargetMachine instance is created with.
|
||||||
std::string TargetTriple;
|
std::string TargetTriple;
|
||||||
@ -119,9 +124,7 @@ public:
|
|||||||
|
|
||||||
/// getDataLayout - This method returns a pointer to the DataLayout for
|
/// getDataLayout - This method returns a pointer to the DataLayout for
|
||||||
/// the target. It should be unchanging for every subtarget.
|
/// the target. It should be unchanging for every subtarget.
|
||||||
virtual const DataLayout *getDataLayout() const {
|
const DataLayout *getDataLayout() const { return &DL; }
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief Reset the target options based on the function's attributes.
|
/// \brief Reset the target options based on the function's attributes.
|
||||||
// FIXME: Remove TargetOptions that affect per-function code generation
|
// FIXME: Remove TargetOptions that affect per-function code generation
|
||||||
@ -236,9 +239,9 @@ public:
|
|||||||
///
|
///
|
||||||
class LLVMTargetMachine : public TargetMachine {
|
class LLVMTargetMachine : public TargetMachine {
|
||||||
protected: // Can only create subclasses.
|
protected: // Can only create subclasses.
|
||||||
LLVMTargetMachine(const Target &T, StringRef TargetTriple,
|
LLVMTargetMachine(const Target &T, StringRef DataLayoutString,
|
||||||
StringRef CPU, StringRef FS, TargetOptions Options,
|
StringRef TargetTriple, StringRef CPU, StringRef FS,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
TargetOptions Options, Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL);
|
CodeGenOpt::Level OL);
|
||||||
|
|
||||||
void initAsmInfo();
|
void initAsmInfo();
|
||||||
|
@ -66,12 +66,13 @@ void LLVMTargetMachine::initAsmInfo() {
|
|||||||
AsmInfo = TmpAsmInfo;
|
AsmInfo = TmpAsmInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMTargetMachine::LLVMTargetMachine(const Target &T, StringRef Triple,
|
LLVMTargetMachine::LLVMTargetMachine(const Target &T,
|
||||||
StringRef CPU, StringRef FS,
|
StringRef DataLayoutString,
|
||||||
TargetOptions Options,
|
StringRef Triple, StringRef CPU,
|
||||||
|
StringRef FS, TargetOptions Options,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL)
|
CodeGenOpt::Level OL)
|
||||||
: TargetMachine(T, Triple, CPU, FS, Options) {
|
: TargetMachine(T, DataLayoutString, Triple, CPU, FS, Options) {
|
||||||
CodeGenInfo = T.createMCCodeGenInfo(Triple, RM, CM, OL);
|
CodeGenInfo = T.createMCCodeGenInfo(Triple, RM, CM, OL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,16 @@ static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
|
|||||||
return make_unique<AArch64_ELFTargetObjectFile>();
|
return make_unique<AArch64_ELFTargetObjectFile>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper function to build a DataLayout string
|
||||||
|
static std::string computeDataLayout(StringRef TT, bool LittleEndian) {
|
||||||
|
Triple Triple(TT);
|
||||||
|
if (Triple.isOSBinFormatMachO())
|
||||||
|
return "e-m:o-i64:64-i128:128-n32:64-S128";
|
||||||
|
if (LittleEndian)
|
||||||
|
return "e-m:e-i64:64-i128:128-n32:64-S128";
|
||||||
|
return "E-m:e-i64:64-i128:128-n32:64-S128";
|
||||||
|
}
|
||||||
|
|
||||||
/// TargetMachine ctor - Create an AArch64 architecture model.
|
/// TargetMachine ctor - Create an AArch64 architecture model.
|
||||||
///
|
///
|
||||||
AArch64TargetMachine::AArch64TargetMachine(const Target &T, StringRef TT,
|
AArch64TargetMachine::AArch64TargetMachine(const Target &T, StringRef TT,
|
||||||
@ -112,16 +122,14 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, StringRef TT,
|
|||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL,
|
CodeGenOpt::Level OL,
|
||||||
bool LittleEndian)
|
bool LittleEndian)
|
||||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
// This nested ternary is horrible, but DL needs to be properly
|
||||||
// This nested ternary is horrible, but DL needs to be properly
|
// initialized
|
||||||
// initialized
|
// before TLInfo is constructed.
|
||||||
// before TLInfo is constructed.
|
: LLVMTargetMachine(T, computeDataLayout(TT, LittleEndian), TT, CPU, FS,
|
||||||
DL(Triple(TT).isOSBinFormatMachO()
|
Options, RM, CM, OL),
|
||||||
? "e-m:o-i64:64-i128:128-n32:64-S128"
|
|
||||||
: (LittleEndian ? "e-m:e-i64:64-i128:128-n32:64-S128"
|
|
||||||
: "E-m:e-i64:64-i128:128-n32:64-S128")),
|
|
||||||
TLOF(createTLOF(Triple(getTargetTriple()))),
|
TLOF(createTLOF(Triple(getTargetTriple()))),
|
||||||
Subtarget(TT, CPU, FS, *this, LittleEndian), isLittle(LittleEndian) {
|
Subtarget(TT, CPU, FS, *this, LittleEndian),
|
||||||
|
isLittle(LittleEndian) {
|
||||||
initAsmInfo();
|
initAsmInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ namespace llvm {
|
|||||||
|
|
||||||
class AArch64TargetMachine : public LLVMTargetMachine {
|
class AArch64TargetMachine : public LLVMTargetMachine {
|
||||||
protected:
|
protected:
|
||||||
const DataLayout DL;
|
|
||||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||||
AArch64Subtarget Subtarget;
|
AArch64Subtarget Subtarget;
|
||||||
mutable StringMap<std::unique_ptr<AArch64Subtarget>> SubtargetMap;
|
mutable StringMap<std::unique_ptr<AArch64Subtarget>> SubtargetMap;
|
||||||
@ -36,7 +35,6 @@ public:
|
|||||||
|
|
||||||
~AArch64TargetMachine() override;
|
~AArch64TargetMachine() override;
|
||||||
|
|
||||||
const DataLayout *getDataLayout() const override { return &DL; }
|
|
||||||
const AArch64Subtarget *getSubtargetImpl() const override {
|
const AArch64Subtarget *getSubtargetImpl() const override {
|
||||||
return &Subtarget;
|
return &Subtarget;
|
||||||
}
|
}
|
||||||
|
@ -105,9 +105,11 @@ computeTargetABI(const Triple &TT, StringRef CPU,
|
|||||||
return TargetABI;
|
return TargetABI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string computeDataLayout(const Triple &TT,
|
static std::string computeDataLayout(StringRef TT, StringRef CPU,
|
||||||
ARMBaseTargetMachine::ARMABI ABI,
|
const TargetOptions &Options,
|
||||||
bool isLittle) {
|
bool isLittle) {
|
||||||
|
const Triple Triple(TT);
|
||||||
|
auto ABI = computeTargetABI(Triple, CPU, Options);
|
||||||
std::string Ret = "";
|
std::string Ret = "";
|
||||||
|
|
||||||
if (isLittle)
|
if (isLittle)
|
||||||
@ -117,7 +119,7 @@ static std::string computeDataLayout(const Triple &TT,
|
|||||||
// Big endian.
|
// Big endian.
|
||||||
Ret += "E";
|
Ret += "E";
|
||||||
|
|
||||||
Ret += DataLayout::getManglingComponent(TT);
|
Ret += DataLayout::getManglingComponent(Triple);
|
||||||
|
|
||||||
// Pointers are 32 bits and aligned to 32 bits.
|
// Pointers are 32 bits and aligned to 32 bits.
|
||||||
Ret += "-p:32:32";
|
Ret += "-p:32:32";
|
||||||
@ -147,7 +149,7 @@ static std::string computeDataLayout(const Triple &TT,
|
|||||||
|
|
||||||
// The stack is 128 bit aligned on NaCl, 64 bit aligned on AAPCS and 32 bit
|
// The stack is 128 bit aligned on NaCl, 64 bit aligned on AAPCS and 32 bit
|
||||||
// aligned everywhere else.
|
// aligned everywhere else.
|
||||||
if (TT.isOSNaCl())
|
if (Triple.isOSNaCl())
|
||||||
Ret += "-S128";
|
Ret += "-S128";
|
||||||
else if (ABI == ARMBaseTargetMachine::ARM_ABI_AAPCS)
|
else if (ABI == ARMBaseTargetMachine::ARM_ABI_AAPCS)
|
||||||
Ret += "-S64";
|
Ret += "-S64";
|
||||||
@ -164,9 +166,9 @@ ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T, StringRef TT,
|
|||||||
const TargetOptions &Options,
|
const TargetOptions &Options,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL, bool isLittle)
|
CodeGenOpt::Level OL, bool isLittle)
|
||||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
: LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options, isLittle), TT,
|
||||||
|
CPU, FS, Options, RM, CM, OL),
|
||||||
TargetABI(computeTargetABI(Triple(TT), CPU, Options)),
|
TargetABI(computeTargetABI(Triple(TT), CPU, Options)),
|
||||||
DL(computeDataLayout(Triple(TT), TargetABI, isLittle)),
|
|
||||||
TLOF(createTLOF(Triple(getTargetTriple()))),
|
TLOF(createTLOF(Triple(getTargetTriple()))),
|
||||||
Subtarget(TT, CPU, FS, *this, isLittle), isLittle(isLittle) {
|
Subtarget(TT, CPU, FS, *this, isLittle), isLittle(isLittle) {
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ public:
|
|||||||
} TargetABI;
|
} TargetABI;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const DataLayout DL;
|
|
||||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||||
ARMSubtarget Subtarget;
|
ARMSubtarget Subtarget;
|
||||||
bool isLittle;
|
bool isLittle;
|
||||||
@ -47,7 +46,6 @@ public:
|
|||||||
|
|
||||||
const ARMSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
const ARMSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||||
const ARMSubtarget *getSubtargetImpl(const Function &F) const override;
|
const ARMSubtarget *getSubtargetImpl(const Function &F) const override;
|
||||||
const DataLayout *getDataLayout() const override { return &DL; }
|
|
||||||
bool isLittleEndian() const { return isLittle; }
|
bool isLittleEndian() const { return isLittle; }
|
||||||
|
|
||||||
/// \brief Get the TargetIRAnalysis for this target.
|
/// \brief Get the TargetIRAnalysis for this target.
|
||||||
|
@ -35,9 +35,9 @@ BPFTargetMachine::BPFTargetMachine(const Target &T, StringRef TT, StringRef CPU,
|
|||||||
StringRef FS, const TargetOptions &Options,
|
StringRef FS, const TargetOptions &Options,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL)
|
CodeGenOpt::Level OL)
|
||||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
: LLVMTargetMachine(T, "e-m:e-p:64:64-i64:64-n32:64-S128", TT, CPU, FS,
|
||||||
|
Options, RM, CM, OL),
|
||||||
TLOF(make_unique<TargetLoweringObjectFileELF>()),
|
TLOF(make_unique<TargetLoweringObjectFileELF>()),
|
||||||
DL("e-m:e-p:64:64-i64:64-n32:64-S128"),
|
|
||||||
Subtarget(TT, CPU, FS, *this) {
|
Subtarget(TT, CPU, FS, *this) {
|
||||||
initAsmInfo();
|
initAsmInfo();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
class BPFTargetMachine : public LLVMTargetMachine {
|
class BPFTargetMachine : public LLVMTargetMachine {
|
||||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||||
const DataLayout DL;
|
|
||||||
BPFSubtarget Subtarget;
|
BPFSubtarget Subtarget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -26,11 +26,11 @@ class CPPSubtarget : public TargetSubtargetInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct CPPTargetMachine : public TargetMachine {
|
struct CPPTargetMachine : public TargetMachine {
|
||||||
CPPTargetMachine(const Target &T, StringRef TT,
|
CPPTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
|
||||||
StringRef CPU, StringRef FS, const TargetOptions &Options,
|
const TargetOptions &Options, Reloc::Model RM,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
CodeModel::Model CM, CodeGenOpt::Level OL)
|
||||||
CodeGenOpt::Level OL)
|
: TargetMachine(T, "", TT, CPU, FS, Options), Subtarget() {}
|
||||||
: TargetMachine(T, TT, CPU, FS, Options), Subtarget() {}
|
|
||||||
private:
|
private:
|
||||||
CPPSubtarget Subtarget;
|
CPPSubtarget Subtarget;
|
||||||
|
|
||||||
|
@ -65,9 +65,10 @@ HexagonTargetMachine::HexagonTargetMachine(const Target &T, StringRef TT,
|
|||||||
const TargetOptions &Options,
|
const TargetOptions &Options,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL)
|
CodeGenOpt::Level OL)
|
||||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
: LLVMTargetMachine(T, "e-m:e-p:32:32-i1:32-i64:64-a:0-n32", TT, CPU, FS,
|
||||||
|
Options, RM, CM, OL),
|
||||||
TLOF(make_unique<HexagonTargetObjectFile>()),
|
TLOF(make_unique<HexagonTargetObjectFile>()),
|
||||||
DL("e-m:e-p:32:32-i1:32-i64:64-a:0-n32"), Subtarget(TT, CPU, FS, *this) {
|
Subtarget(TT, CPU, FS, *this) {
|
||||||
initAsmInfo();
|
initAsmInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ class Module;
|
|||||||
|
|
||||||
class HexagonTargetMachine : public LLVMTargetMachine {
|
class HexagonTargetMachine : public LLVMTargetMachine {
|
||||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||||
const DataLayout DL; // Calculates type size & alignment.
|
|
||||||
HexagonSubtarget Subtarget;
|
HexagonSubtarget Subtarget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -33,7 +32,6 @@ public:
|
|||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL);
|
CodeGenOpt::Level OL);
|
||||||
~HexagonTargetMachine() override;
|
~HexagonTargetMachine() override;
|
||||||
const DataLayout *getDataLayout() const override { return &DL; }
|
|
||||||
const HexagonSubtarget *getSubtargetImpl() const override {
|
const HexagonSubtarget *getSubtargetImpl() const override {
|
||||||
return &Subtarget;
|
return &Subtarget;
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,11 @@ MSP430TargetMachine::MSP430TargetMachine(const Target &T, StringRef TT,
|
|||||||
const TargetOptions &Options,
|
const TargetOptions &Options,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL)
|
CodeGenOpt::Level OL)
|
||||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
: LLVMTargetMachine(T, "e-m:e-p:16:16-i32:16:32-a:16-n8:16", TT, CPU, FS,
|
||||||
|
Options, RM, CM, OL),
|
||||||
TLOF(make_unique<TargetLoweringObjectFileELF>()),
|
TLOF(make_unique<TargetLoweringObjectFileELF>()),
|
||||||
// FIXME: Check DataLayout string.
|
// FIXME: Check DataLayout string.
|
||||||
DL("e-m:e-p:16:16-i32:16:32-a:16-n8:16"), Subtarget(TT, CPU, FS, *this) {
|
Subtarget(TT, CPU, FS, *this) {
|
||||||
initAsmInfo();
|
initAsmInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ namespace llvm {
|
|||||||
///
|
///
|
||||||
class MSP430TargetMachine : public LLVMTargetMachine {
|
class MSP430TargetMachine : public LLVMTargetMachine {
|
||||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||||
const DataLayout DL; // Calculates type size & alignment
|
|
||||||
MSP430Subtarget Subtarget;
|
MSP430Subtarget Subtarget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -35,7 +34,6 @@ public:
|
|||||||
CodeGenOpt::Level OL);
|
CodeGenOpt::Level OL);
|
||||||
~MSP430TargetMachine() override;
|
~MSP430TargetMachine() override;
|
||||||
|
|
||||||
const DataLayout *getDataLayout() const override { return &DL; }
|
|
||||||
const MSP430Subtarget *getSubtargetImpl() const override {
|
const MSP430Subtarget *getSubtargetImpl() const override {
|
||||||
return &Subtarget;
|
return &Subtarget;
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,12 @@ extern "C" void LLVMInitializeMipsTarget() {
|
|||||||
RegisterTargetMachine<MipselTargetMachine> B(TheMips64elTarget);
|
RegisterTargetMachine<MipselTargetMachine> B(TheMips64elTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string computeDataLayout(bool isLittle, MipsABIInfo &ABI) {
|
static std::string computeDataLayout(StringRef TT, StringRef CPU,
|
||||||
|
const TargetOptions &Options,
|
||||||
|
bool isLittle) {
|
||||||
std::string Ret = "";
|
std::string Ret = "";
|
||||||
|
MipsABIInfo ABI =
|
||||||
|
MipsABIInfo::computeTargetABI(Triple(TT), CPU, Options.MCOptions);
|
||||||
|
|
||||||
// There are both little and big endian mips.
|
// There are both little and big endian mips.
|
||||||
if (isLittle)
|
if (isLittle)
|
||||||
@ -86,11 +90,11 @@ MipsTargetMachine::MipsTargetMachine(const Target &T, StringRef TT,
|
|||||||
const TargetOptions &Options,
|
const TargetOptions &Options,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL, bool isLittle)
|
CodeGenOpt::Level OL, bool isLittle)
|
||||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
: LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options, isLittle), TT,
|
||||||
|
CPU, FS, Options, RM, CM, OL),
|
||||||
isLittle(isLittle), TLOF(make_unique<MipsTargetObjectFile>()),
|
isLittle(isLittle), TLOF(make_unique<MipsTargetObjectFile>()),
|
||||||
ABI(MipsABIInfo::computeTargetABI(Triple(TT), CPU, Options.MCOptions)),
|
ABI(MipsABIInfo::computeTargetABI(Triple(TT), CPU, Options.MCOptions)),
|
||||||
DL(computeDataLayout(isLittle, ABI)), Subtarget(nullptr),
|
Subtarget(nullptr), DefaultSubtarget(TT, CPU, FS, isLittle, *this),
|
||||||
DefaultSubtarget(TT, CPU, FS, isLittle, *this),
|
|
||||||
NoMips16Subtarget(TT, CPU, FS.empty() ? "-mips16" : FS.str() + ",-mips16",
|
NoMips16Subtarget(TT, CPU, FS.empty() ? "-mips16" : FS.str() + ",-mips16",
|
||||||
isLittle, *this),
|
isLittle, *this),
|
||||||
Mips16Subtarget(TT, CPU, FS.empty() ? "+mips16" : FS.str() + ",+mips16",
|
Mips16Subtarget(TT, CPU, FS.empty() ? "+mips16" : FS.str() + ",+mips16",
|
||||||
|
@ -31,7 +31,6 @@ class MipsTargetMachine : public LLVMTargetMachine {
|
|||||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||||
// Selected ABI
|
// Selected ABI
|
||||||
MipsABIInfo ABI;
|
MipsABIInfo ABI;
|
||||||
const DataLayout DL; // Calculates type size & alignment
|
|
||||||
MipsSubtarget *Subtarget;
|
MipsSubtarget *Subtarget;
|
||||||
MipsSubtarget DefaultSubtarget;
|
MipsSubtarget DefaultSubtarget;
|
||||||
MipsSubtarget NoMips16Subtarget;
|
MipsSubtarget NoMips16Subtarget;
|
||||||
@ -47,7 +46,6 @@ public:
|
|||||||
|
|
||||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||||
|
|
||||||
const DataLayout *getDataLayout() const override { return &DL; }
|
|
||||||
const MipsSubtarget *getSubtargetImpl() const override {
|
const MipsSubtarget *getSubtargetImpl() const override {
|
||||||
if (Subtarget)
|
if (Subtarget)
|
||||||
return Subtarget;
|
return Subtarget;
|
||||||
|
@ -88,9 +88,10 @@ NVPTXTargetMachine::NVPTXTargetMachine(const Target &T, StringRef TT,
|
|||||||
const TargetOptions &Options,
|
const TargetOptions &Options,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL, bool is64bit)
|
CodeGenOpt::Level OL, bool is64bit)
|
||||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL), is64bit(is64bit),
|
: LLVMTargetMachine(T, computeDataLayout(is64bit), TT, CPU, FS, Options, RM,
|
||||||
TLOF(make_unique<NVPTXTargetObjectFile>()),
|
CM, OL),
|
||||||
DL(computeDataLayout(is64bit)), Subtarget(TT, CPU, FS, *this) {
|
is64bit(is64bit), TLOF(make_unique<NVPTXTargetObjectFile>()),
|
||||||
|
Subtarget(TT, CPU, FS, *this) {
|
||||||
if (Triple(TT).getOS() == Triple::NVCL)
|
if (Triple(TT).getOS() == Triple::NVCL)
|
||||||
drvInterface = NVPTX::NVCL;
|
drvInterface = NVPTX::NVCL;
|
||||||
else
|
else
|
||||||
|
@ -27,7 +27,6 @@ namespace llvm {
|
|||||||
class NVPTXTargetMachine : public LLVMTargetMachine {
|
class NVPTXTargetMachine : public LLVMTargetMachine {
|
||||||
bool is64bit;
|
bool is64bit;
|
||||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||||
const DataLayout DL; // Calculates type size & alignment
|
|
||||||
NVPTX::DrvInterface drvInterface;
|
NVPTX::DrvInterface drvInterface;
|
||||||
NVPTXSubtarget Subtarget;
|
NVPTXSubtarget Subtarget;
|
||||||
|
|
||||||
@ -40,7 +39,6 @@ public:
|
|||||||
CodeModel::Model CM, CodeGenOpt::Level OP, bool is64bit);
|
CodeModel::Model CM, CodeGenOpt::Level OP, bool is64bit);
|
||||||
|
|
||||||
~NVPTXTargetMachine() override;
|
~NVPTXTargetMachine() override;
|
||||||
const DataLayout *getDataLayout() const override { return &DL; }
|
|
||||||
const NVPTXSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
const NVPTXSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||||
bool is64Bit() const { return is64bit; }
|
bool is64Bit() const { return is64bit; }
|
||||||
NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
|
NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
|
||||||
|
@ -160,11 +160,11 @@ PPCTargetMachine::PPCTargetMachine(const Target &T, StringRef TT, StringRef CPU,
|
|||||||
StringRef FS, const TargetOptions &Options,
|
StringRef FS, const TargetOptions &Options,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL)
|
CodeGenOpt::Level OL)
|
||||||
: LLVMTargetMachine(T, TT, CPU, computeFSAdditions(FS, OL, TT), Options, RM,
|
: LLVMTargetMachine(T, getDataLayoutString(Triple(TT)), TT, CPU,
|
||||||
CM, OL),
|
computeFSAdditions(FS, OL, TT), Options, RM, CM, OL),
|
||||||
TLOF(createTLOF(Triple(getTargetTriple()))),
|
TLOF(createTLOF(Triple(getTargetTriple()))),
|
||||||
TargetABI(computeTargetABI(Triple(TT), Options)),
|
TargetABI(computeTargetABI(Triple(TT), Options)),
|
||||||
DL(getDataLayoutString(Triple(TT))), Subtarget(TT, CPU, TargetFS, *this) {
|
Subtarget(TT, CPU, TargetFS, *this) {
|
||||||
initAsmInfo();
|
initAsmInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||||
PPCABI TargetABI;
|
PPCABI TargetABI;
|
||||||
// Calculates type size & alignment
|
|
||||||
const DataLayout DL;
|
|
||||||
PPCSubtarget Subtarget;
|
PPCSubtarget Subtarget;
|
||||||
|
|
||||||
mutable StringMap<std::unique_ptr<PPCSubtarget>> SubtargetMap;
|
mutable StringMap<std::unique_ptr<PPCSubtarget>> SubtargetMap;
|
||||||
@ -42,7 +40,6 @@ public:
|
|||||||
|
|
||||||
~PPCTargetMachine() override;
|
~PPCTargetMachine() override;
|
||||||
|
|
||||||
const DataLayout *getDataLayout() const override { return &DL; }
|
|
||||||
const PPCSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
const PPCSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||||
const PPCSubtarget *getSubtargetImpl(const Function &F) const override;
|
const PPCSubtarget *getSubtargetImpl(const Function &F) const override;
|
||||||
|
|
||||||
|
@ -71,10 +71,10 @@ AMDGPUTargetMachine::AMDGPUTargetMachine(const Target &T, StringRef TT,
|
|||||||
TargetOptions Options, Reloc::Model RM,
|
TargetOptions Options, Reloc::Model RM,
|
||||||
CodeModel::Model CM,
|
CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OptLevel)
|
CodeGenOpt::Level OptLevel)
|
||||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OptLevel),
|
: LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, RM, CM,
|
||||||
DL(computeDataLayout(TT)),
|
OptLevel),
|
||||||
TLOF(new TargetLoweringObjectFileELF()),
|
TLOF(new TargetLoweringObjectFileELF()), Subtarget(TT, CPU, FS, *this),
|
||||||
Subtarget(TT, CPU, FS, *this), IntrinsicInfo() {
|
IntrinsicInfo() {
|
||||||
setRequiresStructuredCFG(true);
|
setRequiresStructuredCFG(true);
|
||||||
initAsmInfo();
|
initAsmInfo();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ namespace llvm {
|
|||||||
|
|
||||||
class AMDGPUTargetMachine : public LLVMTargetMachine {
|
class AMDGPUTargetMachine : public LLVMTargetMachine {
|
||||||
private:
|
private:
|
||||||
const DataLayout DL;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TargetLoweringObjectFile *TLOF;
|
TargetLoweringObjectFile *TLOF;
|
||||||
@ -42,11 +41,7 @@ public:
|
|||||||
StringRef CPU, TargetOptions Options, Reloc::Model RM,
|
StringRef CPU, TargetOptions Options, Reloc::Model RM,
|
||||||
CodeModel::Model CM, CodeGenOpt::Level OL);
|
CodeModel::Model CM, CodeGenOpt::Level OL);
|
||||||
~AMDGPUTargetMachine();
|
~AMDGPUTargetMachine();
|
||||||
// FIXME: This is currently broken, the DataLayout needs to move to
|
|
||||||
// the target machine.
|
|
||||||
const DataLayout *getDataLayout() const override {
|
|
||||||
return &DL;
|
|
||||||
}
|
|
||||||
const AMDGPUSubtarget *getSubtargetImpl() const override {
|
const AMDGPUSubtarget *getSubtargetImpl() const override {
|
||||||
return &Subtarget;
|
return &Subtarget;
|
||||||
}
|
}
|
||||||
|
@ -56,12 +56,11 @@ SparcTargetMachine::SparcTargetMachine(const Target &T, StringRef TT,
|
|||||||
StringRef CPU, StringRef FS,
|
StringRef CPU, StringRef FS,
|
||||||
const TargetOptions &Options,
|
const TargetOptions &Options,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL,
|
CodeGenOpt::Level OL, bool is64bit)
|
||||||
bool is64bit)
|
: LLVMTargetMachine(T, computeDataLayout(is64bit), TT, CPU, FS, Options, RM,
|
||||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
CM, OL),
|
||||||
TLOF(make_unique<SparcELFTargetObjectFile>()),
|
TLOF(make_unique<SparcELFTargetObjectFile>()),
|
||||||
DL(computeDataLayout(is64bit)),
|
Subtarget(TT, CPU, FS, *this, is64bit) {
|
||||||
Subtarget(TT, CPU, FS, *this, is64bit) {
|
|
||||||
initAsmInfo();
|
initAsmInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ namespace llvm {
|
|||||||
|
|
||||||
class SparcTargetMachine : public LLVMTargetMachine {
|
class SparcTargetMachine : public LLVMTargetMachine {
|
||||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||||
const DataLayout DL;
|
|
||||||
SparcSubtarget Subtarget;
|
SparcSubtarget Subtarget;
|
||||||
public:
|
public:
|
||||||
SparcTargetMachine(const Target &T, StringRef TT,
|
SparcTargetMachine(const Target &T, StringRef TT,
|
||||||
@ -31,7 +30,6 @@ public:
|
|||||||
CodeGenOpt::Level OL, bool is64bit);
|
CodeGenOpt::Level OL, bool is64bit);
|
||||||
~SparcTargetMachine() override;
|
~SparcTargetMachine() override;
|
||||||
|
|
||||||
const DataLayout *getDataLayout() const override { return &DL; }
|
|
||||||
const SparcSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
const SparcSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||||
|
|
||||||
// Pass Pipeline Configuration
|
// Pass Pipeline Configuration
|
||||||
|
@ -25,12 +25,12 @@ SystemZTargetMachine::SystemZTargetMachine(const Target &T, StringRef TT,
|
|||||||
const TargetOptions &Options,
|
const TargetOptions &Options,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL)
|
CodeGenOpt::Level OL)
|
||||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
// Make sure that global data has at least 16 bits of alignment by
|
||||||
|
// default, so that we can refer to it using LARL. We don't have any
|
||||||
|
// special requirements for stack variables though.
|
||||||
|
: LLVMTargetMachine(T, "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64",
|
||||||
|
TT, CPU, FS, Options, RM, CM, OL),
|
||||||
TLOF(make_unique<TargetLoweringObjectFileELF>()),
|
TLOF(make_unique<TargetLoweringObjectFileELF>()),
|
||||||
// Make sure that global data has at least 16 bits of alignment by
|
|
||||||
// default, so that we can refer to it using LARL. We don't have any
|
|
||||||
// special requirements for stack variables though.
|
|
||||||
DL("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"),
|
|
||||||
Subtarget(TT, CPU, FS, *this) {
|
Subtarget(TT, CPU, FS, *this) {
|
||||||
initAsmInfo();
|
initAsmInfo();
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ class TargetFrameLowering;
|
|||||||
|
|
||||||
class SystemZTargetMachine : public LLVMTargetMachine {
|
class SystemZTargetMachine : public LLVMTargetMachine {
|
||||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||||
const DataLayout DL;
|
|
||||||
SystemZSubtarget Subtarget;
|
SystemZSubtarget Subtarget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -34,8 +33,6 @@ public:
|
|||||||
CodeGenOpt::Level OL);
|
CodeGenOpt::Level OL);
|
||||||
~SystemZTargetMachine() override;
|
~SystemZTargetMachine() override;
|
||||||
|
|
||||||
// Override TargetMachine.
|
|
||||||
const DataLayout *getDataLayout() const override { return &DL; }
|
|
||||||
const SystemZSubtarget *getSubtargetImpl() const override {
|
const SystemZSubtarget *getSubtargetImpl() const override {
|
||||||
return &Subtarget;
|
return &Subtarget;
|
||||||
}
|
}
|
||||||
|
@ -36,14 +36,12 @@ using namespace llvm;
|
|||||||
// TargetMachine Class
|
// TargetMachine Class
|
||||||
//
|
//
|
||||||
|
|
||||||
TargetMachine::TargetMachine(const Target &T,
|
TargetMachine::TargetMachine(const Target &T, StringRef DataLayoutString,
|
||||||
StringRef TT, StringRef CPU, StringRef FS,
|
StringRef TT, StringRef CPU, StringRef FS,
|
||||||
const TargetOptions &Options)
|
const TargetOptions &Options)
|
||||||
: TheTarget(T), TargetTriple(TT), TargetCPU(CPU), TargetFS(FS),
|
: TheTarget(T), DL(DataLayoutString), TargetTriple(TT), TargetCPU(CPU),
|
||||||
CodeGenInfo(nullptr), AsmInfo(nullptr),
|
TargetFS(FS), CodeGenInfo(nullptr), AsmInfo(nullptr),
|
||||||
RequireStructuredCFG(false),
|
RequireStructuredCFG(false), Options(Options) {}
|
||||||
Options(Options) {
|
|
||||||
}
|
|
||||||
|
|
||||||
TargetMachine::~TargetMachine() {
|
TargetMachine::~TargetMachine() {
|
||||||
delete CodeGenInfo;
|
delete CodeGenInfo;
|
||||||
|
@ -94,9 +94,9 @@ X86TargetMachine::X86TargetMachine(const Target &T, StringRef TT, StringRef CPU,
|
|||||||
StringRef FS, const TargetOptions &Options,
|
StringRef FS, const TargetOptions &Options,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL)
|
CodeGenOpt::Level OL)
|
||||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
: LLVMTargetMachine(T, computeDataLayout(Triple(TT)), TT, CPU, FS, Options,
|
||||||
|
RM, CM, OL),
|
||||||
TLOF(createTLOF(Triple(getTargetTriple()))),
|
TLOF(createTLOF(Triple(getTargetTriple()))),
|
||||||
DL(computeDataLayout(Triple(TT))),
|
|
||||||
Subtarget(TT, CPU, FS, *this, Options.StackAlignmentOverride) {
|
Subtarget(TT, CPU, FS, *this, Options.StackAlignmentOverride) {
|
||||||
// default to hard float ABI
|
// default to hard float ABI
|
||||||
if (Options.FloatABIType == FloatABI::Default)
|
if (Options.FloatABIType == FloatABI::Default)
|
||||||
|
@ -24,8 +24,6 @@ class StringRef;
|
|||||||
|
|
||||||
class X86TargetMachine final : public LLVMTargetMachine {
|
class X86TargetMachine final : public LLVMTargetMachine {
|
||||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||||
// Calculates type size & alignment
|
|
||||||
const DataLayout DL;
|
|
||||||
X86Subtarget Subtarget;
|
X86Subtarget Subtarget;
|
||||||
|
|
||||||
mutable StringMap<std::unique_ptr<X86Subtarget>> SubtargetMap;
|
mutable StringMap<std::unique_ptr<X86Subtarget>> SubtargetMap;
|
||||||
@ -35,7 +33,6 @@ public:
|
|||||||
const TargetOptions &Options, Reloc::Model RM,
|
const TargetOptions &Options, Reloc::Model RM,
|
||||||
CodeModel::Model CM, CodeGenOpt::Level OL);
|
CodeModel::Model CM, CodeGenOpt::Level OL);
|
||||||
~X86TargetMachine() override;
|
~X86TargetMachine() override;
|
||||||
const DataLayout *getDataLayout() const override { return &DL; }
|
|
||||||
const X86Subtarget *getSubtargetImpl() const override { return &Subtarget; }
|
const X86Subtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||||
const X86Subtarget *getSubtargetImpl(const Function &F) const override;
|
const X86Subtarget *getSubtargetImpl(const Function &F) const override;
|
||||||
|
|
||||||
|
@ -27,9 +27,10 @@ XCoreTargetMachine::XCoreTargetMachine(const Target &T, StringRef TT,
|
|||||||
const TargetOptions &Options,
|
const TargetOptions &Options,
|
||||||
Reloc::Model RM, CodeModel::Model CM,
|
Reloc::Model RM, CodeModel::Model CM,
|
||||||
CodeGenOpt::Level OL)
|
CodeGenOpt::Level OL)
|
||||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
: LLVMTargetMachine(
|
||||||
|
T, "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32",
|
||||||
|
TT, CPU, FS, Options, RM, CM, OL),
|
||||||
TLOF(make_unique<XCoreTargetObjectFile>()),
|
TLOF(make_unique<XCoreTargetObjectFile>()),
|
||||||
DL("e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32"),
|
|
||||||
Subtarget(TT, CPU, FS, *this) {
|
Subtarget(TT, CPU, FS, *this) {
|
||||||
initAsmInfo();
|
initAsmInfo();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ namespace llvm {
|
|||||||
|
|
||||||
class XCoreTargetMachine : public LLVMTargetMachine {
|
class XCoreTargetMachine : public LLVMTargetMachine {
|
||||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||||
const DataLayout DL; // Calculates type size & alignment
|
|
||||||
XCoreSubtarget Subtarget;
|
XCoreSubtarget Subtarget;
|
||||||
public:
|
public:
|
||||||
XCoreTargetMachine(const Target &T, StringRef TT,
|
XCoreTargetMachine(const Target &T, StringRef TT,
|
||||||
@ -30,7 +29,6 @@ public:
|
|||||||
CodeGenOpt::Level OL);
|
CodeGenOpt::Level OL);
|
||||||
~XCoreTargetMachine() override;
|
~XCoreTargetMachine() override;
|
||||||
|
|
||||||
const DataLayout *getDataLayout() const override { return &DL; }
|
|
||||||
const XCoreSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
const XCoreSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||||
|
|
||||||
// Pass Pipeline Configuration
|
// Pass Pipeline Configuration
|
||||||
|
Reference in New Issue
Block a user