[llvm-commits] [llvm] r55191 - in /llvm/trunk: include/llvm/CodeGen/FastISel.h lib/CodeGen/SelectionDAG/FastISel.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Dan Gohman
gohman at apple.com
Fri Aug 22 12:21:41 PDT 2008
Author: djg
Date: Fri Aug 22 14:21:41 2008
New Revision: 55191
URL: http://llvm.org/viewvc/llvm-project?rev=55191&view=rev
Log:
Support non-fallthrough unconditional branches in FastISel.
Modified:
llvm/trunk/include/llvm/CodeGen/FastISel.h
llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FastISel.h?rev=55191&r1=55190&r2=55191&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/FastISel.h (original)
+++ llvm/trunk/include/llvm/CodeGen/FastISel.h Fri Aug 22 14:21:41 2008
@@ -17,6 +17,7 @@
#include "llvm/BasicBlock.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/CodeGen/SelectionDAGNodes.h"
+#include <map>
namespace llvm {
@@ -52,6 +53,7 @@
BasicBlock::iterator
SelectInstructions(BasicBlock::iterator Begin, BasicBlock::iterator End,
DenseMap<const Value*, unsigned> &ValueMap,
+ std::map<const BasicBlock*, MachineBasicBlock *> &MBBMap,
MachineBasicBlock *MBB);
virtual ~FastISel();
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=55191&r1=55190&r2=55191&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Fri Aug 22 14:21:41 2008
@@ -145,6 +145,8 @@
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 @@
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;
}
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=55191&r1=55190&r2=55191&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Aug 22 14:21:41 2008
@@ -5113,7 +5113,7 @@
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
More information about the llvm-commits
mailing list