mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-02 08:45:55 +00:00
Move ABI handling and 64-bitness to the PowerPC target machine.
This required changing how the computation of the ABI is handled and how some of the checks for ABI/target are done. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229471 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
cdc4c07360
commit
fb031eee53
@ -132,16 +132,6 @@ def DeprecatedDST : SubtargetFeature<"", "DeprecatedDST", "true",
|
||||
// DFP p6, p6x, p7 decimal floating-point instructions
|
||||
// POPCNTB p5 through p7 popcntb and related instructions
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ABI Selection //
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def FeatureELFv1 : SubtargetFeature<"elfv1", "TargetABI", "PPC_ABI_ELFv1",
|
||||
"Use the ELFv1 ABI">;
|
||||
|
||||
def FeatureELFv2 : SubtargetFeature<"elfv2", "TargetABI", "PPC_ABI_ELFv2",
|
||||
"Use the ELFv2 ABI">;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Classes used for relation maps.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -49,9 +49,8 @@ PPCSubtarget::PPCSubtarget(const std::string &TT, const std::string &CPU,
|
||||
: PPCGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT),
|
||||
IsPPC64(TargetTriple.getArch() == Triple::ppc64 ||
|
||||
TargetTriple.getArch() == Triple::ppc64le),
|
||||
TargetABI(PPC_ABI_UNKNOWN), TM(TM),
|
||||
FrameLowering(initializeSubtargetDependencies(CPU, FS)), InstrInfo(*this),
|
||||
TLInfo(TM, *this), TSInfo(TM.getDataLayout()) {}
|
||||
TM(TM), FrameLowering(initializeSubtargetDependencies(CPU, FS)),
|
||||
InstrInfo(*this), TLInfo(TM, *this), TSInfo(TM.getDataLayout()) {}
|
||||
|
||||
void PPCSubtarget::initializeEnvironment() {
|
||||
StackAlignment = 16;
|
||||
@ -132,16 +131,6 @@ void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
|
||||
|
||||
// Determine endianness.
|
||||
IsLittleEndian = (TargetTriple.getArch() == Triple::ppc64le);
|
||||
|
||||
// Determine default ABI.
|
||||
if (TargetABI == PPC_ABI_UNKNOWN) {
|
||||
if (!isDarwin() && IsPPC64) {
|
||||
if (IsLittleEndian)
|
||||
TargetABI = PPC_ABI_ELFv2;
|
||||
else
|
||||
TargetABI = PPC_ABI_ELFv1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// hasLazyResolverStub - Return true if accesses to the specified global have
|
||||
@ -215,3 +204,5 @@ bool PPCSubtarget::enableSubRegLiveness() const {
|
||||
return UseSubRegLiveness;
|
||||
}
|
||||
|
||||
bool PPCSubtarget::isELFv2ABI() const { return TM.isELFv2ABI(); }
|
||||
bool PPCSubtarget::isPPC64() const { return TM.isPPC64(); }
|
||||
|
@ -114,11 +114,6 @@ protected:
|
||||
bool HasICBT;
|
||||
bool HasInvariantFunctionDescriptors;
|
||||
|
||||
enum {
|
||||
PPC_ABI_UNKNOWN,
|
||||
PPC_ABI_ELFv1,
|
||||
PPC_ABI_ELFv2
|
||||
} TargetABI;
|
||||
const PPCTargetMachine &TM;
|
||||
PPCFrameLowering FrameLowering;
|
||||
PPCInstrInfo InstrInfo;
|
||||
@ -177,7 +172,7 @@ private:
|
||||
public:
|
||||
/// isPPC64 - Return true if we are generating code for 64-bit pointer mode.
|
||||
///
|
||||
bool isPPC64() const { return IsPPC64; }
|
||||
bool isPPC64() const;
|
||||
|
||||
/// has64BitSupport - Return true if the selected CPU supports 64-bit
|
||||
/// instructions, regardless of whether we are in 32-bit or 64-bit mode.
|
||||
@ -245,9 +240,9 @@ public:
|
||||
bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
|
||||
bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
|
||||
|
||||
bool isDarwinABI() const { return isDarwin(); }
|
||||
bool isSVR4ABI() const { return !isDarwin(); }
|
||||
bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; }
|
||||
bool isDarwinABI() const { return isTargetMachO() || isDarwin(); }
|
||||
bool isSVR4ABI() const { return !isDarwinABI(); }
|
||||
bool isELFv2ABI() const;
|
||||
|
||||
bool enableEarlyIfConversion() const override { return hasISEL(); }
|
||||
|
||||
|
@ -123,6 +123,30 @@ static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
|
||||
return make_unique<PPC64LinuxTargetObjectFile>();
|
||||
}
|
||||
|
||||
static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT,
|
||||
const TargetOptions &Options) {
|
||||
if (Options.MCOptions.getABIName().startswith("elfv1"))
|
||||
return PPCTargetMachine::PPC_ABI_ELFv1;
|
||||
else if (Options.MCOptions.getABIName().startswith("elfv2"))
|
||||
return PPCTargetMachine::PPC_ABI_ELFv2;
|
||||
|
||||
assert(Options.MCOptions.getABIName().empty() &&
|
||||
"Unknown target-abi option!");
|
||||
|
||||
if (!TT.isMacOSX()) {
|
||||
switch (TT.getArch()) {
|
||||
case Triple::ppc64le:
|
||||
return PPCTargetMachine::PPC_ABI_ELFv2;
|
||||
case Triple::ppc64:
|
||||
return PPCTargetMachine::PPC_ABI_ELFv1;
|
||||
default:
|
||||
// Fallthrough.
|
||||
;
|
||||
}
|
||||
}
|
||||
return PPCTargetMachine::PPC_ABI_UNKNOWN;
|
||||
}
|
||||
|
||||
// The FeatureString here is a little subtle. We are modifying the feature string
|
||||
// with what are (currently) non-function specific overrides as it goes into the
|
||||
// LLVMTargetMachine constructor and then using the stored value in the
|
||||
@ -134,6 +158,7 @@ PPCTargetMachine::PPCTargetMachine(const Target &T, StringRef TT, StringRef CPU,
|
||||
: LLVMTargetMachine(T, TT, CPU, computeFSAdditions(FS, OL, TT), Options, RM,
|
||||
CM, OL),
|
||||
TLOF(createTLOF(Triple(getTargetTriple()))),
|
||||
TargetABI(computeTargetABI(Triple(TT), Options)),
|
||||
DL(getDataLayoutString(Triple(TT))), Subtarget(TT, CPU, TargetFS, *this) {
|
||||
initAsmInfo();
|
||||
}
|
||||
|
@ -24,7 +24,11 @@ namespace llvm {
|
||||
/// PPCTargetMachine - Common code between 32-bit and 64-bit PowerPC targets.
|
||||
///
|
||||
class PPCTargetMachine : public LLVMTargetMachine {
|
||||
public:
|
||||
enum PPCABI { PPC_ABI_UNKNOWN, PPC_ABI_ELFv1, PPC_ABI_ELFv2 };
|
||||
private:
|
||||
std::unique_ptr<TargetLoweringObjectFile> TLOF;
|
||||
PPCABI TargetABI;
|
||||
// Calculates type size & alignment
|
||||
const DataLayout DL;
|
||||
PPCSubtarget Subtarget;
|
||||
@ -50,6 +54,11 @@ public:
|
||||
TargetLoweringObjectFile *getObjFileLowering() const override {
|
||||
return TLOF.get();
|
||||
}
|
||||
bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; }
|
||||
bool isPPC64() const {
|
||||
Triple TT(getTargetTriple());
|
||||
return (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le);
|
||||
};
|
||||
};
|
||||
|
||||
/// PPC32TargetMachine - PowerPC 32-bit target machine.
|
||||
|
@ -1,9 +1,9 @@
|
||||
; RUN: llc -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv1
|
||||
; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -mattr=+elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
|
||||
; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -mattr=+elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
|
||||
; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
|
||||
; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
|
||||
; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-ELFv2
|
||||
; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -mattr=+elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
|
||||
; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -mattr=+elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
|
||||
; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
|
||||
; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
|
||||
|
||||
; CHECK-ELFv2: .abiversion 2
|
||||
; CHECK-ELFv1-NOT: .abiversion 2
|
||||
|
Loading…
x
Reference in New Issue
Block a user