[llvm] [NFCI][TableGen][DecoderEmitter] Cull Op handling when possible (PR #142974)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 16 17:15:24 PDT 2025


================
@@ -2645,23 +2662,29 @@ namespace {
     TableInfo.Table.push_back(MCD::OPC_Fail);
 
     // Print the table to the output stream.
-    HasTryDecode |= emitTable(OS, TableInfo.Table, indent(0), FC.getBitWidth(),
-                              Opc.first.first, Opc.second);
+    OpcodeMask |= emitTable(OS, TableInfo.Table, indent(0), FC.getBitWidth(),
+                            Opc.first.first, Opc.second);
   }
 
   // For variable instruction, we emit a instruction length table
   // to let the decoder know how long the instructions are.
   // You can see example usage in M68k's disassembler.
   if (IsVarLenInst)
     emitInstrLenTable(OS, InstrLen);
+
+  const bool HasCheckPredicate =
+      OpcodeMask &
+      ((1 << MCD::OPC_CheckPredicate) | (1 << MCD::OPC_CheckPredicateOrFail));
+
   // Emit the predicate function.
-  emitPredicateFunction(OS, TableInfo.Predicates, indent(0));
+  if (HasCheckPredicate)
+    emitPredicateFunction(OS, TableInfo.Predicates, indent(0));
----------------
topperc wrote:

Does this remove the need for the Predicates.empty() check inside `emitPredicateFunction`?

https://github.com/llvm/llvm-project/pull/142974


More information about the llvm-commits mailing list