1 2// RUN: not llvm-tblgen %s 2>&1 > %t 3// RUN: FileCheck %s < %t 4 5def a { 6 bits<2> opc = { 0, 1 }; 7 bits<2> opc2 = { 1, 0 }; 8 bits<1> opc3 = { 1 }; 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 }; 13} 14 15// CHECK: def a { 16// CHECK: bits<2> opc = { 0, 1 }; 17// CHECK: bits<2> opc2 = { 1, 0 }; 18// CHECK: bits<1> opc3 = { 1 }; 19// CHECK: bits<2> a; 20// CHECK: bits<2> b = { 1, 0 }; 21// CHECK: bits<2> c = { 1, 1 }; 22// CHECK: } 23 24def { 25 bits<2> B1 = 0b011; // bitfield is too small, reject 26 bits<3> B2 = 0b011; // ok 27 28 bits<2> C1 = 0b111; // bitfield is too small, reject 29 bits<3> C2 = 0b111; // ok 30 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 39 40 bits<8> E; 41 let E{7-0} = {0,0,1,?,?,?,?,?}; 42 let E{3-0} = 0b0010; 43 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 47 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 51 52 bits<16> H; 53 let H{15-0} = { { 0b11001100 }, 0b00110011 }; 54 bits<16> I = { G1, G2 }; 55 56 // Make sure we can initialise ints with bits<> values. 57 int J = H; 58 int K = { 0, 1 }; 59} 60 61// CHECK: def {{.*}} { 62// CHECK: bits<2> B1; 63// CHECK: bits<3> B2 = { 0, 1, 1 }; 64// CHECK: bits<2> C1; 65// CHECK: bits<3> C2 = { 1, 1, 1 }; 66// CHECK: bits<2> D1 = { 0, 0 }; 67// CHECK: bits<2> D2 = { 0, 0 }; 68// CHECK: bits<3> D3; 69// CHECK: bits<3> D4; 70// CHECK: bits<1> D5 = { 0 }; 71// CHECK: bits<1> D6 = { 1 }; 72// CHECK: bits<1> D7 = { ? }; 73// CHECK: bits<2> D8; 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 }; 76// CHECK: bits<7> F2; 77// CHECK: bits<9> F3; 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; 84// CHECK: int K = 1; 85// CHECK: } 86