[llvm] 2f23666 - [Sparc] Remove Subtarget member of SparcTargetMachine (#66876)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 25 08:31:59 PDT 2023
Author: Sergei Barannikov
Date: 2023-09-25T18:31:54+03:00
New Revision: 2f23666ae7e434a222a67ac6499d118035ab7903
URL: https://github.com/llvm/llvm-project/commit/2f23666ae7e434a222a67ac6499d118035ab7903
DIFF: https://github.com/llvm/llvm-project/commit/2f23666ae7e434a222a67ac6499d118035ab7903.diff
LOG: [Sparc] Remove Subtarget member of SparcTargetMachine (#66876)
It was already removed once in D19265, but was reintroduced in D20353.
Added:
Modified:
llvm/lib/Target/Sparc/LeonPasses.cpp
llvm/lib/Target/Sparc/SparcTargetMachine.cpp
llvm/lib/Target/Sparc/SparcTargetMachine.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/Sparc/LeonPasses.cpp b/llvm/lib/Target/Sparc/LeonPasses.cpp
index bd26710fcbab118..45a46c131d21eaf 100644
--- a/llvm/lib/Target/Sparc/LeonPasses.cpp
+++ b/llvm/lib/Target/Sparc/LeonPasses.cpp
@@ -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();
@@ -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) {
@@ -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();
diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
index 6e146fa30a582a0..dbc26636e39f1f3 100644
--- a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
+++ b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
@@ -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();
}
@@ -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() { }
diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.h b/llvm/lib/Target/Sparc/SparcTargetMachine.h
index 0493829cb1bac68..497d5f6623cd307 100644
--- a/llvm/lib/Target/Sparc/SparcTargetMachine.h
+++ b/llvm/lib/Target/Sparc/SparcTargetMachine.h
@@ -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;
@@ -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;
More information about the llvm-commits
mailing list