@@ -528,82 +528,14 @@ class TypeConverter {
528
528
// Conversion Patterns
529
529
// ===----------------------------------------------------------------------===//
530
530
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
-
593
531
// / Base class for the conversion patterns. This pattern class enables type
594
532
// / conversions, and other uses specific to the conversion framework. As such,
595
533
// / patterns of this type can only be used with the 'apply*' methods below.
596
534
class ConversionPattern : public RewritePattern {
597
535
public:
598
- using OperationT = Operation *;
599
536
using OpAdaptor = ArrayRef<Value>;
600
537
using OneToNOpAdaptor = ArrayRef<ValueRange>;
601
538
602
- // / `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of
603
- // / separate `match` and `rewrite`.
604
- using SplitMatchAndRewrite =
605
- detail::ConversionSplitMatchAndRewriteImpl<ConversionPattern>;
606
-
607
539
// / Hook for derived classes to implement combined matching and rewriting.
608
540
// / This overload supports only 1:1 replacements. The 1:N overload is called
609
541
// / by the driver. By default, it calls this 1:1 overload or reports a fatal
@@ -668,16 +600,10 @@ class ConversionPattern : public RewritePattern {
668
600
template <typename SourceOp>
669
601
class OpConversionPattern : public ConversionPattern {
670
602
public:
671
- using OperationT = SourceOp;
672
603
using OpAdaptor = typename SourceOp::Adaptor;
673
604
using OneToNOpAdaptor =
674
605
typename SourceOp::template GenericAdaptor<ArrayRef<ValueRange>>;
675
606
676
- // / `SplitMatchAndRewrite` is deprecated. Use `matchAndRewrite` instead of
677
- // / separate `match` and `rewrite`.
678
- using SplitMatchAndRewrite =
679
- detail::ConversionSplitMatchAndRewriteImpl<OpConversionPattern<SourceOp>>;
680
-
681
607
OpConversionPattern (MLIRContext *context, PatternBenefit benefit = 1 )
682
608
: ConversionPattern(SourceOp::getOperationName(), benefit, context) {}
683
609
OpConversionPattern (const TypeConverter &typeConverter, MLIRContext *context,
0 commit comments