[llvm] 05827e7 - [TableGen][DecoderEmitter] Dump conflicts earlier

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 16 22:21:11 PDT 2025


Author: Sergei Barannikov
Date: 2025-08-17T08:20:31+03:00
New Revision: 05827e7ccb4e1295648e38b11ebdbb8fd817177b

URL: https://github.com/llvm/llvm-project/commit/05827e7ccb4e1295648e38b11ebdbb8fd817177b
DIFF: https://github.com/llvm/llvm-project/commit/05827e7ccb4e1295648e38b11ebdbb8fd817177b.diff

LOG: [TableGen][DecoderEmitter] Dump conflicts earlier

Dump a conflict as soon as we discover it, no need to wait until
we start building the decoder table.
This improves debugging experience.

Added: 
    

Modified: 
    llvm/utils/TableGen/DecoderEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/DecoderEmitter.cpp b/llvm/utils/TableGen/DecoderEmitter.cpp
index daa30629b022b..7803509356419 100644
--- a/llvm/utils/TableGen/DecoderEmitter.cpp
+++ b/llvm/utils/TableGen/DecoderEmitter.cpp
@@ -1771,32 +1771,9 @@ void FilterChooser::doFilter() {
       filterProcessor(BitAttrs, /*AllowMixed=*/true, /*Greedy=*/false))
     return;
 
-  // If we come to here, the instruction decoding has failed.
-  assert(!BestFilter);
-}
-
-// emitTableEntries - Emit state machine entries to decode our share of
-// instructions.
-void FilterChooser::emitTableEntries(DecoderTableInfo &TableInfo) const {
-  if (Opcodes.size() == 1) {
-    // There is only one instruction in the set, which is great!
-    // Call emitSingletonDecoder() to see whether there are any remaining
-    // encodings bits.
-    emitSingletonTableEntry(TableInfo, Opcodes[0]);
-    return;
-  }
-
-  // Choose the best filter to do the decodings!
-  if (BestFilter) {
-    if (BestFilter->getNumFiltered() == 1)
-      emitSingletonTableEntry(TableInfo, *BestFilter);
-    else
-      BestFilter->emitTableEntry(TableInfo);
-    return;
-  }
-
   // We don't know how to decode these instructions! Dump the
   // conflict set and bail.
+  assert(!BestFilter);
 
   // Print out useful conflict information for postmortem analysis.
   errs() << "Decoding Conflict:\n";
@@ -1812,6 +1789,24 @@ void FilterChooser::emitTableEntries(DecoderTableInfo &TableInfo) const {
   PrintFatalError("Decoding conflict encountered");
 }
 
+// emitTableEntries - Emit state machine entries to decode our share of
+// instructions.
+void FilterChooser::emitTableEntries(DecoderTableInfo &TableInfo) const {
+  if (Opcodes.size() == 1) {
+    // There is only one instruction in the set, which is great!
+    // Call emitSingletonDecoder() to see whether there are any remaining
+    // encodings bits.
+    emitSingletonTableEntry(TableInfo, Opcodes[0]);
+    return;
+  }
+
+  // Use the best filter to do the decoding!
+  if (BestFilter->getNumFiltered() == 1)
+    emitSingletonTableEntry(TableInfo, *BestFilter);
+  else
+    BestFilter->emitTableEntry(TableInfo);
+}
+
 static std::string findOperandDecoderMethod(const Record *Record) {
   std::string Decoder;
 


        


More information about the llvm-commits mailing list