summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2008-05-06 16:36:50 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2008-05-06 16:36:50 +0000
commitd752c3ffd84d2b16d736e01504a9d470863fb679 (patch)
tree0d6c69e7b4108e5a609050b1c2b8025bab9068b2 /utils
parent0a174930e25ff59dd0181beedae1b47d85265ece (diff)
downloadllvm-d752c3ffd84d2b16d736e01504a9d470863fb679.tar.gz
llvm-d752c3ffd84d2b16d736e01504a9d470863fb679.tar.bz2
llvm-d752c3ffd84d2b16d736e01504a9d470863fb679.tar.xz
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.cpp40
1 files changed, 32 insertions, 8 deletions
diff --git a/utils/TableGen/LLVMCCConfigurationEmitter.cpp b/utils/TableGen/LLVMCCConfigurationEmitter.cpp
index 92e2df1885..606510ed02 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";