Mikhail Glushenkov | b90cd83 | 2008-05-06 16:34:12 +0000 | [diff] [blame] | 1 | //===--- CompilationGraph.h - The LLVM Compiler Driver ----------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open |
| 6 | // Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Compilation graph - definition. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_TOOLS_LLVMC2_COMPILATION_GRAPH_H |
| 15 | #define LLVM_TOOLS_LLVMC2_COMPILATION_GRAPH_H |
| 16 | |
| 17 | #include "AutoGenerated.h" |
| 18 | #include "Tool.h" |
| 19 | |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/GraphTraits.h" |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/IntrusiveRefCntPtr.h" |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/iterator" |
Mikhail Glushenkov | 76b1b24 | 2008-05-06 18:15:12 +0000 | [diff] [blame^] | 23 | //#include "llvm/ADT/SmallSet.h" |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 24 | #include "llvm/ADT/SmallVector.h" |
Mikhail Glushenkov | b90cd83 | 2008-05-06 16:34:12 +0000 | [diff] [blame] | 25 | #include "llvm/ADT/StringMap.h" |
| 26 | #include "llvm/System/Path.h" |
| 27 | |
Mikhail Glushenkov | 76b1b24 | 2008-05-06 18:15:12 +0000 | [diff] [blame^] | 28 | #include <set> |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 29 | #include <string> |
| 30 | |
Mikhail Glushenkov | be9d9a1 | 2008-05-06 18:08:59 +0000 | [diff] [blame] | 31 | namespace llvmc { |
Mikhail Glushenkov | b90cd83 | 2008-05-06 16:34:12 +0000 | [diff] [blame] | 32 | |
Mikhail Glushenkov | 76b1b24 | 2008-05-06 18:15:12 +0000 | [diff] [blame^] | 33 | typedef std::set<std::string> InputLanguagesSet; |
| 34 | |
Mikhail Glushenkov | 35a85e8 | 2008-05-06 18:10:20 +0000 | [diff] [blame] | 35 | // An edge of the compilation graph. |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 36 | class Edge : public llvm::RefCountedBaseVPTR<Edge> { |
| 37 | public: |
| 38 | Edge(const std::string& T) : ToolName_(T) {} |
| 39 | virtual ~Edge() {}; |
| 40 | |
| 41 | const std::string& ToolName() const { return ToolName_; } |
Mikhail Glushenkov | 76b1b24 | 2008-05-06 18:15:12 +0000 | [diff] [blame^] | 42 | virtual unsigned Weight(const InputLanguagesSet& InLangs) const = 0; |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 43 | private: |
| 44 | std::string ToolName_; |
| 45 | }; |
| 46 | |
Mikhail Glushenkov | 35a85e8 | 2008-05-06 18:10:20 +0000 | [diff] [blame] | 47 | // Edges that have no properties are instances of this class. |
Mikhail Glushenkov | d752c3f | 2008-05-06 16:36:50 +0000 | [diff] [blame] | 48 | class SimpleEdge : public Edge { |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 49 | public: |
Mikhail Glushenkov | d752c3f | 2008-05-06 16:36:50 +0000 | [diff] [blame] | 50 | SimpleEdge(const std::string& T) : Edge(T) {} |
Mikhail Glushenkov | 76b1b24 | 2008-05-06 18:15:12 +0000 | [diff] [blame^] | 51 | unsigned Weight(const InputLanguagesSet&) const { return 1; } |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 52 | }; |
Mikhail Glushenkov | b90cd83 | 2008-05-06 16:34:12 +0000 | [diff] [blame] | 53 | |
Mikhail Glushenkov | 35a85e8 | 2008-05-06 18:10:20 +0000 | [diff] [blame] | 54 | // A node of the compilation graph. |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 55 | struct Node { |
Mikhail Glushenkov | 35a85e8 | 2008-05-06 18:10:20 +0000 | [diff] [blame] | 56 | // A Node holds a list of the outward edges. |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 57 | typedef llvm::SmallVector<llvm::IntrusiveRefCntPtr<Edge>, 3> container_type; |
| 58 | typedef container_type::iterator iterator; |
| 59 | typedef container_type::const_iterator const_iterator; |
Mikhail Glushenkov | b90cd83 | 2008-05-06 16:34:12 +0000 | [diff] [blame] | 60 | |
Mikhail Glushenkov | c74bfc9 | 2008-05-06 17:26:53 +0000 | [diff] [blame] | 61 | Node() : OwningGraph(0), InEdges(0) {} |
| 62 | Node(CompilationGraph* G) : OwningGraph(G), InEdges(0) {} |
| 63 | Node(CompilationGraph* G, Tool* T) : |
| 64 | OwningGraph(G), ToolPtr(T), InEdges(0) {} |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 65 | |
Mikhail Glushenkov | d752c3f | 2008-05-06 16:36:50 +0000 | [diff] [blame] | 66 | bool HasChildren() const { return !OutEdges.empty(); } |
Mikhail Glushenkov | 0260658 | 2008-05-06 18:07:14 +0000 | [diff] [blame] | 67 | const std::string Name() const |
| 68 | { return ToolPtr ? ToolPtr->Name() : "root"; } |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 69 | |
Mikhail Glushenkov | c74bfc9 | 2008-05-06 17:26:53 +0000 | [diff] [blame] | 70 | // Iteration. |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 71 | iterator EdgesBegin() { return OutEdges.begin(); } |
| 72 | const_iterator EdgesBegin() const { return OutEdges.begin(); } |
| 73 | iterator EdgesEnd() { return OutEdges.end(); } |
| 74 | const_iterator EdgesEnd() const { return OutEdges.end(); } |
| 75 | |
Mikhail Glushenkov | c74bfc9 | 2008-05-06 17:26:53 +0000 | [diff] [blame] | 76 | // Add an outward edge. Takes ownership of the Edge object. |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 77 | void AddEdge(Edge* E) |
| 78 | { OutEdges.push_back(llvm::IntrusiveRefCntPtr<Edge>(E)); } |
| 79 | |
Mikhail Glushenkov | 35a85e8 | 2008-05-06 18:10:20 +0000 | [diff] [blame] | 80 | // Inward edge counter. Used to implement topological sort. |
| 81 | // TOTHINK: Move the mutable counter back into Tool classes? Makes |
| 82 | // us more const-correct. |
Mikhail Glushenkov | c74bfc9 | 2008-05-06 17:26:53 +0000 | [diff] [blame] | 83 | void IncrInEdges() { ++InEdges; } |
| 84 | void DecrInEdges() { --InEdges; } |
| 85 | bool HasNoInEdges() const { return InEdges == 0; } |
| 86 | |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 87 | // Needed to implement NodeChildIterator/GraphTraits |
| 88 | CompilationGraph* OwningGraph; |
| 89 | // The corresponding Tool. |
Mikhail Glushenkov | 35a85e8 | 2008-05-06 18:10:20 +0000 | [diff] [blame] | 90 | // WARNING: ToolPtr can be NULL (for the root node). |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 91 | llvm::IntrusiveRefCntPtr<Tool> ToolPtr; |
| 92 | // Links to children. |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 93 | container_type OutEdges; |
Mikhail Glushenkov | 35a85e8 | 2008-05-06 18:10:20 +0000 | [diff] [blame] | 94 | // Inward edge counter. Updated in |
| 95 | // CompilationGraph::insertEdge(). Used for topological sorting. |
Mikhail Glushenkov | c74bfc9 | 2008-05-06 17:26:53 +0000 | [diff] [blame] | 96 | unsigned InEdges; |
Mikhail Glushenkov | b90cd83 | 2008-05-06 16:34:12 +0000 | [diff] [blame] | 97 | }; |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 98 | |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 99 | class NodesIterator; |
| 100 | |
Mikhail Glushenkov | 0260658 | 2008-05-06 18:07:14 +0000 | [diff] [blame] | 101 | // The compilation graph itself. |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 102 | class CompilationGraph { |
Mikhail Glushenkov | 4f6e3a4 | 2008-05-06 17:28:03 +0000 | [diff] [blame] | 103 | // Main data structure. |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 104 | typedef llvm::StringMap<Node> nodes_map_type; |
Mikhail Glushenkov | 35a85e8 | 2008-05-06 18:10:20 +0000 | [diff] [blame] | 105 | // These are used to map from language names to tools. (We can |
| 106 | // have several tools associated with each language name, hence |
| 107 | // the need for a vector of Edges.) |
Mikhail Glushenkov | 4f6e3a4 | 2008-05-06 17:28:03 +0000 | [diff] [blame] | 108 | typedef |
| 109 | llvm::SmallVector<llvm::IntrusiveRefCntPtr<Edge>, 3> tools_vector_type; |
| 110 | typedef llvm::StringMap<tools_vector_type> tools_map_type; |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 111 | |
| 112 | // Map from file extensions to language names. |
| 113 | LanguageMap ExtsToLangs; |
| 114 | // Map from language names to lists of tool names. |
| 115 | tools_map_type ToolsMap; |
| 116 | // Map from tool names to Tool objects. |
| 117 | nodes_map_type NodesMap; |
| 118 | |
| 119 | public: |
| 120 | |
| 121 | CompilationGraph(); |
| 122 | |
Mikhail Glushenkov | d752c3f | 2008-05-06 16:36:50 +0000 | [diff] [blame] | 123 | // insertVertex - insert a new node into the graph. Takes |
| 124 | // ownership of the object. |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 125 | void insertNode(Tool* T); |
| 126 | |
Mikhail Glushenkov | d752c3f | 2008-05-06 16:36:50 +0000 | [diff] [blame] | 127 | // insertEdge - Insert a new edge into the graph. Takes ownership |
Mikhail Glushenkov | c74bfc9 | 2008-05-06 17:26:53 +0000 | [diff] [blame] | 128 | // of the Edge object. |
Mikhail Glushenkov | d752c3f | 2008-05-06 16:36:50 +0000 | [diff] [blame] | 129 | void insertEdge(const std::string& A, Edge* E); |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 130 | |
Mikhail Glushenkov | d752c3f | 2008-05-06 16:36:50 +0000 | [diff] [blame] | 131 | // Build - Build target(s) from the input file set. Command-line |
| 132 | // options are passed implicitly as global variables. |
Mikhail Glushenkov | 0260658 | 2008-05-06 18:07:14 +0000 | [diff] [blame] | 133 | int Build(llvm::sys::Path const& tempDir); |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 134 | |
| 135 | // Return a reference to the node correponding to the given tool |
| 136 | // name. Throws std::runtime_error. |
| 137 | Node& getNode(const std::string& ToolName); |
| 138 | const Node& getNode(const std::string& ToolName) const; |
| 139 | |
| 140 | // viewGraph - This function is meant for use from the debugger. |
| 141 | // You can just say 'call G->viewGraph()' and a ghostview window |
| 142 | // should pop up from the program, displaying the compilation |
| 143 | // graph. This depends on there being a 'dot' and 'gv' program |
| 144 | // in your path. |
| 145 | void viewGraph(); |
| 146 | |
| 147 | // Write a CompilationGraph.dot file. |
| 148 | void writeGraph(); |
| 149 | |
| 150 | // GraphTraits support |
| 151 | friend NodesIterator GraphBegin(CompilationGraph*); |
| 152 | friend NodesIterator GraphEnd(CompilationGraph*); |
| 153 | friend void PopulateCompilationGraph(CompilationGraph&); |
| 154 | |
| 155 | private: |
| 156 | // Helper functions. |
| 157 | |
| 158 | // Find out which language corresponds to the suffix of this file. |
| 159 | const std::string& getLanguage(const llvm::sys::Path& File) const; |
| 160 | |
| 161 | // Return a reference to the list of tool names corresponding to |
| 162 | // the given language name. Throws std::runtime_error. |
| 163 | const tools_vector_type& getToolsVector(const std::string& LangName) const; |
Mikhail Glushenkov | 2ba4c5a | 2008-05-06 17:25:51 +0000 | [diff] [blame] | 164 | |
| 165 | // Pass the input file through the toolchain. |
Mikhail Glushenkov | 35a85e8 | 2008-05-06 18:10:20 +0000 | [diff] [blame] | 166 | void PassThroughGraph (const llvm::sys::Path& In, const Node* StartNode, |
Mikhail Glushenkov | 76b1b24 | 2008-05-06 18:15:12 +0000 | [diff] [blame^] | 167 | const InputLanguagesSet& InLangs, |
Mikhail Glushenkov | 35a85e8 | 2008-05-06 18:10:20 +0000 | [diff] [blame] | 168 | const llvm::sys::Path& TempDir) const; |
Mikhail Glushenkov | 2ba4c5a | 2008-05-06 17:25:51 +0000 | [diff] [blame] | 169 | |
Mikhail Glushenkov | 0260658 | 2008-05-06 18:07:14 +0000 | [diff] [blame] | 170 | // Find head of the toolchain corresponding to the given file. |
Mikhail Glushenkov | 87416b4 | 2008-05-06 18:10:53 +0000 | [diff] [blame] | 171 | const Node* FindToolChain(const llvm::sys::Path& In, |
Mikhail Glushenkov | 76b1b24 | 2008-05-06 18:15:12 +0000 | [diff] [blame^] | 172 | const std::string* forceLanguage, |
| 173 | InputLanguagesSet& InLangs) const; |
Mikhail Glushenkov | 0260658 | 2008-05-06 18:07:14 +0000 | [diff] [blame] | 174 | |
| 175 | // Sort the nodes in topological order. |
| 176 | void TopologicalSort(std::vector<const Node*>& Out); |
| 177 | // Call TopologicalSort and filter the resulting list to include |
| 178 | // only Join nodes. |
| 179 | void TopologicalSortFilterJoinNodes(std::vector<const Node*>& Out); |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 180 | }; |
| 181 | |
| 182 | /// GraphTraits support code. |
| 183 | |
| 184 | // Auxiliary class needed to implement GraphTraits support. Can be |
| 185 | // generalised to something like value_iterator for map-like |
| 186 | // containers. |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 187 | class NodesIterator : public llvm::StringMap<Node>::iterator { |
| 188 | typedef llvm::StringMap<Node>::iterator super; |
| 189 | typedef NodesIterator ThisType; |
| 190 | typedef Node* pointer; |
| 191 | typedef Node& reference; |
| 192 | |
| 193 | public: |
| 194 | NodesIterator(super I) : super(I) {} |
| 195 | |
| 196 | inline reference operator*() const { |
| 197 | return super::operator->()->second; |
| 198 | } |
| 199 | inline pointer operator->() const { |
| 200 | return &super::operator->()->second; |
| 201 | } |
| 202 | }; |
| 203 | |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 204 | inline NodesIterator GraphBegin(CompilationGraph* G) { |
| 205 | return NodesIterator(G->NodesMap.begin()); |
| 206 | } |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 207 | |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 208 | inline NodesIterator GraphEnd(CompilationGraph* G) { |
| 209 | return NodesIterator(G->NodesMap.end()); |
| 210 | } |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 211 | |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 212 | |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 213 | // Another auxiliary class needed by GraphTraits. |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 214 | class NodeChildIterator : public bidirectional_iterator<Node, ptrdiff_t> { |
| 215 | typedef NodeChildIterator ThisType; |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 216 | typedef Node::container_type::iterator iterator; |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 217 | |
| 218 | CompilationGraph* OwningGraph; |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 219 | iterator EdgeIter; |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 220 | public: |
| 221 | typedef Node* pointer; |
| 222 | typedef Node& reference; |
| 223 | |
| 224 | NodeChildIterator(Node* N, iterator I) : |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 225 | OwningGraph(N->OwningGraph), EdgeIter(I) {} |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 226 | |
| 227 | const ThisType& operator=(const ThisType& I) { |
| 228 | assert(OwningGraph == I.OwningGraph); |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 229 | EdgeIter = I.EdgeIter; |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 230 | return *this; |
| 231 | } |
| 232 | |
| 233 | inline bool operator==(const ThisType& I) const |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 234 | { return EdgeIter == I.EdgeIter; } |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 235 | inline bool operator!=(const ThisType& I) const |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 236 | { return EdgeIter != I.EdgeIter; } |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 237 | |
| 238 | inline pointer operator*() const { |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 239 | return &OwningGraph->getNode((*EdgeIter)->ToolName()); |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 240 | } |
| 241 | inline pointer operator->() const { |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 242 | return &OwningGraph->getNode((*EdgeIter)->ToolName()); |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 243 | } |
| 244 | |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 245 | ThisType& operator++() { ++EdgeIter; return *this; } // Preincrement |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 246 | ThisType operator++(int) { // Postincrement |
| 247 | ThisType tmp = *this; |
| 248 | ++*this; |
| 249 | return tmp; |
| 250 | } |
| 251 | |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 252 | inline ThisType& operator--() { --EdgeIter; return *this; } // Predecrement |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 253 | inline ThisType operator--(int) { // Postdecrement |
| 254 | ThisType tmp = *this; |
| 255 | --*this; |
| 256 | return tmp; |
| 257 | } |
| 258 | |
| 259 | }; |
| 260 | } |
| 261 | |
| 262 | namespace llvm { |
| 263 | template <> |
Mikhail Glushenkov | be9d9a1 | 2008-05-06 18:08:59 +0000 | [diff] [blame] | 264 | struct GraphTraits<llvmc::CompilationGraph*> { |
| 265 | typedef llvmc::CompilationGraph GraphType; |
| 266 | typedef llvmc::Node NodeType; |
| 267 | typedef llvmc::NodeChildIterator ChildIteratorType; |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 268 | |
| 269 | static NodeType* getEntryNode(GraphType* G) { |
| 270 | return &G->getNode("root"); |
| 271 | } |
| 272 | |
| 273 | static ChildIteratorType child_begin(NodeType* N) { |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 274 | return ChildIteratorType(N, N->OutEdges.begin()); |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 275 | } |
| 276 | static ChildIteratorType child_end(NodeType* N) { |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 277 | return ChildIteratorType(N, N->OutEdges.end()); |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 278 | } |
| 279 | |
Mikhail Glushenkov | be9d9a1 | 2008-05-06 18:08:59 +0000 | [diff] [blame] | 280 | typedef llvmc::NodesIterator nodes_iterator; |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 281 | static nodes_iterator nodes_begin(GraphType *G) { |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 282 | return GraphBegin(G); |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 283 | } |
| 284 | static nodes_iterator nodes_end(GraphType *G) { |
Mikhail Glushenkov | 0a17493 | 2008-05-06 16:36:06 +0000 | [diff] [blame] | 285 | return GraphEnd(G); |
Mikhail Glushenkov | 0d08db0 | 2008-05-06 16:35:25 +0000 | [diff] [blame] | 286 | } |
| 287 | }; |
| 288 | |
Mikhail Glushenkov | b90cd83 | 2008-05-06 16:34:12 +0000 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | #endif // LLVM_TOOLS_LLVMC2_COMPILATION_GRAPH_H |