33 unsigned ZMask = Imm & 15;
34 unsigned CountD = (Imm >> 4) & 3;
35 unsigned CountS = (Imm >> 6) & 3;
38 unsigned InVal = 4 + CountS;
40 ShuffleMask[CountD] = InVal;
50 for (
unsigned i = NElts / 2; i != NElts; ++i)
53 for (
unsigned i = NElts / 2; i != NElts; ++i)
59 for (
unsigned i = 0; i != NElts / 2; ++i)
62 for (
unsigned i = 0; i != NElts / 2; ++i)
68 for (
int i = 0, e = NumElts / 2; i < e; ++i) {
76 for (
int i = 0, e = NumElts / 2; i < e; ++i) {
86 unsigned NumLanes = VectorSizeInBits / 128;
87 unsigned NumLaneElts = NumElts / NumLanes;
88 unsigned NumLaneSubElts = 64 / ScalarSizeInBits;
90 for (
unsigned l = 0; l < NumElts; l += NumLaneElts)
91 for (
unsigned i = 0; i < NumLaneElts; i += NumLaneSubElts)
92 for (
unsigned s = 0; s != NumLaneSubElts; s++)
98 unsigned NumElts = VectorSizeInBits / 8;
99 unsigned NumLanes = VectorSizeInBits / 128;
100 unsigned NumLaneElts = NumElts / NumLanes;
102 for (
unsigned l = 0; l < NumElts; l += NumLaneElts)
103 for (
unsigned i = 0; i < NumLaneElts; ++i) {
105 if (i >= Imm) M = i - Imm + l;
112 unsigned NumElts = VectorSizeInBits / 8;
113 unsigned NumLanes = VectorSizeInBits / 128;
114 unsigned NumLaneElts = NumElts / NumLanes;
116 for (
unsigned l = 0; l < NumElts; l += NumLaneElts)
117 for (
unsigned i = 0; i < NumLaneElts; ++i) {
118 unsigned Base = i + Imm;
131 unsigned NumLaneElts = NumElts / NumLanes;
133 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
134 for (
unsigned i = 0; i != NumLaneElts; ++i) {
135 unsigned Base = i + Offset;
137 if (Base >= NumLaneElts) Base += NumElts - NumLaneElts;
150 unsigned NumLaneElts = NumElts / NumLanes;
152 unsigned NewImm = Imm;
153 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
154 for (
unsigned i = 0; i != NumLaneElts; ++i) {
155 ShuffleMask.
push_back(NewImm % NumLaneElts + l);
156 NewImm /= NumLaneElts;
158 if (NumLaneElts == 4) NewImm = Imm;
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));
182 for (
unsigned l = 0; l != NumElts; l += 8) {
183 unsigned NewImm = Imm;
184 for (
unsigned i = 0, e = 4; i != e; ++i) {
188 for (
unsigned i = 4, e = 8; i != e; ++i) {
201 unsigned NumLaneElts = NumElts / NumLanes;
203 unsigned NewImm = Imm;
204 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
206 for (
unsigned s = 0; s != NumElts * 2; s += NumElts) {
207 for (
unsigned i = 0; i != NumLaneElts / 2; ++i) {
208 ShuffleMask.
push_back(NewImm % NumLaneElts + s + l);
209 NewImm /= NumLaneElts;
212 if (NumLaneElts == 4) NewImm = Imm;
225 if (NumLanes == 0 ) NumLanes = 1;
226 unsigned NumLaneElts = NumElts / NumLanes;
228 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
229 for (
unsigned i = l + NumLaneElts / 2, e = l + NumLaneElts; i != e; ++i) {
245 if (NumLanes == 0 ) NumLanes = 1;
246 unsigned NumLaneElts = NumElts / NumLanes;
248 for (
unsigned l = 0; l != NumElts; l += NumLaneElts) {
249 for (
unsigned i = l, e = l + NumLaneElts / 2; i != e; ++i) {
260 for (
unsigned l = 0; l != 2; ++l) {
261 unsigned HalfMask = Imm >> (l * 4);
262 unsigned HalfBegin = (HalfMask & 0x3) * HalfSize;
263 for (
unsigned i = HalfBegin, e = HalfBegin + HalfSize; i != e; ++i)
282 if (MaskTySize != 128 && MaskTySize != 256)
288 ShuffleMask.
reserve(NumElements);
290 for (
int i = 0; i < NumElements; ++i) {
293 int Base = i < 16 ? 0 : 16;
298 }
else if (isa<UndefValue>(COp)) {
302 uint64_t Element = cast<ConstantInt>(COp)->getZExtValue();
304 if (Element & (1 << 7))
308 int Index = Base + (Element & 0xf);
318 for (
int i = 0, e = RawMask.
size(); i < e; ++i) {
319 uint64_t M = RawMask[i];
326 int Base = i < 16 ? 0 : 16;
332 int Index = Base + (M & 0xf);
341 for (
int i = 0; i < NumElements; ++i) {
345 int Bit = NumElements > 8 ? i % (128 / ElementBits) : i;
347 "Immediate blends only operate over 8 elements at a time!");
348 ShuffleMask.
push_back(((Imm >> Bit) & 1) ? NumElements + i : i);
355 for (
unsigned i = 0; i != 4; ++i) {
356 ShuffleMask.
push_back((Imm >> (2 * i)) & 3);
362 assert(MaskTy->
isVectorTy() &&
"Expected a vector constant mask!");
364 "Expected integer constant mask elements!");
367 assert((NumElements == 2 || NumElements == 4 || NumElements == 8) &&
368 "Unexpected number of vector elements.");
369 ShuffleMask.
reserve(NumElements);
370 if (
auto *CDS = dyn_cast<ConstantDataSequential>(C)) {
371 assert((
unsigned)NumElements == CDS->getNumElements() &&
372 "Constant mask has a different number of elements!");
374 for (
int i = 0; i < NumElements; ++i) {
375 int Base = (i * ElementBits / 128) * (128 / ElementBits);
376 uint64_t Element = CDS->getElementAsInteger(i);
378 int Index = Base + (Element & 0x3);
381 }
else if (
auto *CV = dyn_cast<ConstantVector>(C)) {
383 "Constant mask has a different number of elements!");
385 for (
int i = 0; i < NumElements; ++i) {
386 int Base = (i * ElementBits / 128) * (128 / ElementBits);
388 if (isa<UndefValue>(COp)) {
392 uint64_t Element = cast<ConstantInt>(COp)->getZExtValue();
394 int Index = Base + (Element & 0x3);
404 unsigned Scale = DstScalarBits / SrcScalarBits;
405 assert(SrcScalarBits < DstScalarBits &&
406 "Expected zero extension mask to increase scalar size");
408 "Too many zero extension lanes");
410 for (
unsigned i = 0; i != NumDstElts; i++) {
412 for (
unsigned j = 1; j != Scale; j++)
420 for (
unsigned i = 1; i < NumElts; i++)
429 for (
unsigned i = 1; i < NumElts; i++)
441 if (0 != (Len % 8) || 0 != (Idx % 8))
449 if ((Len + Idx) > 64) {
460 for (
int i = 0; i != Len; ++i)
462 for (
int i = Len; i != 8; ++i)
464 for (
int i = 8; i != 16; ++i)
476 if (0 != (Len % 8) || 0 != (Idx % 8))
484 if ((Len + Idx) > 64) {
496 for (
int i = 0; i != Idx; ++i)
498 for (
int i = 0; i != Len; ++i)
500 for (
int i = Idx + Len; i != 8; ++i)
502 for (
int i = 8; i != 16; ++i)
void push_back(const T &Elt)
void DecodePSLLDQMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeScalarMoveMask(MVT VT, bool IsLoad, SmallVectorImpl< int > &Mask)
Decode a scalar float move instruction as a shuffle mask.
unsigned getNumOperands() const
unsigned getScalarSizeInBits() const
void DecodePALIGNRMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
unsigned getSizeInBits() const
void DecodeUNPCKLMask(MVT VT, SmallVectorImpl< int > &ShuffleMask)
DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd and punpckl*.
void reserve(size_type N)
void DecodeMOVDDUPMask(MVT VT, SmallVectorImpl< int > &ShuffleMask)
Type * getVectorElementType() const
void DecodeEXTRQIMask(int Len, int Idx, SmallVectorImpl< int > &ShuffleMask)
Decode a SSE4A EXTRQ instruction as a v16i8 shuffle mask.
void DecodeINSERTQIMask(int Len, int Idx, SmallVectorImpl< int > &ShuffleMask)
Decode a SSE4A INSERTQ instruction as a v16i8 shuffle mask.
size_t size() const
size - Get the array size.
void DecodeZeroMoveLowMask(MVT VT, SmallVectorImpl< int > &ShuffleMask)
Decode a move lower and zero upper instruction as a shuffle mask.
void DecodeBLENDMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decode a BLEND immediate mask into a shuffle mask.
void DecodeMOVSHDUPMask(MVT VT, SmallVectorImpl< int > &ShuffleMask)
void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl< int > &ShuffleMask)
unsigned getVectorNumElements() const
MVT - Machine Value Type.
The instances of the Type class are immutable: once they are created, they are never changed...
bool isVectorTy() const
isVectorTy - True if this is an instance of VectorType.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
void DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
DecodeSHUFPMask - This decodes the shuffle masks for shufp*.
void DecodePSHUFBMask(const Constant *C, SmallVectorImpl< int > &ShuffleMask)
Decode a PSHUFB mask from an IR-level vector constant.
void DecodePSHUFLWMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Value * getOperand(unsigned i) const
void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Constant * getAggregateElement(unsigned Elt) const
getAggregateElement - For aggregates (struct/array/vector) return the constant that corresponds to th...
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
void DecodePSRLDQMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeMOVSLDUPMask(MVT VT, SmallVectorImpl< int > &ShuffleMask)
void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
DecodePSHUFMask - This decodes the shuffle masks for pshufd, and vpermilp*.
unsigned getVectorNumElements() const
unsigned getScalarSizeInBits() const LLVM_READONLY
getScalarSizeInBits - If this is a vector type, return the getPrimitiveSizeInBits value for the eleme...
Type * getType() const
All values are typed, get the type of this value.
bool isIntegerTy() const
isIntegerTy - True if this is an instance of IntegerType.
void DecodeUNPCKHMask(MVT VT, SmallVectorImpl< int > &ShuffleMask)
DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd and punpckh*.
void DecodeVPERM2X128Mask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeVPERMILPMask(const Constant *C, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMILP variable mask from an IR-level vector constant.
void DecodePSHUFHWMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeZeroExtendMask(MVT SrcVT, MVT DstVT, SmallVectorImpl< int > &Mask)
Decode a zero extension instruction as a shuffle mask.
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
getPrimitiveSizeInBits - Return the basic size of this type if it is a primitive type.
void DecodeVPERMMask(unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
void DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl< int > &ShuffleMask)
MVT getVectorElementType() const