brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 1ecd95f Raw
118 lines · plain
1// RUN: llvm-tblgen %s | FileCheck %s2// RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s3// RUN: not llvm-tblgen -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s4 5// This file tests the comparison bang operators.6 7class BitCompare<bit a, bit b> {8  list<bit> compare = [!eq(a, b), !ne(a, b),9                       !lt(a, b), !le(a, b),10                       !gt(a, b), !ge(a, b)];11}12 13class BitsCompare<bits<3> a, bits<3> b> {14  list<bit> compare = [!eq(a, b), !ne(a, b),15                       !lt(a, b), !le(a, b),16                       !gt(a, b), !ge(a, b)];17}18 19class IntCompare<int a, int b> {20  list<bit> compare = [!eq(a, b), !ne(a, b),21                       !lt(a, b), !le(a, b),22                       !gt(a, b), !ge(a, b)];23}24 25class StringCompare<string a, string b> {26  list<bit> compare = [!eq(a, b), !ne(a, b),27                       !lt(a, b), !le(a, b),28                       !gt(a, b), !ge(a, b)];29}30 31multiclass MC {32  def _MC;33}34 35// CHECK: def Bit0036// CHECK:   compare = [1, 0, 0, 1, 0, 1];37// CHECK: def Bit0138// CHECK:   compare = [0, 1, 1, 1, 0, 0];39// CHECK: def Bit1040// CHECK:   compare = [0, 1, 0, 0, 1, 1];41// CHECK: def Bit1142// CHECK:   compare = [1, 0, 0, 1, 0, 1];43 44def Bit00 : BitCompare<0, 0>;45def Bit01 : BitCompare<0, 1>;46def Bit10 : BitCompare<1, 0>;47def Bit11 : BitCompare<1, 1>;48 49// CHECK: def Bits150// CHECK:   compare = [0, 1, 1, 1, 0, 0];51// CHECK: def Bits252// CHECK:   compare = [1, 0, 0, 1, 0, 1];53// CHECK: def Bits354// CHECK:   compare = [0, 1, 0, 0, 1, 1];55 56def Bits1 : BitsCompare<{0, 1, 0}, {1, 0, 1}>;57def Bits2 : BitsCompare<{0, 1, 1}, {0, 1, 1}>;58def Bits3 : BitsCompare<{1, 1, 1}, {0, 1, 1}>;59 60// CHECK: def Int161// CHECK:   compare = [0, 1, 1, 1, 0, 0];62// CHECK: def Int263// CHECK:   compare = [1, 0, 0, 1, 0, 1];64// CHECK: def Int365// CHECK:   compare = [0, 1, 0, 0, 1, 1];66 67def Int1 : IntCompare<-7, 13>;68def Int2 : IntCompare<42, 42>;69def Int3 : IntCompare<108, 42>;70 71// CHECK: def Record172// CHECK:   compare1 = [1, 0];73// CHECK:   compare2 = [0, 1];74// CHECK:   compare3 = [1, 1];75 76defm foo : MC;77defm bar : MC;78 79def Record1 {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)];83}84 85// CHECK: def String186// CHECK:   compare = [0, 1, 1, 1, 0, 0];87// CHECK: def String288// CHECK:   compare = [1, 0, 0, 1, 0, 1];89// CHECK: def String390// CHECK:   compare = [0, 1, 0, 0, 1, 1];91// CHECK: def String492// CHECK:   compare = [0, 1, 0, 0, 1, 1];93def String1 : StringCompare<"bar", "foo">;94def String2 : StringCompare<"foo", "foo">;95def String3 : StringCompare<"foo", "bar">;96def String4 : StringCompare<"foo", "Foo">;97 98#ifdef ERROR199 100// ERROR1: expected bit, bits, int, string, or record; got value101 102def Zerror1 {103  bit compare1 = !eq([0, 1, 2], [0, 1, 2]);104}105 106#endif107 108#ifdef ERROR2109 110// ERROR2: expected bit, bits, int, or string; got value111 112def Zerror2 {113  bit compare1 = !lt(Bit00, Bit00);114}115 116#endif117 118