Skip to content

Commit 127556b

Browse files
[mlir][IR] Delete match and rewrite functions
1 parent a21cfca commit 127556b

File tree

3 files changed

+0
-135
lines changed

3 files changed

+0
-135
lines changed

mlir/include/mlir/Conversion/LLVMCommon/Pattern.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ LogicalResult oneToOneRewrite(
4040
/// during the entire pattern lifetime.
4141
class ConvertToLLVMPattern : public ConversionPattern {
4242
public:
43-
/// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of
44-
/// separate `match` and `rewrite`.
45-
using SplitMatchAndRewrite =
46-
detail::ConversionSplitMatchAndRewriteImpl<ConvertToLLVMPattern>;
47-
4843
ConvertToLLVMPattern(StringRef rootOpName, MLIRContext *context,
4944
const LLVMTypeConverter &typeConverter,
5045
PatternBenefit benefit = 1);
@@ -147,16 +142,10 @@ class ConvertToLLVMPattern : public ConversionPattern {
147142
template <typename SourceOp>
148143
class ConvertOpToLLVMPattern : public ConvertToLLVMPattern {
149144
public:
150-
using OperationT = SourceOp;
151145
using OpAdaptor = typename SourceOp::Adaptor;
152146
using OneToNOpAdaptor =
153147
typename SourceOp::template GenericAdaptor<ArrayRef<ValueRange>>;
154148

155-
/// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of
156-
/// separate `match` and `rewrite`.
157-
using SplitMatchAndRewrite = detail::ConversionSplitMatchAndRewriteImpl<
158-
ConvertOpToLLVMPattern<SourceOp>>;
159-
160149
explicit ConvertOpToLLVMPattern(const LLVMTypeConverter &typeConverter,
161150
PatternBenefit benefit = 1)
162151
: ConvertToLLVMPattern(SourceOp::getOperationName(),

mlir/include/mlir/IR/PatternMatch.h

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -234,48 +234,9 @@ class Pattern {
234234
// RewritePattern
235235
//===----------------------------------------------------------------------===//
236236

237-
namespace detail {
238-
/// Helper class that derives from a RewritePattern class and provides separate
239-
/// `match` and `rewrite` entry points instead of a combined `matchAndRewrite`.
240-
///
241-
/// This class is deprecated. Use `matchAndRewrite` instead of separate `match`
242-
/// and `rewrite`.
243-
template <typename PatternT>
244-
class SplitMatchAndRewriteImpl : public PatternT {
245-
using PatternT::PatternT;
246-
247-
/// Attempt to match against IR rooted at the specified operation, which is
248-
/// the same operation kind as getRootKind().
249-
///
250-
/// Note: This function must not modify the IR.
251-
virtual LogicalResult match(typename PatternT::OperationT op) const = 0;
252-
253-
/// Rewrite the IR rooted at the specified operation with the result of
254-
/// this pattern, generating any new operations with the specified
255-
/// rewriter.
256-
virtual void rewrite(typename PatternT::OperationT op,
257-
PatternRewriter &rewriter) const = 0;
258-
259-
LogicalResult matchAndRewrite(typename PatternT::OperationT op,
260-
PatternRewriter &rewriter) const final {
261-
if (succeeded(match(op))) {
262-
rewrite(op, rewriter);
263-
return success();
264-
}
265-
return failure();
266-
}
267-
};
268-
} // namespace detail
269-
270237
/// RewritePattern is the common base class for all DAG to DAG replacements.
271238
class RewritePattern : public Pattern {
272239
public:
273-
using OperationT = Operation *;
274-
275-
/// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of
276-
/// separate `match` and `rewrite`.
277-
using SplitMatchAndRewrite = detail::SplitMatchAndRewriteImpl<RewritePattern>;
278-
279240
virtual ~RewritePattern() = default;
280241

281242
/// Attempt to match against code rooted at the specified operation,
@@ -334,7 +295,6 @@ namespace detail {
334295
/// class or Interface.
335296
template <typename SourceOp>
336297
struct OpOrInterfaceRewritePatternBase : public RewritePattern {
337-
using OperationT = SourceOp;
338298
using RewritePattern::RewritePattern;
339299

340300
/// Wrapper around the RewritePattern method that passes the derived op type.
@@ -357,11 +317,6 @@ template <typename SourceOp>
357317
struct OpRewritePattern
358318
: public detail::OpOrInterfaceRewritePatternBase<SourceOp> {
359319

360-
/// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of
361-
/// separate `match` and `rewrite`.
362-
using SplitMatchAndRewrite =
363-
detail::SplitMatchAndRewriteImpl<OpRewritePattern<SourceOp>>;
364-
365320
/// Patterns must specify the root operation name they match against, and can
366321
/// also specify the benefit of the pattern matching and a list of generated
367322
/// ops.
@@ -378,11 +333,6 @@ template <typename SourceOp>
378333
struct OpInterfaceRewritePattern
379334
: public detail::OpOrInterfaceRewritePatternBase<SourceOp> {
380335

381-
/// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of
382-
/// separate `match` and `rewrite`.
383-
using SplitMatchAndRewrite =
384-
detail::SplitMatchAndRewriteImpl<OpInterfaceRewritePattern<SourceOp>>;
385-
386336
OpInterfaceRewritePattern(MLIRContext *context, PatternBenefit benefit = 1)
387337
: detail::OpOrInterfaceRewritePatternBase<SourceOp>(
388338
Pattern::MatchInterfaceOpTypeTag(), SourceOp::getInterfaceID(),

mlir/include/mlir/Transforms/DialectConversion.h

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -528,82 +528,14 @@ class TypeConverter {
528528
// Conversion Patterns
529529
//===----------------------------------------------------------------------===//
530530

531-
namespace detail {
532-
/// Helper class that derives from a ConversionRewritePattern class and
533-
/// provides separate `match` and `rewrite` entry points instead of a combined
534-
/// `matchAndRewrite`.
535-
template <typename PatternT>
536-
class ConversionSplitMatchAndRewriteImpl : public PatternT {
537-
using PatternT::PatternT;
538-
539-
/// Attempt to match against IR rooted at the specified operation, which is
540-
/// the same operation kind as getRootKind().
541-
///
542-
/// Note: This function must not modify the IR.
543-
virtual LogicalResult match(typename PatternT::OperationT op) const = 0;
544-
545-
/// Rewrite the IR rooted at the specified operation with the result of
546-
/// this pattern, generating any new operations with the specified
547-
/// rewriter.
548-
virtual void rewrite(typename PatternT::OperationT op,
549-
typename PatternT::OpAdaptor adaptor,
550-
ConversionPatternRewriter &rewriter) const {
551-
// One of the two `rewrite` functions must be implemented.
552-
llvm_unreachable("rewrite is not implemented");
553-
}
554-
555-
virtual void rewrite(typename PatternT::OperationT op,
556-
typename PatternT::OneToNOpAdaptor adaptor,
557-
ConversionPatternRewriter &rewriter) const {
558-
if constexpr (std::is_same<typename PatternT::OpAdaptor,
559-
ArrayRef<Value>>::value) {
560-
rewrite(op, PatternT::getOneToOneAdaptorOperands(adaptor), rewriter);
561-
} else {
562-
SmallVector<Value> oneToOneOperands =
563-
PatternT::getOneToOneAdaptorOperands(adaptor.getOperands());
564-
rewrite(op, typename PatternT::OpAdaptor(oneToOneOperands, adaptor),
565-
rewriter);
566-
}
567-
}
568-
569-
LogicalResult
570-
matchAndRewrite(typename PatternT::OperationT op,
571-
typename PatternT::OneToNOpAdaptor adaptor,
572-
ConversionPatternRewriter &rewriter) const final {
573-
if (succeeded(match(op))) {
574-
rewrite(op, adaptor, rewriter);
575-
return success();
576-
}
577-
return failure();
578-
}
579-
580-
LogicalResult
581-
matchAndRewrite(typename PatternT::OperationT op,
582-
typename PatternT::OpAdaptor adaptor,
583-
ConversionPatternRewriter &rewriter) const final {
584-
// Users would normally override this function in conversion patterns to
585-
// implement a 1:1 pattern. Patterns that are derived from this class have
586-
// separate `match` and `rewrite` functions, so this `matchAndRewrite`
587-
// overload is obsolete.
588-
llvm_unreachable("this function is unreachable");
589-
}
590-
};
591-
} // namespace detail
592-
593531
/// Base class for the conversion patterns. This pattern class enables type
594532
/// conversions, and other uses specific to the conversion framework. As such,
595533
/// patterns of this type can only be used with the 'apply*' methods below.
596534
class ConversionPattern : public RewritePattern {
597535
public:
598-
using OperationT = Operation *;
599536
using OpAdaptor = ArrayRef<Value>;
600537
using OneToNOpAdaptor = ArrayRef<ValueRange>;
601538

602-
/// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of
603-
/// separate `match` and `rewrite`.
604-
using SplitMatchAndRewrite =
605-
detail::ConversionSplitMatchAndRewriteImpl<ConversionPattern>;
606-
607539
/// Hook for derived classes to implement combined matching and rewriting.
608540
/// This overload supports only 1:1 replacements. The 1:N overload is called
609541
/// by the driver. By default, it calls this 1:1 overload or reports a fatal
@@ -668,16 +600,10 @@ class ConversionPattern : public RewritePattern {
668600
template <typename SourceOp>
669601
class OpConversionPattern : public ConversionPattern {
670602
public:
671-
using OperationT = SourceOp;
672603
using OpAdaptor = typename SourceOp::Adaptor;
673604
using OneToNOpAdaptor =
674605
typename SourceOp::template GenericAdaptor<ArrayRef<ValueRange>>;
675606

676-
/// `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of
677-
/// separate `match` and `rewrite`.
678-
using SplitMatchAndRewrite =
679-
detail::ConversionSplitMatchAndRewriteImpl<OpConversionPattern<SourceOp>>;
680-
681607
OpConversionPattern(MLIRContext *context, PatternBenefit benefit = 1)
682608
: ConversionPattern(SourceOp::getOperationName(), benefit, context) {}
683609
OpConversionPattern(const TypeConverter &typeConverter, MLIRContext *context,

0 commit comments

Comments
 (0)