2 // RUN: not llvm-tblgen %s 2>&1 > %t
3 // RUN: FileCheck %s < %t
6 bits<2> opc = { 0, 1 };
7 bits<2> opc2 = { 1, 0 };
9 bits<2> a = { opc, opc2 }; // error!
10 bits<2> b = { opc{0}, opc2{0} };
11 bits<2> c = { opc{1}, opc2{1} };
12 bits<2> c = { opc3{0}, opc3 };
16 // CHECK: bits<2> opc = { 0, 1 };
17 // CHECK: bits<2> opc2 = { 1, 0 };
18 // CHECK: bits<1> opc3 = { 1 };
20 // CHECK: bits<2> b = { 1, 0 };
21 // CHECK: bits<2> c = { 1, 1 };
25 bits<2> B1 = 0b011; // bitfield is too small, reject
26 bits<3> B2 = 0b011; // ok
28 bits<2> C1 = 0b111; // bitfield is too small, reject
29 bits<3> C2 = 0b111; // ok
31 bits<2> D1 = { 0, 0 }; // ok
32 bits<2> D2 = { 0b00 }; // ok
33 bits<3> D3 = { 0, 0 }; // type mismatch. RHS doesn't have enough bits
34 bits<3> D4 = { 0b00 }; // type mismatch. RHS doesn't have enough bits
35 bits<1> D5 = { 0 }; // ok
36 bits<1> D6 = { 1 }; // ok
37 bits<1> D7 = { 3 }; // type mismatch. LHS doesn't have enough bits
38 bits<2> D8 = { 0 }; // type mismatch. RHS doesn't have enough bits
41 let E{7-0} = {0,0,1,?,?,?,?,?};
44 bits<8> F1 = { 0, 1, 0b1001, 0, 0b0 }; // ok
45 bits<7> F2 = { 0, 1, 0b1001, 0, 0b0 }; // LHS doesn't have enough bits
46 bits<9> F3 = { 0, 1, 0b1001, 0, 0b0 }; // RHS doesn't have enough bits
48 bits<8> G1 = { 0, { 1, 0b1001, 0 }, 0b0 }; // ok
49 bits<8> G2 = { 0, { 1, 0b1001 }, 0, 0b0 }; // ok
50 bits<8> G3 = { 0, 1, { 0b1001 }, 0, 0b0 }; // ok
53 let H{15-0} = { { 0b11001100 }, 0b00110011 };
54 bits<16> I = { G1, G2 };
56 // Make sure we can initialise ints with bits<> values.
61 // CHECK: def {{.*}} {
63 // CHECK: bits<3> B2 = { 0, 1, 1 };
65 // CHECK: bits<3> C2 = { 1, 1, 1 };
66 // CHECK: bits<2> D1 = { 0, 0 };
67 // CHECK: bits<2> D2 = { 0, 0 };
70 // CHECK: bits<1> D5 = { 0 };
71 // CHECK: bits<1> D6 = { 1 };
72 // CHECK: bits<1> D7 = { !cast<bit>(3) };
74 // CHECK: bits<8> E = { 0, 0, 1, ?, 0, 0, 1, 0 };
75 // CHECK: bits<8> F1 = { 0, 1, 1, 0, 0, 1, 0, 0 };
78 // CHECK: bits<8> G1 = { 0, 1, 1, 0, 0, 1, 0, 0 };
79 // CHECK: bits<8> G2 = { 0, 1, 1, 0, 0, 1, 0, 0 };
80 // CHECK: bits<8> G3 = { 0, 1, 1, 0, 0, 1, 0, 0 };
81 // CHECK: bits<16> H = { 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1 };
82 // CHECK: bits<16> I = { 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0 };
83 // CHECK: int J = 52275;