diff options
author | Kai Nacke <kai.peter.nacke@ibm.com> | 2022-11-18 19:12:01 +0000 |
---|---|---|
committer | Kai Nacke <kai.peter.nacke@ibm.com> | 2023-01-06 18:01:48 +0000 |
commit | 70a5d8e4c469195e9302dba2c5a9518a69e0773e (patch) | |
tree | a381cb851e4b4d50517e118e3f3bc67745cfae9d /llvm/lib/Target/PowerPC/PPCSubtarget.cpp | |
parent | 4554663bc0da71d61ab488641c95ef98430cb451 (diff) | |
download | llvm-70a5d8e4c469195e9302dba2c5a9518a69e0773e.zip llvm-70a5d8e4c469195e9302dba2c5a9518a69e0773e.tar.gz llvm-70a5d8e4c469195e9302dba2c5a9518a69e0773e.tar.bz2 |
[PPC] Add support for tune-cpu attribute
clang (like gcc) has the -mtune= command line option. This option
adds the "tune-cpu" attribute to a function. The intended functionality
is that the scheduling model of that cpu is used. E.g. -mtune=pwr9 -march=pwr8
generates only instructions supported on pwr8 but uses the scheduling model
of pwr9 for it.
This PR adds the infrastructure to support this in LLVM.
clang support was added in https://reviews.llvm.org/D130526.
Reviewed By: amyk, qiucf
Differential Revision: https://reviews.llvm.org/D138317
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCSubtarget.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCSubtarget.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp index fb37bf4..e32a2ed 100644 --- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp +++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp @@ -48,18 +48,20 @@ static cl::opt<bool> cl::init(false), cl::Hidden); PPCSubtarget &PPCSubtarget::initializeSubtargetDependencies(StringRef CPU, + StringRef TuneCPU, StringRef FS) { initializeEnvironment(); - initSubtargetFeatures(CPU, FS); + initSubtargetFeatures(CPU, TuneCPU, FS); return *this; } PPCSubtarget::PPCSubtarget(const Triple &TT, const std::string &CPU, - const std::string &FS, const PPCTargetMachine &TM) - : PPCGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), TargetTriple(TT), + const std::string &TuneCPU, const std::string &FS, + const PPCTargetMachine &TM) + : PPCGenSubtargetInfo(TT, CPU, TuneCPU, FS), TargetTriple(TT), IsPPC64(TargetTriple.getArch() == Triple::ppc64 || TargetTriple.getArch() == Triple::ppc64le), - TM(TM), FrameLowering(initializeSubtargetDependencies(CPU, FS)), + TM(TM), FrameLowering(initializeSubtargetDependencies(CPU, TuneCPU, FS)), InstrInfo(*this), TLInfo(TM, *this) { CallLoweringInfo.reset(new PPCCallLowering(*getTargetLowering())); Legalizer.reset(new PPCLegalizerInfo(*this)); @@ -76,7 +78,8 @@ void PPCSubtarget::initializeEnvironment() { HasPOPCNTD = POPCNTD_Unavailable; } -void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { +void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef TuneCPU, + StringRef FS) { // Determine default and user specified characteristics std::string CPUName = std::string(CPU); if (CPUName.empty() || CPU == "generic") { @@ -89,11 +92,14 @@ void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { CPUName = "generic"; } + // Determine the CPU to schedule for. + if (TuneCPU.empty()) TuneCPU = CPUName; + // Initialize scheduling itinerary for the specified CPU. InstrItins = getInstrItineraryForCPU(CPUName); // Parse features string. - ParseSubtargetFeatures(CPUName, /*TuneCPU*/ CPUName, FS); + ParseSubtargetFeatures(CPUName, TuneCPU, FS); // If the user requested use of 64-bit regs, but the cpu selected doesn't // support it, ignore. |