Skip to content

Commit 03847f1

Browse files
authored
[SelectionDAG] Add empty implementation of SelectionDAGInfo to some targets (#119968)
#119969 adds a couple of new methods to this class, which will need to be overridden by these targets. Part of #119709. Pull Request: #119968
1 parent 2df48fa commit 03847f1

28 files changed

+281
-42
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "AMDGPUSelectionDAGInfo.h"
10+
11+
using namespace llvm;
12+
13+
AMDGPUSelectionDAGInfo::~AMDGPUSelectionDAGInfo() = default;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUSELECTIONDAGINFO_H
10+
#define LLVM_LIB_TARGET_AMDGPU_AMDGPUSELECTIONDAGINFO_H
11+
12+
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
13+
14+
namespace llvm {
15+
16+
class AMDGPUSelectionDAGInfo : public SelectionDAGTargetInfo {
17+
public:
18+
~AMDGPUSelectionDAGInfo() override;
19+
};
20+
21+
} // namespace llvm
22+
23+
#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUSELECTIONDAGINFO_H

llvm/lib/Target/AMDGPU/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ add_llvm_target(AMDGPUCodeGen
100100
AMDGPUResourceUsageAnalysis.cpp
101101
AMDGPURewriteOutArguments.cpp
102102
AMDGPURewriteUndefForPHI.cpp
103+
AMDGPUSelectionDAGInfo.cpp
103104
AMDGPUSetWavePriority.cpp
104105
AMDGPUSplitModule.cpp
105106
AMDGPUSubtarget.cpp

llvm/lib/Target/AMDGPU/GCNSubtarget.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "AMDGPUInstructionSelector.h"
1717
#include "AMDGPULegalizerInfo.h"
1818
#include "AMDGPURegisterBankInfo.h"
19+
#include "AMDGPUSelectionDAGInfo.h"
1920
#include "AMDGPUTargetMachine.h"
2021
#include "SIMachineFunctionInfo.h"
2122
#include "Utils/AMDGPUBaseInfo.h"
@@ -185,6 +186,9 @@ GCNSubtarget::GCNSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
185186
// clang-format on
186187
MaxWavesPerEU = AMDGPU::IsaInfo::getMaxWavesPerEU(this);
187188
EUsPerCU = AMDGPU::IsaInfo::getEUsPerCU(this);
189+
190+
TSInfo = std::make_unique<AMDGPUSelectionDAGInfo>();
191+
188192
CallLoweringInfo = std::make_unique<AMDGPUCallLowering>(*getTargetLowering());
189193
InlineAsmLoweringInfo =
190194
std::make_unique<InlineAsmLowering>(getTargetLowering());
@@ -194,6 +198,10 @@ GCNSubtarget::GCNSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
194198
std::make_unique<AMDGPUInstructionSelector>(*this, *RegBankInfo, TM);
195199
}
196200

201+
const SelectionDAGTargetInfo *GCNSubtarget::getSelectionDAGInfo() const {
202+
return TSInfo.get();
203+
}
204+
197205
unsigned GCNSubtarget::getConstantBusLimit(unsigned Opcode) const {
198206
if (getGeneration() < GFX10)
199207
return 1;

llvm/lib/Target/AMDGPU/GCNSubtarget.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "SIISelLowering.h"
2222
#include "SIInstrInfo.h"
2323
#include "Utils/AMDGPUBaseInfo.h"
24-
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
2524
#include "llvm/Support/ErrorHandling.h"
2625

2726
#define GET_SUBTARGETINFO_HEADER
@@ -49,6 +48,9 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
4948
};
5049

5150
private:
51+
/// SelectionDAGISel related APIs.
52+
std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
53+
5254
/// GlobalISel related APIs.
5355
std::unique_ptr<AMDGPUCallLowering> CallLoweringInfo;
5456
std::unique_ptr<InlineAsmLowering> InlineAsmLoweringInfo;
@@ -257,7 +259,6 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
257259
// Dummy feature to use for assembler in tablegen.
258260
bool FeatureDisable = false;
259261

260-
SelectionDAGTargetInfo TSInfo;
261262
private:
262263
SIInstrInfo InstrInfo;
263264
SITargetLowering TLInfo;
@@ -291,6 +292,8 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
291292
return &InstrInfo.getRegisterInfo();
292293
}
293294

295+
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
296+
294297
const CallLowering *getCallLowering() const override {
295298
return CallLoweringInfo.get();
296299
}
@@ -315,11 +318,6 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
315318
return TargetID;
316319
}
317320

318-
// Nothing implemented, just prevent crashes on use.
319-
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
320-
return &TSInfo;
321-
}
322-
323321
const InstrItineraryData *getInstrItineraryData() const override {
324322
return &InstrItins;
325323
}

llvm/lib/Target/AMDGPU/R600Subtarget.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "R600Subtarget.h"
15+
#include "AMDGPUSelectionDAGInfo.h"
1516
#include "MCTargetDesc/R600MCTargetDesc.h"
1617

1718
using namespace llvm;
@@ -30,6 +31,13 @@ R600Subtarget::R600Subtarget(const Triple &TT, StringRef GPU, StringRef FS,
3031
TLInfo(TM, initializeSubtargetDependencies(TT, GPU, FS)),
3132
InstrItins(getInstrItineraryForCPU(GPU)) {
3233
LocalMemorySize = AddressableLocalMemorySize;
34+
TSInfo = std::make_unique<AMDGPUSelectionDAGInfo>();
35+
}
36+
37+
R600Subtarget::~R600Subtarget() = default;
38+
39+
const SelectionDAGTargetInfo *R600Subtarget::getSelectionDAGInfo() const {
40+
return TSInfo.get();
3341
}
3442

3543
R600Subtarget &R600Subtarget::initializeSubtargetDependencies(const Triple &TT,

llvm/lib/Target/AMDGPU/R600Subtarget.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "R600ISelLowering.h"
2020
#include "R600InstrInfo.h"
2121
#include "Utils/AMDGPUBaseInfo.h"
22-
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
2322

2423
#define GET_SUBTARGETINFO_HEADER
2524
#include "R600GenSubtargetInfo.inc"
@@ -41,12 +40,14 @@ class R600Subtarget final : public R600GenSubtargetInfo,
4140
Generation Gen = R600;
4241
R600TargetLowering TLInfo;
4342
InstrItineraryData InstrItins;
44-
SelectionDAGTargetInfo TSInfo;
43+
std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
4544

4645
public:
4746
R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
4847
const TargetMachine &TM);
4948

49+
~R600Subtarget() override;
50+
5051
const R600InstrInfo *getInstrInfo() const override { return &InstrInfo; }
5152

5253
const R600FrameLowering *getFrameLowering() const override {
@@ -65,10 +66,7 @@ class R600Subtarget final : public R600GenSubtargetInfo,
6566
return &InstrItins;
6667
}
6768

68-
// Nothing implemented, just prevent crashes on use.
69-
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
70-
return &TSInfo;
71-
}
69+
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
7270

7371
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
7472

llvm/lib/Target/Mips/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ add_llvm_target(MipsCodeGen
5858
MipsSEISelDAGToDAG.cpp
5959
MipsSEISelLowering.cpp
6060
MipsSERegisterInfo.cpp
61+
MipsSelectionDAGInfo.cpp
6162
MipsSubtarget.cpp
6263
MipsTargetMachine.cpp
6364
MipsTargetObjectFile.cpp
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "MipsSelectionDAGInfo.h"
10+
11+
using namespace llvm;
12+
13+
MipsSelectionDAGInfo::~MipsSelectionDAGInfo() = default;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIB_TARGET_MIPS_MIPSSELECTIONDAGINFO_H
10+
#define LLVM_LIB_TARGET_MIPS_MIPSSELECTIONDAGINFO_H
11+
12+
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
13+
14+
namespace llvm {
15+
16+
class MipsSelectionDAGInfo : public SelectionDAGTargetInfo {
17+
public:
18+
~MipsSelectionDAGInfo() override;
19+
};
20+
21+
} // namespace llvm
22+
23+
#endif // LLVM_LIB_TARGET_MIPS_MIPSSELECTIONDAGINFO_H

llvm/lib/Target/Mips/MipsSubtarget.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "MipsLegalizerInfo.h"
1717
#include "MipsRegisterBankInfo.h"
1818
#include "MipsRegisterInfo.h"
19+
#include "MipsSelectionDAGInfo.h"
1920
#include "MipsTargetMachine.h"
2021
#include "llvm/IR/Attributes.h"
2122
#include "llvm/IR/Function.h"
@@ -78,13 +79,14 @@ MipsSubtarget::MipsSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
7879
HasMips3_32(false), HasMips3_32r2(false), HasMips4_32(false),
7980
HasMips4_32r2(false), HasMips5_32r2(false), InMips16Mode(false),
8081
InMips16HardFloat(Mips16HardFloat), InMicroMipsMode(false), HasDSP(false),
81-
HasDSPR2(false), HasDSPR3(false), AllowMixed16_32(Mixed16_32 || Mips_Os16),
82-
Os16(Mips_Os16), HasMSA(false), UseTCCInDIV(false), HasSym32(false),
83-
HasEVA(false), DisableMadd4(false), HasMT(false), HasCRC(false),
84-
HasVirt(false), HasGINV(false), UseIndirectJumpsHazard(false), StrictAlign(false),
82+
HasDSPR2(false), HasDSPR3(false),
83+
AllowMixed16_32(Mixed16_32 || Mips_Os16), Os16(Mips_Os16), HasMSA(false),
84+
UseTCCInDIV(false), HasSym32(false), HasEVA(false), DisableMadd4(false),
85+
HasMT(false), HasCRC(false), HasVirt(false), HasGINV(false),
86+
UseIndirectJumpsHazard(false), StrictAlign(false),
8587
StackAlignOverride(StackAlignOverride), TM(TM), TargetTriple(TT),
86-
TSInfo(), InstrInfo(MipsInstrInfo::create(
87-
initializeSubtargetDependencies(CPU, FS, TM))),
88+
InstrInfo(
89+
MipsInstrInfo::create(initializeSubtargetDependencies(CPU, FS, TM))),
8890
FrameLowering(MipsFrameLowering::create(*this)),
8991
TLInfo(MipsTargetLowering::create(TM, *this)) {
9092

@@ -211,6 +213,8 @@ MipsSubtarget::MipsSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
211213
GINVWarningPrinted = true;
212214
}
213215

216+
TSInfo = std::make_unique<MipsSelectionDAGInfo>();
217+
214218
CallLoweringInfo.reset(new MipsCallLowering(*getTargetLowering()));
215219
Legalizer.reset(new MipsLegalizerInfo(*this));
216220

@@ -219,6 +223,8 @@ MipsSubtarget::MipsSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
219223
InstSelector.reset(createMipsInstructionSelector(TM, *this, *RBI));
220224
}
221225

226+
MipsSubtarget::~MipsSubtarget() = default;
227+
222228
bool MipsSubtarget::isPositionIndependent() const {
223229
return TM.isPositionIndependent();
224230
}
@@ -280,6 +286,10 @@ bool MipsSubtarget::isABI_N32() const { return getABI().IsN32(); }
280286
bool MipsSubtarget::isABI_O32() const { return getABI().IsO32(); }
281287
const MipsABIInfo &MipsSubtarget::getABI() const { return TM.getABI(); }
282288

289+
const SelectionDAGTargetInfo *MipsSubtarget::getSelectionDAGInfo() const {
290+
return TSInfo.get();
291+
}
292+
283293
const CallLowering *MipsSubtarget::getCallLowering() const {
284294
return CallLoweringInfo.get();
285295
}

llvm/lib/Target/Mips/MipsSubtarget.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
2222
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
2323
#include "llvm/CodeGen/RegisterBankInfo.h"
24-
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
2524
#include "llvm/CodeGen/TargetSubtargetInfo.h"
2625
#include "llvm/IR/DataLayout.h"
2726
#include "llvm/MC/MCInstrItineraries.h"
@@ -220,7 +219,7 @@ class MipsSubtarget : public MipsGenSubtargetInfo {
220219

221220
Triple TargetTriple;
222221

223-
const SelectionDAGTargetInfo TSInfo;
222+
std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
224223
std::unique_ptr<const MipsInstrInfo> InstrInfo;
225224
std::unique_ptr<const MipsFrameLowering> FrameLowering;
226225
std::unique_ptr<const MipsTargetLowering> TLInfo;
@@ -243,6 +242,8 @@ class MipsSubtarget : public MipsGenSubtargetInfo {
243242
MipsSubtarget(const Triple &TT, StringRef CPU, StringRef FS, bool little,
244243
const MipsTargetMachine &TM, MaybeAlign StackAlignOverride);
245244

245+
~MipsSubtarget() override;
246+
246247
/// ParseSubtargetFeatures - Parses features string setting specified
247248
/// subtarget options. Definition of function is auto generated by tblgen.
248249
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
@@ -383,9 +384,8 @@ class MipsSubtarget : public MipsGenSubtargetInfo {
383384
void setHelperClassesMips16();
384385
void setHelperClassesMipsSE();
385386

386-
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
387-
return &TSInfo;
388-
}
387+
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
388+
389389
const MipsInstrInfo *getInstrInfo() const override { return InstrInfo.get(); }
390390
const TargetFrameLowering *getFrameLowering() const override {
391391
return FrameLowering.get();

llvm/lib/Target/NVPTX/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ set(NVPTXCodeGen_sources
3131
NVPTXPrologEpilogPass.cpp
3232
NVPTXRegisterInfo.cpp
3333
NVPTXReplaceImageHandles.cpp
34+
NVPTXSelectionDAGInfo.cpp
3435
NVPTXSubtarget.cpp
3536
NVPTXTargetMachine.cpp
3637
NVPTXTargetTransformInfo.cpp
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "NVPTXSelectionDAGInfo.h"
10+
11+
using namespace llvm;
12+
13+
NVPTXSelectionDAGInfo::~NVPTXSelectionDAGInfo() = default;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXSELECTIONDAGINFO_H
10+
#define LLVM_LIB_TARGET_NVPTX_NVPTXSELECTIONDAGINFO_H
11+
12+
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
13+
14+
namespace llvm {
15+
16+
class NVPTXSelectionDAGInfo : public SelectionDAGTargetInfo {
17+
public:
18+
~NVPTXSelectionDAGInfo() override;
19+
};
20+
21+
} // namespace llvm
22+
23+
#endif // LLVM_LIB_TARGET_NVPTX_NVPTXSELECTIONDAGINFO_H

llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "NVPTXSubtarget.h"
14+
#include "NVPTXSelectionDAGInfo.h"
1415
#include "NVPTXTargetMachine.h"
1516
#include "llvm/Support/ErrorHandling.h"
1617
#include "llvm/Support/FormatVariadic.h"
@@ -56,7 +57,15 @@ NVPTXSubtarget::NVPTXSubtarget(const Triple &TT, const std::string &CPU,
5657
const NVPTXTargetMachine &TM)
5758
: NVPTXGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), PTXVersion(0),
5859
FullSmVersion(200), SmVersion(getSmVersion()), TM(TM),
59-
TLInfo(TM, initializeSubtargetDependencies(CPU, FS)) {}
60+
TLInfo(TM, initializeSubtargetDependencies(CPU, FS)) {
61+
TSInfo = std::make_unique<NVPTXSelectionDAGInfo>();
62+
}
63+
64+
NVPTXSubtarget::~NVPTXSubtarget() = default;
65+
66+
const SelectionDAGTargetInfo *NVPTXSubtarget::getSelectionDAGInfo() const {
67+
return TSInfo.get();
68+
}
6069

6170
bool NVPTXSubtarget::hasImageHandles() const {
6271
// Enable handles for Kepler+, where CUDA supports indirect surfaces and

0 commit comments

Comments
 (0)