32 unsigned ZMask = Imm & 15;
33 unsigned CountD = (Imm >> 4) & 3;
34 unsigned CountS = (Imm >> 6) & 3;
37 unsigned InVal = 4 + CountS;
39 ShuffleMask[CountD] = InVal;
49 assert((Idx + Len) <= NumElts &&
"Insertion out of range");
51 for (
unsigned i = 0; i != NumElts; ++i)
53 for (
unsigned i = 0; i != Len; ++i)
54 ShuffleMask[Idx + i] = NumElts + i;
59 for (
unsigned i = NElts / 2; i != NElts; ++i)
62 for (
unsigned i = NElts / 2; i != NElts; ++i)
68 for (
unsigned i = 0; i != NElts / 2; ++i)
71 for (
unsigned i = 0; i != NElts / 2; ++i)
76 for (
int i = 0, e = NumElts / 2; i < e; ++i) {
83 for (
int i = 0, e = NumElts / 2; i < e; ++i) {
90 const unsigned NumLaneElts = 2;
92 for (
unsigned l = 0; l < NumElts; l += NumLaneElts)
93 for (
unsigned i = 0; i < NumLaneElts; ++i)
99 const unsigned NumLaneElts = 16;
101 for (
unsigned l = 0; l < NumElts; l += NumLaneElts)
102 for (
unsigned i = 0; i < NumLaneElts; ++i) {
104 if (i >= Imm) M = i - Imm + l;
111 const unsigned NumLaneElts = 16;
113 for (
unsigned l = 0; l < NumElts; l += NumLaneElts)
114 for (
unsigned i = 0; i < NumLaneElts; ++i) {
115 unsigned Base = i + Imm;
124 const unsigned NumLaneElts = 16;
126 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
127 for (
unsigned i = 0; i != NumLaneElts; ++i) {
128 unsigned Base = i + Imm;
130 if (Base >= NumLaneElts) Base += NumElts - NumLaneElts;
140 Imm = Imm & (NumElts - 1);
141 for (
unsigned i = 0; i != NumElts; ++i)
150 unsigned Size = NumElts * ScalarBits;
151 unsigned NumLanes = Size / 128;
152 if (NumLanes == 0) NumLanes = 1;
153 unsigned NumLaneElts = NumElts / NumLanes;
155 uint32_t SplatImm = (Imm & 0xff) * 0x01010101;
156 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
157 for (
unsigned i = 0; i != NumLaneElts; ++i) {
158 ShuffleMask.
push_back(SplatImm % NumLaneElts + l);
159 SplatImm /= NumLaneElts;
166 for (
unsigned l = 0; l != NumElts; l += 8) {
167 unsigned NewImm = Imm;
168 for (
unsigned i = 0, e = 4; i != e; ++i) {
171 for (
unsigned i = 4, e = 8; i != e; ++i) {
172 ShuffleMask.
push_back(l + 4 + (NewImm & 3));
180 for (
unsigned l = 0; l != NumElts; l += 8) {
181 unsigned NewImm = Imm;
182 for (
unsigned i = 0, e = 4; i != e; ++i) {
186 for (
unsigned i = 4, e = 8; i != e; ++i) {
193 unsigned NumHalfElts = NumElts / 2;
195 for (
unsigned l = 0; l != NumHalfElts; ++l)
197 for (
unsigned h = 0; h != NumHalfElts; ++h)
206 unsigned NumLaneElts = 128 / ScalarBits;
208 unsigned NewImm = Imm;
209 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
211 for (
unsigned s = 0; s != NumElts * 2; s += NumElts) {
212 for (
unsigned i = 0; i != NumLaneElts / 2; ++i) {
213 ShuffleMask.
push_back(NewImm % NumLaneElts + s + l);
214 NewImm /= NumLaneElts;
217 if (NumLaneElts == 4) NewImm = Imm;
228 unsigned NumLanes = (NumElts * ScalarBits) / 128;
229 if (NumLanes == 0) NumLanes = 1;
230 unsigned NumLaneElts = NumElts / NumLanes;
232 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
233 for (
unsigned i = l + NumLaneElts / 2, e = l + NumLaneElts; i != e; ++i) {
247 unsigned NumLanes = (NumElts * ScalarBits) / 128;
248 if (NumLanes == 0 ) NumLanes = 1;
249 unsigned NumLaneElts = NumElts / NumLanes;
251 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
252 for (
unsigned i = l, e = l + NumLaneElts / 2; i != e; ++i) {
262 ShuffleMask.
append(NumElts, 0);
268 unsigned Scale = DstNumElts / SrcNumElts;
270 for (
unsigned i = 0; i != Scale; ++i)
271 for (
unsigned j = 0; j != SrcNumElts; ++j)
281 unsigned NumElementsInLane = 128 / ScalarSize;
282 unsigned NumLanes = NumElts / NumElementsInLane;
284 for (
unsigned l = 0; l != NumElts; l += NumElementsInLane) {
285 unsigned Index = (Imm % NumLanes) * NumElementsInLane;
288 if (l >= (NumElts / 2))
290 for (
unsigned i = 0; i != NumElementsInLane; ++i)
297 unsigned HalfSize = NumElts / 2;
299 for (
unsigned l = 0; l != 2; ++l) {
300 unsigned HalfMask = Imm >> (l * 4);
301 unsigned HalfBegin = (HalfMask & 0x3) * HalfSize;
302 for (
unsigned i = HalfBegin, e = HalfBegin + HalfSize; i != e; ++i)
309 for (
int i = 0, e = RawMask.
size(); i < e; ++i) {
310 uint64_t M = RawMask[i];
317 int Base = (i / 16) * 16;
323 int Index = Base + (M & 0xf);
331 for (
unsigned i = 0; i < NumElts; ++i) {
334 unsigned Bit = i % 8;
335 ShuffleMask.
push_back(((Imm >> Bit) & 1) ? NumElts + i : i);
341 assert(RawMask.
size() == 16 &&
"Illegal VPPERM shuffle mask size");
356 for (
int i = 0, e = RawMask.
size(); i < e; ++i) {
362 uint64_t M = RawMask[i];
363 uint64_t PermuteOp = (M >> 5) & 0x7;
364 if (PermuteOp == 4) {
368 if (PermuteOp != 0) {
373 uint64_t
Index = M & 0x1F;
381 for (
unsigned l = 0; l != NumElts; l += 4)
382 for (
unsigned i = 0; i != 4; ++i)
383 ShuffleMask.
push_back(l + ((Imm >> (2 * i)) & 3));
388 unsigned Scale = DstScalarBits / SrcScalarBits;
389 assert(SrcScalarBits < DstScalarBits &&
390 "Expected zero extension mask to increase scalar size");
392 for (
unsigned i = 0; i != NumDstElts; i++) {
394 for (
unsigned j = 1; j != Scale; j++)
402 for (
unsigned i = 1; i < NumElts; i++)
411 for (
unsigned i = 1; i < NumElts; i++)
417 unsigned HalfElts = NumElts / 2;
425 if (0 != (Len % EltSize) || 0 != (Idx % EltSize))
433 if ((Len + Idx) > 64) {
444 for (
int i = 0; i != Len; ++i)
446 for (
int i = Len; i != (int)HalfElts; ++i)
448 for (
int i = HalfElts; i != (int)NumElts; ++i)
454 unsigned HalfElts = NumElts / 2;
462 if (0 != (Len % EltSize) || 0 != (Idx % EltSize))
470 if ((Len + Idx) > 64) {
482 for (
int i = 0; i != Idx; ++i)
484 for (
int i = 0; i != Len; ++i)
486 for (
int i = Idx + Len; i != (int)HalfElts; ++i)
488 for (
int i = HalfElts; i != (int)NumElts; ++i)
495 unsigned VecSize = NumElts * ScalarBits;
496 unsigned NumLanes = VecSize / 128;
497 unsigned NumEltsPerLane = NumElts / NumLanes;
498 assert((VecSize == 128 || VecSize == 256 || VecSize == 512) &&
499 "Unexpected vector size");
500 assert((ScalarBits == 32 || ScalarBits == 64) &&
"Unexpected element size");
502 for (
unsigned i = 0, e = RawMask.
size(); i < e; ++i) {
507 uint64_t M = RawMask[i];
508 M = (ScalarBits == 64 ? ((M >> 1) & 0x1) : (M & 0x3));
509 unsigned LaneOffset = i & ~(NumEltsPerLane - 1);
510 ShuffleMask.
push_back((
int)(LaneOffset + M));
517 unsigned VecSize = NumElts * ScalarBits;
518 unsigned NumLanes = VecSize / 128;
519 unsigned NumEltsPerLane = NumElts / NumLanes;
520 assert((VecSize == 128 || VecSize == 256) &&
"Unexpected vector size");
521 assert((ScalarBits == 32 || ScalarBits == 64) &&
"Unexpected element size");
522 assert((NumElts == RawMask.
size()) &&
"Unexpected mask size");
524 for (
unsigned i = 0, e = RawMask.
size(); i < e; ++i) {
534 uint64_t Selector = RawMask[i];
535 unsigned MatchBit = (Selector >> 3) & 0x1;
543 if ((M2Z & 0x2) != 0 && MatchBit != (M2Z & 0x1)) {
548 int Index = i & ~(NumEltsPerLane - 1);
549 if (ScalarBits == 64)
550 Index += (Selector >> 1) & 0x1;
552 Index += Selector & 0x3;
554 int Src = (Selector >> 2) & 0x1;
555 Index += Src * NumElts;
562 uint64_t EltMaskSize = RawMask.
size() - 1;
563 for (
int i = 0, e = RawMask.
size(); i != e; ++i) {
568 uint64_t M = RawMask[i];
576 uint64_t EltMaskSize = (RawMask.
size() * 2) - 1;
577 for (
int i = 0, e = RawMask.
size(); i != e; ++i) {
582 uint64_t M = RawMask[i];
This class represents lattice values for constants.
void DecodeVPPERMMask(ArrayRef< uint64_t > RawMask, const APInt &UndefElts, SmallVectorImpl< int > &ShuffleMask)
Decode a VPPERM mask from a raw array of constants such as from BUILD_VECTOR.
void DecodeVPERMV3Mask(ArrayRef< uint64_t > RawMask, const APInt &UndefElts, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMT2 W/D/Q/PS/PD mask from a raw array of constants.
void push_back(const T &Elt)
void DecodeVectorBroadcast(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
Decodes a broadcast of the first element of a vector.
void DecodePSLLDQMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodePSHUFMask(unsigned NumElts, unsigned ScalarBits, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
DecodePSHUFMask - This decodes the shuffle masks for pshufw, pshufd, and vpermilp*.
void DecodeZeroMoveLowMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
Decode a move lower and zero upper instruction as a shuffle mask.
void DecodeUNPCKHMask(unsigned NumElts, unsigned ScalarBits, SmallVectorImpl< int > &ShuffleMask)
DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd and punpckh*.
void DecodeVPERMILPMask(unsigned NumElts, unsigned ScalarBits, ArrayRef< uint64_t > RawMask, const APInt &UndefElts, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMILPD/VPERMILPS variable mask from a raw array of constants.
void DecodeMOVDDUPMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
void DecodeVPERM2X128Mask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeEXTRQIMask(unsigned NumElts, unsigned EltSize, int Len, int Idx, SmallVectorImpl< int > &ShuffleMask)
Decode a SSE4A EXTRQ instruction as a shuffle mask.
void DecodeMOVSHDUPMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
void DecodeVALIGNMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodePSHUFLWMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decodes the shuffle masks for pshuflw.
void DecodeUNPCKLMask(unsigned NumElts, unsigned ScalarBits, SmallVectorImpl< int > &ShuffleMask)
DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd and punpckl*.
void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl< int > &ShuffleMask)
Decode a MOVLHPS instruction as a v2f64/v4f32 shuffle mask.
void DecodeZeroExtendMask(unsigned SrcScalarBits, unsigned DstScalarBits, unsigned NumDstElts, SmallVectorImpl< int > &Mask)
Decode a zero extension instruction as a shuffle mask.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
size_t size() const
size - Get the array size.
void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decode a 128-bit INSERTPS instruction as a v4f32 shuffle mask.
void DecodeBLENDMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decode a BLEND immediate mask into a shuffle mask.
void decodeVSHUF64x2FamilyMask(unsigned NumElts, unsigned ScalarSize, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decode a shuffle packed values at 128-bit granularity (SHUFF32x4/SHUFF64x2/SHUFI32x4/SHUFI64x2) immed...
void DecodeMOVSLDUPMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
void DecodeVPERMIL2PMask(unsigned NumElts, unsigned ScalarBits, unsigned M2Z, ArrayRef< uint64_t > RawMask, const APInt &UndefElts, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMIL2PD/VPERMIL2PS variable mask from a raw array of constants.
void DecodeINSERTQIMask(unsigned NumElts, unsigned EltSize, int Len, int Idx, SmallVectorImpl< int > &ShuffleMask)
Decode a SSE4A INSERTQ instruction as a shuffle mask.
void DecodeVPERMMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
Class for arbitrary precision integers.
void DecodePSHUFHWMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decodes the shuffle masks for pshufhw.
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
void DecodeScalarMoveMask(unsigned NumElts, bool IsLoad, SmallVectorImpl< int > &Mask)
Decode a scalar float move instruction as a shuffle mask.
void DecodePSRLDQMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeSHUFPMask(unsigned NumElts, unsigned ScalarBits, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
DecodeSHUFPMask - This decodes the shuffle masks for shufp*.
void DecodeInsertElementMask(unsigned NumElts, unsigned Idx, unsigned Len, SmallVectorImpl< int > &ShuffleMask)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
void DecodePSWAPMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
Decodes a PSWAPD 3DNow! instruction.
void DecodeSubVectorBroadcast(unsigned DstNumElts, unsigned SrcNumElts, SmallVectorImpl< int > &ShuffleMask)
Decodes a broadcast of a subvector to a larger vector type.
void DecodePALIGNRMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl< int > &ShuffleMask)
Decode a MOVHLPS instruction as a v2f64/v4f32 shuffle mask.
void DecodeVPERMVMask(ArrayRef< uint64_t > RawMask, const APInt &UndefElts, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERM W/D/Q/PS/PD mask from a raw array of constants.
void DecodePSHUFBMask(ArrayRef< uint64_t > RawMask, const APInt &UndefElts, SmallVectorImpl< int > &ShuffleMask)
Decode a PSHUFB mask from a raw array of constants such as from BUILD_VECTOR.