diff --git a/mlir/include/mlir/Conversion/LLVMCommon/Pattern.h b/mlir/include/mlir/Conversion/LLVMCommon/Pattern.h index e78f174ff8586..c65f7d7217be5 100644 --- a/mlir/include/mlir/Conversion/LLVMCommon/Pattern.h +++ b/mlir/include/mlir/Conversion/LLVMCommon/Pattern.h @@ -40,11 +40,6 @@ LogicalResult oneToOneRewrite( /// during the entire pattern lifetime. class ConvertToLLVMPattern : public ConversionPattern { public: - /// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of - /// separate `match` and `rewrite`. - using SplitMatchAndRewrite = - detail::ConversionSplitMatchAndRewriteImpl; - ConvertToLLVMPattern(StringRef rootOpName, MLIRContext *context, const LLVMTypeConverter &typeConverter, PatternBenefit benefit = 1); @@ -147,16 +142,10 @@ class ConvertToLLVMPattern : public ConversionPattern { template class ConvertOpToLLVMPattern : public ConvertToLLVMPattern { public: - using OperationT = SourceOp; using OpAdaptor = typename SourceOp::Adaptor; using OneToNOpAdaptor = typename SourceOp::template GenericAdaptor>; - /// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of - /// separate `match` and `rewrite`. - using SplitMatchAndRewrite = detail::ConversionSplitMatchAndRewriteImpl< - ConvertOpToLLVMPattern>; - explicit ConvertOpToLLVMPattern(const LLVMTypeConverter &typeConverter, PatternBenefit benefit = 1) : ConvertToLLVMPattern(SourceOp::getOperationName(), diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index d1f00c34f87b4..fc6ae8fb55fec 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -234,48 +234,9 @@ class Pattern { // RewritePattern //===----------------------------------------------------------------------===// -namespace detail { -/// Helper class that derives from a RewritePattern class and provides separate -/// `match` and `rewrite` entry points instead of a combined `matchAndRewrite`. -/// -/// This class is deprecated. Use `matchAndRewrite` instead of separate `match` -/// and `rewrite`. -template -class SplitMatchAndRewriteImpl : public PatternT { - using PatternT::PatternT; - - /// Attempt to match against IR rooted at the specified operation, which is - /// the same operation kind as getRootKind(). - /// - /// Note: This function must not modify the IR. - virtual LogicalResult match(typename PatternT::OperationT op) const = 0; - - /// Rewrite the IR rooted at the specified operation with the result of - /// this pattern, generating any new operations with the specified - /// rewriter. - virtual void rewrite(typename PatternT::OperationT op, - PatternRewriter &rewriter) const = 0; - - LogicalResult matchAndRewrite(typename PatternT::OperationT op, - PatternRewriter &rewriter) const final { - if (succeeded(match(op))) { - rewrite(op, rewriter); - return success(); - } - return failure(); - } -}; -} // namespace detail - /// RewritePattern is the common base class for all DAG to DAG replacements. class RewritePattern : public Pattern { public: - using OperationT = Operation *; - - /// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of - /// separate `match` and `rewrite`. - using SplitMatchAndRewrite = detail::SplitMatchAndRewriteImpl; - virtual ~RewritePattern() = default; /// Attempt to match against code rooted at the specified operation, @@ -334,7 +295,6 @@ namespace detail { /// class or Interface. template struct OpOrInterfaceRewritePatternBase : public RewritePattern { - using OperationT = SourceOp; using RewritePattern::RewritePattern; /// Wrapper around the RewritePattern method that passes the derived op type. @@ -357,11 +317,6 @@ template struct OpRewritePattern : public detail::OpOrInterfaceRewritePatternBase { - /// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of - /// separate `match` and `rewrite`. - using SplitMatchAndRewrite = - detail::SplitMatchAndRewriteImpl>; - /// Patterns must specify the root operation name they match against, and can /// also specify the benefit of the pattern matching and a list of generated /// ops. @@ -378,11 +333,6 @@ template struct OpInterfaceRewritePattern : public detail::OpOrInterfaceRewritePatternBase { - /// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of - /// separate `match` and `rewrite`. - using SplitMatchAndRewrite = - detail::SplitMatchAndRewriteImpl>; - OpInterfaceRewritePattern(MLIRContext *context, PatternBenefit benefit = 1) : detail::OpOrInterfaceRewritePatternBase( Pattern::MatchInterfaceOpTypeTag(), SourceOp::getInterfaceID(), diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index f54397e942ae0..879c9a486e694 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -528,82 +528,14 @@ class TypeConverter { // Conversion Patterns //===----------------------------------------------------------------------===// -namespace detail { -/// Helper class that derives from a ConversionRewritePattern class and -/// provides separate `match` and `rewrite` entry points instead of a combined -/// `matchAndRewrite`. -template -class ConversionSplitMatchAndRewriteImpl : public PatternT { - using PatternT::PatternT; - - /// Attempt to match against IR rooted at the specified operation, which is - /// the same operation kind as getRootKind(). - /// - /// Note: This function must not modify the IR. - virtual LogicalResult match(typename PatternT::OperationT op) const = 0; - - /// Rewrite the IR rooted at the specified operation with the result of - /// this pattern, generating any new operations with the specified - /// rewriter. - virtual void rewrite(typename PatternT::OperationT op, - typename PatternT::OpAdaptor adaptor, - ConversionPatternRewriter &rewriter) const { - // One of the two `rewrite` functions must be implemented. - llvm_unreachable("rewrite is not implemented"); - } - - virtual void rewrite(typename PatternT::OperationT op, - typename PatternT::OneToNOpAdaptor adaptor, - ConversionPatternRewriter &rewriter) const { - if constexpr (std::is_same>::value) { - rewrite(op, PatternT::getOneToOneAdaptorOperands(adaptor), rewriter); - } else { - SmallVector oneToOneOperands = - PatternT::getOneToOneAdaptorOperands(adaptor.getOperands()); - rewrite(op, typename PatternT::OpAdaptor(oneToOneOperands, adaptor), - rewriter); - } - } - - LogicalResult - matchAndRewrite(typename PatternT::OperationT op, - typename PatternT::OneToNOpAdaptor adaptor, - ConversionPatternRewriter &rewriter) const final { - if (succeeded(match(op))) { - rewrite(op, adaptor, rewriter); - return success(); - } - return failure(); - } - - LogicalResult - matchAndRewrite(typename PatternT::OperationT op, - typename PatternT::OpAdaptor adaptor, - ConversionPatternRewriter &rewriter) const final { - // Users would normally override this function in conversion patterns to - // implement a 1:1 pattern. Patterns that are derived from this class have - // separate `match` and `rewrite` functions, so this `matchAndRewrite` - // overload is obsolete. - llvm_unreachable("this function is unreachable"); - } -}; -} // namespace detail - /// Base class for the conversion patterns. This pattern class enables type /// conversions, and other uses specific to the conversion framework. As such, /// patterns of this type can only be used with the 'apply*' methods below. class ConversionPattern : public RewritePattern { public: - using OperationT = Operation *; using OpAdaptor = ArrayRef; using OneToNOpAdaptor = ArrayRef; - /// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of - /// separate `match` and `rewrite`. - using SplitMatchAndRewrite = - detail::ConversionSplitMatchAndRewriteImpl; - /// Hook for derived classes to implement combined matching and rewriting. /// This overload supports only 1:1 replacements. The 1:N overload is called /// by the driver. By default, it calls this 1:1 overload or reports a fatal @@ -668,16 +600,10 @@ class ConversionPattern : public RewritePattern { template class OpConversionPattern : public ConversionPattern { public: - using OperationT = SourceOp; using OpAdaptor = typename SourceOp::Adaptor; using OneToNOpAdaptor = typename SourceOp::template GenericAdaptor>; - /// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of - /// separate `match` and `rewrite`. - using SplitMatchAndRewrite = - detail::ConversionSplitMatchAndRewriteImpl>; - OpConversionPattern(MLIRContext *context, PatternBenefit benefit = 1) : ConversionPattern(SourceOp::getOperationName(), benefit, context) {} OpConversionPattern(const TypeConverter &typeConverter, MLIRContext *context,