llvm.org GIT mirror llvm / be86712
Some cosmetic changes (change some comments, move code around a bit). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50762 91177308-0d34-0410-b5e6-96231b3b80d8 Mikhail Glushenkov 12 years ago
2 changed file(s) with 44 addition(s) and 43 deletion(s). Raw diff Collapse all Expand all
1919
2020 #include
2121 #include
22 #include
2322 #include
2423 #include
2524 #include
8786 return I->second;
8887 }
8988
89 // Find the language name corresponding to the given file.
9090 const std::string& CompilationGraph::getLanguage(const sys::Path& File) const {
9191 LanguageMap::const_iterator Lang = ExtsToLangs.find(File.getSuffix());
9292 if (Lang == ExtsToLangs.end())
9494 return Lang->second;
9595 }
9696
97 // Find the tools list corresponding to the given language name.
9798 const CompilationGraph::tools_vector_type&
9899 CompilationGraph::getToolsVector(const std::string& LangName) const
99100 {
188189 }
189190 }
190191
191 // Sort the nodes in topological order.
192 void CompilationGraph::TopologicalSort(std::vector& Out) {
193 std::queue Q;
194 Q.push(&getNode("root"));
195
196 while (!Q.empty()) {
197 const Node* A = Q.front();
198 Q.pop();
199 Out.push_back(A);
200 for (Node::const_iterator EB = A->EdgesBegin(), EE = A->EdgesEnd();
201 EB != EE; ++EB) {
202 Node* B = &getNode((*EB)->ToolName());
203 B->DecrInEdges();
204 if (B->HasNoInEdges())
205 Q.push(B);
206 }
207 }
208 }
209
210 namespace {
211 bool NotJoinNode(const Node* N) {
212 return N->ToolPtr ? !N->ToolPtr->IsJoin() : true;
213 }
214 }
215
216 // Call TopologicalSort and filter the resulting list to include
217 // only Join nodes.
218 void CompilationGraph::
219 TopologicalSortFilterJoinNodes(std::vector& Out) {
220 std::vector TopSorted;
221 TopologicalSort(TopSorted);
222 std::remove_copy_if(TopSorted.begin(), TopSorted.end(),
223 std::back_inserter(Out), NotJoinNode);
224 }
225
226 // Find head of the toolchain corresponding to the given file.
192 // Find the head of the toolchain corresponding to the given file.
227193 // Also, insert an input language into InLangs.
228194 const Node* CompilationGraph::
229195 FindToolChain(const sys::Path& In, const std::string* forceLanguage,
303269 }
304270 }
305271
306 // Build the targets. Command-line options are passed through
307 // temporary variables.
272 // Sort the nodes in topological order.
273 void CompilationGraph::TopologicalSort(std::vector& Out) {
274 std::queue Q;
275 Q.push(&getNode("root"));
276
277 while (!Q.empty()) {
278 const Node* A = Q.front();
279 Q.pop();
280 Out.push_back(A);
281 for (Node::const_iterator EB = A->EdgesBegin(), EE = A->EdgesEnd();
282 EB != EE; ++EB) {
283 Node* B = &getNode((*EB)->ToolName());
284 B->DecrInEdges();
285 if (B->HasNoInEdges())
286 Q.push(B);
287 }
288 }
289 }
290
291 namespace {
292 bool NotJoinNode(const Node* N) {
293 return N->ToolPtr ? !N->ToolPtr->IsJoin() : true;
294 }
295 }
296
297 // Call TopologicalSort and filter the resulting list to include
298 // only Join nodes.
299 void CompilationGraph::
300 TopologicalSortFilterJoinNodes(std::vector& Out) {
301 std::vector TopSorted;
302 TopologicalSort(TopSorted);
303 std::remove_copy_if(TopSorted.begin(), TopSorted.end(),
304 std::back_inserter(Out), NotJoinNode);
305 }
306
307 // Build the targets. Command-line options are accessed through global
308 // variables.
308309 int CompilationGraph::Build (const sys::Path& TempDir) {
309310
310311 InputLanguagesSet InLangs;
324325 JoinTool* JT = &dynamic_cast(*CurNode->ToolPtr.getPtr());
325326 bool IsLast = false;
326327
327 // Are there any files to be joined?
328 // Are there any files in the join list?
328329 if (JT->JoinListEmpty())
329330 continue;
330331
331 // Is this the last tool in the chain?
332 // NOTE: we can process several chains in parallel.
332 // Is this the last tool in the toolchain?
333 // NOTE: we can process several toolchains in parallel.
333334 if (!CurNode->HasChildren() || JT->IsLast()) {
334335 if (OutputFilename.empty()) {
335336 Out.set("a");
11 ============
22
33 Disclaimer: this document is currently somewhat out-of-date and is
4 retained for reference; for documentation, refer to
4 retained for reference; for more recent documentation please refer to
55 LLVMC-Tutorial.rst.
66
77 A complete rewrite of the LLVMC compiler driver is proposed, aimed at