[mips] Expose adjustStackPtr() from MipsInstrInfo. NFC.
authorVasileios Kalintiris <Vasileios.Kalintiris@imgtec.com>
Thu, 2 Apr 2015 10:42:44 +0000 (10:42 +0000)
committerVasileios Kalintiris <Vasileios.Kalintiris@imgtec.com>
Thu, 2 Apr 2015 10:42:44 +0000 (10:42 +0000)
Summary:
adjustStackPtr() is implemented from both MipsSEInstrInfo and
Mips16InstrInfo. It makes sense to expose this function from
MipsInstrInfo and avoid explicit casting in some cases.

Depends on D8638.

Reviewers: dsanders

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D8640

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233905 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/Mips16FrameLowering.cpp
lib/Target/Mips/Mips16InstrInfo.h
lib/Target/Mips/MipsInstrInfo.h
lib/Target/Mips/MipsSEFrameLowering.cpp
lib/Target/Mips/MipsSEInstrInfo.h

index abecfa0bac2d5c5e877de13ed76f9bb4453033f5..6e35de70b96ea04ec07c3eba744997cdc400e484 100644 (file)
@@ -153,10 +153,7 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
     if (I->getOpcode() == Mips::ADJCALLSTACKDOWN)
       Amount = -Amount;
 
-    const Mips16InstrInfo &TII =
-        *static_cast<const Mips16InstrInfo *>(STI.getInstrInfo());
-
-    TII.adjustStackPtr(Mips::SP, Amount, MBB, I);
+    STI.getInstrInfo()->adjustStackPtr(Mips::SP, Amount, MBB, I);
   }
 
   MBB.erase(I);
index f9b738746adc1a83fbf1900fc01a9934ed668a6f..6540b40bc9abfb59887f388c8a010ec7d2606e4d 100644 (file)
@@ -77,7 +77,7 @@ public:
 
   /// Adjust SP by Amount bytes.
   void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB,
-                      MachineBasicBlock::iterator I) const;
+                      MachineBasicBlock::iterator I) const override;
 
   /// Emit a series of instructions to load an immediate.
   // This is to adjust some FrameReg. We return the new register to be used
index 7b2b2892e69259d0963fc61875f77c4cc3cf1063..45895355e1a54db0fc5a54e8e9affe15b47d184b 100644 (file)
@@ -117,6 +117,10 @@ public:
                                 const TargetRegisterInfo *TRI,
                                 int64_t Offset) const = 0;
 
+  virtual void adjustStackPtr(unsigned SP, int64_t Amount,
+                              MachineBasicBlock &MBB,
+                              MachineBasicBlock::iterator I) const = 0;
+
   /// Create an instruction which has the same operands and memory operands
   /// as MI but has a new opcode.
   MachineInstrBuilder genInstrWithNewOpc(unsigned NewOpc,
index 7c79c4c564a7d592239f755b3ef56af02dab70b3..31ee78213cf9a686957d4342622355cee5fd6a8b 100644 (file)
@@ -611,9 +611,6 @@ MipsSEFrameLowering::hasReservedCallFrame(const MachineFunction &MF) const {
 void MipsSEFrameLowering::
 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
                               MachineBasicBlock::iterator I) const {
-  const MipsSEInstrInfo &TII =
-      *static_cast<const MipsSEInstrInfo *>(STI.getInstrInfo());
-
   if (!hasReservedCallFrame(MF)) {
     int64_t Amount = I->getOperand(0).getImm();
 
@@ -621,7 +618,7 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
       Amount = -Amount;
 
     unsigned SP = STI.isABI_N64() ? Mips::SP_64 : Mips::SP;
-    TII.adjustStackPtr(SP, Amount, MBB, I);
+    STI.getInstrInfo()->adjustStackPtr(SP, Amount, MBB, I);
   }
 
   MBB.erase(I);
index d16fab2e92faa3bc0af32887fd483a64b8b444f6..bebbabf7b8387213f1110af0c407252da31ddf86 100644 (file)
@@ -68,7 +68,7 @@ public:
 
   /// Adjust SP by Amount bytes.
   void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB,
-                      MachineBasicBlock::iterator I) const;
+                      MachineBasicBlock::iterator I) const override;
 
   /// Emit a series of instructions to load an immediate. If NewImm is a
   /// non-NULL parameter, the last instruction is not emitted, but instead