aboutsummaryrefslogtreecommitdiff
path: root/test/TableGen
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2011-02-20 12:57:14 +0000
committerDimitry Andric <dim@FreeBSD.org>2011-02-20 12:57:14 +0000
commitcf099d11218cb6f6c5cce947d6738e347f07fb12 (patch)
treed2b61ce94e654cb01a254d2195259db5f9cc3f3c /test/TableGen
parent49011b52fcba02a6051957b84705159f52fae4e4 (diff)
Notes
Diffstat (limited to 'test/TableGen')
-rw-r--r--test/TableGen/Dag.td71
-rw-r--r--test/TableGen/DagDefSubst.td16
-rw-r--r--test/TableGen/DagIntSubst.td11
-rw-r--r--test/TableGen/FieldAccess.td2
-rw-r--r--test/TableGen/ListManip.td4
-rw-r--r--test/TableGen/Slice.td8
-rw-r--r--test/TableGen/defmclass.td12
-rw-r--r--test/TableGen/if.td34
-rw-r--r--test/TableGen/lisp.td2
-rw-r--r--test/TableGen/nameconcat.td91
10 files changed, 122 insertions, 129 deletions
diff --git a/test/TableGen/Dag.td b/test/TableGen/Dag.td
new file mode 100644
index 000000000000..d3481a550c34
--- /dev/null
+++ b/test/TableGen/Dag.td
@@ -0,0 +1,71 @@
+// RUN: tblgen %s | FileCheck %s
+// XFAIL: vg_leak
+
+//===----------------------------------------------------------------------===//
+// Substitution of an int.
+def X1;
+
+class C1<int N> {
+ dag d = (X1 N);
+}
+
+def VAL1 : C1<13>;
+
+// CHECK: def VAL1 {
+// CHECK-NEXT: dag d = (X1 13)
+
+
+//===----------------------------------------------------------------------===//
+// Substitution of a DAG.
+def X2;
+
+class yclass;
+def Y2 : yclass;
+
+class C2<yclass N> {
+ dag d = (X2 N);
+ dag e = (N X2);
+}
+
+def VAL2 : C2<Y2>;
+
+// CHECK: def VAL2 {
+// CHECK-NEXT: dag d = (X2 Y2)
+// CHECK-NEXT: dag e = (Y2 X2)
+
+
+//===----------------------------------------------------------------------===//
+// Complex dag operator (F.TheOp).
+
+class operator;
+def somedef1 : operator;
+def somedef2 : operator;
+
+class foo<operator a> {
+ operator TheOp = a;
+}
+
+class bar<foo F, operator a> {
+ dag Dag1 = (somedef1 1);
+ dag Dag2 = (a 2);
+ dag Dag3 = (F.TheOp 2);
+}
+
+def foo1 : foo<somedef1>;
+def foo2 : foo<somedef2>;
+
+def VAL3 : bar<foo1, somedef1>;
+
+// CHECK: def VAL3 { // bar
+// CHECK-NEXT: dag Dag1 = (somedef1 1);
+// CHECK-NEXT: dag Dag2 = (somedef1 2);
+// CHECK-NEXT: dag Dag3 = (somedef1 2);
+// CHECK-NEXT: }
+
+
+def VAL4 : bar<foo2, somedef2>;
+// CHECK: def VAL4 {
+// CHECK-NEXT: dag Dag1 = (somedef1 1);
+// CHECK-NEXT: dag Dag2 = (somedef2 2);
+// CHECK-NEXT: dag Dag3 = (somedef2 2);
+// CHECK-NEXT: }
diff --git a/test/TableGen/DagDefSubst.td b/test/TableGen/DagDefSubst.td
deleted file mode 100644
index 92a207f41829..000000000000
--- a/test/TableGen/DagDefSubst.td
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: tblgen %s | grep {dag d = (X Y)}
-// RUN: tblgen %s | grep {dag e = (Y X)}
-// XFAIL: vg_leak
-def X;
-
-class yclass;
-def Y : yclass;
-
-class C<yclass N> {
- dag d = (X N);
- dag e = (N X);
-}
-
-def VAL : C<Y>;
-
-
diff --git a/test/TableGen/DagIntSubst.td b/test/TableGen/DagIntSubst.td
deleted file mode 100644
index 00fde694e7dc..000000000000
--- a/test/TableGen/DagIntSubst.td
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: tblgen %s | grep {dag d = (X 13)}
-// XFAIL: vg_leak
-def X;
-
-class C<int N> {
- dag d = (X N);
-}
-
-def VAL : C<13>;
-
-
diff --git a/test/TableGen/FieldAccess.td b/test/TableGen/FieldAccess.td
index ad652e79ea7c..8b4dc83e0a5b 100644
--- a/test/TableGen/FieldAccess.td
+++ b/test/TableGen/FieldAccess.td
@@ -1,4 +1,6 @@
// RUN: tblgen %s
+// XFAIL: vg_leak
+
class Bla<string t>
{
string blu = t;
diff --git a/test/TableGen/ListManip.td b/test/TableGen/ListManip.td
index c221bb1335b6..6b1e491cd25f 100644
--- a/test/TableGen/ListManip.td
+++ b/test/TableGen/ListManip.td
@@ -1,10 +1,12 @@
// RUN: tblgen %s
+// XFAIL: vg_leak
+
class Bli<string _t>
{
string t = _t;
}
class Bla<list<Bli> _bli>
-: Bli<!car(_bli).t>
+: Bli<!head(_bli).t>
{
}
diff --git a/test/TableGen/Slice.td b/test/TableGen/Slice.td
index 22bf7fbfe8cf..13d9da2b9fd6 100644
--- a/test/TableGen/Slice.td
+++ b/test/TableGen/Slice.td
@@ -66,19 +66,19 @@ def not : SDNode;
multiclass scalar<bits<8> opcode, string asmstr = "", list<list<dag>> patterns = []> {
def SSrr : Inst<opcode, (outs FR32:$dst), (ins FR32:$src),
!strconcat(asmstr, "\t$dst, $src"),
- !if(!null(patterns),[]<dag>,patterns[0])>;
+ !if(!empty(patterns),[]<dag>,patterns[0])>;
def SSrm : Inst<opcode, (outs FR32:$dst), (ins FR32:$src),
!strconcat(asmstr, "\t$dst, $src"),
- !if(!null(patterns),[]<dag>,!if(!null(!cdr(patterns)),patterns[0],patterns[1]))>;
+ !if(!empty(patterns),[]<dag>,!if(!empty(!tail(patterns)),patterns[0],patterns[1]))>;
}
multiclass vscalar<bits<8> opcode, string asmstr = "", list<list<dag>> patterns = []> {
def V#NAME#SSrr : Inst<opcode, (outs FR32:$dst), (ins FR32:$src),
!strconcat(asmstr, "\t$dst, $src"),
- !if(!null(patterns),[]<dag>,patterns[0])>;
+ !if(!empty(patterns),[]<dag>,patterns[0])>;
def V#NAME#SSrm : Inst<opcode, (outs FR32:$dst), (ins FR32:$src),
!strconcat(asmstr, "\t$dst, $src"),
- !if(!null(patterns),[]<dag>,!if(!null(!cdr(patterns)),patterns[0],patterns[1]))>;
+ !if(!empty(patterns),[]<dag>,!if(!empty(!tail(patterns)),patterns[0],patterns[1]))>;
}
multiclass myscalar<bits<8> opcode, string asmstr = "", list<list<dag>> patterns = []> :
diff --git a/test/TableGen/defmclass.td b/test/TableGen/defmclass.td
index 55482da4d072..57972b6dae54 100644
--- a/test/TableGen/defmclass.td
+++ b/test/TableGen/defmclass.td
@@ -36,3 +36,15 @@ multiclass Y {
// CHECK: int check = 0;
defm Instr : Y, VEX;
+
+
+// Anonymous defm.
+
+multiclass SomeAnonymous<int x> {
+ def rm;
+ def mr;
+}
+
+// These multiclasses shouldn't conflict.
+defm : SomeAnonymous<1>;
+defm : SomeAnonymous<2>; \ No newline at end of file
diff --git a/test/TableGen/if.td b/test/TableGen/if.td
index 0bac0bac3e98..c4d953ea2245 100644
--- a/test/TableGen/if.td
+++ b/test/TableGen/if.td
@@ -1,20 +1,44 @@
-// 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]);
+ list<int> rest = !if(!empty(!tail(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;
}
-class BB<list<list<int>> vals> : B<!if(!null(!cdr(vals)), vals[0], vals[1])>;
+class BB<list<list<int>> vals> : B<!if(!empty(!tail(vals)), vals[0], vals[1])>;
class BBB<list<list<int>> vals> : BB<vals>;
def OneB : BBB<[[1,2,3]]>;
diff --git a/test/TableGen/lisp.td b/test/TableGen/lisp.td
index b521e04c8913..bbed8690dd5d 100644
--- a/test/TableGen/lisp.td
+++ b/test/TableGen/lisp.td
@@ -15,7 +15,7 @@ class CDR<list<string> r, int n> {
}
class NameList<list<string> Names> :
- List<Names>, CAR<!car(Names)>, CDR<!cdr(Names), !null(!cdr(Names))>;
+ List<Names>, CAR<!head(Names)>, CDR<!tail(Names), !empty(!tail(Names))>;
def Three : NameList<["Tom", "Dick", "Harry"]>;
diff --git a/test/TableGen/nameconcat.td b/test/TableGen/nameconcat.td
deleted file mode 100644
index fd2880a80dff..000000000000
--- a/test/TableGen/nameconcat.td
+++ /dev/null
@@ -1,91 +0,0 @@
-// RUN: tblgen %s | grep {add_ps} | count 3
-// XFAIL: vg_leak
-
-class ValueType<int size, int value> {
- int Size = size;
- int Value = value;
-}
-
-def v2i64 : ValueType<128, 22>; // 2 x i64 vector value
-def v2f64 : ValueType<128, 28>; // 2 x f64 vector value
-
-class Intrinsic<string name> {
- string Name = name;
-}
-
-class Inst<bits<8> opcode, dag oopnds, dag iopnds, string asmstr,
- list<dag> pattern> {
- bits<8> Opcode = opcode;
- dag OutOperands = oopnds;
- dag InOperands = iopnds;
- string AssemblyString = asmstr;
- list<dag> Pattern = pattern;
-}
-
-def ops;
-def outs;
-def ins;
-
-def set;
-
-// Define registers
-class Register<string n> {
- string Name = n;
-}
-
-class RegisterClass<list<ValueType> regTypes, list<Register> regList> {
- list<ValueType> RegTypes = regTypes;
- list<Register> MemberList = regList;
-}
-
-def XMM0: Register<"xmm0">;
-def XMM1: Register<"xmm1">;
-def XMM2: Register<"xmm2">;
-def XMM3: Register<"xmm3">;
-def XMM4: Register<"xmm4">;
-def XMM5: Register<"xmm5">;
-def XMM6: Register<"xmm6">;
-def XMM7: Register<"xmm7">;
-def XMM8: Register<"xmm8">;
-def XMM9: Register<"xmm9">;
-def XMM10: Register<"xmm10">;
-def XMM11: Register<"xmm11">;
-def XMM12: Register<"xmm12">;
-def XMM13: Register<"xmm13">;
-def XMM14: Register<"xmm14">;
-def XMM15: Register<"xmm15">;
-
-def VR128 : RegisterClass<[v2i64, v2f64],
- [XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
- XMM8, XMM9, XMM10, XMM11,
- XMM12, XMM13, XMM14, XMM15]>;
-
-// Define intrinsics
-def int_x86_sse2_add_ps : Intrinsic<"addps">;
-def int_x86_sse2_add_pd : Intrinsic<"addpd">;
-
-multiclass arith<bits<8> opcode, string asmstr, string Intr> {
- def PS : Inst<opcode, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
- !strconcat(asmstr, "\t$dst, $src1, $src2"),
- [(set VR128:$dst, (!nameconcat<Intrinsic>(Intr, "_ps") VR128:$src1, VR128:$src2))]>;
-
- def PD : Inst<opcode, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
- !strconcat(asmstr, "\t$dst, $src1, $src2"),
- [(set VR128:$dst, (!nameconcat<Intrinsic>(Intr, "_pd") VR128:$src1, VR128:$src2))]>;
-}
-
-defm ADD : arith<0x58, "add", "int_x86_sse2_add">;
-
-class IntInst<bits<8> opcode, string asmstr, Intrinsic Intr> :
- Inst<opcode,(outs VR128:$dst), (ins VR128:$src1, VR128:$src2),
- !strconcat(asmstr, "\t$dst, $src1, $src2"),
- [(set VR128:$dst, (Intr VR128:$src1, VR128:$src2))]>;
-
-
-multiclass arith_int<bits<8> opcode, string asmstr, string Intr> {
- def PS_Int : IntInst<opcode, asmstr, !nameconcat<Intrinsic>(Intr, "_ps")>;
-
- def PD_Int : IntInst<opcode, asmstr, !nameconcat<Intrinsic>(Intr, "_pd")>;
-}
-
-defm ADD : arith_int<0x58, "add", "int_x86_sse2_add">;