[PowerPC]: Add powerpcspe target triple subarch component

Summary:
This allows the use of '-target powerpcspe-unknown-linux-gnu' or
'powerpcspe-unknown-freebsd' to be used, instead of
'-target powerpc-unknown-linux-gnu -mspe'.

Reviewed By: dim
Differential Revision: https://reviews.llvm.org/D72014
This commit is contained in:
Justin Hibbits 2019-12-30 15:09:39 -06:00
parent 659efa21f1
commit ff0311c4b3
7 changed files with 22 additions and 6 deletions

View File

@ -316,7 +316,8 @@ bool PPCTargetInfo::initFeatureMap(
.Case("pwr8", true)
.Default(false);
Features["spe"] = llvm::StringSwitch<bool>(CPU)
Features["spe"] = getTriple().getSubArch() == llvm::Triple::PPCSubArch_spe ||
llvm::StringSwitch<bool>(CPU)
.Case("8548", true)
.Case("e500", true)
.Default(false);

View File

@ -87,8 +87,7 @@ public:
// Note: GCC recognizes the following additional cpus:
// 401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801,
// 821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell,
// titan, rs64.
// 821, 823, 8540, e300c2, e300c3, e500mc64, e6500, 860, cell, titan, rs64.
bool isValidCPUName(StringRef Name) const override;
void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;

View File

@ -6551,10 +6551,11 @@
// PPC32-LINUX-NOT: _CALL_LINUX
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-linux-gnu -target-feature +spe < /dev/null | FileCheck -match-full-lines -check-prefix PPC32-SPE %s
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpcspe-unknown-linux-gnu < /dev/null | FileCheck -match-full-lines -check-prefix PPC32-SPE %s
//
// PPC32-SPE:#define __NO_FPRS__ 1
// PPC32-SPE:#define __SPE__ 1
//
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-linux-gnu -target-cpu 8548 < /dev/null | FileCheck -match-full-lines -check-prefix PPC8548 %s
//
// PPC8548:#define __NO_FPRS__ 1

View File

@ -128,7 +128,9 @@ public:
KalimbaSubArch_v4,
KalimbaSubArch_v5,
MipsSubArch_r6
MipsSubArch_r6,
PPCSubArch_spe
};
enum VendorType {
UnknownVendor,

View File

@ -387,7 +387,7 @@ static Triple::ArchType parseArch(StringRef ArchName) {
// FIXME: Do we need to support these?
.Cases("i786", "i886", "i986", Triple::x86)
.Cases("amd64", "x86_64", "x86_64h", Triple::x86_64)
.Cases("powerpc", "ppc", "ppc32", Triple::ppc)
.Cases("powerpc", "powerpcspe", "ppc", "ppc32", Triple::ppc)
.Cases("powerpc64", "ppu", "ppc64", Triple::ppc64)
.Cases("powerpc64le", "ppc64le", Triple::ppc64le)
.Case("xscale", Triple::arm)
@ -559,6 +559,9 @@ static Triple::SubArchType parseSubArch(StringRef SubArchName) {
(SubArchName.endswith("r6el") || SubArchName.endswith("r6")))
return Triple::MipsSubArch_r6;
if (SubArchName == "powerpcspe")
return Triple::PPCSubArch_spe;
StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
// For now, this is the small part. Early return.

View File

@ -151,6 +151,9 @@ void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
TargetTriple.isMusl())
SecurePlt = true;
if (TargetTriple.getSubArch() == Triple::PPCSubArch_spe)
HasSPE = true;
if (HasSPE && IsPPC64)
report_fatal_error( "SPE is only supported for 32-bit targets.\n", false);
if (HasSPE && (HasAltivec || HasQPX || HasVSX || HasFPU))

View File

@ -163,6 +163,13 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::UnknownOS, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
T = Triple("powerpcspe-unknown-freebsd");
EXPECT_EQ(Triple::ppc, T.getArch());
EXPECT_EQ(Triple::PPCSubArch_spe, T.getSubArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::FreeBSD, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
T = Triple("arm-none-none-eabi");
EXPECT_EQ(Triple::arm, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());