50 assert((CstSizeInBits % MaskEltSizeInBits) == 0 &&
51 "Unaligned shuffle mask size");
53 unsigned NumMaskElts = CstSizeInBits / MaskEltSizeInBits;
54 UndefElts =
APInt(NumMaskElts, 0);
55 RawMask.
resize(NumMaskElts, 0);
58 if (MaskEltSizeInBits == CstEltSizeInBits) {
59 assert(NumCstElts == NumMaskElts &&
"Unaligned shuffle mask size");
60 for (
unsigned i = 0; i != NumMaskElts; ++i) {
62 if (!COp || (!isa<UndefValue>(COp) && !isa<ConstantInt>(COp)))
65 if (isa<UndefValue>(COp)) {
71 auto *Elt = cast<ConstantInt>(COp);
72 RawMask[i] = Elt->getValue().getZExtValue();
78 APInt UndefBits(CstSizeInBits, 0);
79 APInt MaskBits(CstSizeInBits, 0);
80 for (
unsigned i = 0; i != NumCstElts; ++i) {
82 if (!COp || (!isa<UndefValue>(COp) && !isa<ConstantInt>(COp)))
85 unsigned BitOffset = i * CstEltSizeInBits;
87 if (isa<UndefValue>(COp)) {
88 UndefBits.
setBits(BitOffset, BitOffset + CstEltSizeInBits);
92 MaskBits.
insertBits(cast<ConstantInt>(COp)->getValue(), BitOffset);
96 for (
unsigned i = 0; i != NumMaskElts; ++i) {
97 unsigned BitOffset = i * MaskEltSizeInBits;
119 assert((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512) &&
120 "Unexpected vector size.");
128 unsigned NumElts = RawMask.
size();
129 assert((NumElts == 16 || NumElts == 32 || NumElts == 64) &&
130 "Unexpected number of vector elements.");
132 for (
unsigned i = 0; i != NumElts; ++i) {
138 uint64_t Element = RawMask[i];
140 if (Element & (1 << 7))
145 unsigned Base = i & ~0xf;
148 int Index = Base + (Element & 0xf);
159 assert((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512) &&
160 "Unexpected vector size.");
161 assert((ElSize == 32 || ElSize == 64) &&
"Unexpected vector element size.");
169 unsigned NumElts = RawMask.
size();
170 unsigned NumEltsPerLane = 128 / ElSize;
171 assert((NumElts == 2 || NumElts == 4 || NumElts == 8 || NumElts == 16) &&
172 "Unexpected number of vector elements.");
174 for (
unsigned i = 0; i != NumElts; ++i) {
180 int Index = i & ~(NumEltsPerLane - 1);
181 uint64_t Element = RawMask[i];
183 Index += (Element >> 1) & 0x1;
185 Index += Element & 0x3;
196 assert((MaskTySize == 128 || MaskTySize == 256) &&
"Unexpected vector size.");
204 unsigned NumElts = RawMask.
size();
205 unsigned NumEltsPerLane = 128 / ElSize;
206 assert((NumElts == 2 || NumElts == 4 || NumElts == 8) &&
207 "Unexpected number of vector elements.");
209 for (
unsigned i = 0; i != NumElts; ++i) {
219 uint64_t Selector = RawMask[i];
220 unsigned MatchBit = (Selector >> 3) & 0x1;
228 if ((M2Z & 0x2) != 0u && MatchBit != (M2Z & 0x1)) {
233 int Index = i & ~(NumEltsPerLane - 1);
235 Index += (Selector >> 1) & 0x1;
237 Index += Selector & 0x3;
239 int Src = (Selector >> 2) & 0x1;
240 Index += Src * NumElts;
247 "Unexpected vector size.");
255 unsigned NumElts = RawMask.
size();
256 assert(NumElts == 16 &&
"Unexpected number of vector elements.");
258 for (
unsigned i = 0; i != NumElts; ++i) {
278 uint64_t Element = RawMask[i];
279 uint64_t
Index = Element & 0x1F;
280 uint64_t PermuteOp = (Element >> 5) & 0x7;
282 if (PermuteOp == 4) {
286 if (PermuteOp != 0) {
299 assert((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512) &&
300 "Unexpected vector size.");
301 assert((ElSize == 8 || ElSize == 16 || ElSize == 32 || ElSize == 64) &&
302 "Unexpected vector element size.");
310 unsigned NumElts = RawMask.
size();
312 for (
unsigned i = 0; i != NumElts; ++i) {
317 int Index = RawMask[i] & (NumElts - 1);
327 assert((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512) &&
328 "Unexpected vector size.");
329 assert((ElSize == 8 || ElSize == 16 || ElSize == 32 || ElSize == 64) &&
330 "Unexpected vector element size.");
338 unsigned NumElts = RawMask.
size();
340 for (
unsigned i = 0; i != NumElts; ++i) {
345 int Index = RawMask[i] & (NumElts*2 - 1);
Type * getVectorElementType() const
void push_back(const T &Elt)
uint64_t getZExtValue() const
Get zero extended value.
void setBits(unsigned loBit, unsigned hiBit)
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
void DecodeVPERMILPMask(unsigned NumElts, unsigned ScalarBits, ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMILPD/VPERMILPS variable mask from a raw array of constants.
Compute iterated dominance frontiers using a linear time algorithm.
bool isVectorTy() const
True if this is an instance of VectorType.
void setBit(unsigned BitPosition)
Set a given bit to 1.
bool isIntegerTy() const
True if this is an instance of IntegerType.
This file implements a class to represent arbitrary precision integral constant values and operations...
Type * getType() const
All values are typed, get the type of this value.
APInt extractBits(unsigned numBits, unsigned bitPosition) const
Return an APInt with the extracted bits [bitPosition,bitPosition+numBits).
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
void insertBits(const APInt &SubBits, unsigned bitPosition)
Insert the bits from a smaller APInt starting at bitPosition.
bool isAllOnesValue() const
Determine if all bits are set.
The instances of the Type class are immutable: once they are created, they are never changed...
void DecodeVPPERMMask(ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPPERM mask from a raw array of constants such as from BUILD_VECTOR.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
void DecodeVPERMIL2PMask(unsigned NumElts, unsigned ScalarBits, unsigned M2Z, ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMIL2PD/VPERMIL2PS variable mask from a raw array of constants.
void DecodeVPERMVMask(ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERM W/D/Q/PS/PD mask from a raw array of constants.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void DecodeVPERMV3Mask(ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMT2 W/D/Q/PS/PD mask from a raw array of constants.
unsigned getVectorNumElements() const
Class for arbitrary precision integers.
static bool extractConstantMask(const Constant *C, unsigned MaskEltSizeInBits, APInt &UndefElts, SmallVectorImpl< uint64_t > &RawMask)
void DecodePSHUFBMask(ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a PSHUFB mask from a raw array of constants such as from BUILD_VECTOR.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.