move isOnlyReachableByFallthrough out of MachineBasicBlock into AsmPrinter,

and add a sparc implementation that knows about delay slots.  Patch by
Nathan Keynes!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96492 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2010-02-17 18:52:56 +00:00
parent 7180f10fc7
commit 0a3f39985b
6 changed files with 75 additions and 37 deletions

View File

@ -143,36 +143,6 @@ MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() {
return I;
}
/// isOnlyReachableViaFallthough - Return true if this basic block has
/// exactly one predecessor and the control transfer mechanism between
/// the predecessor and this block is a fall-through.
bool MachineBasicBlock::isOnlyReachableByFallthrough() const {
// If this is a landing pad, it isn't a fall through. If it has no preds,
// then nothing falls through to it.
if (isLandingPad() || pred_empty())
return false;
// If there isn't exactly one predecessor, it can't be a fall through.
const_pred_iterator PI = pred_begin(), PI2 = PI;
++PI2;
if (PI2 != pred_end())
return false;
// The predecessor has to be immediately before this block.
const MachineBasicBlock *Pred = *PI;
if (!Pred->isLayoutSuccessor(this))
return false;
// If the block is completely empty, then it definitely does fall through.
if (Pred->empty())
return true;
// Otherwise, check the last instruction.
const MachineInstr &LastInst = Pred->back();
return !LastInst.getDesc().isBarrier();
}
void MachineBasicBlock::dump() const {
print(dbgs());
}