mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 06:25:18 +00:00
Make ISelPosition a local variable.
Now that multiple DAGUpdateListeners can be active at the same time, ISelPosition can become a local variable in DoInstructionSelection. We simply register an ISelUpdater with CurDAG while ISelPosition exists. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155249 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -172,49 +172,21 @@ protected:
|
|||||||
///
|
///
|
||||||
unsigned DAGSize;
|
unsigned DAGSize;
|
||||||
|
|
||||||
/// ISelPosition - Node iterator marking the current position of
|
|
||||||
/// instruction selection as it procedes through the topologically-sorted
|
|
||||||
/// node list.
|
|
||||||
SelectionDAG::allnodes_iterator ISelPosition;
|
|
||||||
|
|
||||||
|
|
||||||
/// ISelUpdater - helper class to handle updates of the
|
|
||||||
/// instruction selection graph.
|
|
||||||
class ISelUpdater : public SelectionDAG::DAGUpdateListener {
|
|
||||||
virtual void anchor();
|
|
||||||
SelectionDAG::allnodes_iterator &ISelPosition;
|
|
||||||
public:
|
|
||||||
ISelUpdater(SelectionDAG &DAG, SelectionDAG::allnodes_iterator &isp)
|
|
||||||
: SelectionDAG::DAGUpdateListener(DAG), ISelPosition(isp) {}
|
|
||||||
|
|
||||||
/// NodeDeleted - Handle nodes deleted from the graph. If the
|
|
||||||
/// node being deleted is the current ISelPosition node, update
|
|
||||||
/// ISelPosition.
|
|
||||||
///
|
|
||||||
virtual void NodeDeleted(SDNode *N, SDNode *E) {
|
|
||||||
if (ISelPosition == SelectionDAG::allnodes_iterator(N))
|
|
||||||
++ISelPosition;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// ReplaceUses - replace all uses of the old node F with the use
|
/// ReplaceUses - replace all uses of the old node F with the use
|
||||||
/// of the new node T.
|
/// of the new node T.
|
||||||
void ReplaceUses(SDValue F, SDValue T) {
|
void ReplaceUses(SDValue F, SDValue T) {
|
||||||
ISelUpdater ISU(*CurDAG, ISelPosition);
|
|
||||||
CurDAG->ReplaceAllUsesOfValueWith(F, T);
|
CurDAG->ReplaceAllUsesOfValueWith(F, T);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ReplaceUses - replace all uses of the old nodes F with the use
|
/// ReplaceUses - replace all uses of the old nodes F with the use
|
||||||
/// of the new nodes T.
|
/// of the new nodes T.
|
||||||
void ReplaceUses(const SDValue *F, const SDValue *T, unsigned Num) {
|
void ReplaceUses(const SDValue *F, const SDValue *T, unsigned Num) {
|
||||||
ISelUpdater ISU(*CurDAG, ISelPosition);
|
|
||||||
CurDAG->ReplaceAllUsesOfValuesWith(F, T, Num);
|
CurDAG->ReplaceAllUsesOfValuesWith(F, T, Num);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ReplaceUses - replace all uses of the old node F with the use
|
/// ReplaceUses - replace all uses of the old node F with the use
|
||||||
/// of the new node T.
|
/// of the new node T.
|
||||||
void ReplaceUses(SDNode *F, SDNode *T) {
|
void ReplaceUses(SDNode *F, SDNode *T) {
|
||||||
ISelUpdater ISU(*CurDAG, ISelPosition);
|
|
||||||
CurDAG->ReplaceAllUsesWith(F, T);
|
CurDAG->ReplaceAllUsesWith(F, T);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -263,8 +263,6 @@ void TargetLowering::AdjustInstrPostInstrSelection(MachineInstr *MI,
|
|||||||
// SelectionDAGISel code
|
// SelectionDAGISel code
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
void SelectionDAGISel::ISelUpdater::anchor() { }
|
|
||||||
|
|
||||||
SelectionDAGISel::SelectionDAGISel(const TargetMachine &tm,
|
SelectionDAGISel::SelectionDAGISel(const TargetMachine &tm,
|
||||||
CodeGenOpt::Level OL) :
|
CodeGenOpt::Level OL) :
|
||||||
MachineFunctionPass(ID), TM(tm), TLI(*tm.getTargetLowering()),
|
MachineFunctionPass(ID), TM(tm), TLI(*tm.getTargetLowering()),
|
||||||
@@ -703,6 +701,25 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
|
|||||||
CurDAG->clear();
|
CurDAG->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
/// ISelUpdater - helper class to handle updates of the instruction selection
|
||||||
|
/// graph.
|
||||||
|
class ISelUpdater : public SelectionDAG::DAGUpdateListener {
|
||||||
|
SelectionDAG::allnodes_iterator &ISelPosition;
|
||||||
|
public:
|
||||||
|
ISelUpdater(SelectionDAG &DAG, SelectionDAG::allnodes_iterator &isp)
|
||||||
|
: SelectionDAG::DAGUpdateListener(DAG), ISelPosition(isp) {}
|
||||||
|
|
||||||
|
/// NodeDeleted - Handle nodes deleted from the graph. If the node being
|
||||||
|
/// deleted is the current ISelPosition node, update ISelPosition.
|
||||||
|
///
|
||||||
|
virtual void NodeDeleted(SDNode *N, SDNode *E) {
|
||||||
|
if (ISelPosition == SelectionDAG::allnodes_iterator(N))
|
||||||
|
++ISelPosition;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // end anonymous namespace
|
||||||
|
|
||||||
void SelectionDAGISel::DoInstructionSelection() {
|
void SelectionDAGISel::DoInstructionSelection() {
|
||||||
DEBUG(errs() << "===== Instruction selection begins: BB#"
|
DEBUG(errs() << "===== Instruction selection begins: BB#"
|
||||||
<< FuncInfo->MBB->getNumber()
|
<< FuncInfo->MBB->getNumber()
|
||||||
@@ -719,9 +736,13 @@ void SelectionDAGISel::DoInstructionSelection() {
|
|||||||
// a reference to the root node, preventing it from being deleted,
|
// a reference to the root node, preventing it from being deleted,
|
||||||
// and tracking any changes of the root.
|
// and tracking any changes of the root.
|
||||||
HandleSDNode Dummy(CurDAG->getRoot());
|
HandleSDNode Dummy(CurDAG->getRoot());
|
||||||
ISelPosition = SelectionDAG::allnodes_iterator(CurDAG->getRoot().getNode());
|
SelectionDAG::allnodes_iterator ISelPosition (CurDAG->getRoot().getNode());
|
||||||
++ISelPosition;
|
++ISelPosition;
|
||||||
|
|
||||||
|
// Make sure that ISelPosition gets properly updated when nodes are deleted
|
||||||
|
// in calls made from this function.
|
||||||
|
ISelUpdater ISU(*CurDAG, ISelPosition);
|
||||||
|
|
||||||
// The AllNodes list is now topological-sorted. Visit the
|
// The AllNodes list is now topological-sorted. Visit the
|
||||||
// nodes by starting at the end of the list (the root of the
|
// nodes by starting at the end of the list (the root of the
|
||||||
// graph) and preceding back toward the beginning (the entry
|
// graph) and preceding back toward the beginning (the entry
|
||||||
@@ -748,10 +769,8 @@ void SelectionDAGISel::DoInstructionSelection() {
|
|||||||
|
|
||||||
// If after the replacement this node is not used any more,
|
// If after the replacement this node is not used any more,
|
||||||
// remove this dead node.
|
// remove this dead node.
|
||||||
if (Node->use_empty()) { // Don't delete EntryToken, etc.
|
if (Node->use_empty()) // Don't delete EntryToken, etc.
|
||||||
ISelUpdater ISU(*CurDAG, ISelPosition);
|
|
||||||
CurDAG->RemoveDeadNode(Node);
|
CurDAG->RemoveDeadNode(Node);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CurDAG->setRoot(Dummy.getValue());
|
CurDAG->setRoot(Dummy.getValue());
|
||||||
@@ -1680,8 +1699,6 @@ UpdateChainsAndGlue(SDNode *NodeToMatch, SDValue InputChain,
|
|||||||
bool isMorphNodeTo) {
|
bool isMorphNodeTo) {
|
||||||
SmallVector<SDNode*, 4> NowDeadNodes;
|
SmallVector<SDNode*, 4> NowDeadNodes;
|
||||||
|
|
||||||
ISelUpdater ISU(*CurDAG, ISelPosition);
|
|
||||||
|
|
||||||
// Now that all the normal results are replaced, we replace the chain and
|
// Now that all the normal results are replaced, we replace the chain and
|
||||||
// glue results if present.
|
// glue results if present.
|
||||||
if (!ChainNodesMatched.empty()) {
|
if (!ChainNodesMatched.empty()) {
|
||||||
|
Reference in New Issue
Block a user