[llvm] [NFCI][MC][DecoderEmitter] Fix BitWidth for fixed length inst encodings (PR #154934)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 22 06:56:50 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- llvm/utils/TableGen/DecoderEmitter.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/utils/TableGen/DecoderEmitter.cpp b/llvm/utils/TableGen/DecoderEmitter.cpp
index 9f90e4f75..344ca0ede 100644
--- a/llvm/utils/TableGen/DecoderEmitter.cpp
+++ b/llvm/utils/TableGen/DecoderEmitter.cpp
@@ -1796,7 +1796,8 @@ void InstructionEncoding::parseFixedLenEncoding(
   unsigned InstNumBits = RecordInstBits.getNumBits();
 
   // Returns true if all bits in `Bits` are zero or unset.
-  auto CheckAllZeroOrUnset = [&](ArrayRef<const Init *> Bits, const RecordVal *Field) {
+  auto CheckAllZeroOrUnset = [&](ArrayRef<const Init *> Bits,
+                                 const RecordVal *Field) {
     bool AllZeroOrUnset = llvm::all_of(Bits, [](const Init *Bit) {
       if (const auto *BI = dyn_cast<BitInit>(Bit))
         return !BI->getValue();
@@ -1804,20 +1805,16 @@ void InstructionEncoding::parseFixedLenEncoding(
     });
     if (AllZeroOrUnset)
       return;
-    PrintNote([Field](raw_ostream &OS) {
-      Field->print(OS);
-    });
-    PrintFatalError(
-        EncodingDef,
-        Twine(Name) + ": Size is " + Twine(BitWidth) +
-            " bits, but " +  Field->getName() + " bits beyond that are not zero/unset");
+    PrintNote([Field](raw_ostream &OS) { Field->print(OS); });
+    PrintFatalError(EncodingDef, Twine(Name) + ": Size is " + Twine(BitWidth) +
+                                     " bits, but " + Field->getName() +
+                                     " bits beyond that are not zero/unset");
   };
 
   if (InstNumBits < BitWidth)
-    PrintFatalError(EncodingDef, Twine(Name) + ": Size is " +
-                                      Twine(BitWidth) +
-                                      " bits, but Inst specifies only " +
-                                      Twine(InstNumBits) + " bits");
+    PrintFatalError(EncodingDef, Twine(Name) + ": Size is " + Twine(BitWidth) +
+                                     " bits, but Inst specifies only " +
+                                     Twine(InstNumBits) + " bits");
 
   if (InstNumBits > BitWidth) {
     // Ensure that all the bits beyond 'Size' are 0 or unset (i.e., carry no
@@ -1869,9 +1866,9 @@ void InstructionEncoding::parseFixedLenEncoding(
       if (!InstBits.Zero[I] && !InstBits.One[I]) {
         PrintNote(EncodingDef->getLoc(), "in record");
         PrintError(SoftFailField,
-                    formatv("SoftFail{{{0}} = 1 requires Inst{{{0}} "
-                            "to be fully defined (0 or 1, not '?')",
-                            I));
+                   formatv("SoftFail{{{0}} = 1 requires Inst{{{0}} "
+                           "to be fully defined (0 or 1, not '?')",
+                           I));
       }
       SoftFailBits.setBit(I);
     }

``````````

</details>


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


More information about the llvm-commits mailing list