Permalink
Browse files

Merge pull request #176 from a1k0n/redundant-spills

DCPU16: Add isStoreToStackSlot implementation to DCPU16InstrInfo
  • Loading branch information...
2 parents 081ed14 + 77601d7 commit 6bdcd7f634a11cf6adbf5434f6dfdd1e11b73b74 @krasin krasin committed May 17, 2012
Showing with 15 additions and 0 deletions.
  1. +13 −0 lib/Target/DCPU16/DCPU16InstrInfo.cpp
  2. +2 −0 lib/Target/DCPU16/DCPU16InstrInfo.h
@@ -78,6 +78,19 @@ void DCPU16InstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
llvm_unreachable("Cannot store this register to stack slot!");
}
+unsigned DCPU16InstrInfo::isStoreToStackSlot(const MachineInstr *MI,
+ int &FrameIndex) const {
+ if (MI->getOpcode() == DCPU16::MOV16mr) {
+ if (MI->getOperand(0).isFI()) {
+ // MOV [SP+idx], reg
+ // operand 0 is frame index, 1 is immediate 0, 2 is register
+ FrameIndex = MI->getOperand(0).getIndex();
+ return MI->getOperand(2).getReg();
+ }
+ }
+ return 0;
+}
+
void DCPU16InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
MachineBasicBlock::iterator I, DebugLoc DL,
unsigned DestReg, unsigned SrcReg,
@@ -68,6 +68,8 @@ class DCPU16InstrInfo : public DCPU16GenInstrInfo {
unsigned DestReg, int FrameIdx,
const TargetRegisterClass *RC,
const TargetRegisterInfo *TRI) const;
+ virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
+ int &FrameIndex) const;
unsigned GetInstSizeInBytes(const MachineInstr *MI) const;

0 comments on commit 6bdcd7f

Please sign in to comment.