aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-08-19 22:33:34 +0000
committerDan Gohman <gohman@apple.com>2008-08-19 22:33:34 +0000
commit78eca170e9ac5db7fd525f9bbf27090fefcbb646 (patch)
tree628201ca392132d78be2d6c5674bc6ddf4bbb84d /lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
parent6f2766d59744bb3d48867f3151643eac7111e773 (diff)
Add code to call FastISel, and a command-line option to enable it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55015 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index f4e31f727e..188d938819 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -26,6 +26,7 @@
#include "llvm/Intrinsics.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/ParameterAttributes.h"
+#include "llvm/CodeGen/FastISel.h"
#include "llvm/CodeGen/GCStrategy.h"
#include "llvm/CodeGen/GCMetadata.h"
#include "llvm/CodeGen/MachineFunction.h"
@@ -55,6 +56,9 @@ static cl::opt<bool>
EnableValueProp("enable-value-prop", cl::Hidden);
static cl::opt<bool>
EnableLegalizeTypes("enable-legalize-types", cl::Hidden);
+static cl::opt<bool>
+EnableFastISel("fast-isel", cl::Hidden,
+ cl::desc("Enable the experimental \"fast\" instruction selector"));
#ifndef NDEBUG
@@ -5091,12 +5095,39 @@ void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB,
std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate,
FunctionLoweringInfo &FuncInfo) {
SelectionDAGLowering SDL(DAG, TLI, *AA, FuncInfo, GFI);
+ BB = FuncInfo.MBBMap[LLVMBB];
+
+ // Before doing SelectionDAG ISel, see if FastISel has been requested.
+ // FastISel doesn't currently support entry blocks, because that
+ // requires special handling for arguments. And it doesn't support EH
+ // landing pads, which also require special handling.
+ // For now, also exclude blocks with terminators that aren't
+ // unconditional branches.
+ if (EnableFastISel &&
+ LLVMBB != &LLVMBB->getParent()->getEntryBlock() &&
+ !BB->isLandingPad() &&
+ isa<BranchInst>(LLVMBB->getTerminator()) &&
+ cast<BranchInst>(LLVMBB->getTerminator())->isUnconditional()) {
+ if (FastISel *F = TLI.createFastISel(BB, &FuncInfo.MF,
+ TLI.getTargetMachine().getInstrInfo())) {
+ BasicBlock::iterator I =
+ F->SelectInstructions(LLVMBB->begin(), LLVMBB->end(), FuncInfo.ValueMap);
+ if (I == LLVMBB->end())
+ // The "fast" selector selected the entire block, so we're done.
+ return;
+
+ // The "fast" selector couldn't handle something and bailed.
+ // For the temporary purpose of debugging, just abort.
+ I->dump();
+ assert(0 && "FastISel didn't select the entire block");
+ abort();
+ }
+ }
// Lower any arguments needed in this block if this is the entry block.
if (LLVMBB == &LLVMBB->getParent()->getEntryBlock())
LowerArguments(LLVMBB, SDL);
- BB = FuncInfo.MBBMap[LLVMBB];
SDL.setCurrentBasicBlock(BB);
MachineModuleInfo *MMI = DAG.getMachineModuleInfo();