[llvm] be8f987 - [TableGen] Use consistent field kind checking in getNumericKey. (#83284)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 29 09:57:10 PST 2024
Author: Jason Eckhardt
Date: 2024-03-01T01:57:06+08:00
New Revision: be8f987d8cddd2d1df5ed1afff64fd9a730ec97a
URL: https://github.com/llvm/llvm-project/commit/be8f987d8cddd2d1df5ed1afff64fd9a730ec97a
DIFF: https://github.com/llvm/llvm-project/commit/be8f987d8cddd2d1df5ed1afff64fd9a730ec97a.diff
LOG: [TableGen] Use consistent field kind checking in getNumericKey. (#83284)
Fields GenericField::IsInstruction and GenericField::Enum can be
simultaneously active for a given field. Methods compareBy and
primaryRepresentation both order the checking of IsInstruction before
GenericField::Enum. Do the same in getNumericKey for consistency.
Added:
Modified:
llvm/utils/TableGen/SearchableTableEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp
index 5bab4ff188e8ed..51f18f360ed311 100644
--- a/llvm/utils/TableGen/SearchableTableEmitter.cpp
+++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp
@@ -215,12 +215,15 @@ int64_t SearchableTableEmitter::getNumericKey(const SearchIndex &Index,
Record *Rec) {
assert(Index.Fields.size() == 1);
+ // 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);
+ }
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) {
- Record *TheDef = Rec->getValueAsDef(Index.Fields[0].Name);
- return Target->getInstrIntValue(TheDef);
}
return getInt(Rec, Index.Fields[0].Name);
More information about the llvm-commits
mailing list