Skip to content
Snippets Groups Projects
Commit 39968bbc authored by Misha Brukman's avatar Misha Brukman
Browse files

Cleaned up code layout; no functional changes.

llvm-svn: 6312
parent 5d4589ff
No related branches found
No related tags found
No related merge requests found
...@@ -22,21 +22,19 @@ DeleteInstruction(MachineBasicBlock& mvec, ...@@ -22,21 +22,19 @@ DeleteInstruction(MachineBasicBlock& mvec,
const TargetMachine& target) const TargetMachine& target)
{ {
// Check if this instruction is in a delay slot of its predecessor. // Check if this instruction is in a delay slot of its predecessor.
if (BBI != mvec.begin()) if (BBI != mvec.begin()) {
{
const TargetInstrInfo& mii = target.getInstrInfo(); const TargetInstrInfo& mii = target.getInstrInfo();
MachineInstr* predMI = *(BBI-1); MachineInstr* predMI = *(BBI-1);
if (unsigned ndelay = mii.getNumDelaySlots(predMI->getOpCode())) if (unsigned ndelay = mii.getNumDelaySlots(predMI->getOpCode())) {
{ // This instruction is in a delay slot of its predecessor, so
// This instruction is in a delay slot of its predecessor, so // replace it with a nop. By replacing in place, we save having
// replace it with a nop. By replacing in place, we save having // to update the I-I maps.
// to update the I-I maps. //
// assert(ndelay == 1 && "Not yet handling multiple-delay-slot targets");
assert(ndelay == 1 && "Not yet handling multiple-delay-slot targets"); (*BBI)->replace(mii.getNOPOpCode(), 0);
(*BBI)->replace(mii.getNOPOpCode(), 0); return;
return; }
} }
}
// The instruction is not in a delay slot, so we can simply erase it. // The instruction is not in a delay slot, so we can simply erase it.
mvec.erase(BBI); mvec.erase(BBI);
...@@ -51,11 +49,10 @@ RemoveUselessCopies(MachineBasicBlock& mvec, ...@@ -51,11 +49,10 @@ RemoveUselessCopies(MachineBasicBlock& mvec,
MachineBasicBlock::iterator& BBI, MachineBasicBlock::iterator& BBI,
const TargetMachine& target) const TargetMachine& target)
{ {
if (target.getOptInfo().IsUselessCopy(*BBI)) if (target.getOptInfo().IsUselessCopy(*BBI)) {
{ DeleteInstruction(mvec, BBI, target);
DeleteInstruction(mvec, BBI, target); return true;
return true; }
}
return false; return false;
} }
...@@ -117,11 +114,11 @@ PeepholeOpts::runOnBasicBlock(BasicBlock &BB) ...@@ -117,11 +114,11 @@ PeepholeOpts::runOnBasicBlock(BasicBlock &BB)
// //
for (MachineBasicBlock::reverse_iterator RI=mvec.rbegin(), for (MachineBasicBlock::reverse_iterator RI=mvec.rbegin(),
RE=mvec.rend(); RI != RE; ) RE=mvec.rend(); RI != RE; )
{ {
MachineBasicBlock::iterator BBI = RI.base()-1; // save before incr MachineBasicBlock::iterator BBI = RI.base()-1; // save before incr
++RI; // pre-increment to delete MI or after it ++RI; // pre-increment to delete MI or after it
visit(mvec, BBI); visit(mvec, BBI);
} }
return true; return true;
} }
...@@ -136,4 +133,3 @@ createPeepholeOptsPass(TargetMachine &T) ...@@ -136,4 +133,3 @@ createPeepholeOptsPass(TargetMachine &T)
{ {
return new PeepholeOpts(T); return new PeepholeOpts(T);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment