From: Evan Cheng Date: Mon, 27 Jul 2009 00:24:36 +0000 (+0000) Subject: Merge isLoadFromStackSlot into one since it behaves the same regardless of sub-target. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0e5b14993073a1728c12cc38e42d5155812e034c;p=platform%2Fupstream%2Fllvm.git Merge isLoadFromStackSlot into one since it behaves the same regardless of sub-target. llvm-svn: 77174 --- diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp index c5e74bf..93ac1d5 100644 --- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp +++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp @@ -491,6 +491,7 @@ ARMBaseInstrInfo::isMoveInstr(const MachineInstr &MI, SrcSubIdx = DstSubIdx = 0; // No sub-registers. switch (MI.getOpcode()) { + default: break; case ARM::FCPYS: case ARM::FCPYD: case ARM::VMOVD: @@ -521,8 +522,10 @@ ARMBaseInstrInfo::isMoveInstr(const MachineInstr &MI, unsigned ARMBaseInstrInfo::isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const { - unsigned oc = MI->getOpcode(); - if (oc == getOpcode(ARMII::LDRrr)) { + switch (MI->getOpcode()) { + default: break; + case ARM::LDR: + case ARM::t2LDRs: // FIXME: don't use t2LDRs to access frame. if (MI->getOperand(1).isFI() && MI->getOperand(2).isReg() && MI->getOperand(3).isImm() && @@ -531,22 +534,25 @@ ARMBaseInstrInfo::isLoadFromStackSlot(const MachineInstr *MI, FrameIndex = MI->getOperand(1).getIndex(); return MI->getOperand(0).getReg(); } - } - else if (oc == getOpcode(ARMII::LDRri)) { + break; + case ARM::t2LDRi12: + case ARM::tRestore: if (MI->getOperand(1).isFI() && MI->getOperand(2).isImm() && MI->getOperand(2).getImm() == 0) { FrameIndex = MI->getOperand(1).getIndex(); return MI->getOperand(0).getReg(); } - } - else if (oc == ARM::FLDD || oc == ARM::FLDS) { + break; + case ARM::FLDD: + case ARM::FLDS: if (MI->getOperand(1).isFI() && MI->getOperand(2).isImm() && MI->getOperand(2).getImm() == 0) { FrameIndex = MI->getOperand(1).getIndex(); return MI->getOperand(0).getReg(); } + break; } return 0; @@ -555,8 +561,10 @@ ARMBaseInstrInfo::isLoadFromStackSlot(const MachineInstr *MI, unsigned ARMBaseInstrInfo::isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const { - unsigned oc = MI->getOpcode(); - if (oc == getOpcode(ARMII::STRrr)) { + switch (MI->getOpcode()) { + default: break; + case ARM::STR: + case ARM::t2STRs: // FIXME: don't use t2STRs to access frame. if (MI->getOperand(1).isFI() && MI->getOperand(2).isReg() && MI->getOperand(3).isImm() && @@ -565,22 +573,25 @@ ARMBaseInstrInfo::isStoreToStackSlot(const MachineInstr *MI, FrameIndex = MI->getOperand(1).getIndex(); return MI->getOperand(0).getReg(); } - } - else if (oc == getOpcode(ARMII::STRri)) { + break; + case ARM::t2STRi12: + case ARM::tSpill: if (MI->getOperand(1).isFI() && MI->getOperand(2).isImm() && MI->getOperand(2).getImm() == 0) { FrameIndex = MI->getOperand(1).getIndex(); return MI->getOperand(0).getReg(); } - } - else if (oc == ARM::FSTD || oc == ARM::FSTS) { + break; + case ARM::FSTD: + case ARM::FSTS: if (MI->getOperand(1).isFI() && MI->getOperand(2).isImm() && MI->getOperand(2).getImm() == 0) { FrameIndex = MI->getOperand(1).getIndex(); return MI->getOperand(0).getReg(); } + break; } return 0; diff --git a/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp b/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp index cca4591..19af487 100644 --- a/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp +++ b/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp @@ -71,38 +71,6 @@ Thumb1InstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { return false; } -unsigned Thumb1InstrInfo::isLoadFromStackSlot(const MachineInstr *MI, - int &FrameIndex) const { - switch (MI->getOpcode()) { - default: break; - case ARM::tRestore: - if (MI->getOperand(1).isFI() && - MI->getOperand(2).isImm() && - MI->getOperand(2).getImm() == 0) { - FrameIndex = MI->getOperand(1).getIndex(); - return MI->getOperand(0).getReg(); - } - break; - } - return 0; -} - -unsigned Thumb1InstrInfo::isStoreToStackSlot(const MachineInstr *MI, - int &FrameIndex) const { - switch (MI->getOpcode()) { - default: break; - case ARM::tSpill: - if (MI->getOperand(1).isFI() && - MI->getOperand(2).isImm() && - MI->getOperand(2).getImm() == 0) { - FrameIndex = MI->getOperand(1).getIndex(); - return MI->getOperand(0).getReg(); - } - break; - } - return 0; -} - bool Thumb1InstrInfo::copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned DestReg, unsigned SrcReg, diff --git a/llvm/lib/Target/ARM/Thumb1InstrInfo.h b/llvm/lib/Target/ARM/Thumb1InstrInfo.h index aa2c0ec..e227ce1 100644 --- a/llvm/lib/Target/ARM/Thumb1InstrInfo.h +++ b/llvm/lib/Target/ARM/Thumb1InstrInfo.h @@ -50,11 +50,6 @@ public: MachineBasicBlock::iterator MI, const std::vector &CSI) const; - unsigned isLoadFromStackSlot(const MachineInstr *MI, - int &FrameIndex) const; - unsigned isStoreToStackSlot(const MachineInstr *MI, - int &FrameIndex) const; - bool copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned DestReg, unsigned SrcReg,