[llvm-branch-commits] [llvm] CodeGen: Keep reference to TargetRegisterInfo in TargetInstrInfo (PR #158224)

Sergei Barannikov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Sep 12 02:03:37 PDT 2025


================
@@ -1070,8 +1070,8 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
   OS << "namespace llvm {\n";
   OS << "struct " << ClassName << " : public TargetInstrInfo {\n"
      << "  explicit " << ClassName
-     << "(const TargetSubtargetInfo &STI, unsigned CFSetupOpcode = ~0u, "
-        "unsigned CFDestroyOpcode = ~0u, "
+     << "(const TargetSubtargetInfo &STI, const TargetRegisterInfo &TRI, "
----------------
s-barannikov wrote:

> Most targets have TRI inside TII. After this PR, they all do.

I'd prefer the opposite.
I think most traget have TRI inside TII because it was easier to call `this->getRegInfo()` from inside a TII method than to call `MI->getMF().getSubtarget()->getRegInfo()`. If we have an STI reference as a member of TII, we could get TRI by `this->STI.getRegInfo()`.


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


More information about the llvm-branch-commits mailing list