diff options
author | Chris Lattner <sabre@nondot.org> | 2010-03-02 06:04:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-03-02 06:04:12 +0000 |
commit | 17b4b172eb57c28f82a6ee3a982a7632f60e8967 (patch) | |
tree | afca185bc4db9df7467e64612dbdff86193c738b /include | |
parent | f3d5c915502a64921bff4ed96d8e8171f85b73f3 (diff) | |
download | external_llvm-17b4b172eb57c28f82a6ee3a982a7632f60e8967.zip external_llvm-17b4b172eb57c28f82a6ee3a982a7632f60e8967.tar.gz external_llvm-17b4b172eb57c28f82a6ee3a982a7632f60e8967.tar.bz2 |
move some code out of DAGISelHeader up to SelectionDAGISel.h where it
is shared by all targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97553 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/CodeGen/SelectionDAGISel.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/include/llvm/CodeGen/SelectionDAGISel.h b/include/llvm/CodeGen/SelectionDAGISel.h index 467f92d..c43eede 100644 --- a/include/llvm/CodeGen/SelectionDAGISel.h +++ b/include/llvm/CodeGen/SelectionDAGISel.h @@ -165,6 +165,55 @@ protected: /// DAGSize - Size of DAG being instruction selected. /// 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 { + SelectionDAG::allnodes_iterator &ISelPosition; + public: + explicit ISelUpdater(SelectionDAG::allnodes_iterator &isp) + : 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; + } + + /// NodeUpdated - Ignore updates for now. + virtual void NodeUpdated(SDNode *N) {} + }; + + /// ReplaceUses - replace all uses of the old node F with the use + /// of the new node T. + void ReplaceUses(SDValue F, SDValue T) { + ISelUpdater ISU(ISelPosition); + CurDAG->ReplaceAllUsesOfValueWith(F, T, &ISU); + } + + /// ReplaceUses - replace all uses of the old nodes F with the use + /// of the new nodes T. + void ReplaceUses(const SDValue *F, const SDValue *T, unsigned Num) { + ISelUpdater ISU(ISelPosition); + CurDAG->ReplaceAllUsesOfValuesWith(F, T, Num, &ISU); + } + + /// ReplaceUses - replace all uses of the old node F with the use + /// of the new node T. + void ReplaceUses(SDNode *F, SDNode *T) { + ISelUpdater ISU(ISelPosition); + CurDAG->ReplaceAllUsesWith(F, T, &ISU); + } + /// SelectInlineAsmMemoryOperands - Calls to this are automatically generated /// by tblgen. Others should not call it. |