34 unsigned ZMask = Imm & 15;
35 unsigned CountD = (Imm >> 4) & 3;
36 unsigned CountS = (Imm >> 6) & 3;
39 unsigned InVal = 4 + CountS;
41 ShuffleMask[CountD] = InVal;
51 assert((
Idx + Len) <= NumElts &&
"Insertion out of range");
53 for (
unsigned i = 0; i != NumElts; ++i)
55 for (
unsigned i = 0; i != Len; ++i)
56 ShuffleMask[
Idx + i] = NumElts + i;
61 for (
unsigned i = NElts / 2; i != NElts; ++i)
64 for (
unsigned i = NElts / 2; i != NElts; ++i)
70 for (
unsigned i = 0; i != NElts / 2; ++i)
73 for (
unsigned i = 0; i != NElts / 2; ++i)
78 for (
int i = 0, e = NumElts / 2; i < e; ++i) {
85 for (
int i = 0, e = NumElts / 2; i < e; ++i) {
92 const unsigned NumLaneElts = 2;
94 for (
unsigned l = 0; l < NumElts; l += NumLaneElts)
95 for (
unsigned i = 0; i < NumLaneElts; ++i)
101 const unsigned NumLaneElts = 16;
103 for (
unsigned l = 0; l < NumElts; l += NumLaneElts)
104 for (
unsigned i = 0; i < NumLaneElts; ++i) {
106 if (i >= Imm) M = i - Imm + l;
113 const unsigned NumLaneElts = 16;
115 for (
unsigned l = 0; l < NumElts; l += NumLaneElts)
116 for (
unsigned i = 0; i < NumLaneElts; ++i) {
117 unsigned Base = i + Imm;
126 const unsigned NumLaneElts = 16;
128 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
129 for (
unsigned i = 0; i != NumLaneElts; ++i) {
130 unsigned Base = i + Imm;
132 if (
Base >= NumLaneElts)
Base += NumElts - NumLaneElts;
142 Imm = Imm & (NumElts - 1);
143 for (
unsigned i = 0; i != NumElts; ++i)
149 unsigned Size = NumElts * ScalarBits;
150 unsigned NumLanes =
Size / 128;
151 if (NumLanes == 0) NumLanes = 1;
152 unsigned NumLaneElts = NumElts / NumLanes;
154 uint32_t SplatImm = (Imm & 0xff) * 0x01010101;
155 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
156 for (
unsigned i = 0; i != NumLaneElts; ++i) {
157 ShuffleMask.
push_back(SplatImm % NumLaneElts + l);
158 SplatImm /= NumLaneElts;
165 for (
unsigned l = 0; l != NumElts; l += 8) {
166 unsigned NewImm = Imm;
167 for (
unsigned i = 0, e = 4; i != e; ++i) {
170 for (
unsigned i = 4, e = 8; i != e; ++i) {
171 ShuffleMask.
push_back(l + 4 + (NewImm & 3));
179 for (
unsigned l = 0; l != NumElts; l += 8) {
180 unsigned NewImm = Imm;
181 for (
unsigned i = 0, e = 4; i != e; ++i) {
185 for (
unsigned i = 4, e = 8; i != e; ++i) {
192 unsigned NumHalfElts = NumElts / 2;
194 for (
unsigned l = 0; l != NumHalfElts; ++l)
196 for (
unsigned h = 0; h != NumHalfElts; ++h)
202 unsigned NumLaneElts = 128 / ScalarBits;
204 unsigned NewImm = Imm;
205 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
207 for (
unsigned s = 0; s != NumElts * 2; s += NumElts) {
208 for (
unsigned i = 0; i != NumLaneElts / 2; ++i) {
209 ShuffleMask.
push_back(NewImm % NumLaneElts + s + l);
210 NewImm /= NumLaneElts;
213 if (NumLaneElts == 4) NewImm = Imm;
221 unsigned NumLanes = (NumElts * ScalarBits) / 128;
222 if (NumLanes == 0) NumLanes = 1;
223 unsigned NumLaneElts = NumElts / NumLanes;
225 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
226 for (
unsigned i = l + NumLaneElts / 2, e = l + NumLaneElts; i != e; ++i) {
237 unsigned NumLanes = (NumElts * ScalarBits) / 128;
238 if (NumLanes == 0 ) NumLanes = 1;
239 unsigned NumLaneElts = NumElts / NumLanes;
241 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
242 for (
unsigned i = l, e = l + NumLaneElts / 2; i != e; ++i) {
251 ShuffleMask.
append(NumElts, 0);
256 unsigned Scale = DstNumElts / SrcNumElts;
258 for (
unsigned i = 0; i != Scale; ++i)
259 for (
unsigned j = 0; j != SrcNumElts; ++j)
266 unsigned NumElementsInLane = 128 / ScalarSize;
267 unsigned NumLanes = NumElts / NumElementsInLane;
269 for (
unsigned l = 0; l != NumElts; l += NumElementsInLane) {
270 unsigned Index = (Imm % NumLanes) * NumElementsInLane;
273 if (l >= (NumElts / 2))
275 for (
unsigned i = 0; i != NumElementsInLane; ++i)
282 unsigned HalfSize = NumElts / 2;
284 for (
unsigned l = 0; l != 2; ++l) {
285 unsigned HalfMask = Imm >> (l * 4);
286 unsigned HalfBegin = (HalfMask & 0x3) * HalfSize;
287 for (
unsigned i = HalfBegin, e = HalfBegin + HalfSize; i != e; ++i)
294 for (
int i = 0, e = RawMask.
size(); i < e; ++i) {
302 int Base = (i / 16) * 16;
316 for (
unsigned i = 0; i < NumElts; ++i) {
319 unsigned Bit = i % 8;
320 ShuffleMask.
push_back(((Imm >> Bit) & 1) ? NumElts + i : i);
326 assert(RawMask.
size() == 16 &&
"Illegal VPPERM shuffle mask size");
341 for (
int i = 0, e = RawMask.
size(); i < e; ++i) {
348 uint64_t PermuteOp = (M >> 5) & 0x7;
349 if (PermuteOp == 4) {
353 if (PermuteOp != 0) {
365 for (
unsigned l = 0; l != NumElts; l += 4)
366 for (
unsigned i = 0; i != 4; ++i)
367 ShuffleMask.
push_back(l + ((Imm >> (2 * i)) & 3));
371 unsigned NumDstElts,
bool IsAnyExtend,
373 unsigned Scale = DstScalarBits / SrcScalarBits;
374 assert(SrcScalarBits < DstScalarBits &&
375 "Expected zero extension mask to increase scalar size");
378 for (
unsigned i = 0; i != NumDstElts; i++) {
395 for (
unsigned i = 1; i < NumElts; i++)
401 unsigned HalfElts = NumElts / 2;
409 if (0 != (Len % EltSize) || 0 != (
Idx % EltSize))
417 if ((Len +
Idx) > 64) {
428 for (
int i = 0; i != Len; ++i)
430 for (
int i = Len; i != (int)HalfElts; ++i)
432 for (
int i = HalfElts; i != (int)NumElts; ++i)
438 unsigned HalfElts = NumElts / 2;
446 if (0 != (Len % EltSize) || 0 != (
Idx % EltSize))
454 if ((Len +
Idx) > 64) {
466 for (
int i = 0; i !=
Idx; ++i)
468 for (
int i = 0; i != Len; ++i)
470 for (
int i =
Idx + Len; i != (int)HalfElts; ++i)
472 for (
int i = HalfElts; i != (int)NumElts; ++i)
479 unsigned VecSize = NumElts * ScalarBits;
480 unsigned NumLanes = VecSize / 128;
481 unsigned NumEltsPerLane = NumElts / NumLanes;
482 assert((VecSize == 128 || VecSize == 256 || VecSize == 512) &&
483 "Unexpected vector size");
484 assert((ScalarBits == 32 || ScalarBits == 64) &&
"Unexpected element size");
486 for (
unsigned i = 0, e = RawMask.
size(); i < e; ++i) {
492 M = (ScalarBits == 64 ? ((M >> 1) & 0x1) : (M & 0x3));
493 unsigned LaneOffset = i & ~(NumEltsPerLane - 1);
494 ShuffleMask.
push_back((
int)(LaneOffset + M));
501 unsigned VecSize = NumElts * ScalarBits;
502 unsigned NumLanes = VecSize / 128;
503 unsigned NumEltsPerLane = NumElts / NumLanes;
504 assert((VecSize == 128 || VecSize == 256) &&
"Unexpected vector size");
505 assert((ScalarBits == 32 || ScalarBits == 64) &&
"Unexpected element size");
506 assert((NumElts == RawMask.
size()) &&
"Unexpected mask size");
508 for (
unsigned i = 0, e = RawMask.
size(); i < e; ++i) {
519 unsigned MatchBit = (Selector >> 3) & 0x1;
527 if ((M2Z & 0x2) != 0 && MatchBit != (M2Z & 0x1)) {
532 int Index = i & ~(NumEltsPerLane - 1);
533 if (ScalarBits == 64)
534 Index += (Selector >> 1) & 0x1;
536 Index += Selector & 0x3;
538 int Src = (Selector >> 2) & 0x1;
539 Index += Src * NumElts;
547 for (
int i = 0, e = RawMask.
size(); i != e; ++i) {
561 for (
int i = 0, e = RawMask.
size(); i != e; ++i) {
This file implements a class to represent arbitrary precision integral constant values and operations...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
Class for arbitrary precision integers.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is an optimization pass for GlobalISel generic memory operations.
void DecodeZeroExtendMask(unsigned SrcScalarBits, unsigned DstScalarBits, unsigned NumDstElts, bool IsAnyExtend, SmallVectorImpl< int > &ShuffleMask)
Decode a zero extension instruction as a shuffle mask.
void DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl< int > &ShuffleMask)
Decode a MOVHLPS instruction as a v2f64/v4f32 shuffle mask.
void DecodeZeroMoveLowMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
Decode a move lower and zero upper instruction as a shuffle mask.
void DecodeInsertElementMask(unsigned NumElts, unsigned Idx, unsigned Len, SmallVectorImpl< int > &ShuffleMask)
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 DecodePSHUFLWMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decodes the shuffle masks for pshuflw.
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 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 DecodeVPERMMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decodes the shuffle masks for VPERMQ/VPERMPD.
void DecodeEXTRQIMask(unsigned NumElts, unsigned EltSize, int Len, int Idx, SmallVectorImpl< int > &ShuffleMask)
Decode a SSE4A EXTRQ instruction as a shuffle mask.
void DecodePSRLDQMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeVPERM2X128Mask(unsigned NumElts, unsigned Imm, 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 DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl< int > &ShuffleMask)
Decode a MOVLHPS instruction as a v2f64/v4f32 shuffle mask.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
void DecodePSWAPMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
Decodes a PSWAPD 3DNow! instruction.
void DecodeINSERTQIMask(unsigned NumElts, unsigned EltSize, int Len, int Idx, SmallVectorImpl< int > &ShuffleMask)
Decode a SSE4A INSERTQ instruction as a 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 DecodeVALIGNMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeScalarMoveMask(unsigned NumElts, bool IsLoad, SmallVectorImpl< int > &ShuffleMask)
Decode a scalar float move instruction as a shuffle mask.
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 DecodePALIGNRMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeMOVSLDUPMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
void DecodeSubVectorBroadcast(unsigned DstNumElts, unsigned SrcNumElts, SmallVectorImpl< int > &ShuffleMask)
Decodes a broadcast of a subvector to a larger vector type.
void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decode a 128-bit INSERTPS instruction as a v4f32 shuffle mask.
void DecodeUNPCKLMask(unsigned NumElts, unsigned ScalarBits, SmallVectorImpl< int > &ShuffleMask)
Decodes the shuffle masks for unpcklps/unpcklpd and punpckl*.
void DecodePSLLDQMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeUNPCKHMask(unsigned NumElts, unsigned ScalarBits, SmallVectorImpl< int > &ShuffleMask)
Decodes the shuffle masks for unpckhps/unpckhpd and punpckh*.
void DecodePSHUFMask(unsigned NumElts, unsigned ScalarBits, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decodes the shuffle masks for pshufd/pshufw/vpermilpd/vpermilps.
void DecodeMOVDDUPMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
void DecodeVectorBroadcast(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
Decodes a broadcast of the first element of a vector.
void DecodeSHUFPMask(unsigned NumElts, unsigned ScalarBits, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decodes the shuffle masks for shufp*.
void DecodePSHUFHWMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decodes the shuffle masks for pshufhw.
void DecodeMOVSHDUPMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
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.