Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TableGen: Add !dag function for construction
This allows constructing DAG nodes with programmatically determined names, and can simplify constructing DAG nodes in other cases as well. Also, add documentation and some very simple tests for the already existing !con. Change-Id: Ida61cd82e99752548d7109ce8da34d29da56a5f7 Differential revision: https://reviews.llvm.org/D44110 llvm-svn: 327492
- Loading branch information
Showing
8 changed files
with
181 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// RUN: llvm-tblgen %s | FileCheck %s | ||
// XFAIL: vg_leak | ||
|
||
// CHECK: --- Defs --- | ||
|
||
// CHECK: def A0 { | ||
// CHECK: dag ret = (ops); | ||
// CHECK: } | ||
|
||
// CHECK: def A1 { | ||
// CHECK: dag ret = (ops 1:$a, 2:$b); | ||
// CHECK: } | ||
|
||
// CHECK: def A2 { | ||
// CHECK: dag ret = (ops (ops ?:$name):$a, (ops 1):$b, (ops "foo"):$c); | ||
// CHECK: } | ||
|
||
// CHECK: def A3 { | ||
// CHECK: dag ret = (ops NodeA0:$a, NodeB0:$b); | ||
// CHECK: } | ||
|
||
// CHECK: def A4 { | ||
// CHECK: dag ret = (ops NodeA0, NodeB0); | ||
// CHECK: } | ||
|
||
// CHECK: def B0 { | ||
// CHECK: dag ret = (ops); | ||
// CHECK: } | ||
|
||
// CHECK: def B1 { | ||
// CHECK: dag ret = (ops 1:$a, 2:$b); | ||
// CHECK: } | ||
|
||
// CHECK: def C0 { | ||
// CHECK: dag ret1 = (ops ?:$a, ?:$b); | ||
// CHECK: dag ret2 = (ops 1, 2); | ||
// CHECK: } | ||
|
||
def ops; | ||
|
||
class Node<int val, string name> { | ||
int Val = val; | ||
string Name = name; | ||
} | ||
|
||
class Aint<list<int> nodes, list<string> names> { | ||
dag ret = !dag(ops, nodes, names); | ||
} | ||
|
||
class Adag<list<dag> nodes, list<string> names> { | ||
dag ret = !dag(ops, nodes, names); | ||
} | ||
|
||
class NodeBase; | ||
|
||
class NodeA<int val> : NodeBase { | ||
int x = val; | ||
} | ||
|
||
class NodeB<int val> : NodeBase { | ||
int y = val; | ||
} | ||
|
||
class Anode<list<NodeBase> nodes, list<string> names> { | ||
dag ret = !dag(ops, nodes, names); | ||
} | ||
|
||
class B<list<Node> nodes> { | ||
dag ret = !foldl((ops), nodes, lhs, rhs, !con(lhs, !dag(ops, [rhs.Val], [rhs.Name]))); | ||
} | ||
|
||
def A0 : Aint<[], []>; | ||
def A1 : Aint<[1, 2], ["a", "b"]>; | ||
|
||
def A2 : Adag<[(ops $name), (ops 1), (ops "foo")], ["a", "b", "c"]>; | ||
|
||
def NodeA0 : NodeA<0>; | ||
def NodeB0 : NodeB<0>; | ||
|
||
def A3 : Anode<[NodeA0, NodeB0], ["a", "b"]>; | ||
|
||
def A4 { | ||
// Like A3, but with a literal list directly in the !dag. | ||
dag ret = !dag(ops, [NodeA0, NodeB0], ?); | ||
} | ||
|
||
def B0 : B<[]>; | ||
def B1 : B<[Node<1, "a">, Node<2, "b">]>; | ||
|
||
class C<list<int> nodes, list<string> names> { | ||
dag ret1 = !dag(ops, ?, names); | ||
dag ret2 = !dag(ops, nodes, ?); | ||
} | ||
|
||
def C0 : C<[1, 2], ["a", "b"]>; |