diff options
author | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-06 16:36:50 +0000 |
---|---|---|
committer | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-06 16:36:50 +0000 |
commit | 761958d72ee226e9a4f3c334e8c4743f0be1874d (patch) | |
tree | 0d6c69e7b4108e5a609050b1c2b8025bab9068b2 /utils | |
parent | 46d4e972d157281321fb563d780dc15c0707079f (diff) | |
download | external_llvm-761958d72ee226e9a4f3c334e8c4743f0be1874d.zip external_llvm-761958d72ee226e9a4f3c334e8c4743f0be1874d.tar.gz external_llvm-761958d72ee226e9a4f3c334e8c4743f0be1874d.tar.bz2 |
More work on edge properties. Use Edge classes instead of strings in CompilationGraph.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50726 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/LLVMCCConfigurationEmitter.cpp | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/utils/TableGen/LLVMCCConfigurationEmitter.cpp b/utils/TableGen/LLVMCCConfigurationEmitter.cpp index 92e2df1..606510e 100644 --- a/utils/TableGen/LLVMCCConfigurationEmitter.cpp +++ b/utils/TableGen/LLVMCCConfigurationEmitter.cpp @@ -866,6 +866,8 @@ void FillInToolToLang (const ToolPropertiesList& TPList, } // Check that all output and input language names match. +// TOFIX: check for cycles. +// TOFIX: check for multiple default edges. void TypecheckGraph (Record* CompilationGraph, const ToolPropertiesList& TPList) { StringMap<std::string> ToolToInLang; @@ -889,22 +891,36 @@ void TypecheckGraph (Record* CompilationGraph, if(A->getName() != "root" && IA->second != IB->second) throw "Edge " + A->getName() + "->" + B->getName() + ": output->input language mismatch"; + if(B->getName() == "root") + throw std::string("Edges back to the root are not allowed!"); } } -// Emit Edge* classes used for. +// Emit Edge* classes that represent edges in the graph. +// TOFIX: add edge properties. void EmitEdgeClasses (Record* CompilationGraph, const GlobalOptionDescriptions& OptDescs, std::ostream& O) { ListInit* edges = CompilationGraph->getValueAsListInit("edges"); for (unsigned i = 0; i < edges->size(); ++i) { - //Record* Edge = edges->getElementAsRecord(i); - //Record* A = Edge->getValueAsDef("a"); - //Record* B = Edge->getValueAsDef("b"); - //ListInit* Props = Edge->getValueAsListInit("props"); + Record* Edge = edges->getElementAsRecord(i); + Record* B = Edge->getValueAsDef("b"); + ListInit* Props = Edge->getValueAsListInit("props"); + + if (Props->empty()) + continue; + + O << "class Edge" << i << ": public Edge {\n" + << "public:\n" + << Indent1 << "Edge" << i << "() : Edge(\"" << B->getName() + << "\") {}\n"; + + O << Indent1 << "bool isEnabled() const { return true; }\n"; - O << "class Edge" << i << " {};\n\n"; + O << Indent1 << "bool isDefault() const { return false; }\n"; + + O << "};\n\n"; } } @@ -937,8 +953,16 @@ void EmitPopulateCompilationGraph (Record* CompilationGraph, Record* Edge = edges->getElementAsRecord(i); Record* A = Edge->getValueAsDef("a"); Record* B = Edge->getValueAsDef("b"); - O << Indent1 << "G.insertEdge(\"" << A->getName() << "\", \"" - << B->getName() << "\");\n"; + ListInit* Props = Edge->getValueAsListInit("props"); + + O << Indent1 << "G.insertEdge(\"" << A->getName() << "\", "; + + if (Props->empty()) + O << "new SimpleEdge(\"" << B->getName() << "\")"; + else + O << "new Edge" << i << "()"; + + O << ");\n"; } O << "}\n\n"; |