@@ -517,6 +517,9 @@ class FilterChooser {
517517 // / The "field value" here refers to the encoding bits in the filtered range.
518518 std::map<uint64_t , std::unique_ptr<const FilterChooser>> FilterChooserMap;
519519
520+ // / Set to true if decoding conflict was encountered.
521+ bool HasConflict = false ;
522+
520523 struct Island {
521524 unsigned StartBit;
522525 unsigned NumBits;
@@ -559,6 +562,9 @@ class FilterChooser {
559562 return Encodings[EncodingIDs.back ()].getBitWidth ();
560563 }
561564
565+ // / Returns true if any decoding conflicts were encountered.
566+ bool hasConflict () const { return HasConflict; }
567+
562568private:
563569 // / Applies the given filter to the set of encodings this FilterChooser
564570 // / works with, creating inferior FilterChoosers as necessary.
@@ -684,6 +690,7 @@ void FilterChooser::applyFilter(const Filter &F) {
684690 // group of instructions whose segment values are variable.
685691 VariableFC = std::make_unique<FilterChooser>(Encodings, F.VariableIDs ,
686692 FilterBits, *this );
693+ HasConflict |= VariableFC->HasConflict ;
687694 }
688695
689696 // Otherwise, create sub choosers.
@@ -695,9 +702,11 @@ void FilterChooser::applyFilter(const Filter &F) {
695702
696703 // Delegates to an inferior filter chooser for further processing on this
697704 // category of instructions.
698- FilterChooserMap.try_emplace (FilterVal, std::make_unique<FilterChooser>(
699- Encodings, InferiorEncodingIDs,
700- 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 ;
701710 }
702711}
703712
@@ -1592,7 +1601,7 @@ void FilterChooser::doFilter() {
15921601 // Print out useful conflict information for postmortem analysis.
15931602 errs () << " Decoding Conflict:\n " ;
15941603 dump ();
1595- PrintFatalError ( " Decoding conflict encountered " ) ;
1604+ HasConflict = true ;
15961605}
15971606
15981607void FilterChooser::dump () const {
@@ -2570,12 +2579,17 @@ template <typename T> constexpr uint32_t InsnBitWidth = 0;
25702579 DecoderTableBuilder TableBuilder (Target, Encodings, TableInfo);
25712580 unsigned OpcodeMask = 0 ;
25722581
2582+ bool HasConflict = false ;
25732583 for (const auto &[BitWidth, BWMap] : EncMap) {
25742584 for (const auto &[Key, EncodingIDs] : BWMap) {
25752585 auto [DecoderNamespace, HwModeID] = Key;
25762586
25772587 // Emit the decoder for this (namespace, hwmode, width) combination.
25782588 FilterChooser FC (Encodings, EncodingIDs);
2589+ HasConflict |= FC.hasConflict ();
2590+ // Skip emitting table entries if a conflict has been detected.
2591+ if (HasConflict)
2592+ continue ;
25792593
25802594 // The decode table is cleared for each top level decoder function. The
25812595 // predicates and decoders themselves, however, are shared across
@@ -2600,6 +2614,9 @@ template <typename T> constexpr uint32_t InsnBitWidth = 0;
26002614 }
26012615 }
26022616
2617+ if (HasConflict)
2618+ PrintFatalError (" Decoding conflict encountered" );
2619+
26032620 // Emit the decoder function for the last bucket. This will also emit the
26042621 // single decoder function if SpecializeDecodersPerBitwidth = false.
26052622 if (!SpecializeDecodersPerBitwidth)
0 commit comments