diff options
author | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-06 17:26:53 +0000 |
---|---|---|
committer | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-06 17:26:53 +0000 |
commit | c74bfc946d9d093e299b959be956bde7ceb74cb1 (patch) | |
tree | 250e3442503463eac2cdcb7970b4e1b104541259 /tools/llvmc2/CompilationGraph.h | |
parent | 97fda6d91593b28bcfd8682facfecdaf290f2cb0 (diff) |
Add inward edge counters to Nodes; Associate JoinLists with JoinTools.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50738 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvmc2/CompilationGraph.h')
-rw-r--r-- | tools/llvmc2/CompilationGraph.h | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/tools/llvmc2/CompilationGraph.h b/tools/llvmc2/CompilationGraph.h index bddd8bdf3a..bf46fa5978 100644 --- a/tools/llvmc2/CompilationGraph.h +++ b/tools/llvmc2/CompilationGraph.h @@ -55,31 +55,41 @@ namespace llvmcc { typedef container_type::iterator iterator; typedef container_type::const_iterator const_iterator; - Node() {} - Node(CompilationGraph* G) : OwningGraph(G) {} - Node(CompilationGraph* G, Tool* T) : OwningGraph(G), ToolPtr(T) {} + Node() : OwningGraph(0), InEdges(0) {} + Node(CompilationGraph* G) : OwningGraph(G), InEdges(0) {} + Node(CompilationGraph* G, Tool* T) : + OwningGraph(G), ToolPtr(T), InEdges(0) {} bool HasChildren() const { return !OutEdges.empty(); } const std::string Name() const { return ToolPtr->Name(); } + // Iteration. iterator EdgesBegin() { return OutEdges.begin(); } const_iterator EdgesBegin() const { return OutEdges.begin(); } iterator EdgesEnd() { return OutEdges.end(); } const_iterator EdgesEnd() const { return OutEdges.end(); } - // Choose one of the edges based on command-line options. + // Choose one of the outward edges based on command-line options. const Edge* ChooseEdge() const; - // Takes ownership of the object. + // Add an outward edge. Takes ownership of the Edge object. void AddEdge(Edge* E) { OutEdges.push_back(llvm::IntrusiveRefCntPtr<Edge>(E)); } + // Inward edge counter. Used by Build() to implement topological + // sort. + void IncrInEdges() { ++InEdges; } + void DecrInEdges() { --InEdges; } + bool HasNoInEdges() const { return InEdges == 0; } + // Needed to implement NodeChildIterator/GraphTraits CompilationGraph* OwningGraph; // The corresponding Tool. llvm::IntrusiveRefCntPtr<Tool> ToolPtr; // Links to children. container_type OutEdges; + // Number of parents. + unsigned InEdges; }; class NodesIterator; @@ -105,7 +115,7 @@ namespace llvmcc { void insertNode(Tool* T); // insertEdge - Insert a new edge into the graph. Takes ownership - // of the object. + // of the Edge object. void insertEdge(const std::string& A, Edge* E); // Build - Build target(s) from the input file set. Command-line @@ -143,9 +153,8 @@ namespace llvmcc { const tools_vector_type& getToolsVector(const std::string& LangName) const; // Pass the input file through the toolchain. - const Tool* PassThroughGraph (llvm::sys::Path& In, llvm::sys::Path Out, - const llvm::sys::Path& TempDir, - PathVector& JoinList) const; + const JoinTool* PassThroughGraph (llvm::sys::Path& In, llvm::sys::Path Out, + const llvm::sys::Path& TempDir) const; }; |