summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-08-23 02:25:05 +0000
committerDan Gohman <gohman@apple.com>2008-08-23 02:25:05 +0000
commiteb0cee91f679de1601313852f82e8e6f3f33cfbf (patch)
treebf30a86202954934b3f00cd812836bcbc01e9298 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent9e8c057ab7e53e8ed620df1a95e5c45dfe033b25 (diff)
downloadbcm5719-llvm-eb0cee91f679de1601313852f82e8e6f3f33cfbf.tar.gz
bcm5719-llvm-eb0cee91f679de1601313852f82e8e6f3f33cfbf.zip
Move the point at which FastISel taps into the SelectionDAGISel
process up to a higher level. This allows FastISel to leverage more of SelectionDAGISel's infastructure, such as updating Machine PHI nodes. Also, implement transitioning from SDISel back to FastISel in the middle of a block, so it's now possible to go back and forth. This allows FastISel to hand individual CallInsts and other complicated things off to SDISel to handle, while handling the rest of the block itself. To help support this, reorganize the SelectionDAG class so that it is allocated once and reused throughout a function, instead of being completely reallocated for each block. llvm-svn: 55219
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp50
1 files changed, 35 insertions, 15 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 3e3890142f5..9275a21f9fb 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -547,11 +547,8 @@ void SelectionDAG::DeleteNodeNotInCSEMaps(SDNode *N) {
// Drop all of the operands and decrement used nodes use counts.
for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I)
I->getVal()->removeUser(std::distance(N->op_begin(), I), N);
- if (N->OperandsNeedDelete) {
+ if (N->OperandsNeedDelete)
delete[] N->OperandList;
- }
- N->OperandList = 0;
- N->NumOperands = 0;
AllNodes.remove(N);
}
@@ -563,6 +560,9 @@ void SelectionDAG::DeleteNodeNotInCSEMaps(SDNode *N) {
void SelectionDAG::RemoveNodeFromCSEMaps(SDNode *N) {
bool Erased = false;
switch (N->getOpcode()) {
+ case ISD::EntryToken:
+ assert(0 && "EntryToken should not be in CSEMaps!");
+ return;
case ISD::HANDLENODE: return; // noop.
case ISD::CONDCODE:
assert(CondCodeNodes[cast<CondCodeSDNode>(N)->get()] &&
@@ -764,24 +764,44 @@ unsigned SelectionDAG::getMVTAlignment(MVT VT) const {
}
SelectionDAG::SelectionDAG(TargetLowering &tli, MachineFunction &mf,
- FunctionLoweringInfo &fli, MachineModuleInfo *mmi,
- NodeAllocatorType &nodeallocator)
- : TLI(tli), MF(mf), FLI(fli), MMI(mmi), NodeAllocator(nodeallocator) {
- EntryNode = Root = getNode(ISD::EntryToken, MVT::Other);
+ FunctionLoweringInfo &fli, MachineModuleInfo *mmi)
+ : TLI(tli), MF(mf), FLI(fli), MMI(mmi),
+ EntryNode(ISD::EntryToken, getVTList(MVT::Other)),
+ Root(getEntryNode()) {
+ AllNodes.push_back(&EntryNode);
}
SelectionDAG::~SelectionDAG() {
+ allnodes_clear();
+}
+
+void SelectionDAG::allnodes_clear() {
while (!AllNodes.empty()) {
SDNode *N = AllNodes.remove(AllNodes.begin());
N->SetNextInBucket(0);
- if (N->OperandsNeedDelete) {
+ if (N->OperandsNeedDelete)
delete [] N->OperandList;
- }
- N->OperandList = 0;
- N->NumOperands = 0;
}
}
+void SelectionDAG::reset() {
+ allnodes_clear();
+ OperandAllocator.Reset();
+ CSEMap.clear();
+
+ ExtendedValueTypeNodes.clear();
+ ExternalSymbols.clear();
+ TargetExternalSymbols.clear();
+ std::fill(CondCodeNodes.begin(), CondCodeNodes.end(),
+ static_cast<CondCodeSDNode*>(0));
+ std::fill(ValueTypeNodes.begin(), ValueTypeNodes.end(),
+ static_cast<SDNode*>(0));
+
+ EntryNode.Uses = 0;
+ AllNodes.push_back(&EntryNode);
+ Root = getEntryNode();
+}
+
SDValue SelectionDAG::getZeroExtendInReg(SDValue Op, MVT VT) {
if (Op.getValueType() == VT) return Op;
APInt Imm = APInt::getLowBitsSet(Op.getValueSizeInBits(),
@@ -3988,9 +4008,9 @@ SDNode *SelectionDAG::MorphNodeTo(SDNode *N, unsigned Opc,
delete[] N->OperandList;
if (N->isMachineOpcode()) {
// We're creating a final node that will live unmorphed for the
- // remainder of this SelectionDAG's duration, so we can allocate the
- // operands directly out of the pool with no recycling metadata.
- N->OperandList = Allocator.Allocate<SDUse>(NumOps);
+ // remainder of the current SelectionDAG iteration, so we can allocate
+ // the operands directly out of a pool with no recycling metadata.
+ N->OperandList = OperandAllocator.Allocate<SDUse>(NumOps);
N->OperandsNeedDelete = false;
} else {
N->OperandList = new SDUse[NumOps];
OpenPOWER on IntegriCloud