Skip to content

Commit 2f23666

Browse files
authored
[Sparc] Remove Subtarget member of SparcTargetMachine (#66876)
It was already removed once in D19265, but was reintroduced in D20353.
1 parent 364757d commit 2f23666

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

llvm/lib/Target/Sparc/LeonPasses.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ InsertNOPLoad::InsertNOPLoad() : LEONMachineFunctionPass(ID) {}
3838

3939
bool InsertNOPLoad::runOnMachineFunction(MachineFunction &MF) {
4040
Subtarget = &MF.getSubtarget<SparcSubtarget>();
41+
if (!Subtarget->insertNOPLoad())
42+
return false;
43+
4144
const TargetInstrInfo &TII = *Subtarget->getInstrInfo();
4245
DebugLoc DL = DebugLoc();
4346

@@ -74,6 +77,8 @@ DetectRoundChange::DetectRoundChange() : LEONMachineFunctionPass(ID) {}
7477

7578
bool DetectRoundChange::runOnMachineFunction(MachineFunction &MF) {
7679
Subtarget = &MF.getSubtarget<SparcSubtarget>();
80+
if (!Subtarget->detectRoundChange())
81+
return false;
7782

7883
bool Modified = false;
7984
for (MachineBasicBlock &MBB : MF) {
@@ -122,6 +127,9 @@ FixAllFDIVSQRT::FixAllFDIVSQRT() : LEONMachineFunctionPass(ID) {}
122127

123128
bool FixAllFDIVSQRT::runOnMachineFunction(MachineFunction &MF) {
124129
Subtarget = &MF.getSubtarget<SparcSubtarget>();
130+
if (!Subtarget->fixAllFDIVSQRT())
131+
return false;
132+
125133
const TargetInstrInfo &TII = *Subtarget->getInstrInfo();
126134
DebugLoc DL = DebugLoc();
127135

llvm/lib/Target/Sparc/SparcTargetMachine.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ SparcTargetMachine::SparcTargetMachine(const Target &T, const Triple &TT,
107107
getEffectiveSparcCodeModel(
108108
CM, getEffectiveRelocModel(RM), is64bit, JIT),
109109
OL),
110-
TLOF(std::make_unique<SparcELFTargetObjectFile>()),
111-
Subtarget(TT, std::string(CPU), std::string(FS), *this, is64bit),
112-
is64Bit(is64bit) {
110+
TLOF(std::make_unique<SparcELFTargetObjectFile>()), is64Bit(is64bit) {
113111
initAsmInfo();
114112
}
115113

@@ -189,18 +187,9 @@ void SparcPassConfig::addPreEmitPass(){
189187
addPass(&BranchRelaxationPassID);
190188

191189
addPass(createSparcDelaySlotFillerPass());
192-
193-
if (this->getSparcTargetMachine().getSubtargetImpl()->insertNOPLoad())
194-
{
195-
addPass(new InsertNOPLoad());
196-
}
197-
if (this->getSparcTargetMachine().getSubtargetImpl()->detectRoundChange()) {
198-
addPass(new DetectRoundChange());
199-
}
200-
if (this->getSparcTargetMachine().getSubtargetImpl()->fixAllFDIVSQRT())
201-
{
202-
addPass(new FixAllFDIVSQRT());
203-
}
190+
addPass(new InsertNOPLoad());
191+
addPass(new DetectRoundChange());
192+
addPass(new FixAllFDIVSQRT());
204193
}
205194

206195
void SparcV8TargetMachine::anchor() { }

llvm/lib/Target/Sparc/SparcTargetMachine.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ namespace llvm {
2222

2323
class SparcTargetMachine : public LLVMTargetMachine {
2424
std::unique_ptr<TargetLoweringObjectFile> TLOF;
25-
SparcSubtarget Subtarget;
2625
bool is64Bit;
2726
mutable StringMap<std::unique_ptr<SparcSubtarget>> SubtargetMap;
2827

@@ -34,8 +33,7 @@ class SparcTargetMachine : public LLVMTargetMachine {
3433
bool JIT, bool is64bit);
3534
~SparcTargetMachine() override;
3635

37-
const SparcSubtarget *getSubtargetImpl() const { return &Subtarget; }
38-
const SparcSubtarget *getSubtargetImpl(const Function &) const override;
36+
const SparcSubtarget *getSubtargetImpl(const Function &F) const override;
3937

4038
// Pass Pipeline Configuration
4139
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;

0 commit comments

Comments
 (0)