From 79175dbbae0069ea29ec1ec854f3d28346d33e71 Mon Sep 17 00:00:00 2001 From: Nicolai Haehnle Date: Wed, 14 Mar 2018 11:00:48 +0000 Subject: [PATCH] TableGen: Allow dag operators to be resolved late Change-Id: I51bb80fd5c48c8ac441ab11e43d43c1b91b4b590 Differential revision: https://reviews.llvm.org/D44113 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327495 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/TableGen/Record.cpp | 9 +++++++-- test/TableGen/dag-functional.td | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index 48197f04d11..e9325decfac 100644 --- a/lib/TableGen/Record.cpp +++ b/lib/TableGen/Record.cpp @@ -859,8 +859,13 @@ Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { if (LHSs && RHSs) { DefInit *LOp = dyn_cast(LHSs->getOperator()); DefInit *ROp = dyn_cast(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 Args; SmallVector ArgNames; for (unsigned i = 0, e = LHSs->getNumArgs(); i != e; ++i) { diff --git a/test/TableGen/dag-functional.td b/test/TableGen/dag-functional.td index dc1c37c8eca..6baee695ddd 100644 --- a/test/TableGen/dag-functional.td +++ b/test/TableGen/dag-functional.td @@ -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 = 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 { + // Allow concatenation of DAG nodes with operators from template arguments. + dag ret = !con((op 1), (op 2)); +} + +def E0 : E;