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;
117 assert((Width == 128 || Width == 256 || Width == 512) &&
119 "Unexpected vector size.");
127 unsigned NumElts = Width / 8;
128 assert((NumElts == 16 || NumElts == 32 || NumElts == 64) &&
129 "Unexpected number of vector elements.");
131 for (
unsigned i = 0; i != NumElts; ++i) {
137 uint64_t Element = RawMask[i];
139 if (Element & (1 << 7))
144 unsigned Base = i & ~0xf;
147 int Index = Base + (Element & 0xf);
155 assert((Width == 128 || Width == 256 || Width == 512) &&
157 "Unexpected vector size.");
158 assert((ElSize == 32 || ElSize == 64) &&
"Unexpected vector element size.");
166 unsigned NumElts = Width / ElSize;
167 unsigned NumEltsPerLane = 128 / ElSize;
168 assert((NumElts == 2 || NumElts == 4 || NumElts == 8 || NumElts == 16) &&
169 "Unexpected number of vector elements.");
171 for (
unsigned i = 0; i != NumElts; ++i) {
177 int Index = i & ~(NumEltsPerLane - 1);
178 uint64_t Element = RawMask[i];
180 Index += (Element >> 1) & 0x1;
182 Index += Element & 0x3;
194 assert((MaskTySize == 128 || MaskTySize == 256) &&
195 Width >= MaskTySize &&
"Unexpected vector size.");
203 unsigned NumElts = Width / ElSize;
204 unsigned NumEltsPerLane = 128 / ElSize;
205 assert((NumElts == 2 || NumElts == 4 || NumElts == 8) &&
206 "Unexpected number of vector elements.");
208 for (
unsigned i = 0; i != NumElts; ++i) {
218 uint64_t Selector = RawMask[i];
219 unsigned MatchBit = (Selector >> 3) & 0x1;
227 if ((M2Z & 0x2) != 0u && MatchBit != (M2Z & 0x1)) {
232 int Index = i & ~(NumEltsPerLane - 1);
234 Index += (Selector >> 1) & 0x1;
236 Index += Selector & 0x3;
238 int Src = (Selector >> 2) & 0x1;
239 Index += Src * NumElts;
249 assert(Width == 128 && Width >= MaskTySize &&
"Unexpected vector size.");
257 unsigned NumElts = Width / 8;
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) {
298 assert((Width == 128 || Width == 256 || Width == 512) &&
300 "Unexpected vector size.");
301 assert((ElSize == 8 || ElSize == 16 || ElSize == 32 || ElSize == 64) &&
302 "Unexpected vector element size.");
310 unsigned NumElts = Width / ElSize;
312 for (
unsigned i = 0; i != NumElts; ++i) {
317 int Index = RawMask[i] & (NumElts - 1);
324 assert((Width == 128 || Width == 256 || Width == 512) &&
326 "Unexpected vector size.");
327 assert((ElSize == 8 || ElSize == 16 || ElSize == 32 || ElSize == 64) &&
328 "Unexpected vector element size.");
336 unsigned NumElts = Width / ElSize;
338 for (
unsigned i = 0; i != NumElts; ++i) {
343 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.
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...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
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())
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
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.