|
1 |
| -// RUN: llvm-tblgen %s |
| 1 | +// RUN: llvm-tblgen %s | FileCheck %s |
2 | 2 | // XFAIL: vg_leak
|
3 | 3 |
|
4 |
| -def A { |
5 |
| - list<int> B = [10, 20, 30, 4, 1, 1231, 20]; |
| 4 | +// This file has tests for the list slice suffix. |
| 5 | + |
| 6 | +// Test defvars and literal lists. |
| 7 | + |
| 8 | +// CHECK: def Rec00 |
| 9 | +// CHECK: list<int> ShowVar1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] |
| 10 | +// CHECK: int ShowVar2 = 0 |
| 11 | +// CHECK: list<int> ShowVar3 = [2, 3, 4, 5] |
| 12 | +// CHECK: int ShowVar4 = 0 |
| 13 | +// CHECK: list<int> ShowVar5 = [2, 3, 4, 5] |
| 14 | + |
| 15 | +defvar Var1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; |
| 16 | +defvar Var2 = Var1[0]; |
| 17 | +defvar Var3 = Var1[2...5]; |
| 18 | + |
| 19 | +defvar Var4 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9][0]; |
| 20 | +defvar Var5 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9][2...5]; |
| 21 | + |
| 22 | +def Rec00 { // Display the defvars. |
| 23 | + list<int> ShowVar1 = Var1; |
| 24 | + int ShowVar2 = Var2; |
| 25 | + list<int> ShowVar3 = Var3; |
| 26 | + int ShowVar4 = Var4; |
| 27 | + list<int> ShowVar5 = Var5; |
| 28 | +} |
| 29 | + |
| 30 | +// CHECK: def Rec01 |
| 31 | +// CHECK: int Zero = 0 |
| 32 | +// CHECK: list<int> TwoFive = [2, 3, 4, 5] |
| 33 | + |
| 34 | +def Rec01 { |
| 35 | + int Zero = Var1[0]; |
| 36 | + list<int> TwoFive = Var1[2...5]; |
| 37 | +} |
| 38 | + |
| 39 | +// Test class template arguments. |
| 40 | + |
| 41 | +// CHECK: def Rec02 |
| 42 | +// CHECK: int Zero = 10 |
| 43 | +// CHECK: list<int> TwoFive = [12, 13, 14, 15] |
| 44 | + |
| 45 | +class Class1<list<int> ids> { |
| 46 | + int Zero = ids[0]; |
| 47 | + list<int> TwoFive = ids[2...5]; |
| 48 | +} |
| 49 | + |
| 50 | +def Rec02 : Class1<[10, 11, 12, 13, 14, 15, 16, 17]>; |
| 51 | + |
| 52 | +// Test anonymous record fetches. |
| 53 | + |
| 54 | +// CHECK: def Rec03 |
| 55 | +// CHECK: int Zero = 20 |
| 56 | +// CHECK: list<int> TwoFive = [22, 23, 24, 25] |
| 57 | + |
| 58 | +def Rec03 { |
| 59 | + int Zero = Class1<[20, 21, 22, 23, 24, 25, 26]>.Zero; |
| 60 | + list<int> TwoFive = Class1<[20, 21, 22, 23, 24, 25, 26]>.TwoFive; |
6 | 61 | }
|
7 | 62 |
|
8 |
| -def B { |
9 |
| - list<int> X = [10, 20, 30, 4, 1, 1231, 20] [2...4,2,2,0...6]; |
| 63 | +// Test multiclass template arguments. |
| 64 | + |
| 65 | +// CHECK: def Rec04_MC1 |
| 66 | +// CHECK: int Zero = 30 |
| 67 | +// CHECK: list<int> TwoFive = [32, 33, 34, 35] |
| 68 | +// CHECK: def Rec05_MC1 |
| 69 | +// CHECK: int Zero = 30 |
| 70 | +// CHECK: list<int> TwoFive = [32, 33, 34, 35] |
| 71 | + |
| 72 | +multiclass MC1<list<int> ids> { |
| 73 | + def _MC1 { |
| 74 | + int Zero = ids[0]; |
| 75 | + list<int> TwoFive = ids[2...5]; |
| 76 | + } |
| 77 | +} |
10 | 78 |
|
11 |
| - list<int> Y = X[4,5]; |
12 |
| - int Z = X[4]; |
| 79 | +defm Rec04 : MC1<[30, 31, 32, 33, 34, 35, 36]>; |
| 80 | +defm Rec05 : MC1<[30, 31, 32, 33, 34, 35]>; |
| 81 | + |
| 82 | +// Test taking a complex subset of the list items from another record. |
| 83 | + |
| 84 | +// CHECK: def Rec07 |
| 85 | +// CHECK: list<int> SomeValues = [40, 43, 44, 45, 40, 47, 49, 48, 47, 46, 40] |
| 86 | + |
| 87 | +def Rec06 { |
| 88 | + list<int> Values = [40, 41, 42, 43, 44, 45, 46, 47, 48, 49]; |
| 89 | +} |
| 90 | + |
| 91 | +def Rec07 { |
| 92 | + list<int> SomeValues = Rec06.Values[0, 3...5, 0, 7, 9...6, 0]; |
| 93 | +} |
13 | 94 |
|
14 |
| - list<int> C = A.B[1...4]; |
| 95 | +// Test a double subscript. |
15 | 96 |
|
16 |
| - list<list<int>> AA = [X, Y]; |
| 97 | +// CHECK: def Rec08 |
| 98 | +// CHECK: list<list<string>> Array = {{.*}}"foo", "bar", "snork"], ["zoo", "quux", "flarp"]] |
| 99 | +// CHECK: string Snork = "snork" |
| 100 | +// CHECK: list<string> ZooQuux = ["zoo", "quux"] |
17 | 101 |
|
18 |
| - int BB = AA[0][1]; |
| 102 | +def Rec08 { |
| 103 | + list<list<string>> Array = [["foo", "bar", "snork"], |
| 104 | + ["zoo", "quux", "flarp"]]; |
| 105 | + string Snork = Array[0][2]; |
| 106 | + list<string> ZooQuux = Array[1][0...1]; |
19 | 107 | }
|
0 commit comments