12
12
// ===----------------------------------------------------------------------===//
13
13
14
14
#include " X86ShuffleDecode.h"
15
+ #include " llvm/ADT/APInt.h"
15
16
#include " llvm/ADT/ArrayRef.h"
17
+ #include " llvm/ADT/SmallVector.h"
16
18
17
19
// ===----------------------------------------------------------------------===//
18
20
// Vector Mask Decoding
@@ -141,9 +143,6 @@ void DecodeVALIGNMask(unsigned NumElts, unsigned Imm,
141
143
ShuffleMask.push_back (i + Imm);
142
144
}
143
145
144
- // / DecodePSHUFMask - This decodes the shuffle masks for pshufw, pshufd, and vpermilp*.
145
- // / VT indicates the type of the vector allowing it to handle different
146
- // / datatypes and vector widths.
147
146
void DecodePSHUFMask (unsigned NumElts, unsigned ScalarBits, unsigned Imm,
148
147
SmallVectorImpl<int > &ShuffleMask) {
149
148
unsigned Size = NumElts * ScalarBits;
@@ -197,9 +196,6 @@ void DecodePSWAPMask(unsigned NumElts, SmallVectorImpl<int> &ShuffleMask) {
197
196
ShuffleMask.push_back (h);
198
197
}
199
198
200
- // / DecodeSHUFPMask - This decodes the shuffle masks for shufp*. VT indicates
201
- // / the type of the vector allowing it to handle different datatypes and vector
202
- // / widths.
203
199
void DecodeSHUFPMask (unsigned NumElts, unsigned ScalarBits,
204
200
unsigned Imm, SmallVectorImpl<int > &ShuffleMask) {
205
201
unsigned NumLaneElts = 128 / ScalarBits;
@@ -217,9 +213,6 @@ void DecodeSHUFPMask(unsigned NumElts, unsigned ScalarBits,
217
213
}
218
214
}
219
215
220
- // / DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd
221
- // / and punpckh*. VT indicates the type of the vector allowing it to handle
222
- // / different datatypes and vector widths.
223
216
void DecodeUNPCKHMask (unsigned NumElts, unsigned ScalarBits,
224
217
SmallVectorImpl<int > &ShuffleMask) {
225
218
// Handle 128 and 256-bit vector lengths. AVX defines UNPCK* to operate
@@ -236,9 +229,6 @@ void DecodeUNPCKHMask(unsigned NumElts, unsigned ScalarBits,
236
229
}
237
230
}
238
231
239
- // / DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd
240
- // / and punpckl*. VT indicates the type of the vector allowing it to handle
241
- // / different datatypes and vector widths.
242
232
void DecodeUNPCKLMask (unsigned NumElts, unsigned ScalarBits,
243
233
SmallVectorImpl<int > &ShuffleMask) {
244
234
// Handle 128 and 256-bit vector lengths. AVX defines UNPCK* to operate
@@ -255,13 +245,11 @@ void DecodeUNPCKLMask(unsigned NumElts, unsigned ScalarBits,
255
245
}
256
246
}
257
247
258
- // / Decodes a broadcast of the first element of a vector.
259
248
void DecodeVectorBroadcast (unsigned NumElts,
260
249
SmallVectorImpl<int > &ShuffleMask) {
261
250
ShuffleMask.append (NumElts, 0 );
262
251
}
263
252
264
- // / Decodes a broadcast of a subvector to a larger vector type.
265
253
void DecodeSubVectorBroadcast (unsigned DstNumElts, unsigned SrcNumElts,
266
254
SmallVectorImpl<int > &ShuffleMask) {
267
255
unsigned Scale = DstNumElts / SrcNumElts;
@@ -271,9 +259,6 @@ void DecodeSubVectorBroadcast(unsigned DstNumElts, unsigned SrcNumElts,
271
259
ShuffleMask.push_back (j);
272
260
}
273
261
274
- // / Decode a shuffle packed values at 128-bit granularity
275
- // / (SHUFF32x4/SHUFF64x2/SHUFI32x4/SHUFI64x2)
276
- // / immediate mask into a shuffle mask.
277
262
void decodeVSHUF64x2FamilyMask (unsigned NumElts, unsigned ScalarSize,
278
263
unsigned Imm,
279
264
SmallVectorImpl<int > &ShuffleMask) {
@@ -374,7 +359,6 @@ void DecodeVPPERMMask(ArrayRef<uint64_t> RawMask, const APInt &UndefElts,
374
359
}
375
360
}
376
361
377
- // / DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
378
362
void DecodeVPERMMask (unsigned NumElts, unsigned Imm,
379
363
SmallVectorImpl<int > &ShuffleMask) {
380
364
for (unsigned l = 0 ; l != NumElts; l += 4 )
@@ -384,32 +368,31 @@ void DecodeVPERMMask(unsigned NumElts, unsigned Imm,
384
368
385
369
void DecodeZeroExtendMask (unsigned SrcScalarBits, unsigned DstScalarBits,
386
370
unsigned NumDstElts, bool IsAnyExtend,
387
- SmallVectorImpl<int > &Mask ) {
371
+ SmallVectorImpl<int > &ShuffleMask ) {
388
372
unsigned Scale = DstScalarBits / SrcScalarBits;
389
373
assert (SrcScalarBits < DstScalarBits &&
390
374
" Expected zero extension mask to increase scalar size" );
391
375
376
+ int Sentinel = IsAnyExtend ? SM_SentinelUndef : SM_SentinelZero;
392
377
for (unsigned i = 0 ; i != NumDstElts; i++) {
393
- Mask.push_back (i);
394
- for (unsigned j = 1 ; j != Scale; j++)
395
- Mask.push_back (IsAnyExtend ? SM_SentinelUndef : SM_SentinelZero);
378
+ ShuffleMask.push_back (i);
379
+ ShuffleMask.append (Scale - 1 , Sentinel);
396
380
}
397
381
}
398
382
399
383
void DecodeZeroMoveLowMask (unsigned NumElts,
400
384
SmallVectorImpl<int > &ShuffleMask) {
401
385
ShuffleMask.push_back (0 );
402
- for (unsigned i = 1 ; i < NumElts; i++)
403
- ShuffleMask.push_back (SM_SentinelZero);
386
+ ShuffleMask.append (NumElts - 1 , SM_SentinelZero);
404
387
}
405
388
406
389
void DecodeScalarMoveMask (unsigned NumElts, bool IsLoad,
407
- SmallVectorImpl<int > &Mask ) {
390
+ SmallVectorImpl<int > &ShuffleMask ) {
408
391
// First element comes from the first element of second source.
409
392
// Remaining elements: Load zero extends / Move copies from first source.
410
- Mask .push_back (NumElts);
393
+ ShuffleMask .push_back (NumElts);
411
394
for (unsigned i = 1 ; i < NumElts; i++)
412
- Mask .push_back (IsLoad ? static_cast <int >(SM_SentinelZero) : i);
395
+ ShuffleMask .push_back (IsLoad ? static_cast <int >(SM_SentinelZero) : i);
413
396
}
414
397
415
398
void DecodeEXTRQIMask (unsigned NumElts, unsigned EltSize, int Len, int Idx,
0 commit comments