1 // RUN: llvm-tblgen %s | FileCheck %s
2 // RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s
3 // RUN: not llvm-tblgen -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s
5 // This file tests the comparison bang operators.
7 class BitCompare<bit a, bit b> {
8 list<bit> compare = [!eq(a, b), !ne(a, b),
10 !gt(a, b), !ge(a, b)];
13 class BitsCompare<bits<3> a, bits<3> b> {
14 list<bit> compare = [!eq(a, b), !ne(a, b),
16 !gt(a, b), !ge(a, b)];
19 class IntCompare<int a, int b> {
20 list<bit> compare = [!eq(a, b), !ne(a, b),
22 !gt(a, b), !ge(a, b)];
25 class StringCompare<string a, string b> {
26 list<bit> compare = [!eq(a, b), !ne(a, b),
28 !gt(a, b), !ge(a, b)];
36 // CHECK: compare = [1, 0, 0, 1, 0, 1];
38 // CHECK: compare = [0, 1, 1, 1, 0, 0];
40 // CHECK: compare = [0, 1, 0, 0, 1, 1];
42 // CHECK: compare = [1, 0, 0, 1, 0, 1];
44 def Bit00 : BitCompare<0, 0>;
45 def Bit01 : BitCompare<0, 1>;
46 def Bit10 : BitCompare<1, 0>;
47 def Bit11 : BitCompare<1, 1>;
50 // CHECK: compare = [0, 1, 1, 1, 0, 0];
52 // CHECK: compare = [1, 0, 0, 1, 0, 1];
54 // CHECK: compare = [0, 1, 0, 0, 1, 1];
56 def Bits1 : BitsCompare<{0, 1, 0}, {1, 0, 1}>;
57 def Bits2 : BitsCompare<{0, 1, 1}, {0, 1, 1}>;
58 def Bits3 : BitsCompare<{1, 1, 1}, {0, 1, 1}>;
61 // CHECK: compare = [0, 1, 1, 1, 0, 0];
63 // CHECK: compare = [1, 0, 0, 1, 0, 1];
65 // CHECK: compare = [0, 1, 0, 0, 1, 1];
67 def Int1 : IntCompare<-7, 13>;
68 def Int2 : IntCompare<42, 42>;
69 def Int3 : IntCompare<108, 42>;
72 // CHECK: compare1 = [1, 0];
73 // CHECK: compare2 = [0, 1];
74 // CHECK: compare3 = [1, 1];
80 list<bit> compare1 = [!eq(Bit00, Bit00), !eq(Bit00, Bit01)];
81 list<bit> compare2 = [!ne(Bit00, Bit00), !ne(Bit00, Int1)];
82 list<bit> compare3 = [!eq(bar_MC, bar_MC), !ne(bar_MC, foo_MC)];
86 // CHECK: compare = [0, 1, 1, 1, 0, 0];
88 // CHECK: compare = [1, 0, 0, 1, 0, 1];
90 // CHECK: compare = [0, 1, 0, 0, 1, 1];
92 // CHECK: compare = [0, 1, 0, 0, 1, 1];
93 def String1 : StringCompare<"bar", "foo">;
94 def String2 : StringCompare<"foo", "foo">;
95 def String3 : StringCompare<"foo", "bar">;
96 def String4 : StringCompare<"foo", "Foo">;
100 // ERROR1: expected bit, bits, int, string, or record; got value
103 bit compare1 = !eq([0, 1, 2], [0, 1, 2]);
110 // ERROR2: expected bit, bits, int, or string; got value
113 bit compare1 = !lt(Bit00, Bit00);