[llvm] CodeGen: Make TargetInstrInfo constructor protected (PR #157336)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 7 04:41:08 PDT 2025
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/157336
There's no use for the standalone base class TargetRegisterInfo
and TargetSubtargetInfo already do this.
>From df3ba086fe4db1d3353f146143476973e9244b0d Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Sun, 7 Sep 2025 18:32:37 +0900
Subject: [PATCH] CodeGen: Make TargetInstrInfo constructor protected
There's no use for the standalone base class TargetRegisterInfo
and TargetSubtargetInfo already do this.
---
llvm/include/llvm/CodeGen/TargetInstrInfo.h | 4 +++-
llvm/unittests/CodeGen/MFCommon.inc | 7 ++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
index b5b83c7ff1164..087affcfd55ce 100644
--- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -112,12 +112,14 @@ struct ExtAddrMode {
/// TargetInstrInfo - Interface to description of machine instruction set
///
class LLVM_ABI TargetInstrInfo : public MCInstrInfo {
-public:
+protected:
TargetInstrInfo(unsigned CFSetupOpcode = ~0u, unsigned CFDestroyOpcode = ~0u,
unsigned CatchRetOpcode = ~0u, unsigned ReturnOpcode = ~0u)
: CallFrameSetupOpcode(CFSetupOpcode),
CallFrameDestroyOpcode(CFDestroyOpcode), CatchRetOpcode(CatchRetOpcode),
ReturnOpcode(ReturnOpcode) {}
+
+public:
TargetInstrInfo(const TargetInstrInfo &) = delete;
TargetInstrInfo &operator=(const TargetInstrInfo &) = delete;
virtual ~TargetInstrInfo();
diff --git a/llvm/unittests/CodeGen/MFCommon.inc b/llvm/unittests/CodeGen/MFCommon.inc
index 425453fb0e280..cb4a2410df08b 100644
--- a/llvm/unittests/CodeGen/MFCommon.inc
+++ b/llvm/unittests/CodeGen/MFCommon.inc
@@ -75,6 +75,11 @@ public:
}
};
+class BogusTargetInstrInfo : public TargetInstrInfo {
+public:
+ BogusTargetInstrInfo() : TargetInstrInfo() {}
+};
+
class BogusSubtarget : public TargetSubtargetInfo {
public:
BogusSubtarget(TargetMachine &TM)
@@ -95,7 +100,7 @@ private:
BogusFrameLowering FL;
BogusRegisterInfo TRI;
BogusTargetLowering TL;
- TargetInstrInfo TII;
+ BogusTargetInstrInfo TII;
};
static TargetOptions getTargetOptionsForBogusMachine() {
More information about the llvm-commits
mailing list