diff options
author | Dan Gohman <gohman@apple.com> | 2008-08-22 19:21:41 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-08-22 19:21:41 +0000 |
commit | 87ff7058e78a5fce93625a2adecd2a6398326a54 (patch) | |
tree | 3f8d4cd7d9f56fec4827043bacc651010031c06d /llvm/lib/CodeGen | |
parent | 736779f0882e917b1cc2408519a2d2e8360c8c4a (diff) | |
download | bcm5719-llvm-87ff7058e78a5fce93625a2adecd2a6398326a54.tar.gz bcm5719-llvm-87ff7058e78a5fce93625a2adecd2a6398326a54.zip |
Support non-fallthrough unconditional branches in FastISel.
llvm-svn: 55191
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 24 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 2 |
2 files changed, 17 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp index 1462472ea4a..74174519fb3 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -145,6 +145,8 @@ BasicBlock::iterator FastISel::SelectInstructions(BasicBlock::iterator Begin, BasicBlock::iterator End, DenseMap<const Value*, unsigned> &ValueMap, + std::map<const BasicBlock*, + MachineBasicBlock *> &MBBMap, MachineBasicBlock *mbb) { MBB = mbb; BasicBlock::iterator I = Begin; @@ -195,19 +197,25 @@ FastISel::SelectInstructions(BasicBlock::iterator Begin, case Instruction::Br: { BranchInst *BI = cast<BranchInst>(I); - // For now, check for and handle just the most trivial case: an - // unconditional fall-through branch. if (BI->isUnconditional()) { - MachineFunction::iterator NextMBB = + MachineFunction::iterator NextMBB = next(MachineFunction::iterator(MBB)); - if (NextMBB != MF.end() && - NextMBB->getBasicBlock() == BI->getSuccessor(0)) { - MBB->addSuccessor(NextMBB); - break; + BasicBlock *LLVMSucc = BI->getSuccessor(0); + MachineBasicBlock *MSucc = MBBMap[LLVMSucc]; + + if (NextMBB != MF.end() && MSucc == NextMBB) { + // The unconditional fall-through case, which needs no instructions. + } else { + // The unconditional branch case. + const SmallVector<MachineOperand, 0> NoCond(0); + TII.InsertBranch(*MBB, MSucc, NULL, NoCond); } + MBB->addSuccessor(MSucc); + break; } - // Something more complicated. Halt "fast" selection and bail. + // Conditional branches are not handed yet. + // Halt "fast" selection and bail. return I; } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 9304c0e7a16..e13cfc0fa03 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -5113,7 +5113,7 @@ void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB, cast<BranchInst>(LLVMBB->getTerminator())->isUnconditional()) { if (FastISel *F = TLI.createFastISel(FuncInfo.MF)) { Begin = F->SelectInstructions(Begin, LLVMBB->end(), - FuncInfo.ValueMap, BB); + FuncInfo.ValueMap, FuncInfo.MBBMap, BB); // Clean up the FastISel object. TODO: Reorganize what data is // stored in the FastISel class itself and what is merely passed |