1 // RUN: llvm-tblgen %s | FileCheck %s
4 // Support for an `!if' operator as part of a `let' statement.
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> {
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}});
16 // CHECK-NEXT: list<int> first = [1, 2, 3];
17 // CHECK-NEXT: list<int> rest = [1, 2, 3];
20 // CHECK-NEXT: list<int> vals = [1, 2, 3];
23 // CHECK-NEXT: list<int> first = [1, 2, 3];
24 // CHECK-NEXT: list<int> rest = [4, 5, 6];
27 // CHECK-NEXT: list<int> vals = [4, 5, 6];
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]);
34 def One : A<[[1,2,3]]>;
35 def Two : A<[[1,2,3], [4,5,6]]>;
37 class B<list<int> v> {
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>;
44 def OneB : BBB<[[1,2,3]]>;
45 def TwoB : BBB<[[1,2,3],[4,5,6]]>;