[llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h DSNode.h

Chris Lattner lattner at cs.uiuc.edu
Sat Feb 7 18:54:43 PST 2004


Changes in directory llvm/include/llvm/Analysis:

DSGraph.h updated: 1.72 -> 1.73
DSNode.h updated: 1.37 -> 1.38

---
Log message:

Switch the Nodes list from being an std::vector<DSNode*> to an ilist<DSNode>


---
Diffs of the changes:  (+33 -4)

Index: llvm/include/llvm/Analysis/DSGraph.h
diff -u llvm/include/llvm/Analysis/DSGraph.h:1.72 llvm/include/llvm/Analysis/DSGraph.h:1.73
--- llvm/include/llvm/Analysis/DSGraph.h:1.72	Sat Feb  7 18:22:41 2004
+++ llvm/include/llvm/Analysis/DSGraph.h	Sat Feb  7 18:53:07 2004
@@ -92,7 +92,7 @@
   typedef DSScalarMap ScalarMapTy;
   typedef hash_map<Function*, DSNodeHandle> ReturnNodesTy;
   typedef hash_set<GlobalValue*> GlobalSetTy;
-  typedef std::vector<DSNode*> NodeListTy;
+  typedef ilist<DSNode> NodeListTy;
 
   /// NodeMapTy - This data type is used when cloning one graph into another to
   /// keep track of the correspondence between the nodes in the old and new
@@ -171,9 +171,9 @@
 
   /// getNodes - Get a vector of all the nodes in the graph
   /// 
-  typedef NodeListTy::const_iterator node_iterator;
-  node_iterator node_begin() const { return Nodes.begin(); }
-  node_iterator node_end()   const { return Nodes.end(); }
+  typedef NodeListTy::compat_iterator node_iterator;
+  node_iterator node_begin() const { return Nodes.compat_begin(); }
+  node_iterator node_end()   const { return Nodes.compat_end(); }
 
   /// getFunctionNames - Return a space separated list of the name of the
   /// functions in this graph (if any)


Index: llvm/include/llvm/Analysis/DSNode.h
diff -u llvm/include/llvm/Analysis/DSNode.h:1.37 llvm/include/llvm/Analysis/DSNode.h:1.38
--- llvm/include/llvm/Analysis/DSNode.h:1.37	Sat Feb  7 17:02:32 2004
+++ llvm/include/llvm/Analysis/DSNode.h	Sat Feb  7 18:53:07 2004
@@ -42,6 +42,11 @@
   /// null.
   DSNodeHandle ForwardNH;
 
+  /// Next, Prev - These instance variables are used to keep the node on a
+  /// doubly-linked ilist in the DSGraph.
+  DSNode *Next, *Prev;
+  friend class ilist_traits<DSNode>;
+
   /// Size - The current size of the node.  This should be equal to the size of
   /// the current type record.
   ///
@@ -334,6 +339,30 @@
   static void MergeNodes(DSNodeHandle& CurNodeH, DSNodeHandle& NH);
 };
 
+//===----------------------------------------------------------------------===//
+// Define the ilist_traits specialization for the DSGraph ilist.
+//
+template<>
+struct ilist_traits<DSNode> {
+  static DSNode *getPrev(const DSNode *N) { return N->Prev; }
+  static DSNode *getNext(const DSNode *N) { return N->Next; }
+
+  static void setPrev(DSNode *N, DSNode *Prev) { N->Prev = Prev; }
+  static void setNext(DSNode *N, DSNode *Next) { N->Next = Next; }
+
+  static DSNode *createNode() { return new DSNode(0,0); }
+  //static DSNode *createNode(const DSNode &V) { return new DSNode(V); }
+
+
+  void addNodeToList(DSNode *NTy) {}
+  void removeNodeFromList(DSNode *NTy) {}
+  void transferNodesFromList(iplist<DSNode, ilist_traits> &L2,
+                             ilist_iterator<DSNode> first,
+                             ilist_iterator<DSNode> last) {}
+};
+
+template<>
+struct ilist_traits<const DSNode> : public ilist_traits<DSNode> {};
 
 //===----------------------------------------------------------------------===//
 // Define inline DSNodeHandle functions that depend on the definition of DSNode





More information about the llvm-commits mailing list