aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-17 17:15:02 +0000
committerChris Lattner <sabre@nondot.org>2005-01-17 17:15:02 +0000
commit068a81e9fca511b9a3b3a0f28a8988a57f994652 (patch)
tree6fd0940979578d4b1f25a493190fa21b0ee75e0a /lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
parent80d8a93489a5a3d1a90f8e23d27393d6844259b4 (diff)
Refactor code into a new method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19635 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp33
1 files changed, 22 insertions, 11 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index f747b35cf8..64940aa6b6 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -806,30 +806,41 @@ CopyValueToVirtualRegister(SelectionDAGLowering &SDL, Value *V, unsigned Reg) {
return DAG.getCopyToReg(DAG.getRoot(), Op, Reg);
}
-void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB,
- std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate,
- FunctionLoweringInfo &FuncInfo) {
- SelectionDAGLowering SDL(DAG, TLI, FuncInfo);
-
- std::vector<SDOperand> UnorderedChains;
-
+void SelectionDAGISel::
+LowerArguments(BasicBlock *BB, SelectionDAGLowering &SDL,
+ std::vector<SDOperand> &UnorderedChains) {
// If this is the entry block, emit arguments.
- Function *F = LLVMBB->getParent();
- if (LLVMBB == &F->front()) {
+ Function &F = *BB->getParent();
+
+ if (BB == &F.front()) {
// FIXME: If an argument is only used in one basic block, we could directly
// emit it (ONLY) into that block, not emitting the COPY_TO_VREG node. This
// would improve codegen in several cases on X86 by allowing the loads to be
// folded into the user operation.
- std::vector<SDOperand> Args = TLI.LowerArguments(*LLVMBB->getParent(), DAG);
+ std::vector<SDOperand> Args = TLI.LowerArguments(F, SDL.DAG);
+
+ FunctionLoweringInfo &FuncInfo = SDL.FuncInfo;
unsigned a = 0;
- for (Function::aiterator AI = F->abegin(), E = F->aend(); AI != E; ++AI,++a)
+ for (Function::aiterator AI = F.abegin(), E = F.aend(); AI != E; ++AI,++a)
if (!AI->use_empty()) {
SDL.setValue(AI, Args[a]);
UnorderedChains.push_back(
CopyValueToVirtualRegister(SDL, AI, FuncInfo.ValueMap[AI]));
}
}
+}
+
+
+void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB,
+ std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate,
+ FunctionLoweringInfo &FuncInfo) {
+ SelectionDAGLowering SDL(DAG, TLI, FuncInfo);
+
+ std::vector<SDOperand> UnorderedChains;
+
+ // Lower any arguments needed in this block.
+ LowerArguments(LLVMBB, SDL, UnorderedChains);
BB = FuncInfo.MBBMap[LLVMBB];
SDL.setCurrentBasicBlock(BB);