Skip to content

Commit 68964f5

Browse files
committed
[TableGen][DecoderEmitter] Small refactoring (NFC)
Few changes extracted from llvm#155065 to make it smaller.
1 parent 01bbbb5 commit 68964f5

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -677,15 +677,13 @@ Filter::Filter(const FilterChooser &owner, unsigned startBit, unsigned numBits)
677677
// instructions. In order to unambiguously decode the singleton, we need to
678678
// match the remaining undecoded encoding bits against the singleton.
679679
void Filter::recurse() {
680-
// Starts by inheriting our parent filter chooser's filter bit values.
681-
KnownBits FilterBits = Owner.FilterBits;
682-
assert(FilterBits.extractBits(NumBits, StartBit).isUnknown());
680+
assert(Owner.FilterBits.extractBits(NumBits, StartBit).isUnknown());
683681

684682
if (!VariableIDs.empty()) {
685683
// Delegates to an inferior filter chooser for further processing on this
686684
// group of instructions whose segment values are variable.
687685
VariableFC = std::make_unique<FilterChooser>(Owner.Encodings, VariableIDs,
688-
FilterBits, Owner);
686+
Owner.FilterBits, Owner);
689687
}
690688

691689
// No need to recurse for a singleton filtered instruction.
@@ -696,16 +694,18 @@ void Filter::recurse() {
696694
}
697695

698696
// Otherwise, create sub choosers.
699-
for (const auto &[FilterVal, EncodingIDs] : FilteredIDs) {
697+
for (const auto &[FilterVal, InferiorEncodingIDs] : FilteredIDs) {
700698
// Create a new filter by inserting the field bits into the parent filter.
701699
APInt FieldBits(NumBits, FilterVal);
702-
FilterBits.insertBits(KnownBits::makeConstant(FieldBits), StartBit);
700+
KnownBits InferiorFilterBits = Owner.FilterBits;
701+
InferiorFilterBits.insertBits(KnownBits::makeConstant(FieldBits), StartBit);
703702

704703
// Delegates to an inferior filter chooser for further processing on this
705704
// category of instructions.
706705
FilterChooserMap.try_emplace(
707-
FilterVal, std::make_unique<FilterChooser>(Owner.Encodings, EncodingIDs,
708-
FilterBits, Owner));
706+
FilterVal,
707+
std::make_unique<FilterChooser>(Owner.Encodings, InferiorEncodingIDs,
708+
InferiorFilterBits, Owner));
709709
}
710710
}
711711

@@ -1386,15 +1386,14 @@ void FilterChooser::emitSingletonTableEntry(DecoderTableInfo &TableInfo,
13861386

13871387
// Check any additional encoding fields needed.
13881388
for (const Island &Ilnd : reverse(Islands)) {
1389-
unsigned NumBits = Ilnd.NumBits;
1390-
assert(isUInt<8>(NumBits) && "NumBits overflowed uint8 table entry!");
1389+
assert(isUInt<8>(Ilnd.NumBits) && "NumBits overflowed uint8 table entry!");
13911390
const uint8_t DecoderOp = TableInfo.isOutermostScope()
13921391
? MCD::OPC_CheckFieldOrFail
13931392
: MCD::OPC_CheckField;
13941393
TableInfo.Table.push_back(DecoderOp);
13951394

13961395
TableInfo.Table.insertULEB128(Ilnd.StartBit);
1397-
TableInfo.Table.push_back(NumBits);
1396+
TableInfo.Table.push_back(Ilnd.NumBits);
13981397
TableInfo.Table.insertULEB128(Ilnd.FieldVal);
13991398

14001399
if (DecoderOp == MCD::OPC_CheckField) {

0 commit comments

Comments
 (0)