[llvm] [TableGen] Use consistent field kind checking in getNumericKey. (PR #83284)
Piotr Sobczak via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 29 02:37:15 PST 2024
================
@@ -215,12 +215,14 @@ int64_t SearchableTableEmitter::getNumericKey(const SearchIndex &Index,
Record *Rec) {
assert(Index.Fields.size() == 1);
- if (Index.Fields[0].Enum) {
- Record *EnumEntry = Rec->getValueAsDef(Index.Fields[0].Name);
- return Index.Fields[0].Enum->EntryMap[EnumEntry]->second;
- } else if (Index.Fields[0].IsInstruction) {
+ // To be consistent with compareBy and primaryRepresentation elsewhere,
+ // we check for IsInstruction before Enum-- these fields are not exclusive.
+ if (Index.Fields[0].IsInstruction) {
Record *TheDef = Rec->getValueAsDef(Index.Fields[0].Name);
return Target->getInstrIntValue(TheDef);
+ } else if (Index.Fields[0].Enum) {
----------------
piotrAMD wrote:
Nit: No need for `else if` after return, `if` is enough.
https://github.com/llvm/llvm-project/pull/83284
More information about the llvm-commits
mailing list