[llvm] [MC] Reorder TARGETInstrTable to shrink MCInstrDesc::ImplicitOffset (PR #171199)

Carl Ritson via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 9 00:58:15 PST 2025


================
@@ -959,13 +959,19 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
 
     OS << "struct " << TargetName << "InstrTable {\n";
     OS << "  MCInstrDesc Insts[" << NumberedInstructions.size() << "];\n";
+    OS << "  static_assert(alignof(MCInstrDesc) >= alignof(MCPhysReg), "
+          "\"Unwanted padding between Insts and ImplicitOps\");\n";
+    OS << "  MCPhysReg ImplicitOps[" << std::max(ImplicitListSize, 1U)
+       << "];\n";
+    // Emit enough padding to make ImplicitOps plus Padding add up to the size
+    // of a whole number of MCOperandInfo structs. This allows us to index into
+    // the OperandInfo array starting from the end of the Insts array, by
+    // biasing the indices by the OpInfoBase value calculated below.
+    OS << "  char Padding[sizeof(MCOperandInfo) - sizeof ImplicitOps % "
----------------
perlfu wrote:

Sure, I know syntactically it's OK -- but would it be more consistent to use brackets for them all? (Feel free to ignore me, I know this is just a nit.) 

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


More information about the llvm-commits mailing list