[llvm-commits] [llvm] r141150 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp
Akira Hatanaka
ahatanaka at mips.com
Tue Oct 4 18:23:40 PDT 2011
Author: ahatanak
Date: Tue Oct 4 20:23:39 2011
New Revision: 141150
URL: http://llvm.org/viewvc/llvm-project?rev=141150&view=rev
Log:
Clean up Filler::runOnMachineBasicBlock. Change interface of
Filler::findDelayInstr.
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=141150&r1=141149&r2=141150&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Tue Oct 4 20:23:39 2011
@@ -78,8 +78,9 @@
SmallSet<unsigned, 32> &RegDefs,
SmallSet<unsigned, 32> &RegUses);
- MachineBasicBlock::iterator
- findDelayInstr(MachineBasicBlock &MBB, MachineBasicBlock::iterator slot);
+ bool
+ findDelayInstr(MachineBasicBlock &MBB, MachineBasicBlock::iterator slot,
+ MachineBasicBlock::iterator &Filler);
};
@@ -93,19 +94,19 @@
bool Changed = false;
for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I)
if (I->getDesc().hasDelaySlot()) {
- MachineBasicBlock::iterator D = MBB.end();
- MachineBasicBlock::iterator J = I;
-
- if (EnableDelaySlotFiller)
- D = findDelayInstr(MBB, I);
-
++FilledSlots;
Changed = true;
- if (D == MBB.end())
- BuildMI(MBB, ++J, I->getDebugLoc(), TII->get(Mips::NOP));
- else
- MBB.splice(++J, &MBB, D);
+ MachineBasicBlock::iterator D;
+
+ if (EnableDelaySlotFiller && findDelayInstr(MBB, I, D)) {
+ MBB.splice(llvm::next(I), &MBB, D);
+ ++UsefulSlots;
+ }
+ else
+ BuildMI(MBB, llvm::next(I), I->getDebugLoc(), TII->get(Mips::NOP));
+
+ ++I; // Skip instruction that has just been moved to delay slot.
}
return Changed;
@@ -117,9 +118,9 @@
return new Filler(tm);
}
-MachineBasicBlock::iterator
-Filler::findDelayInstr(MachineBasicBlock &MBB,
- MachineBasicBlock::iterator slot) {
+bool Filler::findDelayInstr(MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator slot,
+ MachineBasicBlock::iterator &Filler) {
SmallSet<unsigned, 32> RegDefs;
SmallSet<unsigned, 32> RegUses;
bool sawLoad = false;
@@ -162,9 +163,11 @@
continue;
}
- return I;
+ Filler = I;
+ return true;
}
- return MBB.end();
+
+ return false;
}
bool Filler::delayHasHazard(MachineBasicBlock::iterator candidate,
More information about the llvm-commits
mailing list