1// RUN: llvm-tblgen %s | FileCheck %s 2// XFAIL: vg_leak 3 4// CHECK: def range_op_ranges { 5def range_op_ranges { 6 // !range(n) generates half-open interval "[0,n)" 7 // CHECK: list<int> idxs8 = [0, 1, 2, 3, 4, 5, 6, 7]; 8 list<int> idxs8 = !range(8); 9 10 // !range(m, n) generates half-open interval "[m,n)" 11 // CHECK: list<int> idxs4 = [4, 5, 6, 7]; 12 list<int> idxs4 = !range(4, 8); 13 14 // !range(m, n, s) generates half-open interval "[m,n)" with step s 15 // CHECK: list<int> step = [0, 2, 4, 6]; 16 list<int> step = !range(0, 8, 2); 17 18 // Step can be negative. 19 // CHECK: list<int> negative_step = [8, 6, 4, 2]; 20 list<int> negative_step = !range(8, 0, -2); 21 22 // !range(m, n) generates empty set if m >= n 23 // CHECK: list<int> idxs84 = []; 24 list<int> idxs84 = !range(8, 4); 25 26 // !range(m, n, s) generates empty set if m < n and s < 0 27 // CHECK: list<int> emptycase0 = []; 28 list<int> emptycase0 = !range(4, 8, -1); 29 30 // !range(m, n, s) generates empty set if m > n and s > 0 31 // CHECK: list<int> emptycase1 = []; 32 list<int> emptycase1 = !range(8, 4, 1); 33 34 // !range(list) generates index values for the list. (Not a copy of the list) 35 // CHECK: list<int> idxsl = [0, 1, 2, 3]; 36 list<int> idxsl = !range(idxs4); 37 38 // !range(emptylist) generates empty set 39 // CHECK: list<int> idxs0 = []; 40 list<int> idxs0 = !range(idxs84); 41 42 // Example: Dynamic !range(n) 43 // CHECK: list<list<int>> rn = {{\[}}[0, 1, 2, 3], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5, 6]]; 44 list<list<int>> rn = !foreach(i, idxs4, !range(i)); 45 46 // Example: Dynamic !range(m, n) 47 // CHECK: list<list<int>> rm = {{\[}}[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5], [2, 3, 4], [3], [], [], [], []]; 48 list<list<int>> rm = !foreach(i, idxs8, !range(i, !sub(7, i))); 49 50 // Example: Dynamic !range(list) 51 // CHECK: list<list<int>> rl = {{\[}}[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4], [0, 1, 2], [0], [], [], [], []]; 52 list<list<int>> rl = !foreach(r, rm, !range(r)); 53} 54