brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · a76ac21 Raw
33 lines · plain
1// RUN: llvm-tblgen %s | FileCheck %s2 3class Flatten<list<int> A, list<int> B> {4    list<int> Flat1 = !listflatten([A, B, [6], [7, 8]]);5 6    list<list<int>> X = [A, B];7    list<int> Flat2 = !listflatten(!listconcat(X, [[7]]));8 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]);14 15    // Flatten it completely.16    list<int> Flat3=!listflatten(!listflatten(!listflatten(Y3)));17 18    // Flatten it partially.19    list<list<list<int>>> Flat4 = !listflatten(Y3);20    list<list<int>> Flat5 = !listflatten(!listflatten(Y3));21 22    // Test NOP flattening.23    list<string> Flat6 = !listflatten(["a", "b"]);24}25 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"];31def F : Flatten<[1,2], [3,4,5]>;32 33