[llvm] r327495 - TableGen: Allow dag operators to be resolved late

Nicolai Haehnle via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 14 04:00:48 PDT 2018


Author: nha
Date: Wed Mar 14 04:00:48 2018
New Revision: 327495

URL: http://llvm.org/viewvc/llvm-project?rev=327495&view=rev
Log:
TableGen: Allow dag operators to be resolved late

Change-Id: I51bb80fd5c48c8ac441ab11e43d43c1b91b4b590

Differential revision: https://reviews.llvm.org/D44113

Modified:
    llvm/trunk/lib/TableGen/Record.cpp
    llvm/trunk/test/TableGen/dag-functional.td

Modified: llvm/trunk/lib/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=327495&r1=327494&r2=327495&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Record.cpp (original)
+++ llvm/trunk/lib/TableGen/Record.cpp Wed Mar 14 04:00:48 2018
@@ -859,8 +859,13 @@ Init *BinOpInit::Fold(Record *CurRec, Mu
     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) {

Modified: llvm/trunk/test/TableGen/dag-functional.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/dag-functional.td?rev=327495&r1=327494&r2=327495&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/dag-functional.td (original)
+++ llvm/trunk/test/TableGen/dag-functional.td Wed Mar 14 04:00:48 2018
@@ -40,7 +40,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 Node<int val, string name> {
   int Val = val;
@@ -100,4 +106,11 @@ def C0 : C<[1, 2], ["a", "b"]>;
 
 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>;




More information about the llvm-commits mailing list