Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions llvm/utils/TableGen/DecoderEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ class Filter {
const FilterChooser &Owner; // FilterChooser who owns this filter
unsigned StartBit; // the starting bit position
unsigned NumBits; // number of bits to filter
bool Mixed; // a mixed region contains both set and unset bits

// Map of well-known segment value to the set of uid's with that value.
std::map<uint64_t, std::vector<EncodingIDAndOpcode>> FilteredInstructions;
Expand All @@ -404,8 +403,7 @@ class Filter {

public:
Filter(Filter &&f);
Filter(const FilterChooser &owner, unsigned startBit, unsigned numBits,
bool mixed);
Filter(const FilterChooser &owner, unsigned startBit, unsigned numBits);

~Filter() = default;

Expand Down Expand Up @@ -614,7 +612,7 @@ class FilterChooser {
unsigned Opc) const;

// Assign a single filter and run with it.
void runSingleFilter(unsigned startBit, unsigned numBit, bool mixed);
void runSingleFilter(unsigned startBit, unsigned numBit);

// reportRegion is a helper function for filterProcessor to mark a region as
// eligible for use as a filter region.
Expand Down Expand Up @@ -646,15 +644,14 @@ class FilterChooser {
///////////////////////////

Filter::Filter(Filter &&f)
: Owner(f.Owner), StartBit(f.StartBit), NumBits(f.NumBits), Mixed(f.Mixed),
: Owner(f.Owner), StartBit(f.StartBit), NumBits(f.NumBits),
FilteredInstructions(std::move(f.FilteredInstructions)),
VariableInstructions(std::move(f.VariableInstructions)),
FilterChooserMap(std::move(f.FilterChooserMap)),
NumFiltered(f.NumFiltered), LastOpcFiltered(f.LastOpcFiltered) {}

Filter::Filter(const FilterChooser &owner, unsigned startBit, unsigned numBits,
bool mixed)
: Owner(owner), StartBit(startBit), NumBits(numBits), Mixed(mixed) {
Filter::Filter(const FilterChooser &owner, unsigned startBit, unsigned numBits)
: Owner(owner), StartBit(startBit), NumBits(numBits) {
assert(StartBit + NumBits - 1 < Owner.BitWidth);

NumFiltered = 0;
Expand Down Expand Up @@ -1537,10 +1534,9 @@ void FilterChooser::emitSingletonTableEntry(DecoderTableInfo &TableInfo,

// Assign a single filter and run with it. Top level API client can initialize
// with a single filter to start the filtering process.
void FilterChooser::runSingleFilter(unsigned startBit, unsigned numBit,
bool mixed) {
void FilterChooser::runSingleFilter(unsigned startBit, unsigned numBit) {
Filters.clear();
Filters.emplace_back(*this, startBit, numBit, true);
Filters.emplace_back(*this, startBit, numBit);
BestIndex = 0; // Sole Filter instance to choose from.
bestFilter().recurse();
}
Expand All @@ -1549,10 +1545,8 @@ void FilterChooser::runSingleFilter(unsigned startBit, unsigned numBit,
// eligible for use as a filter region.
void FilterChooser::reportRegion(bitAttr_t RA, unsigned StartBit,
unsigned BitIndex, bool AllowMixed) {
if (RA == ATTR_MIXED && AllowMixed)
Filters.emplace_back(*this, StartBit, BitIndex - StartBit, true);
else if (RA == ATTR_ALL_SET && !AllowMixed)
Filters.emplace_back(*this, StartBit, BitIndex - StartBit, false);
if (AllowMixed ? RA == ATTR_MIXED : RA == ATTR_ALL_SET)
Filters.emplace_back(*this, StartBit, BitIndex - StartBit);
}

// FilterProcessor scans the well-known encoding bits of the instructions and
Expand Down Expand Up @@ -1583,7 +1577,7 @@ bool FilterChooser::filterProcessor(bool AllowMixed, bool Greedy) {
// Look for islands of undecoded bits of any instruction.
if (getIslands(Islands, Insn) > 0) {
// Found an instruction with island(s). Now just assign a filter.
runSingleFilter(Islands[0].StartBit, Islands[0].NumBits, true);
runSingleFilter(Islands[0].StartBit, Islands[0].NumBits);
return true;
}
}
Expand Down