-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGARelOps.td
More file actions
224 lines (162 loc) · 5.18 KB
/
Copy pathGARelOps.td
File metadata and controls
224 lines (162 loc) · 5.18 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#ifndef GAREL_OPS
#define GAREL_OPS
/**
* Relation-level ops in the GARel dialect.
*
* See ./GARelTupleOps.td for the tuple-level ops.
*/
include "mlir/Interfaces/InferTypeOpInterface.td"
include "GARelDialect.td"
include "GARelTypes.td"
// Per-tuple ops kept in a separate file.
include "GARelTupleOps.td"
def ProjectOp : GARel_Op<"project", [IsolatedFromAbove]> {
let summary = "Remaps, reorders, drops and computes columns";
let arguments = (ins Relation:$input);
let regions = (region SizedRegion<1>:$projections);
let results = (outs Relation:$result);
let assemblyFormat = [{
$input `:` type($input) `->` type($result) $projections attr-dict
}];
let hasRegionVerifier = 1;
let extraClassDeclaration = [{
mlir::Block& createProjectionsBlock();
ProjectReturnOp getTerminator();
}];
}
def ProjectReturnOp : GARel_Op<"project.return", [
Terminator,
HasParent<"ProjectOp">]> {
let summary = "The output projections";
let arguments = (ins Variadic<ColumnType>:$projections);
let assemblyFormat = [{
$projections `:` type($projections) attr-dict
}];
// NOTE: verification performed by ProjectOp
}
def SelectOp : GARel_Op<"select", [
SameOperandsAndResultType,
IsolatedFromAbove]> {
let summary = "Removes tuples that fail (one of) the predicates";
let arguments = (ins Relation:$input);
let regions = (region SizedRegion<1>:$predicates);
let results = (outs Relation:$result);
let assemblyFormat = [{
$input `:` type($input) $predicates attr-dict
}];
let hasRegionVerifier = 1;
let extraClassDeclaration = [{
mlir::Block& createPredicatesBlock();
SelectReturnOp getTerminator();
}];
}
def SelectReturnOp : GARel_Op<"select.return", [
Terminator,
HasParent<"SelectOp">]> {
let summary = "Return the select predicates";
let arguments = (ins Variadic<I1>:$predicates);
let assemblyFormat = [{
$predicates attr-dict
}];
}
def JoinOp : GARel_Op<"join", [InferTypeOpAdaptor]> {
let summary = "Natural (equi)join of relations";
let arguments = (ins
// NOTE: All inputs must have distinct columns
Variadic<Relation>:$inputs,
// NOTE: Equality predicates only
JoinPredicates:$predicates);
let results = (outs Relation:$result);
let assemblyFormat = [{
$inputs `:` type($inputs)
$predicates
attr-dict
}];
let hasVerifier = 1;
let hasFolder = 1;
}
def UnionOp : GARel_Op<"union", [SameOperandsAndResultType]> {
let summary = "Union of relations";
let arguments = (ins Variadic<Relation>:$inputs);
let results = (outs Relation:$result);
let assemblyFormat = [{
$inputs `:` type($result)
attr-dict
}];
let hasFolder = 1;
}
def AggregateOp : GARel_Op<"aggregate", [InferTypeOpAdaptor]> {
let summary = "Groups tuples by key columns, aggregating values of other columns";
let arguments = (ins
Relation:$input,
DenseI32ArrayAttr:$groupBy,
Aggregators:$aggregators);
let results = (outs Relation:$result);
let assemblyFormat = [{
$input `:` type($input)
`group_by` `` `=` `` $groupBy
`aggregators` `` `=` `` $aggregators
attr-dict
}];
}
def ForOp : GARel_Op<"for", [InferTypeOpAdaptor]> {
let summary = "Bounded iteration";
let arguments = (ins
Variadic<Relation>:$init,
I64Relation:$iters,
I64Attr:$resultIdx);
let regions = (region
SizedRegion<1>:$body,
MaxSizedRegion<1>:$until);
let results = (outs Relation:$result);
let assemblyFormat = [{
$init `:` type($init)
`iters` `` `=` `` $iters
`result_idx` `` `=` `` $resultIdx
$body
(`until` $until^)?
attr-dict
}];
let hasVerifier = 1;
let hasRegionVerifier = 1;
}
def ForYieldOp : GARel_Op<"for.yield", [
Terminator,
HasParent<"ForOp">]> {
let summary = "Produces the iter args for the next iteration";
let arguments = (ins Variadic<Relation>:$inputs);
let assemblyFormat = [{
$inputs `:` type($inputs)
attr-dict
}];
// Note: verification performed by parent ForOp.
}
def RangeOp : GARel_Op<"range", [InferTypeOpAdaptor]> {
let summary = "generates a range of `index` values from `[0, size)`";
let arguments = (ins I64Attr:$size);
let results = (outs Relation:$result);
let assemblyFormat = [{
$size attr-dict
}];
}
def RemapOp : GARel_Op<"remap", [InferTypeOpAdaptor]> {
let summary = "reorders or drop columns";
let arguments = (ins Relation:$input, DenseI32ArrayAttr:$remap);
let results = (outs Relation:$result);
let assemblyFormat = [{
$input `:` type($input)
$remap
attr-dict
}];
let hasVerifier = 1;
let hasFolder = 1;
}
def ConstantOp : GARel_Op<"const", [InferTypeOpAdaptor]> {
let summary = "A relation with one constant-value tuple";
let arguments = (ins TypedAttrInterface:$value);
let results = (outs Relation:$result);
let assemblyFormat = [{
$value attr-dict
}];
}
#endif // GAREL_OPS