Skip to content

[Sparc] Remove Subtarget member of SparcTargetMachine #66876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions llvm/lib/Target/Sparc/LeonPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ InsertNOPLoad::InsertNOPLoad() : LEONMachineFunctionPass(ID) {}

bool InsertNOPLoad::runOnMachineFunction(MachineFunction &MF) {
Subtarget = &MF.getSubtarget<SparcSubtarget>();
if (!Subtarget->insertNOPLoad())
return false;

const TargetInstrInfo &TII = *Subtarget->getInstrInfo();
DebugLoc DL = DebugLoc();

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

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

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

bool FixAllFDIVSQRT::runOnMachineFunction(MachineFunction &MF) {
Subtarget = &MF.getSubtarget<SparcSubtarget>();
if (!Subtarget->fixAllFDIVSQRT())
return false;

const TargetInstrInfo &TII = *Subtarget->getInstrInfo();
DebugLoc DL = DebugLoc();

Expand Down
19 changes: 4 additions & 15 deletions llvm/lib/Target/Sparc/SparcTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ SparcTargetMachine::SparcTargetMachine(const Target &T, const Triple &TT,
getEffectiveSparcCodeModel(
CM, getEffectiveRelocModel(RM), is64bit, JIT),
OL),
TLOF(std::make_unique<SparcELFTargetObjectFile>()),
Subtarget(TT, std::string(CPU), std::string(FS), *this, is64bit),
is64Bit(is64bit) {
TLOF(std::make_unique<SparcELFTargetObjectFile>()), is64Bit(is64bit) {
initAsmInfo();
}

Expand Down Expand Up @@ -189,18 +187,9 @@ void SparcPassConfig::addPreEmitPass(){
addPass(&BranchRelaxationPassID);

addPass(createSparcDelaySlotFillerPass());

if (this->getSparcTargetMachine().getSubtargetImpl()->insertNOPLoad())
{
addPass(new InsertNOPLoad());
}
if (this->getSparcTargetMachine().getSubtargetImpl()->detectRoundChange()) {
addPass(new DetectRoundChange());
}
if (this->getSparcTargetMachine().getSubtargetImpl()->fixAllFDIVSQRT())
{
addPass(new FixAllFDIVSQRT());
}
addPass(new InsertNOPLoad());
addPass(new DetectRoundChange());
addPass(new FixAllFDIVSQRT());
}

void SparcV8TargetMachine::anchor() { }
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Target/Sparc/SparcTargetMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace llvm {

class SparcTargetMachine : public LLVMTargetMachine {
std::unique_ptr<TargetLoweringObjectFile> TLOF;
SparcSubtarget Subtarget;
bool is64Bit;
mutable StringMap<std::unique_ptr<SparcSubtarget>> SubtargetMap;

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

const SparcSubtarget *getSubtargetImpl() const { return &Subtarget; }
const SparcSubtarget *getSubtargetImpl(const Function &) const override;
const SparcSubtarget *getSubtargetImpl(const Function &F) const override;

// Pass Pipeline Configuration
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
Expand Down