[llvm] r325796 - TableGen: Generalize type deduction for !listconcat
Nicolai Haehnle via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 22 07:26:28 PST 2018
Author: nha
Date: Thu Feb 22 07:26:28 2018
New Revision: 325796
URL: http://llvm.org/viewvc/llvm-project?rev=325796&view=rev
Log:
TableGen: Generalize type deduction for !listconcat
Summary:
This way, it should work even with complex operands.
Change-Id: Iaccf5bbb50bd5882a0ba5d59689e4381315fb361
Reviewers: arsenm, craig.topper, tra, MartinO
Subscribers: wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D43554
Modified:
llvm/trunk/lib/TableGen/TGParser.cpp
llvm/trunk/test/TableGen/listconcat.td
Modified: llvm/trunk/lib/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=325796&r1=325795&r2=325796&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Thu Feb 22 07:26:28 2018
@@ -944,9 +944,7 @@ Init *TGParser::ParseOperation(Record *C
// If we are doing !listconcat, we should know the type by now
if (OpTok == tgtok::XListConcat) {
- if (VarInit *Arg0 = dyn_cast<VarInit>(InitList[0]))
- Type = Arg0->getType();
- else if (ListInit *Arg0 = dyn_cast<ListInit>(InitList[0]))
+ if (TypedInit *Arg0 = dyn_cast<TypedInit>(InitList[0]))
Type = Arg0->getType();
else {
InitList[0]->print(errs());
Modified: llvm/trunk/test/TableGen/listconcat.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/listconcat.td?rev=325796&r1=325795&r2=325796&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/listconcat.td (original)
+++ llvm/trunk/test/TableGen/listconcat.td Thu Feb 22 07:26:28 2018
@@ -1,18 +1,32 @@
// RUN: llvm-tblgen %s | FileCheck %s
+// CHECK: class X<list<int> X:a = ?, list<int> X:b = ?, list<int> X:c = ?> {
+// CHECK: list<int> x = !listconcat(!listconcat(X:a, X:b), !listconcat(X:b, X:c));
+// CHECK: }
+
// CHECK: class Y<list<string> Y:S = ?> {
// CHECK: list<string> T1 = !listconcat(Y:S, ["foo"]);
// CHECK: list<string> T2 = !listconcat(Y:S, !listconcat(["foo"], !listconcat(Y:S, ["bar", "baz"])));
// CHECK: }
+// CHECK: def DX {
+// CHECK: list<int> x = [0, 1, 1, 2]
+// CHECK: }
+
// CHECK: def Z {
// CHECK: list<string> T1 = ["fu", "foo"];
// CHECK: list<string> T2 = ["fu", "foo", "fu", "bar", "baz"];
// CHECK: }
+class X<list<int> a, list<int> b, list<int> c> {
+ list<int> x = !listconcat(!listconcat(a, b), !listconcat(b, c));
+}
+
class Y<list<string> S> {
list<string> T1 = !listconcat(S, ["foo"]);
list<string> T2 = !listconcat(S, ["foo"], S, ["bar", "baz"]);
}
+def DX : X<[0], [1], [2]>;
+
def Z : Y<["fu"]>;
More information about the llvm-commits
mailing list