[Mips][CodeGen] Remove MachineFunction::setSubtarget. Change Mips to just copy the subtarget from the MachineFunction instead of recalculating it.

Summary:
The MachineFunction should have been created with the correct subtarget. As
long as there is no way to change it, MipsTargetMachine can just capture it
directly from the MachineFunction without calling getSubtargetImpl again.

While there, const correct the Subtarget pointer to avoid a const_cast.

I believe the Mips16Subtarget and NoMips16Subtarget members are never used, but
I'll leave there removal for a separate patch.

Reviewers: echristo, atanasyan

Reviewed By: atanasyan

Subscribers: sdardis, arichardson, hiraditya, jrtc27, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60936

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359071 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2019-04-24 06:48:31 +00:00
parent 8b0afcf334
commit 685ae82844
3 changed files with 2 additions and 4 deletions

View File

@ -439,7 +439,6 @@ public:
/// getSubtarget - Return the subtarget for which this machine code is being
/// compiled.
const TargetSubtargetInfo &getSubtarget() const { return *STI; }
void setSubtarget(const TargetSubtargetInfo *ST) { STI = ST; }
/// getSubtarget - This method returns a pointer to the specified type of
/// TargetSubtargetInfo. In debug builds, it verifies that the object being

View File

@ -204,8 +204,7 @@ MipsTargetMachine::getSubtargetImpl(const Function &F) const {
void MipsTargetMachine::resetSubtarget(MachineFunction *MF) {
LLVM_DEBUG(dbgs() << "resetSubtarget\n");
Subtarget = const_cast<MipsSubtarget *>(getSubtargetImpl(MF->getFunction()));
MF->setSubtarget(Subtarget);
Subtarget = &MF->getSubtarget<MipsSubtarget>();
}
namespace {

View File

@ -29,7 +29,7 @@ class MipsTargetMachine : public LLVMTargetMachine {
std::unique_ptr<TargetLoweringObjectFile> TLOF;
// Selected ABI
MipsABIInfo ABI;
MipsSubtarget *Subtarget;
const MipsSubtarget *Subtarget;
MipsSubtarget DefaultSubtarget;
MipsSubtarget NoMips16Subtarget;
MipsSubtarget Mips16Subtarget;