[llvm] [TableGen][Decoder] Decode operands with zero width or all bits known (PR #156358)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 1 13:29:35 PDT 2025


================
@@ -1058,11 +1070,23 @@ FilterChooser::getIslands(const KnownBits &EncodingBits) const {
 
 void DecoderTableBuilder::emitBinaryParser(raw_ostream &OS, indent Indent,
                                            const OperandInfo &OpInfo) const {
-  bool UseInsertBits = OpInfo.numFields() != 1 || OpInfo.InitValue != 0;
+  // Special case for 'bits<0>'.
+  if (OpInfo.Fields.empty() && !OpInfo.InitValue) {
+    if (IgnoreNonDecodableOperands)
+      return;
+    assert(!OpInfo.Decoder.empty());
+    OS << Indent << OpInfo.Decoder << "(MI, Decoder);\n";
+    return;
+  }
----------------
s-barannikov wrote:

I didn't want to pass zero (or any other placeholder value) to the function so as not to give the impression that it means something. It would be just a dead parameter.

If you get the signature wrong, you will get a compiler error pointing at the call site (where you can figure out the correct signature).


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


More information about the llvm-commits mailing list