Skip to content

Commit dcceab1

Browse files
[PowerPC] Add new Future CPU for PowerPC in LLVM
This is a continuation of D70262 The previous patch as listed above added the future CPU in clang. This patch adds the future CPU in the PowerPC backend. At this point the patch simply assumes that a future CPU will have the same characteristics as pwr9. Those characteristics may change with later patches. Differential Revision: https://reviews.llvm.org/D70333
1 parent f584f04 commit dcceab1

File tree

7 files changed

+37
-4
lines changed

7 files changed

+37
-4
lines changed

llvm/lib/Support/Host.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ StringRef sys::detail::getHostCPUNameForPowerPC(StringRef ProcCpuinfoContent) {
140140
.Case("POWER8E", "pwr8")
141141
.Case("POWER8NVL", "pwr8")
142142
.Case("POWER9", "pwr9")
143+
// FIXME: If we get a simulator or machine with the capabilities of
144+
// mcpu=future, we should revisit this and add the name reported by the
145+
// simulator/machine.
143146
.Default(generic);
144147
}
145148

llvm/lib/Target/PowerPC/PPC.td

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def DirectivePwr6x
5151
def DirectivePwr7: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR7", "">;
5252
def DirectivePwr8: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR8", "">;
5353
def DirectivePwr9: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR9", "">;
54+
def DirectivePwrFuture
55+
: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR_FUTURE", "">;
5456

5557
def Feature64Bit : SubtargetFeature<"64bit","Has64BitSupport", "true",
5658
"Enable 64-bit instructions">;
@@ -239,6 +241,13 @@ def ProcessorFeatures {
239241
FeatureVectorsUseTwoUnits, FeaturePPCPreRASched, FeaturePPCPostRASched];
240242
list<SubtargetFeature> Power9FeatureList =
241243
!listconcat(Power8FeatureList, Power9SpecificFeatures);
244+
245+
// For future CPU we assume that all of the existing features from Power 9
246+
// still exist.
247+
list<SubtargetFeature> FutureSpecificFeatures =
248+
[];
249+
list<SubtargetFeature> FutureFeatureList =
250+
!listconcat(Power9FeatureList, FutureSpecificFeatures);
242251
}
243252

244253
// Note: Future features to add when support is extended to more
@@ -441,6 +450,9 @@ def : ProcessorModel<"pwr6x", G5Model,
441450
def : ProcessorModel<"pwr7", P7Model, ProcessorFeatures.Power7FeatureList>;
442451
def : ProcessorModel<"pwr8", P8Model, ProcessorFeatures.Power8FeatureList>;
443452
def : ProcessorModel<"pwr9", P9Model, ProcessorFeatures.Power9FeatureList>;
453+
// No scheduler model for future CPU.
454+
def : ProcessorModel<"future", NoSchedModel,
455+
ProcessorFeatures.FutureFeatureList>;
444456
def : Processor<"ppc", G3Itineraries, [Directive32, FeatureHardFloat,
445457
FeatureMFTB]>;
446458
def : Processor<"ppc32", G3Itineraries, [Directive32, FeatureHardFloat,

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,8 @@ void PPCDarwinAsmPrinter::EmitStartOfAsmFile(Module &M) {
16031603
// FIXME: why is power8 missing here?
16041604
"ppc64",
16051605
"ppc64le",
1606-
"power9"
1606+
"power9",
1607+
"future"
16071608
};
16081609

16091610
// Get the numerically largest directive.

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,7 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
12171217
case PPC::DIR_PWR7:
12181218
case PPC::DIR_PWR8:
12191219
case PPC::DIR_PWR9:
1220+
case PPC::DIR_PWR_FUTURE:
12201221
setPrefLoopAlignment(Align(16));
12211222
setPrefFunctionAlignment(Align(16));
12221223
break;
@@ -14204,7 +14205,8 @@ Align PPCTargetLowering::getPrefLoopAlignment(MachineLoop *ML) const {
1420414205
case PPC::DIR_PWR6X:
1420514206
case PPC::DIR_PWR7:
1420614207
case PPC::DIR_PWR8:
14207-
case PPC::DIR_PWR9: {
14208+
case PPC::DIR_PWR9:
14209+
case PPC::DIR_PWR_FUTURE: {
1420814210
if (!ML)
1420914211
break;
1421014212

@@ -15383,6 +15385,7 @@ SDValue PPCTargetLowering::combineMUL(SDNode *N, DAGCombinerInfo &DCI) const {
1538315385
// vector 7 2 2
1538415386
return true;
1538515387
case PPC::DIR_PWR9:
15388+
case PPC::DIR_PWR_FUTURE:
1538615389
// type mul add shl
1538715390
// scalar 5 2 2
1538815391
// vector 7 2 2

llvm/lib/Target/PowerPC/PPCSubtarget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ namespace PPC {
5757
DIR_PWR7,
5858
DIR_PWR8,
5959
DIR_PWR9,
60+
DIR_PWR_FUTURE,
6061
DIR_64
6162
};
6263
}

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,9 @@ unsigned PPCTTIImpl::getCacheLineSize() const {
651651

652652
// On P7, P8 or P9 we have a cache line size of 128.
653653
unsigned Directive = ST->getCPUDirective();
654+
// Assume that Future CPU has the same cache line size as the others.
654655
if (Directive == PPC::DIR_PWR7 || Directive == PPC::DIR_PWR8 ||
655-
Directive == PPC::DIR_PWR9)
656+
Directive == PPC::DIR_PWR9 || Directive == PPC::DIR_PWR_FUTURE)
656657
return 128;
657658

658659
// On other processors return a default of 64 bytes.
@@ -684,8 +685,9 @@ unsigned PPCTTIImpl::getMaxInterleaveFactor(unsigned VF) {
684685
// For P7 and P8, floating-point instructions have a 6-cycle latency and
685686
// there are two execution units, so unroll by 12x for latency hiding.
686687
// FIXME: the same for P9 as previous gen until POWER9 scheduling is ready
688+
// Assume that future is the same as the others.
687689
if (Directive == PPC::DIR_PWR7 || Directive == PPC::DIR_PWR8 ||
688-
Directive == PPC::DIR_PWR9)
690+
Directive == PPC::DIR_PWR9 || Directive == PPC::DIR_PWR_FUTURE)
689691
return 12;
690692

691693
// For most things, modern systems have two execution units (and
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
2+
; RUN: -mcpu=future < %s | FileCheck %s
3+
; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
4+
; RUN: -mcpu=future < %s | FileCheck %s
5+
6+
7+
; Test mcpu=future that should be recognized on PowerPC.
8+
9+
; CHECK-NOT: is not a recognized processor for this target
10+
; CHECK: .text
11+

0 commit comments

Comments
 (0)