• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: llvm-tblgen %s | FileCheck %s
2// XFAIL: vg_leak
3
4// This file has tests for range lists and range pieces. Some use the
5// deprecated '-' range punctuation just to be sure it still works.
6
7// These are tests for bits ranges.
8
9def bit_range_hyphen {
10  bits<16> field1;
11  let field1{15, 14, 13, 12} = {1, 0, 1, 0};
12  let field1{11-8} = {1, 0, 1, 1};
13  let field1{+7-4} = {1, 1, 0, 0};
14  let field1{+3-+0} = {1, 1, 0, 1};
15  bit hyphen_field1_ok = !eq(field1, 0xABCD);
16}
17
18def bit_range_dotdotdot {
19  bits<16> field1;
20  let field1{15, 14, 13, 12} = {1, 0, 1, 0};
21  let field1{11...8} = {1, 0, 1, 1};
22  let field1{+7...4} = {1, 1, 0, 0};
23  let field1{+3...+0} = {1, 1, 0, 1};
24  bit dotdotdot_field1_ok = !eq(field1, 0xABCD);
25}
26
27if !eq(bit_range_hyphen.field1, bit_range_dotdotdot.field1) then
28  def bit_range_ok {}
29else
30  def bit_range_not_ok {}
31
32// These are tests for lists.
33
34def list_range_hyphen {
35  list<string> field1 = ["foo", "bar", "baz", "snork", "quux", "quuux",
36                         "bazola", "ztesch", "bletch", "flarp"];
37  list<string> subfielda = field1[0, 1, 2, 3];
38  list<string> subfieldb = field1[4-5];
39  list<string> subfieldc = field1[+6-7];
40  list<string> subfieldd = field1[+8-+9];
41  bit hyphen_subfields_ok = !and(!eq(subfieldb[0], "quux"),
42                                 !eq(subfieldd[1], "flarp"));
43}
44
45def list_range_dotdotdot {
46  list<string> field1 = ["foo", "bar", "baz", "snork", "quux", "quuux",
47                         "bazola", "ztesch", "bletch", "flarp"];
48  list<string> subfielda = field1[0, 1, 2, 3];
49  list<string> subfieldb = field1[4...5];
50  list<string> subfieldc = field1[+6...7];
51  list<string> subfieldd = field1[+8...+9];
52  bit dotdotdot_subfields_ok = !and(!eq(subfieldb[0], "quux"),
53                                    !eq(subfieldd[1], "flarp"));
54}
55
56if !eq(!head(list_range_hyphen.subfieldd),
57       !head(list_range_dotdotdot.subfieldd)) then
58  def list_range_ok {}
59else
60  def list_range_not_ok {}
61
62// This is a test of foreach.
63
64foreach i = {0-3} in
65  foreach j = {4...5} in
66    def eachrec#i#j {
67      int fi = i;
68      int fj = j;
69    }
70
71//CHECK: bit dotdotdot_field1_ok = 1
72//CHECK: bit hyphen_field1_ok = 1
73//CHECK: def bit_range_ok {
74
75//CHECK: def eachrec04 {
76//CHECK: def eachrec35 {
77
78//CHECK: bit dotdotdot_subfields_ok = 1
79//CHECK: bit hyphen_subfields_ok = 1
80//CHECK: def list_range_ok {
81
82