49 assert((CstSizeInBits % MaskEltSizeInBits) == 0 &&
50 "Unaligned shuffle mask size");
52 unsigned NumMaskElts = CstSizeInBits / MaskEltSizeInBits;
53 UndefElts =
APInt(NumMaskElts, 0);
54 RawMask.
resize(NumMaskElts, 0);
57 if (MaskEltSizeInBits == CstEltSizeInBits) {
58 assert(NumCstElts == NumMaskElts &&
"Unaligned shuffle mask size");
59 for (
unsigned i = 0; i != NumMaskElts; ++i) {
61 if (!COp || (!isa<UndefValue>(COp) && !isa<ConstantInt>(COp)))
64 if (isa<UndefValue>(COp)) {
70 auto *Elt = cast<ConstantInt>(COp);
71 RawMask[i] = Elt->getValue().getZExtValue();
77 APInt UndefBits(CstSizeInBits, 0);
78 APInt MaskBits(CstSizeInBits, 0);
79 for (
unsigned i = 0; i != NumCstElts; ++i) {
81 if (!COp || (!isa<UndefValue>(COp) && !isa<ConstantInt>(COp)))
84 unsigned BitOffset = i * CstEltSizeInBits;
86 if (isa<UndefValue>(COp)) {
87 UndefBits.
setBits(BitOffset, BitOffset + CstEltSizeInBits);
91 MaskBits.
insertBits(cast<ConstantInt>(COp)->getValue(), BitOffset);
95 for (
unsigned i = 0; i != NumMaskElts; ++i) {
96 unsigned BitOffset = i * MaskEltSizeInBits;
116 assert((Width == 128 || Width == 256 || Width == 512) &&
118 "Unexpected vector size.");
126 unsigned NumElts = Width / 8;
127 assert((NumElts == 16 || NumElts == 32 || NumElts == 64) &&
128 "Unexpected number of vector elements.");
130 for (
unsigned i = 0; i != NumElts; ++i) {
136 uint64_t Element = RawMask[i];
138 if (Element & (1 << 7))
143 unsigned Base = i & ~0xf;
146 int Index = Base + (Element & 0xf);
154 assert((Width == 128 || Width == 256 || Width == 512) &&
156 "Unexpected vector size.");
157 assert((ElSize == 32 || ElSize == 64) &&
"Unexpected vector element size.");
165 unsigned NumElts = Width / ElSize;
166 unsigned NumEltsPerLane = 128 / ElSize;
167 assert((NumElts == 2 || NumElts == 4 || NumElts == 8 || NumElts == 16) &&
168 "Unexpected number of vector elements.");
170 for (
unsigned i = 0; i != NumElts; ++i) {
176 int Index = i & ~(NumEltsPerLane - 1);
177 uint64_t Element = RawMask[i];
179 Index += (Element >> 1) & 0x1;
181 Index += Element & 0x3;
193 assert((MaskTySize == 128 || MaskTySize == 256) &&
194 Width >= MaskTySize &&
"Unexpected vector size.");
202 unsigned NumElts = Width / ElSize;
203 unsigned NumEltsPerLane = 128 / ElSize;
204 assert((NumElts == 2 || NumElts == 4 || NumElts == 8) &&
205 "Unexpected number of vector elements.");
207 for (
unsigned i = 0; i != NumElts; ++i) {
217 uint64_t Selector = RawMask[i];
218 unsigned MatchBit = (Selector >> 3) & 0x1;
226 if ((M2Z & 0x2) != 0u && MatchBit != (M2Z & 0x1)) {
231 int Index = i & ~(NumEltsPerLane - 1);
233 Index += (Selector >> 1) & 0x1;
235 Index += Selector & 0x3;
237 int Src = (Selector >> 2) & 0x1;
238 Index += Src * NumElts;
248 assert(Width == 128 && Width >= MaskTySize &&
"Unexpected vector size.");
256 unsigned NumElts = Width / 8;
257 assert(NumElts == 16 &&
"Unexpected number of vector elements.");
259 for (
unsigned i = 0; i != NumElts; ++i) {
279 uint64_t Element = RawMask[i];
280 uint64_t
Index = Element & 0x1F;
281 uint64_t PermuteOp = (Element >> 5) & 0x7;
283 if (PermuteOp == 4) {
287 if (PermuteOp != 0) {
297 assert((Width == 128 || Width == 256 || Width == 512) &&
299 "Unexpected vector size.");
300 assert((ElSize == 8 || ElSize == 16 || ElSize == 32 || ElSize == 64) &&
301 "Unexpected vector element size.");
309 unsigned NumElts = Width / ElSize;
311 for (
unsigned i = 0; i != NumElts; ++i) {
316 int Index = RawMask[i] & (NumElts - 1);
323 assert((Width == 128 || Width == 256 || Width == 512) &&
325 "Unexpected vector size.");
326 assert((ElSize == 8 || ElSize == 16 || ElSize == 32 || ElSize == 64) &&
327 "Unexpected vector element size.");
335 unsigned NumElts = Width / ElSize;
337 for (
unsigned i = 0; i != NumElts; ++i) {
342 int Index = RawMask[i] & (NumElts*2 - 1);
Type * getVectorElementType() const
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.
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)
bool isVectorTy() const
True if this is an instance of VectorType.
void setBit(unsigned BitPosition)
Set a given bit to 1.
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.
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.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
The instances of the Type class are immutable: once they are created, they are never changed...
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, const APInt &UndefElts, 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...
unsigned getVectorNumElements() const
Class for arbitrary precision integers.
static bool extractConstantMask(const Constant *C, unsigned MaskEltSizeInBits, APInt &UndefElts, SmallVectorImpl< uint64_t > &RawMask)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.