Skip to content

Commit 5a5e072

Browse files
committed
wip
1 parent d919d4d commit 5a5e072

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

llvm/utils/TableGen/SearchableTableEmitter.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,20 +211,21 @@ class SearchableTableEmitter {
211211
// known, return that numeric value.
212212
int64_t SearchableTableEmitter::getNumericKey(const SearchIndex &Index,
213213
const Record *Rec) {
214-
assert(Index.Fields.size() == 1);
214+
const GenericField &Field = Index.Fields[0];
215215

216216
// To be consistent with compareBy and primaryRepresentation elsewhere,
217217
// we check for IsInstruction before Enum-- these fields are not exclusive.
218-
if (Index.Fields[0].IsInstruction) {
219-
const Record *TheDef = Rec->getValueAsDef(Index.Fields[0].Name);
218+
if (Field.IsInstruction) {
219+
const Record *TheDef = Rec->getValueAsDef(Field.Name);
220220
return Target->getInstrIntValue(TheDef);
221221
}
222-
if (Index.Fields[0].Enum) {
223-
const Record *EnumEntry = Rec->getValueAsDef(Index.Fields[0].Name);
224-
return Index.Fields[0].Enum->EntryMap[EnumEntry]->second;
222+
if (Field.Enum) {
223+
const Record *EnumEntry = Rec->getValueAsDef(Field.Name);
224+
return Field.Enum->EntryMap[EnumEntry]->second;
225225
}
226+
assert(isa<BitsRecTy>(Field.RecType) && "unexpected field type");
226227

227-
return getInt(Rec, Index.Fields[0].Name);
228+
return getInt(Rec, Field.Name);
228229
}
229230

230231
/// Less-than style comparison between \p LHS and \p RHS according to the
@@ -405,10 +406,9 @@ void SearchableTableEmitter::emitLookupFunction(const GenericTable &Table,
405406
OS << " (" << Field.Name << " > " << LastRepr << "))\n";
406407
OS << " return nullptr;\n\n";
407408

408-
if (IsContiguous) {
409+
if (IsContiguous && !Index.EarlyOut) {
409410
OS << " auto Table = ArrayRef(" << IndexName << ");\n";
410-
OS << " size_t Idx = " << Index.Fields[0].Name << " - " << FirstRepr
411-
<< ";\n";
411+
OS << " size_t Idx = " << Field.Name << " - " << FirstRepr << ";\n";
412412
OS << " return ";
413413
if (IsPrimary)
414414
OS << "&Table[Idx]";

0 commit comments

Comments
 (0)