[llvm] [TableGen] Emit Debug code for dynamic bits(eg: instruction operands) in DecoderEmitter (PR #194699)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 22 07:33:52 PDT 2026
================
@@ -1517,6 +1567,36 @@ namespace {
// on their usage.
template <typename T> constexpr uint32_t InsnBitWidth = 0;
+#ifndef NDEBUG
+// Operand with no encoding fields: `Desc` is either "imm" (a constant
+// immediate) or "bits<0>" (no encoding at all).
+[[maybe_unused]] void reportOperandDecodeFailure(const char *Op,
+ const char *Desc,
+ const char *Decoder) {
+ dbgs() << "OPC_Decode for " << Op << ": " << Desc << " using " << Decoder
+ << " : FAIL\n";
+}
+
+// Operand with encoding fields, passed as (base, width) integer pairs.
+[[maybe_unused]] void reportOperandDecodeFailure(const char *Op,
+ const char *Decoder,
+ ArrayRef<uint32_t> Fields) {
+ dbgs() << "OPC_Decode for " << Op << ": ";
+ for (unsigned I = 0, E = Fields.size(); I != E; I += 2) {
----------------
jurahul wrote:
nit: Use range for loop and ListSeparator here:
```
ListSeparator Plus(" + ");
for (const auto &[Base, Width]: Fields)
dbgs() << Plus << "field(" << Base << ',' << Width << ')';
```
something like that.
https://github.com/llvm/llvm-project/pull/194699
More information about the llvm-commits
mailing list