53 APInt UndefBits(CstSizeInBits, 0);
54 APInt MaskBits(CstSizeInBits, 0);
55 for (
unsigned i = 0;
i != NumCstElts; ++
i) {
57 if (!COp || (!isa<UndefValue>(COp) && !isa<ConstantInt>(COp)))
60 if (isa<UndefValue>(COp)) {
62 UndefBits |= EltUndef.
shl(
i * CstEltSizeInBits);
66 APInt EltBits = cast<ConstantInt>(COp)->getValue();
68 MaskBits |= EltBits.
shl(
i * CstEltSizeInBits);
72 assert((CstSizeInBits % MaskEltSizeInBits) == 0 &&
73 "Unaligned shuffle mask size");
75 unsigned NumMaskElts = CstSizeInBits / MaskEltSizeInBits;
77 RawMask.
resize(NumMaskElts, 0);
79 for (
unsigned i = 0;
i != NumMaskElts; ++
i) {
80 APInt EltUndef = UndefBits.
lshr(
i * MaskEltSizeInBits);
91 APInt EltBits = MaskBits.
lshr(
i * MaskEltSizeInBits);
103 assert((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512) &&
104 "Unexpected vector size.");
112 unsigned NumElts = RawMask.
size();
113 assert((NumElts == 16 || NumElts == 32 || NumElts == 64) &&
114 "Unexpected number of vector elements.");
116 for (
unsigned i = 0;
i != NumElts; ++
i) {
122 uint64_t Element = RawMask[
i];
124 if (Element & (1 << 7))
129 unsigned Base = i & ~0xf;
132 int Index = Base + (Element & 0xf);
143 assert((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512) &&
144 "Unexpected vector size.");
145 assert((ElSize == 32 || ElSize == 64) &&
"Unexpected vector element size.");
153 unsigned NumElts = RawMask.
size();
154 unsigned NumEltsPerLane = 128 / ElSize;
155 assert((NumElts == 2 || NumElts == 4 || NumElts == 8 || NumElts == 16) &&
156 "Unexpected number of vector elements.");
158 for (
unsigned i = 0;
i != NumElts; ++
i) {
164 int Index = i & ~(NumEltsPerLane - 1);
165 uint64_t Element = RawMask[
i];
167 Index += (Element >> 1) & 0x1;
169 Index += Element & 0x3;
180 assert((MaskTySize == 128 || MaskTySize == 256) &&
"Unexpected vector size.");
188 unsigned NumElts = RawMask.
size();
189 unsigned NumEltsPerLane = 128 / ElSize;
190 assert((NumElts == 2 || NumElts == 4 || NumElts == 8) &&
191 "Unexpected number of vector elements.");
193 for (
unsigned i = 0;
i != NumElts; ++
i) {
203 uint64_t Selector = RawMask[
i];
204 unsigned MatchBit = (Selector >> 3) & 0x1;
212 if ((M2Z & 0x2) != 0u && MatchBit != (M2Z & 0x1)) {
217 int Index = i & ~(NumEltsPerLane - 1);
219 Index += (Selector >> 1) & 0x1;
221 Index += Selector & 0x3;
223 int Src = (Selector >> 2) & 0x1;
224 Index += Src * NumElts;
231 "Unexpected vector size.");
239 unsigned NumElts = RawMask.
size();
240 assert(NumElts == 16 &&
"Unexpected number of vector elements.");
242 for (
unsigned i = 0;
i != NumElts; ++
i) {
262 uint64_t Element = RawMask[
i];
263 uint64_t Index = Element & 0x1F;
264 uint64_t PermuteOp = (Element >> 5) & 0x7;
266 if (PermuteOp == 4) {
270 if (PermuteOp != 0) {
283 assert((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512) &&
284 "Unexpected vector size.");
285 assert((ElSize == 8 || ElSize == 16 || ElSize == 32 || ElSize == 64) &&
286 "Unexpected vector element size.");
294 unsigned NumElts = RawMask.
size();
296 for (
unsigned i = 0;
i != NumElts; ++
i) {
301 int Index = RawMask[
i] & (NumElts - 1);
311 assert((MaskTySize == 128 || MaskTySize == 256 || MaskTySize == 512) &&
312 "Unexpected vector size.");
313 assert((ElSize == 8 || ElSize == 16 || ElSize == 32 || ElSize == 64) &&
314 "Unexpected vector element size.");
322 unsigned NumElts = RawMask.
size();
324 for (
unsigned i = 0;
i != NumElts; ++
i) {
329 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.
uint64_t getZExtValue() const
Get zero extended value.
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Get a value with low bits set.
APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
static bool extractConstantMask(const Constant *C, unsigned MaskEltSizeInBits, SmallBitVector &UndefElts, SmallVectorImpl< uint64_t > &RawMask)
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
Type * getVectorElementType() const
APInt shl(unsigned shiftAmt) const
Left-shift function.
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.
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.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
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.
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.