16
16
//
17
17
//===----------------------------------------------------------------------===//
18
18
19
- multiclass VectorBinaryArith<
20
- SDPatternOperator OpNode,
21
- ValueType ScalarVT, ValueType DataVT, ValueType MaskVT,
22
- string OpBaseName> {
23
- // No mask.
24
- def : Pat<(OpNode
25
- (any_broadcast ScalarVT:$sx),
26
- DataVT:$vy, (MaskVT true_mask), i32:$avl),
27
- (!cast<Instruction>(OpBaseName#"rvl")
28
- ScalarVT:$sx, $vy, $avl)>;
29
- def : Pat<(OpNode DataVT:$vx, DataVT:$vy, (MaskVT true_mask), i32:$avl),
30
- (!cast<Instruction>(OpBaseName#"vvl")
31
- $vx, $vy, $avl)>;
32
-
33
- // Mask.
34
- def : Pat<(OpNode
35
- (any_broadcast ScalarVT:$sx),
36
- DataVT:$vy, MaskVT:$mask, i32:$avl),
37
- (!cast<Instruction>(OpBaseName#"rvml")
38
- ScalarVT:$sx, $vy, $mask, $avl)>;
39
- def : Pat<(OpNode DataVT:$vx, DataVT:$vy, MaskVT:$mask, i32:$avl),
40
- (!cast<Instruction>(OpBaseName#"vvml")
41
- $vx, $vy, $mask, $avl)>;
42
-
43
- // TODO We do not specify patterns for the immediate variants here. There
44
- // will be an immediate folding pass that takes care of switching to the
45
- // immediate variant where applicable.
46
-
47
- // TODO Fold vvp_select into passthru.
48
- }
49
-
50
- // Expand both 64bit and 32 bit variant (256 elements)
51
- multiclass VectorBinaryArith_ShortLong<
52
- SDPatternOperator OpNode,
53
- ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName,
54
- ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
55
- defm : VectorBinaryArith<OpNode,
56
- LongScalarVT, LongDataVT, v256i1,
57
- LongOpBaseName>;
58
- defm : VectorBinaryArith<OpNode,
59
- ShortScalarVT, ShortDataVT, v256i1,
60
- ShortOpBaseName>;
61
- }
62
-
63
-
64
- defm : VectorBinaryArith_ShortLong<c_vvp_add,
65
- i64, v256i64, "VADDSL",
66
- i32, v256i32, "VADDSWSX">;
67
- defm : VectorBinaryArith_ShortLong<c_vvp_and,
68
- i64, v256i64, "VAND",
69
- i32, v256i32, "PVANDLO">;
70
19
71
20
// Vector Gather and scatter
72
21
multiclass VectorGather<ValueType DataVT, ValueType PtrVT, ValueType MaskVT, string GTPrefix> {
@@ -206,7 +155,12 @@ multiclass Unary_ShortLong<SDPatternOperator OpNode, ValueType LongScalarVT, Val
206
155
207
156
208
157
209
- multiclass Binary_rv<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
158
+
159
+ // Expand both 64bit and 32 bit variant (256 elements)
160
+
161
+ multiclass Binary_rv<SDPatternOperator OpNode,
162
+ ValueType ScalarVT, ValueType DataVT,
163
+ ValueType MaskVT, string OpBaseName> {
210
164
// Masked with select, broadcast.
211
165
def : Pat<(vvp_select (OpNode (any_broadcast ScalarVT:$sx), DataVT:$vy, (MaskVT srcvalue), (i32 srcvalue)),
212
166
DataVT:$vfalse,
@@ -221,7 +175,9 @@ multiclass Binary_rv<SDPatternOperator OpNode, ValueType ScalarVT, ValueType Dat
221
175
(!cast<Instruction>(OpBaseName#"rvml") ScalarVT:$sx, $vy, $mask, $avl)>;
222
176
}
223
177
224
- multiclass Binary_vr<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
178
+ multiclass Binary_vr<SDPatternOperator OpNode,
179
+ ValueType ScalarVT, ValueType DataVT,
180
+ ValueType MaskVT, string OpBaseName> {
225
181
// Masked with select, broadcast.
226
182
def : Pat<(vvp_select (OpNode DataVT:$vx, (DataVT (any_broadcast ScalarVT:$sy)), (MaskVT srcvalue), (i32 srcvalue)),
227
183
DataVT:$vfalse,
@@ -236,7 +192,9 @@ multiclass Binary_vr<SDPatternOperator OpNode, ValueType ScalarVT, ValueType Dat
236
192
(!cast<Instruction>(OpBaseName#"vrml") $vx, ScalarVT:$sy, $mask, $avl)>;
237
193
}
238
194
239
- multiclass Binary_vv<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
195
+ multiclass Binary_vv<SDPatternOperator OpNode,
196
+ ValueType DataVT,
197
+ ValueType MaskVT, string OpBaseName> {
240
198
// Masked with select.
241
199
def : Pat<(vvp_select (OpNode DataVT:$vx, DataVT:$vy, (MaskVT srcvalue), (i32 srcvalue)),
242
200
DataVT:$vfalse,
@@ -254,37 +212,60 @@ multiclass Binary_vv<SDPatternOperator OpNode, ValueType ScalarVT, ValueType Dat
254
212
}
255
213
256
214
// Binary operators that support broadcasts only on RHS.
257
- multiclass Binary_vr_vv<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
215
+ multiclass Binary_vr_vv<
216
+ SDPatternOperator OpNode,
217
+ ValueType ScalarVT, ValueType DataVT, ValueType MaskVT,
218
+ string OpBaseName> {
258
219
defm : Binary_vr<OpNode, ScalarVT, DataVT, MaskVT, OpBaseName>;
259
- defm : Binary_vv<OpNode, ScalarVT, DataVT, MaskVT, OpBaseName>;
220
+ defm : Binary_vv<OpNode, DataVT, MaskVT, OpBaseName>;
260
221
}
261
222
multiclass Binary_vr_vv_ShortLong<SDPatternOperator OpNode, ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName, ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
262
223
defm : Binary_vr_vv<OpNode, LongScalarVT, LongDataVT, v256i1, LongOpBaseName>;
263
224
defm : Binary_vr_vv<OpNode, ShortScalarVT, ShortDataVT, v256i1, ShortOpBaseName>;
264
225
}
265
226
266
227
// Binary operators that support broadcasts only on LHS.
267
- multiclass Binary_rv_vv<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
228
+ multiclass Binary_rv_vv<
229
+ SDPatternOperator OpNode,
230
+ ValueType ScalarVT, ValueType DataVT, ValueType MaskVT,
231
+ string OpBaseName> {
268
232
defm : Binary_rv<OpNode, ScalarVT, DataVT, MaskVT, OpBaseName>;
269
- defm : Binary_vv<OpNode, ScalarVT, DataVT, MaskVT, OpBaseName>;
233
+ defm : Binary_vv<OpNode, DataVT, MaskVT, OpBaseName>;
270
234
}
271
- multiclass Binary_rv_vv_ShortLong<SDPatternOperator OpNode, ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName, ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
272
- defm : Binary_rv_vv<OpNode, LongScalarVT, LongDataVT, v256i1, LongOpBaseName>;
273
- defm : Binary_rv_vv<OpNode, ShortScalarVT, ShortDataVT, v256i1, ShortOpBaseName>;
235
+
236
+ multiclass Binary_rv_vv_ShortLong<
237
+ SDPatternOperator OpNode,
238
+ ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName,
239
+ ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
240
+ defm : Binary_rv_vv<OpNode,
241
+ LongScalarVT, LongDataVT, v256i1,
242
+ LongOpBaseName>;
243
+ defm : Binary_rv_vv<OpNode,
244
+ ShortScalarVT, ShortDataVT, v256i1,
245
+ ShortOpBaseName>;
274
246
}
275
247
276
248
// Binary operators that support broadcasts on LHS and RHS.
277
- multiclass Binary_all<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
249
+ multiclass Binary_all<
250
+ SDPatternOperator OpNode,
251
+ ValueType ScalarVT, ValueType DataVT,
252
+ ValueType MaskVT, string OpBaseName> {
278
253
defm : Binary_rv<OpNode, ScalarVT, DataVT, MaskVT, OpBaseName>;
279
254
defm : Binary_vr_vv<OpNode, ScalarVT, DataVT, MaskVT, OpBaseName>;
280
255
}
281
- multiclass Binary_ShortLong<SDPatternOperator OpNode, ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName, ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
256
+
257
+ multiclass Binary_ShortLong<
258
+ SDPatternOperator OpNode,
259
+ ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName,
260
+ ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
282
261
defm : Binary_all<OpNode, LongScalarVT, LongDataVT, v256i1, LongOpBaseName>;
283
262
defm : Binary_all<OpNode, ShortScalarVT, ShortDataVT, v256i1, ShortOpBaseName>;
284
263
}
285
264
286
-
287
- multiclass Ternary<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, string OpBaseName> {
265
+ multiclass Ternary<
266
+ SDPatternOperator OpNode,
267
+ ValueType ScalarVT, ValueType DataVT,
268
+ ValueType MaskVT, string OpBaseName> {
288
269
//// Mask + vvp_select /////
289
270
// with mask, broadcast first
290
271
def : Pat<(vvp_select
@@ -330,7 +311,10 @@ multiclass Ternary<SDPatternOperator OpNode, ValueType ScalarVT, ValueType DataV
330
311
}
331
312
332
313
// Expand both 64bit and 32 bit variant (256 elements)
333
- multiclass Ternary_ShortLong<SDPatternOperator OpNode, ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName, ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
314
+ multiclass Ternary_ShortLong<
315
+ SDPatternOperator OpNode,
316
+ ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName,
317
+ ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
334
318
defm : Ternary<OpNode, LongScalarVT, LongDataVT, v256i1, LongOpBaseName>;
335
319
defm : Ternary<OpNode, ShortScalarVT, ShortDataVT, v256i1, ShortOpBaseName>;
336
320
}
@@ -339,21 +323,32 @@ multiclass Ternary_ShortLong<SDPatternOperator OpNode, ValueType LongScalarVT, V
339
323
// Integer arithmetic (256 elements)
340
324
defm : Unary_ShortLong<vvp_ctpop, i64, v256i64, "VPCNT", i32, v256i32, "PVPCNTLO">;
341
325
342
- defm : Binary_rv_vv_ShortLong<c_vvp_add, i64, v256i64, "VADDSL", i32, v256i32, "VADDSWSX">;
326
+ defm : Binary_rv_vv_ShortLong<c_vvp_add,
327
+ i64, v256i64, "VADDSL",
328
+ i32, v256i32, "VADDSWSX">;
329
+ defm : Binary_rv_vv_ShortLong<vvp_sub,
330
+ i64, v256i64, "VSUBSL",
331
+ i32, v256i32, "VSUBSWSX">;
332
+ defm : Binary_rv_vv_ShortLong<c_vvp_mul,
333
+ i64, v256i64, "VMULSL",
334
+ i32, v256i32, "VMULSWSX">;
335
+ defm : Binary_rv_vv_ShortLong<c_vvp_and,
336
+ i64, v256i64, "VAND",
337
+ i32, v256i32, "PVANDLO">;
338
+ defm : Binary_rv_vv_ShortLong<c_vvp_or,
339
+ i64, v256i64, "VOR",
340
+ i32, v256i32, "PVORLO">;
341
+ defm : Binary_rv_vv_ShortLong<c_vvp_xor,
342
+ i64, v256i64, "VXOR",
343
+ i32, v256i32, "PVXORLO">;
343
344
344
- defm : Binary_rv_vv_ShortLong<vvp_sub, i64, v256i64, "VSUBSL", i32, v256i32, "VSUBSWSX">;
345
- defm : Binary_rv_vv_ShortLong<c_vvp_mul, i64, v256i64, "VMULSL", i32, v256i32, "VMULSWSX">;
346
345
defm : Binary_ShortLong<vvp_sdiv, i64, v256i64, "VDIVSL", i32, v256i32, "VDIVSWSX">;
347
346
defm : Binary_ShortLong<vvp_udiv, i64, v256i64, "VDIVUL", i32, v256i32, "VDIVUW">;
348
347
349
348
defm : Binary_vr_vv_ShortLong<vvp_srl, i64, v256i64, "VSRL", i32, v256i32, "PVSRLLO">;
350
349
defm : Binary_vr_vv_ShortLong<vvp_sra, i64, v256i64, "VSRAL", i32, v256i32, "PVSRALO">;
351
350
defm : Binary_vr_vv_ShortLong<vvp_shl, i64, v256i64, "VSLL", i32, v256i32, "PVSLLLO">;
352
351
353
- defm : Binary_rv_vv_ShortLong<c_vvp_and, i64, v256i64, "VAND", i32, v256i32, "PVANDLO">;
354
- defm : Binary_rv_vv_ShortLong<c_vvp_xor, i64, v256i64, "VXOR", i32, v256i32, "PVXORLO">;
355
- defm : Binary_rv_vv_ShortLong<c_vvp_or, i64, v256i64, "VOR", i32, v256i32, "PVORLO">;
356
-
357
352
// Floating-point arithmetic (256 elements)
358
353
defm : Unary_ShortLong<vvp_frcp, f64, v256f64, "VRCPD", f32, v256f32, "VRCPS">;
359
354
defm : Unary_ShortLong<vvp_fsqrt, f64, v256f64, "VFSQRTD", f32, v256f32, "VFSQRTS">;
0 commit comments