1// RUN: llvm-tblgen %s | FileCheck %s 2// XFAIL: vg_leak 3 4// CHECK: --- Defs --- 5 6// CHECK: def A00 { 7// CHECK: int sum = 7; 8// CHECK: } 9 10// CHECK: def A01 { 11// CHECK: int sum = 8; 12// CHECK: } 13 14// CHECK-NOT: def B0 15 16// CHECK: def B12 { 17// CHECK: int val = 9; 18// CHECK: } 19 20// CHECK: def B20 { 21// CHECK: int val = 7; 22// CHECK: } 23 24// CHECK: def B24 { 25// CHECK: int val = 11; 26// CHECK: } 27 28// CHECK: def B25 { 29// CHECK: int val = 12; 30// CHECK: } 31 32// CHECK: def C04 33// CHECK: def C05 34 35// CHECK: def D0A 36// CHECK-NOT: def D0B 37// CHECK: def D1A 38// CHECK: def D1B 39 40// CHECK: def E01 41// CHECK: def E02 42// CHECK-NOT: def E0C 43 44// CHECK: def E18 45// CHECK: def E19 46// CHECK: def E1C33 47// CHECK: def E1C34 48// CHECK: def E1C55 49// CHECK: def E1C56 50 51// CHECK-NOT: def F0 52// CHECK-NOT: def F1 53// CHECK-NOT: def F2_0_0 54// CHECK: def F2_1_0 55// CHECK-NOT: def F2_1_2 56// CHECK: def F2_2_0 57// CHECK: def F2_2_1 58// CHECK-NOT: def F2_2_2 59 60multiclass A<int x> { 61 foreach i = [0, 1] in { 62 def NAME#i { 63 int sum = !add(x, i); 64 } 65 } 66} 67 68defm A0 : A<7>; 69 70multiclass B<int x, list<int> lst> { 71 foreach i = lst in { 72 def NAME#i { 73 int val = !add(x, i); 74 } 75 } 76} 77 78defm B0 : B<7, []>; 79defm B1 : B<7, [2]>; 80defm B2 : B<7, [0, 4, 5]>; 81 82multiclass C<int x> { 83 foreach i = [x, !add(x, 1)] in { 84 def NAME#i; 85 } 86} 87 88defm C0 : C<4>; 89 90multiclass D<bit b> { 91 def A; 92 93 foreach _ = !if(b, [0], []<int>) in 94 def B; 95} 96 97defm D0 : D<0>; 98defm D1 : D<1>; 99 100multiclass E<list<int> lst, int x> 101 : C<x> { 102 foreach i = lst in 103 defm C#i : C<i>; 104} 105 106defm E0 : E<[], 1>; 107defm E1 : E<[3, 5], 8>; 108 109multiclass F<list<int> lst> { 110 foreach i = lst in 111 foreach j = !foldl([]<int>, lst, lhs, x, 112 !if(!lt(x, i), !listconcat(lhs, [x]), lhs)) in 113 def _#i#_#j; 114} 115 116defm F0 : F<[]>; 117defm F1 : F<[0]>; 118defm F2 : F<[0, 1, 2]>; 119