Skip to content

Commit be8f987

Browse files
authored
[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.
1 parent 3e0425c commit be8f987

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/utils/TableGen/SearchableTableEmitter.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,15 @@ int64_t SearchableTableEmitter::getNumericKey(const SearchIndex &Index,
215215
Record *Rec) {
216216
assert(Index.Fields.size() == 1);
217217

218+
// To be consistent with compareBy and primaryRepresentation elsewhere,
219+
// we check for IsInstruction before Enum-- these fields are not exclusive.
220+
if (Index.Fields[0].IsInstruction) {
221+
Record *TheDef = Rec->getValueAsDef(Index.Fields[0].Name);
222+
return Target->getInstrIntValue(TheDef);
223+
}
218224
if (Index.Fields[0].Enum) {
219225
Record *EnumEntry = Rec->getValueAsDef(Index.Fields[0].Name);
220226
return Index.Fields[0].Enum->EntryMap[EnumEntry]->second;
221-
} else if (Index.Fields[0].IsInstruction) {
222-
Record *TheDef = Rec->getValueAsDef(Index.Fields[0].Name);
223-
return Target->getInstrIntValue(TheDef);
224227
}
225228

226229
return getInt(Rec, Index.Fields[0].Name);

0 commit comments

Comments
 (0)