1 // RUN: llvm-tblgen %s | FileCheck %s
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.
7 // These are tests for bits ranges.
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);
18 def bit_range_dotdotdot {
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);
27 if !eq(bit_range_hyphen.field1, bit_range_dotdotdot.field1) then
30 def bit_range_not_ok {}
32 // These are tests for lists.
34 def 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"));
45 def 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"));
56 if !eq(!head(list_range_hyphen.subfieldd),
57 !head(list_range_dotdotdot.subfieldd)) then
60 def list_range_not_ok {}
62 // This is a test of foreach.
65 foreach j = {4...5} in
71 //CHECK: bit dotdotdot_field1_ok = 1
72 //CHECK: bit hyphen_field1_ok = 1
73 //CHECK: def bit_range_ok {
75 //CHECK: def eachrec04 {
76 //CHECK: def eachrec35 {
78 //CHECK: bit dotdotdot_subfields_ok = 1
79 //CHECK: bit hyphen_subfields_ok = 1
80 //CHECK: def list_range_ok {