[PATCH] D44113: TableGen: Allow dag operators to be resolved late
Nicolai Hähnle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 5 12:20:40 PST 2018
nhaehnle created this revision.
nhaehnle added reviewers: arsenm, craig.topper, tra, MartinO.
Herald added a subscriber: wdng.
Change-Id: I51bb80fd5c48c8ac441ab11e43d43c1b91b4b590
Repository:
rL LLVM
https://reviews.llvm.org/D44113
Files:
lib/TableGen/Record.cpp
test/TableGen/dag-functional.td
Index: test/TableGen/dag-functional.td
===================================================================
--- test/TableGen/dag-functional.td
+++ test/TableGen/dag-functional.td
@@ -28,7 +28,13 @@
// CHECK: dag d1 = (ops 1, ?:$name1, 2, 3);
// CHECK: }
-def ops;
+// CHECK: def E0 {
+// CHECK: dag ret = (ops 1, 2);
+// CHECK: }
+
+class Ops;
+
+def ops : Ops;
class A<list<int> nodes, list<string> names> {
dag ret = !dag(ops, nodes, names);
@@ -58,4 +64,11 @@
def D {
dag d1 = !con((ops 1), (ops $name1), (ops), (ops 2, 3));
-}
\ No newline at end of file
+}
+
+class E<Ops op> {
+ // Allow concatenation of DAG nodes with operators from template arguments.
+ dag ret = !con((op 1), (op 2));
+}
+
+def E0 : E<ops>;
Index: lib/TableGen/Record.cpp
===================================================================
--- lib/TableGen/Record.cpp
+++ lib/TableGen/Record.cpp
@@ -859,8 +859,13 @@
if (LHSs && RHSs) {
DefInit *LOp = dyn_cast<DefInit>(LHSs->getOperator());
DefInit *ROp = dyn_cast<DefInit>(RHSs->getOperator());
- if (!LOp || !ROp || LOp->getDef() != ROp->getDef())
- PrintFatalError("Concated Dag operators do not match!");
+ if (!LOp || !ROp)
+ break;
+ if (LOp->getDef() != ROp->getDef()) {
+ PrintFatalError(Twine("Concatenated Dag operators do not match: '") +
+ LHSs->getAsString() + "' vs. '" + RHSs->getAsString() +
+ "'");
+ }
SmallVector<Init*, 8> Args;
SmallVector<StringInit*, 8> ArgNames;
for (unsigned i = 0, e = LHSs->getNumArgs(); i != e; ++i) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44113.137061.patch
Type: text/x-patch
Size: 1623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180305/ac1657ed/attachment.bin>
More information about the llvm-commits
mailing list