Add 8548 CPU definition and attributes

8548 CPU is GCC's name for the e500v2, so accept this in clang.  The
e500v2 doesn't support lwsync, so define __NO_LWSYNC__ for this as well,
as GCC does.

Differential Revision:  https://reviews.llvm.org/D67787
This commit is contained in:
Justin Hibbits 2019-10-24 16:22:47 -05:00
parent 9d7bccab66
commit bc4bc5aa0d
6 changed files with 44 additions and 15 deletions

View File

@ -157,6 +157,8 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("_ARCH_A2Q");
Builder.defineMacro("_ARCH_QP");
}
if (ArchDefs & ArchDefineE500)
Builder.defineMacro("__NO_LWSYNC__");
if (getTriple().getVendor() == llvm::Triple::BGQ) {
Builder.defineMacro("__bg__");
@ -312,6 +314,11 @@ bool PPCTargetInfo::initFeatureMap(
.Case("pwr8", true)
.Default(false);
Features["spe"] = llvm::StringSwitch<bool>(CPU)
.Case("8548", true)
.Case("e500", true)
.Default(false);
if (!ppcUserFeaturesCheck(Diags, FeaturesVec))
return false;
@ -449,16 +456,16 @@ ArrayRef<TargetInfo::AddlRegName> PPCTargetInfo::getGCCAddlRegNames() const {
}
static constexpr llvm::StringLiteral ValidCPUNames[] = {
{"generic"}, {"440"}, {"450"}, {"601"}, {"602"},
{"603"}, {"603e"}, {"603ev"}, {"604"}, {"604e"},
{"620"}, {"630"}, {"g3"}, {"7400"}, {"g4"},
{"7450"}, {"g4+"}, {"750"}, {"970"}, {"g5"},
{"a2"}, {"a2q"}, {"e500mc"}, {"e5500"}, {"power3"},
{"pwr3"}, {"power4"}, {"pwr4"}, {"power5"}, {"pwr5"},
{"power5x"}, {"pwr5x"}, {"power6"}, {"pwr6"}, {"power6x"},
{"pwr6x"}, {"power7"}, {"pwr7"}, {"power8"}, {"pwr8"},
{"power9"}, {"pwr9"}, {"powerpc"}, {"ppc"}, {"powerpc64"},
{"ppc64"}, {"powerpc64le"}, {"ppc64le"},
{"generic"}, {"440"}, {"450"}, {"601"}, {"602"},
{"603"}, {"603e"}, {"603ev"}, {"604"}, {"604e"},
{"620"}, {"630"}, {"g3"}, {"7400"}, {"g4"},
{"7450"}, {"g4+"}, {"750"}, {"8548"}, {"970"},
{"g5"}, {"a2"}, {"a2q"}, {"e500"}, {"e500mc"},
{"e5500"}, {"power3"}, {"pwr3"}, {"power4"}, {"pwr4"},
{"power5"}, {"pwr5"}, {"power5x"}, {"pwr5x"}, {"power6"},
{"pwr6"}, {"power6x"}, {"pwr6x"}, {"power7"}, {"pwr7"},
{"power8"}, {"pwr8"}, {"power9"}, {"pwr9"}, {"powerpc"},
{"ppc"}, {"powerpc64"}, {"ppc64"}, {"powerpc64le"}, {"ppc64le"},
};
bool PPCTargetInfo::isValidCPUName(StringRef Name) const {

View File

@ -44,7 +44,8 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public TargetInfo {
ArchDefinePwr8 = 1 << 12,
ArchDefinePwr9 = 1 << 13,
ArchDefineA2 = 1 << 14,
ArchDefineA2q = 1 << 15
ArchDefineA2q = 1 << 15,
ArchDefineE500 = 1 << 16
} ArchDefineTypes;
@ -145,6 +146,7 @@ public:
ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7 |
ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
.Cases("8548", "e500", ArchDefineE500)
.Default(ArchDefineNone);
}
return CPUKnown;

View File

@ -53,10 +53,12 @@ std::string ppc::getPPCTargetCPU(const ArgList &Args) {
.Case("7450", "7450")
.Case("G4+", "g4+")
.Case("750", "750")
.Case("8548", "e500")
.Case("970", "970")
.Case("G5", "g5")
.Case("a2", "a2")
.Case("a2q", "a2q")
.Case("e500", "e500")
.Case("e500mc", "e500mc")
.Case("e5500", "e5500")
.Case("power3", "pwr3")

View File

@ -276,6 +276,18 @@
// PPC64NS: "-cc1"
// PPC64NS: "-target-cpu" "ppc64"
// RUN: %clang -target powerpc-fsl-linux -### -S %s \
// RUN: -mcpu=e500 2>&1 | FileCheck -check-prefix=PPCE500 %s
// PPCE500: clang
// PPCE500: "-cc1"
// PPCE500: "-target-cpu" "e500"
// RUN: %clang -target powerpc-fsl-linux -### -S %s \
// RUN: -mcpu=8548 2>&1 | FileCheck -check-prefix=PPC8548 %s
// PPC8548: clang
// PPC8548: "-cc1"
// PPC8548: "-target-cpu" "e500"
// RUN: %clang -target powerpc-fsl-linux -### -S %s \
// RUN: -mcpu=e500mc 2>&1 | FileCheck -check-prefix=PPCE500MC %s
// PPCE500MC: clang

View File

@ -79,10 +79,10 @@
// PPC: error: unknown target CPU 'not-a-cpu'
// PPC: note: valid target CPU values are: generic, 440, 450, 601, 602, 603,
// PPC-SAME: 603e, 603ev, 604, 604e, 620, 630, g3, 7400, g4, 7450, g4+, 750,
// PPC-SAME: 970, g5, a2, a2q, e500mc, e5500, power3, pwr3, power4, pwr4,
// PPC-SAME: power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x, power7,
// PPC-SAME: pwr7, power8, pwr8, power9, pwr9, powerpc, ppc, powerpc64, ppc64,
// PPC-SAME: powerpc64le, ppc64le
// PPC-SAME: 8548, 970, g5, a2, a2q, e500, e500mc, e5500, power3, pwr3, power4,
// PPC-SAME: pwr4, power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x,
// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, powerpc, ppc, powerpc64,
// PPC-SAME: ppc64, powerpc64le, ppc64le
// RUN: not %clang_cc1 -triple mips--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix MIPS
// MIPS: error: unknown target CPU 'not-a-cpu'

View File

@ -7604,6 +7604,12 @@
//
// 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
// PPC8548:#define __NO_LWSYNC__ 1
// PPC8548:#define __SPE__ 1
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-apple-darwin8 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-DARWIN %s
//