29template <
typename LoadStoreOp>
31 return llvm::isa<MemRefType>(cast<LoadStoreOp>(op).
getBase().
getType());
37 return llvm::map_to_vector(
38 llvm::zip_equal(vecTy.getShape(), vecTy.getScalableDims()), [](
auto dim) {
39 auto [size, scalable] = dim;
40 return scalable ? ShapedType::kDynamic : size;
44template <
typename LoadStoreOp>
45struct VectorLoadStoreLikeOpImpl final
46 : IndexedAccessOpInterface::ExternalModel<
47 VectorLoadStoreLikeOpImpl<LoadStoreOp>, LoadStoreOp> {
49 return cast<LoadStoreOp>(op).getBase();
53 return cast<LoadStoreOp>(op).getIndices();
56 SmallVector<int64_t> getAccessedShape(Operation *op)
const {
57 assert(hasMemrefSemantics<LoadStoreOp>(op) &&
58 "expected vector op with memref semantics");
59 return getAccessedVectorShape(cast<LoadStoreOp>(op).
getVectorType());
62 std::optional<SmallVector<Value>>
63 updateMemrefAndIndices(Operation *op, RewriterBase &rewriter, Value newMemref,
65 assert(hasMemrefSemantics<LoadStoreOp>(op) &&
66 "expected vector op with memref semantics");
67 assert(llvm::isa<MemRefType>(newMemref.
getType()) &&
68 "expected replacement memref");
70 auto concreteOp = cast<LoadStoreOp>(op);
71 concreteOp.getBaseMutable().assign(newMemref);
72 concreteOp.getIndicesMutable().assign(newIndices);
80 bool hasInboundsIndices(Operation *op)
const {
81 assert(hasMemrefSemantics<LoadStoreOp>(op) &&
82 "expected vector op with memref semantics");
87template <
typename... Ops>
89 (Ops::template attachInterface<VectorLoadStoreLikeOpImpl<Ops>>(*ctx), ...);
97 attachAll<vector::LoadOp, vector::StoreOp, vector::MaskedLoadOp,
98 vector::MaskedStoreOp, vector::ExpandLoadOp,
99 vector::CompressStoreOp>(ctx);
static Value getBase(Value v)
Looks through known "view-like" ops to find the base memref.
static VectorType getVectorType(Type scalarTy, const VectorizationStrategy *strategy)
Returns the vector type resulting from applying the provided vectorization strategy on the scalar typ...
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
MLIRContext is the top-level object for a collection of MLIR operations.
Operation is the basic unit of execution within MLIR.
OperandRange operand_range
void modifyOpInPlace(Operation *root, CallableT &&callable)
This method is a utility wrapper around an in-place modification of an operation.
Type getType() const
Return the type of this value.
Operation::operand_range getIndices(Operation *op)
Get the indices that the given load/store operation is operating on.
void registerIndexedAccessOpInterfaceExternalModels(DialectRegistry ®istry)
Include the generated interface declarations.
Type getType(OpFoldResult ofr)
Returns the int type of the integer in ofr.
std::conditional_t< std::is_same_v< Ty, mlir::Type >, mlir::Value, detail::TypedValue< Ty > > TypedValue
If Ty is mlir::Type this will select Value instead of having a wrapper around it.