[Mlir-commits] [mlir] [mlir][vector][spirv] Lower vector.load and vector.store to SPIR-V (PR #71674)
Lei Zhang
llvmlistbot at llvm.org
Wed Nov 8 21:39:16 PST 2023
================
@@ -509,6 +509,72 @@ struct VectorShuffleOpConvert final
}
};
+struct VectorLoadOpConverter final
+ : public OpConversionPattern<vector::LoadOp> {
+ using OpConversionPattern::OpConversionPattern;
+
+ LogicalResult
+ matchAndRewrite(vector::LoadOp loadOp, OpAdaptor adaptor,
+ ConversionPatternRewriter &rewriter) const override {
+ auto memrefType = loadOp.getMemRefType();
+ auto attr =
+ dyn_cast_or_null<spirv::StorageClassAttr>(memrefType.getMemorySpace());
+ if (!attr)
+ return failure();
+
+ const auto &typeConverter = *getTypeConverter<SPIRVTypeConverter>();
+ auto loc = loadOp.getLoc();
+ Value accessChain =
+ spirv::getElementPtr(typeConverter, memrefType, adaptor.getBase(),
+ adaptor.getIndices(), loc, rewriter);
+ if (!accessChain)
+ return failure();
----------------
antiagainst wrote:
Similarly, `return rewriter.notifyMatchFailure(loadOp, "failed to get memref element pointer")`.
https://github.com/llvm/llvm-project/pull/71674
More information about the Mlir-commits
mailing list