diff options
author | Chris Lattner <sabre@nondot.org> | 2008-02-03 06:49:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-02-03 06:49:24 +0000 |
commit | f8dc0617baceeba8ccd67c8881eb88eb1be2902c (patch) | |
tree | 6fd770020176095d656d85005b3a5508542fe962 /include/llvm/CodeGen/SelectionDAG.h | |
parent | 3d62d780abbe0c2dd8edd7dd37a27365b2032d73 (diff) |
Change the 'global modification' APIs in SelectionDAG to take a new
DAGUpdateListener object pointer instead of just returning a vector
of deleted nodes. This makes the interfaces more efficient (no more
allocating a vector [at least a malloc], filling it in, then walking
it) and more clean. This also allows the client to be notified of
nodes that are *changed* but not deleted.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46677 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/SelectionDAG.h')
-rw-r--r-- | include/llvm/CodeGen/SelectionDAG.h | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index c1a01ea744..2550d64c14 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -139,11 +139,6 @@ public: /// SelectionDAG. void RemoveDeadNodes(); - /// RemoveDeadNode - Remove the specified node from the system. If any of its - /// operands then becomes dead, remove them as well. The vector Deleted is - /// populated with nodes that are deleted. - void RemoveDeadNode(SDNode *N, std::vector<SDNode*> &Deleted); - /// DeleteNode - Remove the specified node from the system. This node must /// have no referrers. void DeleteNode(SDNode *N); @@ -464,28 +459,41 @@ public: SDNode *getTargetNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys, const SDOperand *Ops, unsigned NumOps); + /// DAGUpdateListener - Clients of various APIs that cause global effects on + /// the DAG can optionally implement this interface. This allows the clients + /// to handle the various sorts of updates that happen. + class DAGUpdateListener { + public: + virtual ~DAGUpdateListener(); + virtual void NodeDeleted(SDNode *N) = 0; + virtual void NodeUpdated(SDNode *N) = 0; + }; + + /// RemoveDeadNode - Remove the specified node from the system. If any of its + /// operands then becomes dead, remove them as well. Inform UpdateListener + /// for each node deleted. + void RemoveDeadNode(SDNode *N, DAGUpdateListener *UpdateListener = 0); + /// ReplaceAllUsesWith - Modify anything using 'From' to use 'To' instead. /// This can cause recursive merging of nodes in the DAG. Use the first /// version if 'From' is known to have a single result, use the second /// if you have two nodes with identical results, use the third otherwise. /// - /// These methods all take an optional vector, which (if not null) is - /// populated with any nodes that are deleted from the SelectionDAG, due to - /// new equivalences that are discovered. + /// These methods all take an optional UpdateListener, which (if not null) is + /// informed about nodes that are deleted and modified due to recursive + /// changes in the dag. /// void ReplaceAllUsesWith(SDOperand From, SDOperand Op, - std::vector<SDNode*> *Deleted = 0); + DAGUpdateListener *UpdateListener = 0); void ReplaceAllUsesWith(SDNode *From, SDNode *To, - std::vector<SDNode*> *Deleted = 0); + DAGUpdateListener *UpdateListener = 0); void ReplaceAllUsesWith(SDNode *From, const SDOperand *To, - std::vector<SDNode*> *Deleted = 0); + DAGUpdateListener *UpdateListener = 0); /// ReplaceAllUsesOfValueWith - Replace any uses of From with To, leaving - /// uses of other values produced by From.Val alone. The Deleted vector is - /// handled the same was as for ReplaceAllUsesWith, but it is required for - /// this method. + /// uses of other values produced by From.Val alone. void ReplaceAllUsesOfValueWith(SDOperand From, SDOperand To, - std::vector<SDNode*> *Deleted = 0); + DAGUpdateListener *UpdateListener = 0); /// AssignNodeIds - Assign a unique node id for each node in the DAG based on /// their allnodes order. It returns the maximum id. |