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

0 commit comments

Comments
 (0)