22 template <
typename OpT>
26 LogicalResult matchAndRewrite(OpT op,
28 auto mRef = op.getRef();
29 if (mRef.getType().hasStaticShape()) {
30 return mlir::failure();
32 auto defOp = mRef.getDefiningOp();
33 if (!defOp || !mlir::isa<mlir::memref::CastOp>(defOp)) {
34 return mlir::failure();
36 auto src = mlir::cast<mlir::memref::CastOp>(defOp).getSource();
37 if (!src.getType().hasStaticShape()) {
38 return mlir::failure();
40 op.getRefMutable().assign(src);
41 return mlir::success();
46 void mlir::mpi::SendOp::getCanonicalizationPatterns(
48 results.
add<FoldCast<mlir::mpi::SendOp>>(context);
51 void mlir::mpi::RecvOp::getCanonicalizationPatterns(
53 results.
add<FoldCast<mlir::mpi::RecvOp>>(context);
56 void mlir::mpi::ISendOp::getCanonicalizationPatterns(
58 results.
add<FoldCast<mlir::mpi::ISendOp>>(context);
61 void mlir::mpi::IRecvOp::getCanonicalizationPatterns(
63 results.
add<FoldCast<mlir::mpi::IRecvOp>>(context);
70 #define GET_OP_CLASSES
71 #include "mlir/Dialect/MPI/IR/MPIOps.cpp.inc"
MLIRContext is the top-level object for a collection of MLIR operations.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
RewritePatternSet & add(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
Include the generated interface declarations.
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...