diff options
author | Craig Topper <craig.topper@sifive.com> | 2022-08-18 14:39:37 -0700 |
---|---|---|
committer | Craig Topper <craig.topper@sifive.com> | 2022-08-18 16:22:25 -0700 |
commit | 37c47b2cacae99d65b4b82eb41655f0820100677 (patch) | |
tree | 34f20f21b7e59f89b2fba9b7fae93f02d7cd70ed /llvm/lib/Support/TargetParser.cpp | |
parent | d7a4ff9986c8dcaf967770c868e9020d3f328e9f (diff) | |
download | llvm-37c47b2cacae99d65b4b82eb41655f0820100677.zip llvm-37c47b2cacae99d65b4b82eb41655f0820100677.tar.gz llvm-37c47b2cacae99d65b4b82eb41655f0820100677.tar.bz2 |
[RISCV] Change how mtune aliases are implemented.
The previous implementation translated from names like sifive-7-series
to sifive-7-rv32 or sifive-7-rv64. This also required sifive-7-rv32
and sifive-7-rv64 to be valid CPU names. As those are not real
CPUs it doesn't make sense to accept them in -mcpu.
This patch does away with the translation and adds sifive-7-series
directly to RISCV.td. Removing sifive-7-rv32 and sifive-7-rv64.
sifive-7-series is only allowed in -mtune.
I've also added "rocket" to RISCV.td but have not removed rocket-rv32
or rocket-rv64.
To prevent -mcpu=sifive-7-series or -mcpu=rocket being used with llc,
I've added a Feature32Bit to all rv32 CPUs. And made it an error to
have an rv32 triple without Feature32Bit. sifive-7-series and rocket
do not have Feature32Bit or Feature64Bit set so the user would need
to provide -mattr=+32bit or -mattr=+64bit along with the -mcpu to
avoid the error.
SiFive no longer names their newer products with 3, 5, or 7 series.
Instead we have p200 series, x200 series, p500 series, and p600 series.
Following the previous behavior would require a sifive-p500-rv32 and
sifive-p500-rv64 in order to support -mtune=sifive-p500-series. There
is currently no p500 product, but it could start getting confusing if
there was in the future.
I'm open to hearing alternatives for how to achieve my main goal
of removing sifive-7-rv32/rv64 as a CPU name.
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D131708
Diffstat (limited to 'llvm/lib/Support/TargetParser.cpp')
-rw-r--r-- | llvm/lib/Support/TargetParser.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/llvm/lib/Support/TargetParser.cpp b/llvm/lib/Support/TargetParser.cpp index cd72c97..a7eccb6 100644 --- a/llvm/lib/Support/TargetParser.cpp +++ b/llvm/lib/Support/TargetParser.cpp @@ -278,6 +278,8 @@ bool checkCPUKind(CPUKind Kind, bool IsRV64) { bool checkTuneCPUKind(CPUKind Kind, bool IsRV64) { if (Kind == CK_INVALID) return false; +#define TUNE_PROC(ENUM, NAME) if (Kind == CK_##ENUM) return true; +#include "llvm/Support/RISCVTargetParser.def" return RISCVCPUInfo[static_cast<unsigned>(Kind)].is64Bit() == IsRV64; } @@ -288,18 +290,10 @@ CPUKind parseCPUKind(StringRef CPU) { .Default(CK_INVALID); } -StringRef resolveTuneCPUAlias(StringRef TuneCPU, bool IsRV64) { - return llvm::StringSwitch<StringRef>(TuneCPU) -#define TUNE_ALIAS(NAME, RV32, RV64) .Case(NAME, IsRV64 ? StringRef(RV64) : StringRef(RV32)) -#include "llvm/Support/RISCVTargetParser.def" - .Default(TuneCPU); -} - CPUKind parseTuneCPUKind(StringRef TuneCPU, bool IsRV64) { - TuneCPU = resolveTuneCPUAlias(TuneCPU, IsRV64); - return llvm::StringSwitch<CPUKind>(TuneCPU) #define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) .Case(NAME, CK_##ENUM) +#define TUNE_PROC(ENUM, NAME) .Case(NAME, CK_##ENUM) #include "llvm/Support/RISCVTargetParser.def" .Default(CK_INVALID); } @@ -321,7 +315,7 @@ void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64) { if (C.Kind != CK_INVALID && IsRV64 == C.is64Bit()) Values.emplace_back(C.Name); } -#define TUNE_ALIAS(NAME, RV32, RV64) Values.emplace_back(StringRef(NAME)); +#define TUNE_PROC(ENUM, NAME) Values.emplace_back(StringRef(NAME)); #include "llvm/Support/RISCVTargetParser.def" } |