Skip to content

Commit e8e9868

Browse files
authored
[RISCV][NFC] Use bitmasks generated by TableGen
So that we don't need to sync-up the table manually. Reviewers: BeMg, preames, lenary Reviewed By: BeMg Pull Request: #135600
1 parent 123993f commit e8e9868

File tree

3 files changed

+11
-54
lines changed

3 files changed

+11
-54
lines changed

llvm/include/llvm/TargetParser/RISCVTargetParser.h

-8
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ class Triple;
2424

2525
namespace RISCV {
2626

27-
namespace RISCVExtensionBitmaskTable {
28-
struct RISCVExtensionBitmask {
29-
const char *Name;
30-
unsigned GroupID;
31-
unsigned BitPosition;
32-
};
33-
} // namespace RISCVExtensionBitmaskTable
34-
3527
struct CPUModel {
3628
uint32_t MVendorID;
3729
uint64_t MArchID;

llvm/lib/TargetParser/RISCVISAInfo.cpp

+11-31
Original file line numberDiff line numberDiff line change
@@ -1048,41 +1048,21 @@ struct RISCVExtBit {
10481048
uint8_t bitpos;
10491049
};
10501050

1051-
constexpr static RISCVExtBit RISCVBitPositions[] = {
1052-
{"a", 0, 0}, {"c", 0, 2},
1053-
{"d", 0, 3}, {"f", 0, 5},
1054-
{"i", 0, 8}, {"m", 0, 12},
1055-
{"v", 0, 21}, {"zacas", 0, 26},
1056-
{"zba", 0, 27}, {"zbb", 0, 28},
1057-
{"zbc", 0, 29}, {"zbkb", 0, 30},
1058-
{"zbkc", 0, 31}, {"zbkx", 0, 32},
1059-
{"zbs", 0, 33}, {"zfa", 0, 34},
1060-
{"zfh", 0, 35}, {"zfhmin", 0, 36},
1061-
{"zicboz", 0, 37}, {"zicond", 0, 38},
1062-
{"zihintntl", 0, 39}, {"zihintpause", 0, 40},
1063-
{"zknd", 0, 41}, {"zkne", 0, 42},
1064-
{"zknh", 0, 43}, {"zksed", 0, 44},
1065-
{"zksh", 0, 45}, {"zkt", 0, 46},
1066-
{"ztso", 0, 47}, {"zvbb", 0, 48},
1067-
{"zvbc", 0, 49}, {"zvfh", 0, 50},
1068-
{"zvfhmin", 0, 51}, {"zvkb", 0, 52},
1069-
{"zvkg", 0, 53}, {"zvkned", 0, 54},
1070-
{"zvknha", 0, 55}, {"zvknhb", 0, 56},
1071-
{"zvksed", 0, 57}, {"zvksh", 0, 58},
1072-
{"zvkt", 0, 59}, {"zve32x", 0, 60},
1073-
{"zve32f", 0, 61}, {"zve64x", 0, 62},
1074-
{"zve64f", 0, 63}, {"zve64d", 1, 0},
1075-
{"zimop", 1, 1}, {"zca", 1, 2},
1076-
{"zcb", 1, 3}, {"zcd", 1, 4},
1077-
{"zcf", 1, 5}, {"zcmop", 1, 6},
1078-
{"zawrs", 1, 7}};
1051+
struct RISCVExtensionBitmask {
1052+
const char *Name;
1053+
unsigned GroupID;
1054+
unsigned BitPosition;
1055+
};
1056+
1057+
#define GET_RISCVExtensionBitmaskTable_IMPL
1058+
#include "llvm/TargetParser/RISCVTargetParserDef.inc"
10791059

10801060
std::pair<int, int> RISCVISAInfo::getRISCVFeaturesBitsInfo(StringRef Ext) {
10811061
// Note that this code currently accepts mixed case extension names, but
10821062
// does not handle extension versions at all. That's probably fine because
10831063
// there's only one extension version in the __riscv_feature_bits vector.
1084-
for (auto E : RISCVBitPositions)
1085-
if (E.ext.equals_insensitive(Ext))
1086-
return std::make_pair(E.groupid, E.bitpos);
1064+
for (auto E : ExtensionBitmask)
1065+
if (Ext.equals_insensitive(E.Name))
1066+
return std::make_pair(E.GroupID, E.BitPosition);
10871067
return std::make_pair(-1, -1);
10881068
}

llvm/lib/TargetParser/RISCVTargetParser.cpp

-15
Original file line numberDiff line numberDiff line change
@@ -138,21 +138,6 @@ void getFeaturesForCPU(StringRef CPU,
138138
EnabledFeatures.push_back(F.substr(1));
139139
}
140140

141-
namespace RISCVExtensionBitmaskTable {
142-
#define GET_RISCVExtensionBitmaskTable_IMPL
143-
#include "llvm/TargetParser/RISCVTargetParserDef.inc"
144-
145-
} // namespace RISCVExtensionBitmaskTable
146-
147-
namespace {
148-
struct LessExtName {
149-
bool operator()(const RISCVExtensionBitmaskTable::RISCVExtensionBitmask &LHS,
150-
StringRef RHS) {
151-
return StringRef(LHS.Name) < RHS;
152-
}
153-
};
154-
} // namespace
155-
156141
} // namespace RISCV
157142

158143
namespace RISCVVType {

0 commit comments

Comments
 (0)