File: range-op.td

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (53 lines) | stat: -rw-r--r-- 1,954 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// RUN: llvm-tblgen %s | FileCheck %s
// XFAIL: vg_leak

// CHECK: def range_op_ranges {
def range_op_ranges {
  // !range(n) generates half-open interval "[0,n)"
  // CHECK: list<int> idxs8 = [0, 1, 2, 3, 4, 5, 6, 7];
  list<int> idxs8 = !range(8);

  // !range(m, n) generates half-open interval "[m,n)"
  // CHECK: list<int> idxs4 = [4, 5, 6, 7];
  list<int> idxs4 = !range(4, 8);

  // !range(m, n, s) generates half-open interval "[m,n)" with step s
  // CHECK: list<int> step = [0, 2, 4, 6];
  list<int> step = !range(0, 8, 2);

  // Step can be negative.
  // CHECK: list<int> negative_step = [8, 6, 4, 2];
  list<int> negative_step = !range(8, 0, -2);

  // !range(m, n) generates empty set if m >= n
  // CHECK: list<int> idxs84 = [];
  list<int> idxs84 = !range(8, 4);

  // !range(m, n, s) generates empty set if m < n and s < 0
  // CHECK: list<int> emptycase0 = [];
  list<int> emptycase0 = !range(4, 8, -1);

  // !range(m, n, s) generates empty set if m > n and s > 0
  // CHECK: list<int> emptycase1 = [];
  list<int> emptycase1 = !range(8, 4, 1);

  // !range(list) generates index values for the list. (Not a copy of the list)
  // CHECK: list<int> idxsl = [0, 1, 2, 3];
  list<int> idxsl = !range(idxs4);

  // !range(emptylist) generates empty set
  // CHECK: list<int> idxs0 = [];
  list<int> idxs0 = !range(idxs84);

  // Example: Dynamic !range(n)
  // 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]];
  list<list<int>> rn = !foreach(i, idxs4, !range(i));

  // Example: Dynamic !range(m, n)
  // CHECK: list<list<int>> rm = {{\[}}[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5], [2, 3, 4], [3], [], [], [], []];
  list<list<int>> rm = !foreach(i, idxs8, !range(i, !sub(7, i)));

  // Example: Dynamic !range(list)
  // CHECK: list<list<int>> rl = {{\[}}[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4], [0, 1, 2], [0], [], [], [], []];
  list<list<int>> rl = !foreach(r, rm, !range(r));
}