[llvm] [TableGen] Allow AsmWriter to generate uint64_t tables. NFC. (PR #227641)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 03:15:59 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-tablegen
Author: Jay Foad (jayfoad)
<details>
<summary>Changes</summary>
Each OpInfo entry in the generated AMDGPUInstPrinter::getMnemonic
carries 8 bytes of data. Previously GenAsmWriter would split that into
two uint32_t tables for no good reason. Generating a single uint64_t
table makes for shorter output and slightly better generated code.
---
Full diff: https://github.com/llvm/llvm-project/pull/227641.diff
1 Files Affected:
- (modified) llvm/utils/TableGen/AsmWriterEmitter.cpp (+5-4)
``````````diff
diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp b/llvm/utils/TableGen/AsmWriterEmitter.cpp
index f3e04bb0f0849e..c2d2fa574388b4 100644
--- a/llvm/utils/TableGen/AsmWriterEmitter.cpp
+++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp
@@ -462,15 +462,16 @@ void AsmWriterEmitter::EmitGetMnemonic(
BitsOS << " uint" << ((BitsLeft < (OpcodeInfoBits - 32)) ? 64 : 32)
<< "_t Bits = 0;\n";
while (BytesNeeded != 0) {
- // Figure out how big this table section needs to be, but no bigger than 4.
- unsigned TableSize = std::min(llvm::bit_floor(BytesNeeded), 4u);
+ // Figure out how big this table section needs to be.
+ unsigned TableSize = llvm::bit_floor(BytesNeeded);
BytesNeeded -= TableSize;
TableSize *= 8; // Convert to bits;
- uint64_t Mask = (1ULL << TableSize) - 1;
+ uint64_t Mask = maskTrailingOnes<uint64_t>(TableSize);
O << " static const uint" << TableSize << "_t OpInfo" << Table
<< "[] = {\n";
+ StringRef Suffix = TableSize == 64 ? "ULL" : "U";
for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) {
- O << " " << ((OpcodeInfo[i] >> Shift) & Mask) << "U,\t// "
+ O << " " << ((OpcodeInfo[i] >> Shift) & Mask) << Suffix << ",\t// "
<< NumberedInstructions[i]->getName() << '\n';
}
O << " };\n\n";
``````````
</details>
https://github.com/llvm/llvm-project/pull/227641
More information about the llvm-commits
mailing list