[llvm] [Sparc] Remove Subtarget member of SparcTargetMachine (PR #66876)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 20 01:55:29 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-sparc
<details>
<summary>Changes</summary>
It was already removed once in D19265, but was reintroduced in D20353.
---
Full diff: https://github.com/llvm/llvm-project/pull/66876.diff
3 Files Affected:
- (modified) llvm/lib/Target/Sparc/LeonPasses.cpp (+8)
- (modified) llvm/lib/Target/Sparc/SparcTargetMachine.cpp (+4-15)
- (modified) llvm/lib/Target/Sparc/SparcTargetMachine.h (+1-3)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/66876
More information about the llvm-commits
mailing list