[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Jan 13 09:59:56 PST 2005
Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAGISel.cpp updated: 1.12 -> 1.13
---
Log message:
Codegen independent ops as being independent.
---
Diffs of the changes: (+21 -7)
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.12 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.13
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.12 Tue Jan 11 21:41:21 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu Jan 13 11:59:43 2005
@@ -768,19 +768,21 @@
}
-void SelectionDAGISel::CopyValueToVirtualRegister(SelectionDAGLowering &SDL,
- Value *V, unsigned Reg) {
+SDOperand SelectionDAGISel::
+CopyValueToVirtualRegister(SelectionDAGLowering &SDL, Value *V, unsigned Reg) {
SelectionDAG &DAG = SDL.DAG;
SDOperand Op = SDL.getValue(V);
if (CopyRegSDNode *CR = dyn_cast<CopyRegSDNode>(Op))
assert(CR->getReg() != Reg && "Copy from a reg to the same reg!");
- DAG.setRoot(DAG.getCopyToReg(DAG.getRoot(), Op, 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;
// If this is the entry block, emit arguments.
Function *F = LLVMBB->getParent();
@@ -795,7 +797,8 @@
for (Function::aiterator AI = F->abegin(), E = F->aend(); AI != E; ++AI,++a)
if (!AI->use_empty()) {
SDL.setValue(AI, Args[a]);
- CopyValueToVirtualRegister(SDL, AI, FuncInfo.ValueMap[AI]);
+ UnorderedChains.push_back(
+ CopyValueToVirtualRegister(SDL, AI, FuncInfo.ValueMap[AI]));
}
}
@@ -813,7 +816,8 @@
if (!I->use_empty() && !isa<PHINode>(I)) {
std::map<const Value*, unsigned>::iterator VMI =FuncInfo.ValueMap.find(I);
if (VMI != FuncInfo.ValueMap.end())
- CopyValueToVirtualRegister(SDL, I, VMI->second);
+ UnorderedChains.push_back(
+ CopyValueToVirtualRegister(SDL, I, VMI->second));
}
// Handle PHI nodes in successor blocks. Emit code into the SelectionDAG to
@@ -847,7 +851,8 @@
unsigned &RegOut = ConstantsOut[C];
if (RegOut == 0) {
RegOut = FuncInfo.CreateRegForValue(C);
- CopyValueToVirtualRegister(SDL, C, RegOut);
+ UnorderedChains.push_back(
+ CopyValueToVirtualRegister(SDL, C, RegOut));
}
Reg = RegOut;
} else {
@@ -857,7 +862,8 @@
FuncInfo.StaticAllocaMap.count(cast<AllocaInst>(PHIOp)) &&
"Didn't codegen value into a register!??");
Reg = FuncInfo.CreateRegForValue(PHIOp);
- CopyValueToVirtualRegister(SDL, PHIOp, Reg);
+ UnorderedChains.push_back(
+ CopyValueToVirtualRegister(SDL, PHIOp, Reg));
}
}
@@ -871,6 +877,14 @@
}
ConstantsOut.clear();
+ // Turn all of the unordered chains into one factored node.
+ switch (UnorderedChains.size()) {
+ case 0: break;
+ case 1: DAG.setRoot(UnorderedChains[0]); break;
+ default:
+ DAG.setRoot(DAG.getNode(ISD::TokenFactor, MVT::Other, UnorderedChains));
+ }
+
// Lower the terminator after the copies are emitted.
SDL.visit(*LLVMBB->getTerminator());
}
More information about the llvm-commits
mailing list