1 // RUN: llvm-tblgen %s | FileCheck %s
3 class Flatten<list<int> A, list<int> B> {
4 list<int> Flat1 = !listflatten([A, B, [6], [7, 8]]);
6 list<list<int>> X = [A, B];
7 list<int> Flat2 = !listflatten(!listconcat(X, [[7]]));
9 // Generate a nested list of integers.
10 list<int> Y0 = [1, 2, 3, 4];
11 list<list<int>> Y1 = !foreach(elem, Y0, [elem]);
12 list<list<list<int>>> Y2 = !foreach(elem, Y1, [elem]);
13 list<list<list<list<int>>>> Y3 = !foreach(elem, Y2, [elem]);
15 // Flatten it completely.
16 list<int> Flat3=!listflatten(!listflatten(!listflatten(Y3)));
18 // Flatten it partially.
19 list<list<list<int>>> Flat4 = !listflatten(Y3);
20 list<list<int>> Flat5 = !listflatten(!listflatten(Y3));
22 // Test NOP flattening.
23 list<string> Flat6 = !listflatten(["a", "b"]);
26 // CHECK: list<int> Flat1 = [1, 2, 3, 4, 5, 6, 7, 8];
27 // CHECK: list<int> Flat2 = [1, 2, 3, 4, 5, 7];
28 // CHECK: list<int> Flat3 = [1, 2, 3, 4];
29 // CHECK{LITERAL}: list<list<list<int>>> Flat4 = [[[1]], [[2]], [[3]], [[4]]];
30 // CHECK: list<string> Flat6 = ["a", "b"];
31 def F : Flatten<[1,2], [3,4,5]>;