Skip to content

Commit a757c4e

Browse files
authored
CodeGen: Add subtarget to TargetLoweringBase constructor (#168620)
Currently LibcallLoweringInfo is defined inside of TargetLowering, which is owned by the subtarget. Pass in the subtarget so we can construct LibcallLoweringInfo with the subtarget. This is a temporary step that should be revertable in the future, after LibcallLoweringInfo is moved out of TargetLowering.
1 parent 1233c4b commit a757c4e

31 files changed

+62
-49
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ class LLVM_ABI TargetLoweringBase {
355355
llvm_unreachable("Invalid content kind");
356356
}
357357

358-
explicit TargetLoweringBase(const TargetMachine &TM);
358+
explicit TargetLoweringBase(const TargetMachine &TM,
359+
const TargetSubtargetInfo &STI);
359360
TargetLoweringBase(const TargetLoweringBase &) = delete;
360361
TargetLoweringBase &operator=(const TargetLoweringBase &) = delete;
361362
virtual ~TargetLoweringBase();
@@ -3977,7 +3978,8 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
39773978
TargetLowering(const TargetLowering &) = delete;
39783979
TargetLowering &operator=(const TargetLowering &) = delete;
39793980

3980-
explicit TargetLowering(const TargetMachine &TM);
3981+
explicit TargetLowering(const TargetMachine &TM,
3982+
const TargetSubtargetInfo &STI);
39813983
~TargetLowering() override;
39823984

39833985
bool isPositionIndependent() const;

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ using namespace llvm;
4141
using namespace llvm::SDPatternMatch;
4242

4343
/// NOTE: The TargetMachine owns TLOF.
44-
TargetLowering::TargetLowering(const TargetMachine &tm)
45-
: TargetLoweringBase(tm) {}
44+
TargetLowering::TargetLowering(const TargetMachine &tm,
45+
const TargetSubtargetInfo &STI)
46+
: TargetLoweringBase(tm, STI) {}
4647

4748
// Define the virtual destructor out-of-line for build efficiency.
4849
TargetLowering::~TargetLowering() = default;

llvm/lib/CodeGen/TargetLoweringBase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,8 @@ ISD::CondCode TargetLoweringBase::getSoftFloatCmpLibcallPredicate(
749749
}
750750

751751
/// NOTE: The TargetMachine owns TLOF.
752-
TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm)
752+
TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm,
753+
const TargetSubtargetInfo &STI)
753754
: TM(tm),
754755
RuntimeLibcallInfo(TM.getTargetTriple(), TM.Options.ExceptionModel,
755756
TM.Options.FloatABIType, TM.Options.EABIVersion,

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ extractPtrauthBlendDiscriminators(SDValue Disc, SelectionDAG *DAG) {
387387

388388
AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
389389
const AArch64Subtarget &STI)
390-
: TargetLowering(TM), Subtarget(&STI) {
390+
: TargetLowering(TM, STI), Subtarget(&STI) {
391391
// AArch64 doesn't have comparisons which set GPRs or setcc instructions, so
392392
// we have to make something up. Arbitrarily, choose ZeroOrOne.
393393
setBooleanContents(ZeroOrOneBooleanContent);

llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ unsigned AMDGPUTargetLowering::numBitsSigned(SDValue Op, SelectionDAG &DAG) {
6060
}
6161

6262
AMDGPUTargetLowering::AMDGPUTargetLowering(const TargetMachine &TM,
63-
const AMDGPUSubtarget &STI)
64-
: TargetLowering(TM), Subtarget(&STI) {
63+
const TargetSubtargetInfo &STI,
64+
const AMDGPUSubtarget &AMDGPUSTI)
65+
: TargetLowering(TM, STI), Subtarget(&AMDGPUSTI) {
6566
// Always lower memset, memcpy, and memmove intrinsics to load/store
6667
// instructions, rather then generating calls to memset, mempcy or memmove.
6768
MaxStoresPerMemset = MaxStoresPerMemsetOptSize = ~0U;

llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ class AMDGPUTargetLowering : public TargetLowering {
180180
const SmallVectorImpl<ISD::InputArg> &Ins) const;
181181

182182
public:
183-
AMDGPUTargetLowering(const TargetMachine &TM, const AMDGPUSubtarget &STI);
183+
AMDGPUTargetLowering(const TargetMachine &TM, const TargetSubtargetInfo &STI,
184+
const AMDGPUSubtarget &AMDGPUSTI);
184185

185186
bool mayIgnoreSignedZero(SDValue Op) const;
186187

llvm/lib/Target/AMDGPU/R600ISelLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ using namespace llvm;
3030

3131
R600TargetLowering::R600TargetLowering(const TargetMachine &TM,
3232
const R600Subtarget &STI)
33-
: AMDGPUTargetLowering(TM, STI), Subtarget(&STI), Gen(STI.getGeneration()) {
33+
: AMDGPUTargetLowering(TM, STI, STI), Subtarget(&STI),
34+
Gen(STI.getGeneration()) {
3435
addRegisterClass(MVT::f32, &R600::R600_Reg32RegClass);
3536
addRegisterClass(MVT::i32, &R600::R600_Reg32RegClass);
3637
addRegisterClass(MVT::v2f32, &R600::R600_Reg64RegClass);

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static unsigned findFirstFreeSGPR(CCState &CCInfo) {
8787

8888
SITargetLowering::SITargetLowering(const TargetMachine &TM,
8989
const GCNSubtarget &STI)
90-
: AMDGPUTargetLowering(TM, STI), Subtarget(&STI) {
90+
: AMDGPUTargetLowering(TM, STI, STI), Subtarget(&STI) {
9191
addRegisterClass(MVT::i1, &AMDGPU::VReg_1RegClass);
9292
addRegisterClass(MVT::i64, &AMDGPU::SReg_64RegClass);
9393

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ const ARMBaseTargetMachine &ARMTargetLowering::getTM() const {
508508

509509
ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM_,
510510
const ARMSubtarget &STI)
511-
: TargetLowering(TM_), Subtarget(&STI),
511+
: TargetLowering(TM_, STI), Subtarget(&STI),
512512
RegInfo(Subtarget->getRegisterInfo()),
513513
Itins(Subtarget->getInstrItineraryData()) {
514514
const auto &TM = static_cast<const ARMBaseTargetMachine &>(TM_);

llvm/lib/Target/AVR/AVRISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace llvm {
3434

3535
AVRTargetLowering::AVRTargetLowering(const AVRTargetMachine &TM,
3636
const AVRSubtarget &STI)
37-
: TargetLowering(TM), Subtarget(STI) {
37+
: TargetLowering(TM, STI), Subtarget(STI) {
3838
// Set up the register classes.
3939
addRegisterClass(MVT::i8, &AVR::GPR8RegClass);
4040
addRegisterClass(MVT::i16, &AVR::DREGSRegClass);

0 commit comments

Comments
 (0)