1 // RUN: llvm-tblgen %s | FileCheck %s 2 // XFAIL: vg_leak 3 4 // Support for an `!if' operator as part of a `let' statement. 5 // CHECK: class C 6 // CHECK-NEXT: bits<16> n = { ?, ?, ?, ?, ?, ?, ?, !if({ C:x{2} }, 0, 1), !if({ C:x{2} }, 1, 1), !if({ C:x{2} }, 0, 0), !if({ C:x{1} }, C:y{3}, 0), !if({ C:x{1} }, C:y{2}, 1), !if({ C:x{0} }, C:y{3}, C:z), !if({ C:x{0} }, C:y{2}, C:y{2}), !if({ C:x{0} }, C:y{1}, C:y{1}), !if({ C:x{0} }, C:y{0}, C:y{0}) }; 7 class C<bits<3> x, bits<4> y, bit z> { 8 bits<16> n; 9 10 let n{8-6} = !if(x{2}, 0b010, 0b110); 11 let n{5-4} = !if(x{1}, y{3-2}, {0, 1}); 12 let n{3-0} = !if(x{0}, y{3-0}, {z, y{2}, y{1}, y{0}}); 13 } 14 15 // CHECK: def One 16 // CHECK-NEXT: list<int> first = [1, 2, 3]; 17 // CHECK-NEXT: list<int> rest = [1, 2, 3]; 18 19 // CHECK: def OneB 20 // CHECK-NEXT: list<int> vals = [1, 2, 3]; 21 22 // CHECK: def Two 23 // CHECK-NEXT: list<int> first = [1, 2, 3]; 24 // CHECK-NEXT: list<int> rest = [4, 5, 6]; 25 26 // CHECK: def TwoB 27 // CHECK-NEXT: list<int> vals = [4, 5, 6]; 28 29 class A<list<list<int>> vals> { 30 list<int> first = vals[0]; 31 list<int> rest = !if(!empty(!tail(vals)), vals[0], vals[1]); 32 } 33 34 def One : A<[[1,2,3]]>; 35 def Two : A<[[1,2,3], [4,5,6]]>; 36 37 class B<list<int> v> { 38 list<int> vals = v; 39 } 40 41 class BB<list<list<int>> vals> : B<!if(!empty(!tail(vals)), vals[0], vals[1])>; 42 class BBB<list<list<int>> vals> : BB<vals>; 43 44 def OneB : BBB<[[1,2,3]]>; 45 def TwoB : BBB<[[1,2,3],[4,5,6]]>; 46