[llvm] [TableGen] List the indices of sub-operands (PR #163723)
    Simon Tatham via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Oct 20 02:05:56 PDT 2025
    
    
  
================
@@ -1135,6 +1135,20 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
 
   OS << "\n};\n} // end namespace llvm\n";
 
+  OS << "namespace llvm::" << Target.getInstNamespace() << " {\n";
+  for (const Record *R : Records.getAllDerivedDefinitions("Operand")) {
+    if (R->isAnonymous())
+      continue;
+    if (const DagInit *D = R->getValueAsDag("MIOperandInfo")) {
+      for (unsigned i = 0, e = D->getNumArgs(); i < e; ++i) {
+        if (const StringInit *Name = D->getArgName(i))
+          OS << "  constexpr unsigned SUBOP_" << R->getName() << "_"
+             << Name->getValue() << " = " << i << ";\n";
+      }
+    }
+  }
+  OS << "} // end namespace llvm::" << Target.getInstNamespace() << "\n";
----------------
statham-arm wrote:
Thanks, I didn't know about that helper. (In my defence, apparently neither did anyone who wrote the surrounding code!)
https://github.com/llvm/llvm-project/pull/163723
    
    
More information about the llvm-commits
mailing list