mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
Add a bit of lazy evaluation to PopulateCompilationGraph().
Only the tools that are mentioned in the compilation graph definition are now inserted by PopulateCompilationGraph(). This should cut down plugin loading time a little. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59097 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1595,26 +1595,33 @@ void EmitPopulateCompilationGraph (Record* CompilationGraph,
|
|||||||
{
|
{
|
||||||
ListInit* edges = CompilationGraph->getValueAsListInit("edges");
|
ListInit* edges = CompilationGraph->getValueAsListInit("edges");
|
||||||
|
|
||||||
// Generate code
|
|
||||||
O << "namespace {\n\n";
|
O << "namespace {\n\n";
|
||||||
O << "void PopulateCompilationGraphLocal(CompilationGraph& G) {\n";
|
O << "void PopulateCompilationGraphLocal(CompilationGraph& G) {\n";
|
||||||
|
|
||||||
// Insert vertices
|
// Insert vertices.
|
||||||
|
// Only tools mentioned in the graph definition are inserted.
|
||||||
|
|
||||||
RecordVector Tools = Records.getAllDerivedDefinitions("Tool");
|
llvm::StringSet<> ToolsInGraph;
|
||||||
if (Tools.empty())
|
|
||||||
throw std::string("No tool definitions found!");
|
|
||||||
|
|
||||||
for (RecordVector::iterator B = Tools.begin(), E = Tools.end(); B != E; ++B) {
|
for (unsigned i = 0; i < edges->size(); ++i) {
|
||||||
const std::string& Name = (*B)->getName();
|
Record* Edge = edges->getElementAsRecord(i);
|
||||||
if (Name != "root")
|
Record* A = Edge->getValueAsDef("a");
|
||||||
O << Indent1 << "G.insertNode(new "
|
Record* B = Edge->getValueAsDef("b");
|
||||||
<< Name << "());\n";
|
|
||||||
|
if (A->getName() != "root")
|
||||||
|
ToolsInGraph.insert(A->getName());
|
||||||
|
if (B->getName() != "root")
|
||||||
|
ToolsInGraph.insert(B->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (llvm::StringSet<>::iterator B = ToolsInGraph.begin(),
|
||||||
|
E = ToolsInGraph.end(); B != E; ++B)
|
||||||
|
O << Indent1 << "G.insertNode(new " << B->first() << "());\n";
|
||||||
|
|
||||||
O << '\n';
|
O << '\n';
|
||||||
|
|
||||||
// Insert edges
|
// Insert edges.
|
||||||
|
|
||||||
for (unsigned i = 0; i < edges->size(); ++i) {
|
for (unsigned i = 0; i < edges->size(); ++i) {
|
||||||
Record* Edge = edges->getElementAsRecord(i);
|
Record* Edge = edges->getElementAsRecord(i);
|
||||||
Record* A = Edge->getValueAsDef("a");
|
Record* A = Edge->getValueAsDef("a");
|
||||||
|
|||||||
Reference in New Issue
Block a user