From e4a2cf5761fef90c228a2d90c6f1fefa986561c8 Mon Sep 17 00:00:00 2001 From: Nicolai Haehnle Date: Thu, 22 Feb 2018 15:26:28 +0000 Subject: [PATCH] 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 llvm-svn: 325796 --- llvm/lib/TableGen/TGParser.cpp | 4 +--- llvm/test/TableGen/listconcat.td | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index b6e207f..12ae237 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -944,9 +944,7 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) { // If we are doing !listconcat, we should know the type by now if (OpTok == tgtok::XListConcat) { - if (VarInit *Arg0 = dyn_cast(InitList[0])) - Type = Arg0->getType(); - else if (ListInit *Arg0 = dyn_cast(InitList[0])) + if (TypedInit *Arg0 = dyn_cast(InitList[0])) Type = Arg0->getType(); else { InitList[0]->print(errs()); diff --git a/llvm/test/TableGen/listconcat.td b/llvm/test/TableGen/listconcat.td index 870e649..26dce17 100644 --- a/llvm/test/TableGen/listconcat.td +++ b/llvm/test/TableGen/listconcat.td @@ -1,18 +1,32 @@ // RUN: llvm-tblgen %s | FileCheck %s +// CHECK: class X X:a = ?, list X:b = ?, list X:c = ?> { +// CHECK: list x = !listconcat(!listconcat(X:a, X:b), !listconcat(X:b, X:c)); +// CHECK: } + // CHECK: class Y Y:S = ?> { // CHECK: list T1 = !listconcat(Y:S, ["foo"]); // CHECK: list T2 = !listconcat(Y:S, !listconcat(["foo"], !listconcat(Y:S, ["bar", "baz"]))); // CHECK: } +// CHECK: def DX { +// CHECK: list x = [0, 1, 1, 2] +// CHECK: } + // CHECK: def Z { // CHECK: list T1 = ["fu", "foo"]; // CHECK: list T2 = ["fu", "foo", "fu", "bar", "baz"]; // CHECK: } +class X a, list b, list c> { + list x = !listconcat(!listconcat(a, b), !listconcat(b, c)); +} + class Y S> { list T1 = !listconcat(S, ["foo"]); list T2 = !listconcat(S, ["foo"], S, ["bar", "baz"]); } +def DX : X<[0], [1], [2]>; + def Z : Y<["fu"]>; -- 2.7.4