@@ -403,26 +403,25 @@ class Filter {
403
403
// A filter chooser for encodings that contain some '?' in the filtered range.
404
404
std::unique_ptr<const FilterChooser> VariableFC;
405
405
406
- // Number of instructions which fall under FilteredInstructions category.
407
- unsigned NumFiltered;
408
-
409
406
public:
410
407
Filter (Filter &&f);
411
408
Filter (const FilterChooser &owner, unsigned startBit, unsigned numBits);
412
409
413
410
~Filter () = default ;
414
411
415
- unsigned getNumFiltered () const { return NumFiltered; }
412
+ bool hasSingleFilteredID () const {
413
+ return FilteredIDs.size () == 1 && FilteredIDs.begin ()->second .size () == 1 ;
414
+ }
416
415
417
416
unsigned getSingletonEncodingID () const {
418
- assert (NumFiltered == 1 );
417
+ assert (hasSingleFilteredID () );
419
418
return FilteredIDs.begin ()->second .front ();
420
419
}
421
420
422
421
// Return the filter chooser for the group of instructions without constant
423
422
// segment values.
424
423
const FilterChooser &getVariableFC () const {
425
- assert (NumFiltered == 1 && FilterChooserMap.empty ());
424
+ assert (hasSingleFilteredID () && FilterChooserMap.empty ());
426
425
return *VariableFC;
427
426
}
428
427
@@ -617,14 +616,12 @@ Filter::Filter(Filter &&f)
617
616
FilteredIDs(std::move(f.FilteredIDs)),
618
617
VariableIDs(std::move(f.VariableIDs)),
619
618
FilterChooserMap(std::move(f.FilterChooserMap)),
620
- VariableFC(std::move(f.VariableFC)), NumFiltered(f.NumFiltered) {}
619
+ VariableFC(std::move(f.VariableFC)) {}
621
620
622
621
Filter::Filter (const FilterChooser &owner, unsigned startBit, unsigned numBits)
623
622
: Owner(owner), StartBit(startBit), NumBits(numBits) {
624
623
assert (StartBit + NumBits - 1 < Owner.BitWidth );
625
624
626
- NumFiltered = 0 ;
627
-
628
625
for (unsigned EncodingID : Owner.EncodingIDs ) {
629
626
// Populates the insn given the uid.
630
627
KnownBits EncodingBits = Owner.getMandatoryEncodingBits (EncodingID);
@@ -636,7 +633,6 @@ Filter::Filter(const FilterChooser &owner, unsigned startBit, unsigned numBits)
636
633
// The encoding bits are well-known. Lets add the uid of the
637
634
// instruction into the bucket keyed off the constant field value.
638
635
FilteredIDs[FieldBits.getConstant ().getZExtValue ()].push_back (EncodingID);
639
- ++NumFiltered;
640
636
} else {
641
637
// Some of the encoding bit(s) are unspecified. This contributes to
642
638
// one additional member of "Variable" instructions.
@@ -668,7 +664,7 @@ void Filter::recurse() {
668
664
669
665
// No need to recurse for a singleton filtered instruction.
670
666
// See also Filter::emit*().
671
- if (getNumFiltered () == 1 ) {
667
+ if (hasSingleFilteredID () ) {
672
668
assert (VariableFC && " Shouldn't have created a filter for one encoding!" );
673
669
return ;
674
670
}
@@ -1716,7 +1712,7 @@ void FilterChooser::emitTableEntries(DecoderTableInfo &TableInfo) const {
1716
1712
}
1717
1713
1718
1714
// Use the best filter to do the decoding!
1719
- if (BestFilter->getNumFiltered () == 1 )
1715
+ if (BestFilter->hasSingleFilteredID () )
1720
1716
emitSingletonTableEntry (TableInfo, *BestFilter);
1721
1717
else
1722
1718
BestFilter->emitTableEntry (TableInfo);
0 commit comments