Skip to content

Commit 26d5825

Browse files
committed
Review feedback
1 parent 8d5a48b commit 26d5825

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@ class FilterChooser {
562562
return Encodings[EncodingIDs.back()].getBitWidth();
563563
}
564564

565+
/// Returns true if any decoding conflicts were encountered.
566+
bool getHasConflict() const { return HasConflict; }
567+
565568
private:
566569
/// Applies the given filter to the set of encodings this FilterChooser
567570
/// works with, creating inferior FilterChoosers as necessary.
@@ -603,22 +606,18 @@ class DecoderTableBuilder {
603606
ArrayRef<InstructionEncoding> Encodings;
604607
DecoderTableInfo &TableInfo;
605608

606-
bool HasConflict = false;
607-
608609
public:
609610
DecoderTableBuilder(const CodeGenTarget &Target,
610611
ArrayRef<InstructionEncoding> Encodings,
611612
DecoderTableInfo &TableInfo)
612613
: Target(Target), Encodings(Encodings), TableInfo(TableInfo) {}
613614

614-
/// Returns true if a decoding conflict was encountered.
615-
bool buildTable(const FilterChooser &FC, unsigned BitWidth) {
615+
void buildTable(const FilterChooser &FC, unsigned BitWidth) const {
616616
// When specializing decoders per bit width, each decoder table will begin
617617
// with the bitwidth for that table.
618618
if (SpecializeDecodersPerBitwidth)
619619
TableInfo.Table.insertULEB128(BitWidth);
620620
emitTableEntries(FC);
621-
return HasConflict;
622621
}
623622

624623
private:
@@ -644,7 +643,7 @@ class DecoderTableBuilder {
644643

645644
void emitSingletonTableEntry(const FilterChooser &FC) const;
646645

647-
void emitTableEntries(const FilterChooser &FC);
646+
void emitTableEntries(const FilterChooser &FC) const;
648647
};
649648

650649
} // end anonymous namespace
@@ -691,6 +690,7 @@ void FilterChooser::applyFilter(const Filter &F) {
691690
// group of instructions whose segment values are variable.
692691
VariableFC = std::make_unique<FilterChooser>(Encodings, F.VariableIDs,
693692
FilterBits, *this);
693+
HasConflict |= VariableFC->HasConflict;
694694
}
695695

696696
// Otherwise, create sub choosers.
@@ -702,9 +702,11 @@ void FilterChooser::applyFilter(const Filter &F) {
702702

703703
// Delegates to an inferior filter chooser for further processing on this
704704
// category of instructions.
705-
FilterChooserMap.try_emplace(FilterVal, std::make_unique<FilterChooser>(
706-
Encodings, InferiorEncodingIDs,
707-
InferiorFilterBits, *this));
705+
auto [It, _] = FilterChooserMap.try_emplace(
706+
FilterVal,
707+
std::make_unique<FilterChooser>(Encodings, InferiorEncodingIDs,
708+
InferiorFilterBits, *this));
709+
HasConflict |= It->second->HasConflict;
708710
}
709711
}
710712

@@ -1619,12 +1621,7 @@ void FilterChooser::dump() const {
16191621
}
16201622
}
16211623

1622-
void DecoderTableBuilder::emitTableEntries(const FilterChooser &FC) {
1623-
if (FC.HasConflict) {
1624-
HasConflict = true;
1625-
return;
1626-
}
1627-
1624+
void DecoderTableBuilder::emitTableEntries(const FilterChooser &FC) const {
16281625
DecoderTable &Table = TableInfo.Table;
16291626

16301627
// If there are other encodings that could match if those with all bits
@@ -2589,6 +2586,10 @@ template <typename T> constexpr uint32_t InsnBitWidth = 0;
25892586

25902587
// Emit the decoder for this (namespace, hwmode, width) combination.
25912588
FilterChooser FC(Encodings, EncodingIDs);
2589+
HasConflict |= FC.getHasConflict();
2590+
// Skip emitting table entries if a conflict has been detected.
2591+
if (HasConflict)
2592+
continue;
25922593

25932594
// The decode table is cleared for each top level decoder function. The
25942595
// predicates and decoders themselves, however, are shared across
@@ -2598,10 +2599,7 @@ template <typename T> constexpr uint32_t InsnBitWidth = 0;
25982599
// across all decoder tables.
25992600
// - predicates are shared across all decoder tables.
26002601
TableInfo.Table.clear();
2601-
HasConflict |= TableBuilder.buildTable(FC, BitWidth);
2602-
// Skip emitting table entries if a conflict has been detected.
2603-
if (HasConflict)
2604-
continue;
2602+
TableBuilder.buildTable(FC, BitWidth);
26052603

26062604
// Print the table to the output stream.
26072605
OpcodeMask |= emitTable(OS, TableInfo.Table, DecoderNamespace, HwModeID,

0 commit comments

Comments
 (0)