summaryrefslogtreecommitdiff
path: root/test/TableGen
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2010-12-13 01:46:19 +0000
committerBill Wendling <isanbard@gmail.com>2010-12-13 01:46:19 +0000
commit548f5a0b751aafba88473e4863c2baf7741b56a5 (patch)
treea27b4776c6bc3c5ee1d938632121d9d6e2664e61 /test/TableGen
parentdcb54ce3da15ba41adeee020288e6c62cfae8c42 (diff)
downloadllvm-548f5a0b751aafba88473e4863c2baf7741b56a5.tar.gz
llvm-548f5a0b751aafba88473e4863c2baf7741b56a5.tar.bz2
llvm-548f5a0b751aafba88473e4863c2baf7741b56a5.tar.xz
Add support for using the `!if' operator when initializing variables:
class A<bit a, bits<3> x, bits<3> y> { bits<3> z; let z = !if(a, x, y); } The variable z will get the value of x when 'a' is 1 and 'y' when a is '0'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121666 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/TableGen')
-rw-r--r--test/TableGen/if.td30
1 files changed, 27 insertions, 3 deletions
diff --git a/test/TableGen/if.td b/test/TableGen/if.td
index 0bac0bac3e..bff927802b 100644
--- a/test/TableGen/if.td
+++ b/test/TableGen/if.td
@@ -1,14 +1,38 @@
-// RUN: tblgen %s | grep {\\\[1, 2, 3\\\]} | count 4
-// RUN: tblgen %s | grep {\\\[4, 5, 6\\\]} | count 2
+// RUN: tblgen %s | FileCheck %s
// XFAIL: vg_leak
+// Support for an `!if' operator as part of a `let' statement.
+// CHECK: class C
+// CHECK-NEXT: bits<16> n = { ?, ?, ?, ?, ?, ?, ?, !if({ C:x{2} }, 0, 1), !if({ C:x{2} }, 1, 1), !if({ C:x{2} }, 0, 0), !if({ C:x{1} }, C:y{3}, 0), !if({ C:x{1} }, C:y{2}, 1), !if({ C:x{0} }, C:y{3}, C:z), !if({ C:x{0} }, C:y{2}, C:y{2}), !if({ C:x{0} }, C:y{1}, C:y{1}), !if({ C:x{0} }, C:y{0}, C:y{0}) };
+class C<bits<3> x, bits<4> y, bit z> {
+ bits<16> n;
+
+ let n{8-6} = !if(x{2}, 0b010, 0b110);
+ let n{5-4} = !if(x{1}, y{3-2}, {0, 1});
+ let n{3-0} = !if(x{0}, y{3-0}, {z, y{2}, y{1}, y{0}});
+}
+
+// CHECK: def One
+// CHECK-NEXT: list<int> first = [1, 2, 3];
+// CHECK-NEXT: list<int> rest = [1, 2, 3];
+
+// CHECK: def OneB
+// CHECK-NEXT: list<int> vals = [1, 2, 3];
+
+// CHECK: def Two
+// CHECK-NEXT: list<int> first = [1, 2, 3];
+// CHECK-NEXT: list<int> rest = [4, 5, 6];
+
+// CHECK: def TwoB
+// CHECK-NEXT: list<int> vals = [4, 5, 6];
+
class A<list<list<int>> vals> {
list<int> first = vals[0];
list<int> rest = !if(!null(!cdr(vals)), vals[0], vals[1]);
}
def One : A<[[1,2,3]]>;
-def Two : A<[[1,2,3],[4,5,6]]>;
+def Two : A<[[1,2,3], [4,5,6]]>;
class B<list<int> v> {
list<int> vals = v;