[llvm] r176318 - [mips] Define helper function searchRange
Akira Hatanaka
ahatanaka at mips.com
Thu Feb 28 16:26:14 PST 2013
Author: ahatanak
Date: Thu Feb 28 18:26:14 2013
New Revision: 176318
URL: http://llvm.org/viewvc/llvm-project?rev=176318&view=rev
Log:
[mips] Define helper function searchRange
No functionality change.
Modified:
llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp
Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=176318&r1=176317&r2=176318&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Thu Feb 28 18:26:14 2013
@@ -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::createMipsDelaySlotF
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(MachineBasic
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;
}
More information about the llvm-commits
mailing list