[OCaml] Expose Llvm_bitwriter.write_bitcode_to_memory_buffer.
[oota-llvm.git] / test / TableGen / SetTheory.td
1 // Test evaluation of set operations in dags.
2 // RUN: llvm-tblgen -print-sets %s | FileCheck %s
3 // XFAIL: vg_leak
4 //
5 // The -print-sets driver configures a primitive SetTheory instance that
6 // understands these sets:
7
8 class Set<dag d> {
9   dag Elements = d;
10 }
11
12 // It prints all Set instances and their ordered set interpretation.
13
14 // Define some elements.
15 def a;
16 def b;
17 def c;
18 def d;
19
20 // The 'add' operator evaluates and concatenates its arguments.
21 def add;
22 def S0a : Set<(add)>;
23 def S0b : Set<(add a)>;
24 def S0c : Set<(add a, b)>;
25 def S0d : Set<(add b, a)>;
26 def S0e : Set<(add a, a)>;
27 def S0f : Set<(add a, a, b, a, c, b, d, a)>;
28 def S0g : Set<(add b, a, b)>;
29 // CHECK: S0a = [ ]
30 // CHECK: S0b = [ a ]
31 // CHECK: S0c = [ a b ]
32 // CHECK: S0d = [ b a ]
33 // CHECK: S0e = [ a ]
34 // CHECK: S0f = [ a b c d ]
35 // CHECK: S0g = [ b a ]
36
37 // Defs of Set class expand into their elements.
38 // Mixed sets and elements are flattened.
39 def S1a : Set<(add S0a)>;
40 def S1b : Set<(add S0a, S0a)>;
41 def S1c : Set<(add S0d, S0f)>;
42 def S1d : Set<(add d, S0d, S0f)>;
43 // CHECK: S1a = [ ]
44 // CHECK: S1b = [ ]
45 // CHECK: S1c = [ b a c d ]
46 // CHECK: S1d = [ d b a c ]
47
48 // The 'sub' operator returns the first argument with the following arguments
49 // removed.
50 def sub;
51 def S2a : Set<(sub S1a, S1c)>;
52 def S2b : Set<(sub S1c, S1d)>;
53 def S2c : Set<(sub S1c, b)>;
54 def S2d : Set<(sub S1c, S0c)>;
55 def S2e : Set<(sub S1c, S2d)>;
56 // CHECK: S2a = [ ]
57 // CHECK: S2b = [ ]
58 // CHECK: S2c = [ a c d ]
59 // CHECK: S2d = [ c d ]
60 // CHECK: S2e = [ b a ]
61
62 // The 'and' operator intersects two sets. The result has the same order as the
63 // first argument.
64 def and;
65 def S3a : Set<(and S2d, S2e)>;
66 def S3b : Set<(and S2d, S1d)>;
67 // CHECK: S3a = [ ]
68 // CHECK: S3b = [ c d ]
69
70 // The 'shl' operator removes the first N elements.
71 def shl;
72 def S4a : Set<(shl S0f, 0)>;
73 def S4b : Set<(shl S0f, 1)>;
74 def S4c : Set<(shl S0f, 3)>;
75 def S4d : Set<(shl S0f, 4)>;
76 def S4e : Set<(shl S0f, 5)>;
77 // CHECK: S4a = [ a b c d ]
78 // CHECK: S4b = [ b c d ]
79 // CHECK: S4c = [ d ]
80 // CHECK: S4d = [ ]
81 // CHECK: S4e = [ ]
82
83 // The 'trunc' operator truncates after the first N elements.
84 def trunc;
85 def S5a : Set<(trunc S0f, 0)>;
86 def S5b : Set<(trunc S0f, 1)>;
87 def S5c : Set<(trunc S0f, 3)>;
88 def S5d : Set<(trunc S0f, 4)>;
89 def S5e : Set<(trunc S0f, 5)>;
90 // CHECK: S5a = [ ]
91 // CHECK: S5b = [ a ]
92 // CHECK: S5c = [ a b c ]
93 // CHECK: S5d = [ a b c d ]
94 // CHECK: S5e = [ a b c d ]
95
96 // The 'rotl' operator rotates left, but also accepts a negative shift.
97 def rotl;
98 def S6a : Set<(rotl S0f, 0)>;
99 def S6b : Set<(rotl S0f, 1)>;
100 def S6c : Set<(rotl S0f, 3)>;
101 def S6d : Set<(rotl S0f, 4)>;
102 def S6e : Set<(rotl S0f, 5)>;
103 def S6f : Set<(rotl S0f, -1)>;
104 def S6g : Set<(rotl S0f, -4)>;
105 def S6h : Set<(rotl S0f, -5)>;
106 // CHECK: S6a = [ a b c d ]
107 // CHECK: S6b = [ b c d a ]
108 // CHECK: S6c = [ d a b c ]
109 // CHECK: S6d = [ a b c d ]
110 // CHECK: S6e = [ b c d a ]
111 // CHECK: S6f = [ d a b c ]
112 // CHECK: S6g = [ a b c d ]
113 // CHECK: S6h = [ d a b c ]
114
115 // The 'rotr' operator rotates right, but also accepts a negative shift.
116 def rotr;
117 def S7a : Set<(rotr S0f, 0)>;
118 def S7b : Set<(rotr S0f, 1)>;
119 def S7c : Set<(rotr S0f, 3)>;
120 def S7d : Set<(rotr S0f, 4)>;
121 def S7e : Set<(rotr S0f, 5)>;
122 def S7f : Set<(rotr S0f, -1)>;
123 def S7g : Set<(rotr S0f, -4)>;
124 def S7h : Set<(rotr S0f, -5)>;
125 // CHECK: S7a = [ a b c d ]
126 // CHECK: S7b = [ d a b c ]
127 // CHECK: S7c = [ b c d a ]
128 // CHECK: S7d = [ a b c d ]
129 // CHECK: S7e = [ d a b c ]
130 // CHECK: S7f = [ b c d a ]
131 // CHECK: S7g = [ a b c d ]
132 // CHECK: S7h = [ b c d a ]
133
134 // The 'decimate' operator picks every N'th element.
135 def decimate;
136 def e0;
137 def e1;
138 def e2;
139 def e3;
140 def e4;
141 def e5;
142 def e6;
143 def e7;
144 def e8;
145 def e9;
146 def E : Set<(add e0, e1, e2, e3, e4, e5, e6, e7, e8, e9)>;
147 def S8a : Set<(decimate E, 3)>;
148 def S8b : Set<(decimate E, 9)>;
149 def S8c : Set<(decimate E, 10)>;
150 def S8d : Set<(decimate (rotl E, 1), 2)>;
151 def S8e : Set<(add (decimate E, 2), (decimate (rotl E, 1), 2))>;
152 // CHECK: S8a = [ e0 e3 e6 e9 ]
153 // CHECK: S8b = [ e0 e9 ]
154 // CHECK: S8c = [ e0 ]
155 // CHECK: S8d = [ e1 e3 e5 e7 e9 ]
156 // CHECK: S8e = [ e0 e2 e4 e6 e8 e1 e3 e5 e7 e9 ]
157
158 // The 'sequence' operator finds a sequence of records from their name.
159 def sequence;
160 def S9a : Set<(sequence "e%u", 3, 7)>;
161 def S9b : Set<(sequence "e%u", 7, 3)>;
162 def S9c : Set<(sequence "e%u", 0, 0)>;
163 def S9d : Set<(sequence "S%ua", 7, 9)>;
164 def S9e : Set<(sequence "e%u", 3, 6, 2)>;
165 // CHECK: S9a = [ e3 e4 e5 e6 e7 ]
166 // CHECK: S9b = [ e7 e6 e5 e4 e3 ]
167 // CHECK: S9c = [ e0 ]
168 // CHECK: S9d = [ a b c d e0 e3 e6 e9 e4 e5 e7 ]
169 // CHECK: S9e = [ e3 e5 ]
170
171 // The 'interleave' operator is almost the inverse of 'decimate'.
172 def interleave;
173 def T0a : Set<(interleave S9a, S9b)>;
174 def T0b : Set<(interleave S8e, S8d)>;
175 // CHECK: T0a = [ e3 e7 e4 e6 e5 ]
176 // CHECK: T0b = [ e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ]