File: dag-functional.td

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (116 lines) | stat: -rw-r--r-- 2,262 bytes parent folder | download | duplicates (26)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// 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 ?:$a, 1:$b, 2);
// 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: }

// CHECK: def D {
// CHECK:   dag d1 = (ops 1, ?:$name1, 2, 3);
// CHECK: }

// CHECK: def E0 {
// CHECK:   dag ret = (ops 1, 2);
// CHECK: }

class Ops;

def ops : 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"]>;

def D {
  dag d1 = !con((ops 1), (ops $name1), (ops), (ops 2, 3));
}

class E<Ops op> {
  // Allow concatenation of DAG nodes with operators from template arguments.
  dag ret = !con((op 1), (op 2));
}

def E0 : E<ops>;