[llvm] [NFC][InstrInfoEmitter] Include location of inst definition in comment (PR #156927)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 4 13:10:08 PDT 2025


================
@@ -1302,18 +1305,29 @@ void InstrInfoEmitter::emitEnums(
 
   OS << "namespace llvm::" << Namespace << " {\n";
 
+  auto II = llvm::max_element(
+      NumberedInstructions,
+      [](const CodeGenInstruction *InstA, const CodeGenInstruction *InstB) {
+        return InstA->getName().size() < InstB->getName().size();
+      });
+  size_t MaxNameSize = (*II)->getName().size();
+
   OS << "  enum {\n";
-  for (const CodeGenInstruction *Inst : NumberedInstructions)
-    OS << "    " << Inst->TheDef->getName()
-       << "\t= " << Target.getInstrIntValue(Inst->TheDef) << ",\n";
+  for (const CodeGenInstruction *Inst : NumberedInstructions) {
+    OS << "    " << Inst->TheDef->getName();
+    OS.PadToColumn(MaxNameSize + 5);
+    OS << " = " << Target.getInstrIntValue(Inst->TheDef) << ", // (";
+    OS << SrcMgr.getFormattedLocationNoOffset(Inst->TheDef->getLoc().front())
+       << ")\n";
----------------
jurahul wrote:

Done.

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


More information about the llvm-commits mailing list