1 // RUN: llvm-tblgen %s | FileCheck %s
7 // CHECK: dag ret = (ops);
11 // CHECK: dag ret = (ops ?:$a, 1:$b, 2);
15 // CHECK: dag ret = (ops (ops ?:$name):$a, (ops 1):$b, (ops "foo"):$c);
19 // CHECK: dag ret = (ops NodeA0:$a, NodeB0:$b);
23 // CHECK: dag ret = (ops NodeA0, NodeB0);
27 // CHECK: dag ret = (ops);
31 // CHECK: dag ret = (ops 1:$a, 2:$b);
35 // CHECK: dag ret1 = (ops ?:$a, ?:$b);
36 // CHECK: dag ret2 = (ops 1, 2);
40 // CHECK: dag d1 = (ops 1, ?:$name1, 2, 3);
44 // CHECK: dag ret = (ops 1, 2);
51 class Node<int val, string name> {
56 class Aint<list<int> nodes, list<string> names> {
57 dag ret = !dag(ops, nodes, names);
60 class Adag<list<dag> nodes, list<string> names> {
61 dag ret = !dag(ops, nodes, names);
66 class NodeA<int val> : NodeBase {
70 class NodeB<int val> : NodeBase {
74 class Anode<list<NodeBase> nodes, list<string> names> {
75 dag ret = !dag(ops, nodes, names);
78 class B<list<Node> nodes> {
79 dag ret = !foldl((ops), nodes, lhs, rhs, !con(lhs, !dag(ops, [rhs.Val], [rhs.Name])));
82 def A0 : Aint<[], []>;
83 def A1 : Aint<[?, 1, 2], ["a", "b", ?]>;
85 def A2 : Adag<[(ops $name), (ops 1), (ops "foo")], ["a", "b", "c"]>;
87 def NodeA0 : NodeA<0>;
88 def NodeB0 : NodeB<0>;
90 def A3 : Anode<[NodeA0, NodeB0], ["a", "b"]>;
93 // Like A3, but with a literal list directly in the !dag.
94 dag ret = !dag(ops, [NodeA0, NodeB0], ?);
98 def B1 : B<[Node<1, "a">, Node<2, "b">]>;
100 class C<list<int> nodes, list<string> names> {
101 dag ret1 = !dag(ops, ?, names);
102 dag ret2 = !dag(ops, nodes, ?);
105 def C0 : C<[1, 2], ["a", "b"]>;
108 dag d1 = !con((ops 1), (ops $name1), (ops), (ops 2, 3));
112 // Allow concatenation of DAG nodes with operators from template arguments.
113 dag ret = !con((op 1), (op 2));