aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/Mips/MipsDelaySlotFiller.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@mips.com>2011-10-05 01:23:39 +0000
committerAkira Hatanaka <ahatanaka@mips.com>2011-10-05 01:23:39 +0000
commit6f818abbe3dce0bee8257ea7d7dd4cb951f4dc7c (patch)
treebb0a620002c136fcc72af3a31ba27ce73df62e75 /lib/Target/Mips/MipsDelaySlotFiller.cpp
parent98f4d4d2db66375bedb461a9f6f9092a3c6703b2 (diff)
Clean up Filler::runOnMachineBasicBlock. Change interface of
Filler::findDelayInstr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141150 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Mips/MipsDelaySlotFiller.cpp')
-rw-r--r--lib/Target/Mips/MipsDelaySlotFiller.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/lib/Target/Mips/MipsDelaySlotFiller.cpp b/lib/Target/Mips/MipsDelaySlotFiller.cpp
index 6cc6a4d0de..3c5f4314e5 100644
--- a/lib/Target/Mips/MipsDelaySlotFiller.cpp
+++ b/lib/Target/Mips/MipsDelaySlotFiller.cpp
@@ -78,8 +78,9 @@ namespace {
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 @@ runOnMachineBasicBlock(MachineBasicBlock &MBB) {
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 @@ FunctionPass *llvm::createMipsDelaySlotFillerPass(MipsTargetMachine &tm) {
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 @@ Filler::findDelayInstr(MachineBasicBlock &MBB,
continue;
}
- return I;
+ Filler = I;
+ return true;
}
- return MBB.end();
+
+ return false;
}
bool Filler::delayHasHazard(MachineBasicBlock::iterator candidate,