[PATCH] [mips] Expose adjustStackPtr() from MipsInstrInfo. NFC.

Vasileios Kalintiris Vasileios.Kalintiris at imgtec.com
Thu Mar 26 11:07:37 PDT 2015


Hi dsanders,

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.

http://reviews.llvm.org/D8640

Files:
  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: lib/Target/Mips/Mips16FrameLowering.cpp
===================================================================
--- lib/Target/Mips/Mips16FrameLowering.cpp
+++ lib/Target/Mips/Mips16FrameLowering.cpp
@@ -147,16 +147,13 @@
 void Mips16FrameLowering::
 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
                               MachineBasicBlock::iterator I) const {
-  const Mips16InstrInfo &TII =
-    *static_cast<const Mips16InstrInfo *>(STI.getInstrInfo());
-
   if (!hasReservedCallFrame(MF)) {
     int64_t Amount = I->getOperand(0).getImm();
     if (Amount) {
       if (I->getOpcode() == Mips::ADJCALLSTACKDOWN)
         Amount = -Amount;
 
-      TII.adjustStackPtr(Mips::SP, Amount, MBB, I);
+      STI.getInstrInfo()->adjustStackPtr(Mips::SP, Amount, MBB, I);
     }
   }
 
Index: lib/Target/Mips/Mips16InstrInfo.h
===================================================================
--- lib/Target/Mips/Mips16InstrInfo.h
+++ lib/Target/Mips/Mips16InstrInfo.h
@@ -77,7 +77,7 @@
 
   /// 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: lib/Target/Mips/MipsInstrInfo.h
===================================================================
--- lib/Target/Mips/MipsInstrInfo.h
+++ lib/Target/Mips/MipsInstrInfo.h
@@ -117,6 +117,10 @@
                                 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: lib/Target/Mips/MipsSEFrameLowering.cpp
===================================================================
--- lib/Target/Mips/MipsSEFrameLowering.cpp
+++ lib/Target/Mips/MipsSEFrameLowering.cpp
@@ -611,17 +611,14 @@
 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();
     if (Amount) {
       if (I->getOpcode() == Mips::ADJCALLSTACKDOWN)
         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);
     }
   }
 
Index: lib/Target/Mips/MipsSEInstrInfo.h
===================================================================
--- lib/Target/Mips/MipsSEInstrInfo.h
+++ lib/Target/Mips/MipsSEInstrInfo.h
@@ -68,7 +68,7 @@
 
   /// 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

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8640.22742.patch
Type: text/x-patch
Size: 3560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150326/888fd463/attachment.bin>


More information about the llvm-commits mailing list