52 assert((CstSizeInBits % MaskEltSizeInBits) == 0 &&
53 "Unaligned shuffle mask size");
55 unsigned NumMaskElts = CstSizeInBits / MaskEltSizeInBits;
56 UndefElts =
APInt(NumMaskElts, 0);
57 RawMask.
resize(NumMaskElts, 0);
60 if (MaskEltSizeInBits == CstEltSizeInBits) {
61 assert(NumCstElts == NumMaskElts &&
"Unaligned shuffle mask size");
62 for (
unsigned i = 0; i != NumMaskElts; ++i) {
64 if (!COp || (!isa<UndefValue>(COp) && !isa<ConstantInt>(COp)))
67 if (isa<UndefValue>(COp)) {
73 auto *Elt = cast<ConstantInt>(COp);
74 RawMask[i] = Elt->getValue().getZExtValue();
80 APInt UndefBits(CstSizeInBits, 0);
81 APInt MaskBits(CstSizeInBits, 0);
82 for (
unsigned i = 0; i != NumCstElts; ++i) {
84 if (!COp || (!isa<UndefValue>(COp) && !isa<ConstantInt>(COp)))
87 unsigned BitOffset = i * CstEltSizeInBits;
89 if (isa<UndefValue>(COp)) {
90 UndefBits.
setBits(BitOffset, BitOffset + CstEltSizeInBits);
94 MaskBits.
insertBits(cast<ConstantInt>(COp)->getValue(), BitOffset);
98 for (
unsigned i = 0; i != NumMaskElts; ++i) {
99 unsigned BitOffset = i * MaskEltSizeInBits;
121 assert((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512) &&
122 "Unexpected vector size.");
130 unsigned NumElts = RawMask.
size();
131 assert((NumElts == 16 || NumElts == 32 || NumElts == 64) &&
132 "Unexpected number of vector elements.");
134 for (
unsigned i = 0; i != NumElts; ++i) {
140 uint64_t Element = RawMask[i];
142 if (Element & (1 << 7))
147 unsigned Base = i & ~0xf;
150 int Index = Base + (Element & 0xf);
161 assert((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512) &&
162 "Unexpected vector size.");
163 assert((ElSize == 32 || ElSize == 64) &&
"Unexpected vector element size.");
171 unsigned NumElts = RawMask.
size();
172 unsigned NumEltsPerLane = 128 / ElSize;
173 assert((NumElts == 2 || NumElts == 4 || NumElts == 8 || NumElts == 16) &&
174 "Unexpected number of vector elements.");
176 for (
unsigned i = 0; i != NumElts; ++i) {
182 int Index = i & ~(NumEltsPerLane - 1);
183 uint64_t Element = RawMask[i];
185 Index += (Element >> 1) & 0x1;
187 Index += Element & 0x3;
198 assert((MaskTySize == 128 || MaskTySize == 256) &&
"Unexpected vector size.");
206 unsigned NumElts = RawMask.
size();
207 unsigned NumEltsPerLane = 128 / ElSize;
208 assert((NumElts == 2 || NumElts == 4 || NumElts == 8) &&
209 "Unexpected number of vector elements.");
211 for (
unsigned i = 0; i != NumElts; ++i) {
221 uint64_t Selector = RawMask[i];
222 unsigned MatchBit = (Selector >> 3) & 0x1;
230 if ((M2Z & 0x2) != 0u && MatchBit != (M2Z & 0x1)) {
235 int Index = i & ~(NumEltsPerLane - 1);
237 Index += (Selector >> 1) & 0x1;
239 Index += Selector & 0x3;
241 int Src = (Selector >> 2) & 0x1;
242 Index += Src * NumElts;
249 "Unexpected vector size.");
257 unsigned NumElts = RawMask.
size();
258 assert(NumElts == 16 &&
"Unexpected number of vector elements.");
260 for (
unsigned i = 0; i != NumElts; ++i) {
280 uint64_t Element = RawMask[i];
281 uint64_t Index = Element & 0x1F;
282 uint64_t PermuteOp = (Element >> 5) & 0x7;
284 if (PermuteOp == 4) {
288 if (PermuteOp != 0) {
301 assert((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512) &&
302 "Unexpected vector size.");
303 assert((ElSize == 8 || ElSize == 16 || ElSize == 32 || ElSize == 64) &&
304 "Unexpected vector element size.");
312 unsigned NumElts = RawMask.
size();
314 for (
unsigned i = 0; i != NumElts; ++i) {
319 int Index = RawMask[i] & (NumElts - 1);
329 assert((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512) &&
330 "Unexpected vector size.");
331 assert((ElSize == 8 || ElSize == 16 || ElSize == 32 || ElSize == 64) &&
332 "Unexpected vector element size.");
340 unsigned NumElts = RawMask.
size();
342 for (
unsigned i = 0; i != NumElts; ++i) {
347 int Index = RawMask[i] & (NumElts*2 - 1);
void push_back(const T &Elt)
void DecodeVPERMILPMask(MVT VT, ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMILPD/VPERMILPS variable mask from a raw array of constants.
void setBits(unsigned loBit, unsigned hiBit)
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
uint64_t getZExtValue() const
Get zero extended value.
void setBit(unsigned BitPosition)
Set a given bit to 1.
Type * getVectorElementType() const
This file implements a class to represent arbitrary precision integral constant values and operations...
void insertBits(const APInt &SubBits, unsigned bitPosition)
Insert the bits from a smaller APInt starting at bitPosition.
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.
APInt extractBits(unsigned numBits, unsigned bitPosition) const
Return an APInt with the extracted bits [bitPosition,bitPosition+numBits).
bool isVectorTy() const
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...
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
void DecodeVPERMVMask(ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERM W/D/Q/PS/PD mask from a raw array of constants.
void DecodeVPERMIL2PMask(MVT VT, unsigned M2Z, ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMIL2PD/VPERMIL2PS variable 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...
Type * getType() const
All values are typed, get the type of this value.
void DecodeVPERMV3Mask(ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMT2 W/D/Q/PS/PD mask from a raw array of constants.
Class for arbitrary precision integers.
bool isIntegerTy() const
True if this is an instance of IntegerType.
unsigned getVectorNumElements() const
bool isAllOnesValue() const
Determine if all bits are set.
static bool extractConstantMask(const Constant *C, unsigned MaskEltSizeInBits, APInt &UndefElts, SmallVectorImpl< uint64_t > &RawMask)
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
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.