12#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_VECUTILS_H
13#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_VECUTILS_H
28 assert(!isa<ScalableVectorType>(Ty));
29 return Ty->
isVectorTy() ? cast<FixedVectorType>(Ty)->getNumElements() : 1;
33 return Ty->
isVectorTy() ? cast<FixedVectorType>(Ty)->getElementType() : Ty;
38 template <
typename LoadOrStoreT>
41 static_assert(std::is_same<LoadOrStoreT, LoadInst>::value ||
42 std::is_same<LoadOrStoreT, StoreInst>::value,
43 "Expected Load or Store!");
48 return *Diff == ElmBytes;
51 template <
typename LoadOrStoreT>
54 static_assert(std::is_same<LoadOrStoreT, LoadInst>::value ||
55 std::is_same<LoadOrStoreT, StoreInst>::value,
56 "Expected Load or Store!");
57 assert(isa<LoadOrStoreT>(Bndl[0]) &&
"Expected Load or Store!");
58 auto *LastLS = cast<LoadOrStoreT>(Bndl[0]);
60 assert(isa<LoadOrStoreT>(V) &&
61 "Unimplemented: we only support StoreInst!");
62 auto *LS = cast<LoadOrStoreT>(V);
73 assert(!isa<ScalableVectorType>(Ty) &&
"Expect scalar or fixed vector");
74 if (
auto *FixedVecTy = dyn_cast<FixedVectorType>(Ty))
75 return FixedVecTy->getNumElements();
97 auto *VecTy = cast<FixedVectorType>(ElemTy);
98 ElemTy = VecTy->getElementType();
99 NumElts = VecTy->getNumElements() * NumElts;
120 if (NScalarTy != ScalarTy)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & front() const
front - Get the first element.
A parsed version of the target data layout string in and methods for querying it.
The main scalar evolution driver.
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
bool comesBefore(const Instruction *Other) const
Given an instruction Other in the same basic block as this instruction, return true if this instructi...
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
bool isVectorTy() const
True if this is an instance of VectorType.
static unsigned getNumBits(Value *V, const DataLayout &DL)
\Returns the number of bits required to represent the operands or return value of V in DL.
static std::optional< int > getPointerDiffInBytes(LoadOrStoreT *I0, LoadOrStoreT *I1, ScalarEvolution &SE)
\Returns the gap between the memory locations accessed by I0 and I1 in bytes.
static Type * getExpectedType(const Value *V)
\Returns the expected type of Value V.
A SandboxIR Value has users. This is the base class.
static Type * tryGetCommonScalarType(ArrayRef< Value * > Bndl)
If all values in Bndl are of the same scalar type then return it, otherwise return nullptr.
static Instruction * getLowest(ArrayRef< Instruction * > Instrs)
static Type * getCommonScalarType(ArrayRef< Value * > Bndl)
Similar to tryGetCommonScalarType() but will assert that there is a common type.
static int getNumElements(Type *Ty)
\Returns the number of elements in Ty.
static unsigned getNumLanes(Type *Ty)
\Returns the number of vector lanes of Ty or 1 if not a vector.
static Type * getWideType(Type *ElemTy, unsigned NumElts)
\Returns <NumElts x ElemTy>.
static bool areConsecutive(LoadOrStoreT *I1, LoadOrStoreT *I2, ScalarEvolution &SE, const DataLayout &DL)
\Returns true if I1 and I2 are load/stores accessing consecutive memory addresses.
static Type * getElementType(Type *Ty)
Returns Ty if scalar or its element type if vector.
static bool areConsecutive(ArrayRef< Value * > &Bndl, ScalarEvolution &SE, const DataLayout &DL)
static unsigned getNumLanes(Value *V)
\Returns the expected vector lanes of V or 1 if not a vector.
static unsigned getNumLanes(ArrayRef< Value * > Bndl)
\Returns the total number of lanes across all values in Bndl.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.