[TableGen][DecoderEmitter] Remove redundant variable (NFC) (#154880)
`NumFiltered` is the number of elements in all vectors in a map. It is ever compared to 1, which is equivalent to checking if the map contains exactly one vector with exactly one element.
This commit is contained in:
parent
586a7131d3
commit
6a7ade03d1
@ -403,26 +403,25 @@ protected:
|
|||||||
// A filter chooser for encodings that contain some '?' in the filtered range.
|
// A filter chooser for encodings that contain some '?' in the filtered range.
|
||||||
std::unique_ptr<const FilterChooser> VariableFC;
|
std::unique_ptr<const FilterChooser> VariableFC;
|
||||||
|
|
||||||
// Number of instructions which fall under FilteredInstructions category.
|
|
||||||
unsigned NumFiltered;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Filter(Filter &&f);
|
Filter(Filter &&f);
|
||||||
Filter(const FilterChooser &owner, unsigned startBit, unsigned numBits);
|
Filter(const FilterChooser &owner, unsigned startBit, unsigned numBits);
|
||||||
|
|
||||||
~Filter() = default;
|
~Filter() = default;
|
||||||
|
|
||||||
unsigned getNumFiltered() const { return NumFiltered; }
|
bool hasSingleFilteredID() const {
|
||||||
|
return FilteredIDs.size() == 1 && FilteredIDs.begin()->second.size() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned getSingletonEncodingID() const {
|
unsigned getSingletonEncodingID() const {
|
||||||
assert(NumFiltered == 1);
|
assert(hasSingleFilteredID());
|
||||||
return FilteredIDs.begin()->second.front();
|
return FilteredIDs.begin()->second.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the filter chooser for the group of instructions without constant
|
// Return the filter chooser for the group of instructions without constant
|
||||||
// segment values.
|
// segment values.
|
||||||
const FilterChooser &getVariableFC() const {
|
const FilterChooser &getVariableFC() const {
|
||||||
assert(NumFiltered == 1 && FilterChooserMap.empty());
|
assert(hasSingleFilteredID() && FilterChooserMap.empty());
|
||||||
return *VariableFC;
|
return *VariableFC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,14 +616,12 @@ Filter::Filter(Filter &&f)
|
|||||||
FilteredIDs(std::move(f.FilteredIDs)),
|
FilteredIDs(std::move(f.FilteredIDs)),
|
||||||
VariableIDs(std::move(f.VariableIDs)),
|
VariableIDs(std::move(f.VariableIDs)),
|
||||||
FilterChooserMap(std::move(f.FilterChooserMap)),
|
FilterChooserMap(std::move(f.FilterChooserMap)),
|
||||||
VariableFC(std::move(f.VariableFC)), NumFiltered(f.NumFiltered) {}
|
VariableFC(std::move(f.VariableFC)) {}
|
||||||
|
|
||||||
Filter::Filter(const FilterChooser &owner, unsigned startBit, unsigned numBits)
|
Filter::Filter(const FilterChooser &owner, unsigned startBit, unsigned numBits)
|
||||||
: Owner(owner), StartBit(startBit), NumBits(numBits) {
|
: Owner(owner), StartBit(startBit), NumBits(numBits) {
|
||||||
assert(StartBit + NumBits - 1 < Owner.BitWidth);
|
assert(StartBit + NumBits - 1 < Owner.BitWidth);
|
||||||
|
|
||||||
NumFiltered = 0;
|
|
||||||
|
|
||||||
for (unsigned EncodingID : Owner.EncodingIDs) {
|
for (unsigned EncodingID : Owner.EncodingIDs) {
|
||||||
// Populates the insn given the uid.
|
// Populates the insn given the uid.
|
||||||
KnownBits EncodingBits = Owner.getMandatoryEncodingBits(EncodingID);
|
KnownBits EncodingBits = Owner.getMandatoryEncodingBits(EncodingID);
|
||||||
@ -636,7 +633,6 @@ Filter::Filter(const FilterChooser &owner, unsigned startBit, unsigned numBits)
|
|||||||
// The encoding bits are well-known. Lets add the uid of the
|
// The encoding bits are well-known. Lets add the uid of the
|
||||||
// instruction into the bucket keyed off the constant field value.
|
// instruction into the bucket keyed off the constant field value.
|
||||||
FilteredIDs[FieldBits.getConstant().getZExtValue()].push_back(EncodingID);
|
FilteredIDs[FieldBits.getConstant().getZExtValue()].push_back(EncodingID);
|
||||||
++NumFiltered;
|
|
||||||
} else {
|
} else {
|
||||||
// Some of the encoding bit(s) are unspecified. This contributes to
|
// Some of the encoding bit(s) are unspecified. This contributes to
|
||||||
// one additional member of "Variable" instructions.
|
// one additional member of "Variable" instructions.
|
||||||
@ -668,7 +664,7 @@ void Filter::recurse() {
|
|||||||
|
|
||||||
// No need to recurse for a singleton filtered instruction.
|
// No need to recurse for a singleton filtered instruction.
|
||||||
// See also Filter::emit*().
|
// See also Filter::emit*().
|
||||||
if (getNumFiltered() == 1) {
|
if (hasSingleFilteredID()) {
|
||||||
assert(VariableFC && "Shouldn't have created a filter for one encoding!");
|
assert(VariableFC && "Shouldn't have created a filter for one encoding!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1716,7 +1712,7 @@ void FilterChooser::emitTableEntries(DecoderTableInfo &TableInfo) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use the best filter to do the decoding!
|
// Use the best filter to do the decoding!
|
||||||
if (BestFilter->getNumFiltered() == 1)
|
if (BestFilter->hasSingleFilteredID())
|
||||||
emitSingletonTableEntry(TableInfo, *BestFilter);
|
emitSingletonTableEntry(TableInfo, *BestFilter);
|
||||||
else
|
else
|
||||||
BestFilter->emitTableEntry(TableInfo);
|
BestFilter->emitTableEntry(TableInfo);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user