diff options
author | Akira Hatanaka <ahatanaka@mips.com> | 2013-03-01 00:26:14 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@mips.com> | 2013-03-01 00:26:14 +0000 |
commit | 1f7330b16239f50daee57dbf53b20fbacd028ee4 (patch) | |
tree | ffd32a38ac0085553cad48d4048973bd5830456f /lib | |
parent | 49d58723d2f8d4578c07b37cf636a81b8b8a24a5 (diff) |
[mips] Define helper function searchRange
No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176318 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/Mips/MipsDelaySlotFiller.cpp | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/lib/Target/Mips/MipsDelaySlotFiller.cpp b/lib/Target/Mips/MipsDelaySlotFiller.cpp index 2762e2542d..0d6b00915f 100644 --- a/lib/Target/Mips/MipsDelaySlotFiller.cpp +++ b/lib/Target/Mips/MipsDelaySlotFiller.cpp @@ -129,6 +129,12 @@ namespace { bool delayHasHazard(const MachineInstr &Candidate, RegDefsUses &RegDU, MemDefsUses &MemDU) const; + /// This function searches range [Begin, End) for an instruction that can be + /// moved to the delay slot. Returns true on success. + template<typename IterTy> + bool searchRange(MachineBasicBlock &MBB, IterTy Begin, IterTy End, + RegDefsUses &RegDU, MemDefsUses &MemDU, IterTy &Filler) const; + bool searchBackward(MachineBasicBlock &MBB, Iter Slot, Iter &Filler) const; bool terminateSearch(const MachineInstr &Candidate) const; @@ -312,14 +318,11 @@ FunctionPass *llvm::createMipsDelaySlotFillerPass(MipsTargetMachine &tm) { return new Filler(tm); } -bool Filler::searchBackward(MachineBasicBlock &MBB, Iter Slot, - Iter &Filler) const { - RegDefsUses RegDU(TM); - MemDefsUses MemDU(MBB.getParent()->getFrameInfo()); - - RegDU.init(*Slot); - - for (ReverseIter I(Slot); I != MBB.rend(); ++I) { +template<typename IterTy> +bool Filler::searchRange(MachineBasicBlock &MBB, IterTy Begin, IterTy End, + RegDefsUses &RegDU, MemDefsUses &MemDU, + IterTy &Filler) const { + for (IterTy I = Begin; I != End; ++I) { // skip debug value if (I->isDebugValue()) continue; @@ -333,7 +336,24 @@ bool Filler::searchBackward(MachineBasicBlock &MBB, Iter Slot, if (delayHasHazard(*I, RegDU, MemDU)) continue; - Filler = llvm::next(I).base(); + Filler = I; + return true; + } + + return false; +} + +bool Filler::searchBackward(MachineBasicBlock &MBB, Iter Slot, + Iter &Filler) const { + RegDefsUses RegDU(TM); + MemDefsUses MemDU(MBB.getParent()->getFrameInfo()); + ReverseIter FillerReverse; + + RegDU.init(*Slot); + + if (searchRange(MBB, ReverseIter(Slot), MBB.rend(), RegDU, MemDU, + FillerReverse)) { + Filler = llvm::next(FillerReverse).base(); return true; } |