[Mlir-commits] [mlir] [mlir][EmitC] Expand the MemRefToEmitC pass - Lowering `reinterpret_cast` (PR #152610)
Jacques Pienaar
llvmlistbot at llvm.org
Sun Aug 10 20:33:14 PDT 2025
================
@@ -269,6 +272,62 @@ struct ConvertLoad final : public OpConversionPattern<memref::LoadOp> {
}
};
+struct ConvertReinterpretCastOp final
+ : public OpConversionPattern<memref::ReinterpretCastOp> {
+ using OpConversionPattern::OpConversionPattern;
+
+ LogicalResult
+ matchAndRewrite(memref::ReinterpretCastOp castOp, OpAdaptor adaptor,
+ ConversionPatternRewriter &rewriter) const override {
+
+ MemRefType srcType = cast<MemRefType>(castOp.getSource().getType());
+
+ MemRefType targetMemRefType =
+ cast<MemRefType>(castOp.getResult().getType());
+
+ auto srcInEmitC = convertMemRefType(srcType, getTypeConverter());
+ auto targetInEmitC =
+ convertMemRefType(targetMemRefType, getTypeConverter());
+ if (!srcInEmitC || !targetInEmitC) {
+ return rewriter.notifyMatchFailure(castOp.getLoc(),
+ "cannot convert memref type");
+ }
+ Location loc = castOp.getLoc();
----------------
jpienaar wrote:
Empty lines are for me similar to paragraphs in text, it creates logical separations/groupings which aid reading. Here I can't quite figure those out.
https://github.com/llvm/llvm-project/pull/152610
More information about the Mlir-commits
mailing list