[X86] Remove encoding value from the X86_FEATURE and X86_FEATURE_COMPAT macro. NFCI

This was orignally done so we could separate the compatibility
values and the llvm internal only features into a separate entries
in the feature array. This was needed when we explicitly had to
convert the feature into the proper 32-bit chunk at every reference
and we didn't want things moving around.

Now everything is in an array and we have helper funtions or macros
to convert encoding to index. So we renumbering is no longer an
issue.
This commit is contained in:
Craig Topper 2020-06-21 20:20:04 -07:00
parent 5ac144fe64
commit 0dfc8e1837
4 changed files with 51 additions and 50 deletions

View File

@ -1518,14 +1518,14 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const {
// X86TargetInfo::hasFeature for a somewhat comprehensive list).
bool X86TargetInfo::validateCpuSupports(StringRef FeatureStr) const {
return llvm::StringSwitch<bool>(FeatureStr)
#define X86_FEATURE_COMPAT(VAL, ENUM, STR) .Case(STR, true)
#define X86_FEATURE_COMPAT(ENUM, STR) .Case(STR, true)
#include "llvm/Support/X86TargetParser.def"
.Default(false);
}
static llvm::X86::ProcessorFeatures getFeature(StringRef Name) {
return llvm::StringSwitch<llvm::X86::ProcessorFeatures>(Name)
#define X86_FEATURE_COMPAT(VAL, ENUM, STR) .Case(STR, llvm::X86::ENUM)
#define X86_FEATURE_COMPAT(ENUM, STR) .Case(STR, llvm::X86::ENUM)
#include "llvm/Support/X86TargetParser.def"
;
// Note, this function should only be used after ensuring the value is

View File

@ -11662,7 +11662,7 @@ CodeGenFunction::GetX86CpuSupportsMask(ArrayRef<StringRef> FeatureStrs) {
for (const StringRef &FeatureStr : FeatureStrs) {
unsigned Feature =
StringSwitch<unsigned>(FeatureStr)
#define X86_FEATURE_COMPAT(VAL, ENUM, STR) .Case(STR, VAL)
#define X86_FEATURE_COMPAT(ENUM, STR) .Case(STR, llvm::X86::ENUM)
#include "llvm/Support/X86TargetParser.def"
;
FeaturesMask |= (1ULL << Feature);

View File

@ -125,56 +125,57 @@ X86_CPU_SUBTYPE ("geode", AMDPENTIUM_GEODE)
// This macro is used for cpu types present in compiler-rt/libgcc.
#ifndef X86_FEATURE_COMPAT
#define X86_FEATURE_COMPAT(VAL, ENUM, STR) X86_FEATURE(VAL, ENUM)
#define X86_FEATURE_COMPAT(ENUM, STR) X86_FEATURE(ENUM)
#endif
#ifndef X86_FEATURE
#define X86_FEATURE(VAL, ENUM)
#define X86_FEATURE(ENUM)
#endif
X86_FEATURE_COMPAT( 0, FEATURE_CMOV, "cmov")
X86_FEATURE_COMPAT( 1, FEATURE_MMX, "mmx")
X86_FEATURE_COMPAT( 2, FEATURE_POPCNT, "popcnt")
X86_FEATURE_COMPAT( 3, FEATURE_SSE, "sse")
X86_FEATURE_COMPAT( 4, FEATURE_SSE2, "sse2")
X86_FEATURE_COMPAT( 5, FEATURE_SSE3, "sse3")
X86_FEATURE_COMPAT( 6, FEATURE_SSSE3, "ssse3")
X86_FEATURE_COMPAT( 7, FEATURE_SSE4_1, "sse4.1")
X86_FEATURE_COMPAT( 8, FEATURE_SSE4_2, "sse4.2")
X86_FEATURE_COMPAT( 9, FEATURE_AVX, "avx")
X86_FEATURE_COMPAT(10, FEATURE_AVX2, "avx2")
X86_FEATURE_COMPAT(11, FEATURE_SSE4_A, "sse4a")
X86_FEATURE_COMPAT(12, FEATURE_FMA4, "fma4")
X86_FEATURE_COMPAT(13, FEATURE_XOP, "xop")
X86_FEATURE_COMPAT(14, FEATURE_FMA, "fma")
X86_FEATURE_COMPAT(15, FEATURE_AVX512F, "avx512f")
X86_FEATURE_COMPAT(16, FEATURE_BMI, "bmi")
X86_FEATURE_COMPAT(17, FEATURE_BMI2, "bmi2")
X86_FEATURE_COMPAT(18, FEATURE_AES, "aes")
X86_FEATURE_COMPAT(19, FEATURE_PCLMUL, "pclmul")
X86_FEATURE_COMPAT(20, FEATURE_AVX512VL, "avx512vl")
X86_FEATURE_COMPAT(21, FEATURE_AVX512BW, "avx512bw")
X86_FEATURE_COMPAT(22, FEATURE_AVX512DQ, "avx512dq")
X86_FEATURE_COMPAT(23, FEATURE_AVX512CD, "avx512cd")
X86_FEATURE_COMPAT(24, FEATURE_AVX512ER, "avx512er")
X86_FEATURE_COMPAT(25, FEATURE_AVX512PF, "avx512pf")
X86_FEATURE_COMPAT(26, FEATURE_AVX512VBMI, "avx512vbmi")
X86_FEATURE_COMPAT(27, FEATURE_AVX512IFMA, "avx512ifma")
X86_FEATURE_COMPAT(28, FEATURE_AVX5124VNNIW, "avx5124vnniw")
X86_FEATURE_COMPAT(29, FEATURE_AVX5124FMAPS, "avx5124fmaps")
X86_FEATURE_COMPAT(30, FEATURE_AVX512VPOPCNTDQ, "avx512vpopcntdq")
X86_FEATURE_COMPAT(31, FEATURE_AVX512VBMI2, "avx512vbmi2")
X86_FEATURE_COMPAT(32, FEATURE_GFNI, "gfni")
X86_FEATURE_COMPAT(33, FEATURE_VPCLMULQDQ, "vpclmulqdq")
X86_FEATURE_COMPAT(34, FEATURE_AVX512VNNI, "avx512vnni")
X86_FEATURE_COMPAT(35, FEATURE_AVX512BITALG, "avx512bitalg")
X86_FEATURE_COMPAT(36, FEATURE_AVX512BF16, "avx512bf16")
X86_FEATURE_COMPAT(37, FEATURE_AVX512VP2INTERSECT, "avx512vp2intersect")
X86_FEATURE_COMPAT(FEATURE_CMOV, "cmov")
X86_FEATURE_COMPAT(FEATURE_MMX, "mmx")
X86_FEATURE_COMPAT(FEATURE_POPCNT, "popcnt")
X86_FEATURE_COMPAT(FEATURE_SSE, "sse")
X86_FEATURE_COMPAT(FEATURE_SSE2, "sse2")
X86_FEATURE_COMPAT(FEATURE_SSE3, "sse3")
X86_FEATURE_COMPAT(FEATURE_SSSE3, "ssse3")
X86_FEATURE_COMPAT(FEATURE_SSE4_1, "sse4.1")
X86_FEATURE_COMPAT(FEATURE_SSE4_2, "sse4.2")
X86_FEATURE_COMPAT(FEATURE_AVX, "avx")
X86_FEATURE_COMPAT(FEATURE_AVX2, "avx2")
X86_FEATURE_COMPAT(FEATURE_SSE4_A, "sse4a")
X86_FEATURE_COMPAT(FEATURE_FMA4, "fma4")
X86_FEATURE_COMPAT(FEATURE_XOP, "xop")
X86_FEATURE_COMPAT(FEATURE_FMA, "fma")
X86_FEATURE_COMPAT(FEATURE_AVX512F, "avx512f")
X86_FEATURE_COMPAT(FEATURE_BMI, "bmi")
X86_FEATURE_COMPAT(FEATURE_BMI2, "bmi2")
X86_FEATURE_COMPAT(FEATURE_AES, "aes")
X86_FEATURE_COMPAT(FEATURE_PCLMUL, "pclmul")
X86_FEATURE_COMPAT(FEATURE_AVX512VL, "avx512vl")
X86_FEATURE_COMPAT(FEATURE_AVX512BW, "avx512bw")
X86_FEATURE_COMPAT(FEATURE_AVX512DQ, "avx512dq")
X86_FEATURE_COMPAT(FEATURE_AVX512CD, "avx512cd")
X86_FEATURE_COMPAT(FEATURE_AVX512ER, "avx512er")
X86_FEATURE_COMPAT(FEATURE_AVX512PF, "avx512pf")
X86_FEATURE_COMPAT(FEATURE_AVX512VBMI, "avx512vbmi")
X86_FEATURE_COMPAT(FEATURE_AVX512IFMA, "avx512ifma")
X86_FEATURE_COMPAT(FEATURE_AVX5124VNNIW, "avx5124vnniw")
X86_FEATURE_COMPAT(FEATURE_AVX5124FMAPS, "avx5124fmaps")
X86_FEATURE_COMPAT(FEATURE_AVX512VPOPCNTDQ, "avx512vpopcntdq")
X86_FEATURE_COMPAT(FEATURE_AVX512VBMI2, "avx512vbmi2")
X86_FEATURE_COMPAT(FEATURE_GFNI, "gfni")
X86_FEATURE_COMPAT(FEATURE_VPCLMULQDQ, "vpclmulqdq")
X86_FEATURE_COMPAT(FEATURE_AVX512VNNI, "avx512vnni")
X86_FEATURE_COMPAT(FEATURE_AVX512BITALG, "avx512bitalg")
X86_FEATURE_COMPAT(FEATURE_AVX512BF16, "avx512bf16")
X86_FEATURE_COMPAT(FEATURE_AVX512VP2INTERSECT, "avx512vp2intersect")
// Features below here are not in libgcc/compiler-rt.
X86_FEATURE (64, FEATURE_MOVBE)
X86_FEATURE (65, FEATURE_ADX)
X86_FEATURE (66, FEATURE_EM64T)
X86_FEATURE (67, FEATURE_CLFLUSHOPT)
X86_FEATURE (68, FEATURE_SHA)
X86_FEATURE (FEATURE_MOVBE)
X86_FEATURE (FEATURE_ADX)
X86_FEATURE (FEATURE_EM64T)
X86_FEATURE (FEATURE_CLFLUSHOPT)
X86_FEATURE (FEATURE_SHA)
#undef X86_FEATURE_COMPAT
#undef X86_FEATURE

View File

@ -53,8 +53,8 @@ enum ProcessorSubtypes : unsigned {
// This should be kept in sync with libcc/compiler-rt as it should be used
// by clang as a proxy for what's in libgcc/compiler-rt.
enum ProcessorFeatures {
#define X86_FEATURE(VAL, ENUM) \
ENUM = VAL,
#define X86_FEATURE(ENUM) \
ENUM,
#include "llvm/Support/X86TargetParser.def"
CPU_FEATURE_MAX
};