From 16f64df93ada0051fae30ca854c8f8a4fc7c0389 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 17 Jan 2005 17:15:02 +0000 Subject: Refactor code into a new method. llvm-svn: 19635 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp') diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index f747b35cf8d..64940aa6b6c 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/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 > &PHINodesToUpdate, - FunctionLoweringInfo &FuncInfo) { - SelectionDAGLowering SDL(DAG, TLI, FuncInfo); - - std::vector UnorderedChains; - +void SelectionDAGISel:: +LowerArguments(BasicBlock *BB, SelectionDAGLowering &SDL, + std::vector &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 Args = TLI.LowerArguments(*LLVMBB->getParent(), DAG); + std::vector 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 > &PHINodesToUpdate, + FunctionLoweringInfo &FuncInfo) { + SelectionDAGLowering SDL(DAG, TLI, FuncInfo); + + std::vector UnorderedChains; + + // Lower any arguments needed in this block. + LowerArguments(LLVMBB, SDL, UnorderedChains); BB = FuncInfo.MBBMap[LLVMBB]; SDL.setCurrentBasicBlock(BB); -- cgit v1.2.3