MLIR: include/mlir/IR/PatternMatch.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9 #ifndef MLIR_IR_PATTERNMATCH_H
10 #define MLIR_IR_PATTERNMATCH_H
11
14 #include "llvm/ADT/FunctionExtras.h"
15 #include "llvm/Support/TypeName.h"
16 #include
17
19 namespace mlir {
20
21 class PatternRewriter;
22
23
24
25
26
27
28
29
30
31
32
33
35 enum { ImpossibleToMatchSentinel = 65535 };
36
37 public:
42
45
46
47
49
51 return representation == rhs.representation;
52 }
55 return representation < rhs.representation;
56 }
60
61 private:
62 unsigned short representation{ImpossibleToMatchSentinel};
63 };
64
65
66
67
68
69
70
71
72
74
75
76 enum class RootKind {
77
78 Any,
79
81
82 InterfaceID,
83
84 TraitID
85 };
86
87 public:
88
89
91
92
93
94 std::optional getRootKind() const {
95 if (rootKind == RootKind::OperationName)
97 return std::nullopt;
98 }
99
100
101
102
104 if (rootKind == RootKind::InterfaceID)
106 return std::nullopt;
107 }
108
109
110
111
113 if (rootKind == RootKind::TraitID)
115 return std::nullopt;
116 }
117
118
119
120
121
122
124
125
126
127
128
130 return contextAndHasBoundedRecursion.getInt();
131 }
132
133
135 return contextAndHasBoundedRecursion.getPointer();
136 }
137
138
139
141
142
143
145
146
148
149
151 debugLabels.append(labels.begin(), labels.end());
152 }
153 void addDebugLabels(StringRef label) { debugLabels.push_back(label); }
154
155 protected:
156
157
158
160
161
162
163
165
166
167
168
170
171
172
175
176
177
178
179
182
183
184
185
186
187
188 Pattern(MatchInterfaceOpTypeTag tag, TypeID interfaceID,
189 PatternBenefit benefit, MLIRContext *context,
190 ArrayRef generatedNames = {});
191
192
193
194
195
196
197 Pattern(MatchTraitOpTypeTag tag, TypeID traitID, PatternBenefit benefit,
198 MLIRContext *context, ArrayRef generatedNames = {});
199
200
201
203 contextAndHasBoundedRecursion.setInt(hasBoundedRecursionArg);
204 }
205
206 private:
207 Pattern(const void *rootValue, RootKind rootKind,
210
211
212 const void *rootValue;
213 RootKind rootKind;
214
215
217
218
219
220 llvm::PointerIntPair<MLIRContext *, 1, bool> contextAndHasBoundedRecursion;
221
222
223
225
226
227 StringRef debugName;
228
229
231 };
232
233
234
235
236
237
239 public:
241
242
243
244
245
246
247
250
251
252
253 template <typename T, typename... Args>
254 static std::unique_ptr create(Args &&...args) {
255 std::unique_ptr pattern =
256 std::make_unique(std::forward(args)...);
257 initializePattern(*pattern);
258
259
260 if (pattern->getDebugName().empty())
261 pattern->setDebugName(llvm::getTypeName());
262 return pattern;
263 }
264
265 protected:
266
268
269 private:
270
271 template <typename T, typename... Args>
272 using has_initialize = decltype(std::declval().initialize());
273 template
274 using detect_has_initialize = llvm::is_detected<has_initialize, T>;
275
276
277
278 template
279 static void initializePattern(T &pattern) {
280 if constexpr (detect_has_initialize::value)
281 pattern.initialize();
282 }
283
284
285 virtual void anchor();
286 };
287
288 namespace detail {
289
290
291
292 template
294 using RewritePattern::RewritePattern;
295
296
300 }
301
302
303
306 };
307 }
308
309
310
311
312 template
315
316
317
318
322 SourceOp::getOperationName(), benefit, context, generatedNames) {}
323 };
324
325
326
327
328 template
331
333 : detail::OpOrInterfaceRewritePatternBase(
335 benefit, context) {}
336 };
337
338
339
340
341 template <template <typename> class TraitType>
343 public:
346 benefit, context) {}
347 };
348
349
350
351
352
353
354
355
356
357
359 public:
363
364
365
367
368
370
371
372
373
374
375
376
380 }
381
382
383
384
385
388
389
390
391
392
394
395
396
398
399
400
401
402
403
405 LogicalResult status) {}
406
407
408
409
410
411 virtual void
414
416 };
417
418
419
420
423 : listener(listener),
424 rewriteListener(
426
428 if (listener)
430 }
433 if (listener)
435 }
437 if (rewriteListener)
439 }
441 if (rewriteListener)
443 }
445 if (rewriteListener)
447 }
450 if (rewriteListener)
452 }
454 if (rewriteListener)
456 }
458 if (rewriteListener)
460 }
462 LogicalResult status) override {
463 if (rewriteListener)
465 }
469 if (rewriteListener)
471 }
472
473 private:
476 };
477
478
479
480
481
485
486
487
488
490
491
492
493
495
496
497
498
499 template <typename OpTy, typename... Args>
501 auto newOp = create(op->getLoc(), std::forward(args)...);
502 replaceOp(op, newOp.getOperation());
503 return newOp;
504 }
505
506
508
509
511
512
513
514
515
516
517
518
519
520
523 ValueRange argValues = std::nullopt);
524
525
526
527
528
529
530
532 ValueRange argValues = std::nullopt);
533
534
535
536
537
538
539
541 ValueRange argValues = std::nullopt);
542
543
544
546
547
548
549
551
552
553
555
556
557
558
560
561
562
564
565
567
568
569
571
572
573
574
575
576
577
579
580
581
582
584
585
586
587
589
590
591
592
593 template
596 callable();
598 }
599
600
601
603 for (OpOperand &operand : llvm::make_early_inc_range(from.getUses())) {
604 Operation *op = operand.getOwner();
606 }
607 }
609 for (BlockOperand &operand : llvm::make_early_inc_range(from->getUses())) {
610 Operation *op = operand.getOwner();
612 }
613 }
615 assert(from.size() == to.size() && "incorrect number of replacements");
616 for (auto it : llvm::zip(from, to))
618 }
619
620
621
622
623
624
625
626
629
630
631
632
633
636 bool *allUsesReplaced = nullptr);
639 bool *allUsesReplaced = nullptr);
640
641
642
645 bool *allUsesReplaced = nullptr) {
647 }
648
649
650
651
652
654 Block *block, bool *allUsesReplaced = nullptr) {
656 op, newValues,
659 },
660 allUsesReplaced);
661 }
662
663
664
665
669 return user != exceptedUser;
670 });
671 }
674
675
676
677
678
679
680 template
681 std::enable_if_t<!std::is_convertible<CallbackT, Twine>::value, LogicalResult>
683 if (auto *rewriteListener = dyn_cast_if_present(listener))
684 rewriteListener->notifyMatchFailure(
686 return failure();
687 }
688 template
689 std::enable_if_t<!std::is_convertible<CallbackT, Twine>::value, LogicalResult>
691 if (auto *rewriteListener = dyn_cast_if_present(listener))
692 rewriteListener->notifyMatchFailure(
694 return failure();
695 }
696 template
700 }
701 template
704 }
705
706 protected:
707
716
717 private:
718 void operator=(const RewriterBase &) = delete;
720 };
721
722
723
724
725
726
727
728
729
731 public:
737 };
738
739
740
741
742
743
744
745
746
747
748
750 public:
753
754
755
756
757
759 };
760
761 }
762
763
765
766 namespace mlir {
767
768
769
770
771
773 using NativePatternListT = std::vector<std::unique_ptr>;
774
775 public:
777
778
780 std::unique_ptr pattern)
781 : context(context) {
782 nativePatterns.emplace_back(std::move(pattern));
783 }
785 : context(pattern.getContext()), pdlPatterns(std::move(pattern)) {}
786
788
789
791
792
794
795
797 nativePatterns.clear();
798 pdlPatterns.clear();
799 }
800
801
802
803
804
805
806
807
808 template <typename... Ts, typename ConstructorArg,
809 typename... ConstructorArgs,
810 typename = std::enable_if_t<sizeof...(Ts) != 0>>
812
813
814 (addImpl(std::nullopt,
815 std::forward(arg),
816 std::forward(args)...),
817 ...);
818 return *this;
819 }
820
821
822
823
824 template <typename... Ts, typename ConstructorArg,
825 typename... ConstructorArgs,
826 typename = std::enable_if_t<sizeof...(Ts) != 0>>
828 ConstructorArg &&arg,
829 ConstructorArgs &&...args) {
830
831
832 (addImpl(debugLabels, arg, args...), ...);
833 return *this;
834 }
835
836
837
838 template <typename... Ts>
840 (addImpl(), ...);
841 return *this;
842 }
843
844
845
847 nativePatterns.emplace_back(std::move(pattern));
848 return *this;
849 }
850
851
852
854 pdlPatterns.mergeIn(std::move(pattern));
855 return *this;
856 }
857
858
859 template
864 FnPattern(LogicalResult (*implFn)(OpType, PatternRewriter &rewriter),
867 : OpRewritePattern(context, benefit, generatedNames),
868 implFn(implFn) {}
869
870 LogicalResult matchAndRewrite(OpType op,
871 PatternRewriter &rewriter) const override {
872 return implFn(op, rewriter);
873 }
874
875 private:
876 LogicalResult (*implFn)(OpType, PatternRewriter &rewriter);
877 };
878 add(std::make_unique(std::move(implFn), getContext(), benefit,
879 generatedNames));
880 return *this;
881 }
882
883
884
885
886
887
888
889
890
891
892 template <typename... Ts, typename ConstructorArg,
893 typename... ConstructorArgs,
894 typename = std::enable_if_t<sizeof...(Ts) != 0>>
896
897
898 (addImpl(std::nullopt, arg, args...), ...);
899 return *this;
900 }
901
902
903
904 template <typename... Ts>
906 (addImpl(), ...);
907 return *this;
908 }
909
910
911
913 nativePatterns.emplace_back(std::move(pattern));
914 return *this;
915 }
916
917
918
920 pdlPatterns.mergeIn(std::move(pattern));
921 return *this;
922 }
923
924
925 template
929 FnPattern(LogicalResult (*implFn)(OpType, PatternRewriter &rewriter),
932 this->setDebugName(llvm::getTypeName());
933 }
934
935 LogicalResult matchAndRewrite(OpType op,
937 return implFn(op, rewriter);
938 }
939
940 private:
941 LogicalResult (*implFn)(OpType, PatternRewriter &rewriter);
942 };
943 add(std::make_unique(std::move(implFn), getContext()));
944 return *this;
945 }
946
947 private:
948
949
950 template <typename T, typename... Args>
951 std::enable_if_t<std::is_base_of<RewritePattern, T>::value>
953 std::unique_ptr pattern =
954 RewritePattern::create(std::forward(args)...);
955 pattern->addDebugLabels(debugLabels);
956 nativePatterns.emplace_back(std::move(pattern));
957 }
958
959 template <typename T, typename... Args>
960 std::enable_if_t<std::is_base_of<PDLPatternModule, T>::value>
961 addImpl(ArrayRef debugLabels, Args &&...args) {
962
963
964 pdlPatterns.mergeIn(T(std::forward(args)...));
965 }
966
967 MLIRContext *const context;
968 NativePatternListT nativePatterns;
969
970
971
972 PDLPatternModule pdlPatterns;
973 };
974
975 }
976
977 #endif
static std::string diag(const llvm::Value &value)
A block operand represents an operand that holds a reference to a Block, e.g.
Block represents an ordered list of Operations.
OpListType::iterator iterator
Operation * getParentOp()
Returns the closest surrounding operation that contains this block.
This class contains all of the information necessary to report a diagnostic to the DiagnosticEngine.
use_range getUses() const
Returns a range of all uses, which is useful for iterating over all uses.
This class coordinates rewriting a piece of IR outside of a pattern rewrite, providing a way to keep ...
IRRewriter(MLIRContext *ctx, OpBuilder::Listener *listener=nullptr)
IRRewriter(const OpBuilder &builder)
IRRewriter(Operation *op, OpBuilder::Listener *listener=nullptr)
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
MLIRContext is the top-level object for a collection of MLIR operations.
This class represents a saved insertion point.
This class helps build Operations.
Listener * listener
The optional listener for events of this builder.
This class represents an operand of an operation.
OpTraitRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting again...
OpTraitRewritePattern(MLIRContext *context, PatternBenefit benefit=1)
static OperationName getFromOpaquePointer(const void *pointer)
Operation is the basic unit of execution within MLIR.
Location getLoc()
The source location the operation was defined or derived from.
result_range getResults()
This class represents the benefit of a pattern match in a unitless scheme that ranges from 0 (very li...
PatternBenefit & operator=(const PatternBenefit &)=default
bool operator<(const PatternBenefit &rhs) const
bool operator==(const PatternBenefit &rhs) const
static PatternBenefit impossibleToMatch()
bool operator>=(const PatternBenefit &rhs) const
bool operator<=(const PatternBenefit &rhs) const
PatternBenefit(const PatternBenefit &)=default
bool isImpossibleToMatch() const
bool operator!=(const PatternBenefit &rhs) const
bool operator>(const PatternBenefit &rhs) const
unsigned short getBenefit() const
If the corresponding pattern can match, return its benefit. If the.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
PatternRewriter(MLIRContext *ctx)
virtual bool canRecoverFromRewriteFailure() const
A hook used to indicate if the pattern rewriter can recover from failure during the rewrite stage of ...
This class contains all of the data related to a pattern, but does not contain any methods or logic f...
std::optional< TypeID > getRootInterfaceID() const
Return the interface ID used to match the root operation of this pattern.
Pattern(StringRef rootName, PatternBenefit benefit, MLIRContext *context, ArrayRef< StringRef > generatedNames={})
Construct a pattern with a certain benefit that matches the operation with the given root name.
bool hasBoundedRewriteRecursion() const
Returns true if this pattern is known to result in recursive application, i.e.
std::optional< OperationName > getRootKind() const
Return the root node that this pattern matches.
MLIRContext * getContext() const
Return the MLIRContext used to create this pattern.
ArrayRef< StringRef > getDebugLabels() const
Return the set of debug labels attached to this pattern.
void setHasBoundedRewriteRecursion(bool hasBoundedRecursionArg=true)
Set the flag detailing if this pattern has bounded rewrite recursion or not.
ArrayRef< OperationName > getGeneratedOps() const
Return a list of operations that may be generated when rewriting an operation instance with this patt...
PatternBenefit getBenefit() const
Return the benefit (the inverse of "cost") of matching this pattern.
std::optional< TypeID > getRootTraitID() const
Return the trait ID used to match the root operation of this pattern.
void setDebugName(StringRef name)
Set the human readable debug name used for this pattern.
void addDebugLabels(StringRef label)
void addDebugLabels(ArrayRef< StringRef > labels)
Add the provided debug labels to this pattern.
StringRef getDebugName() const
Return a readable name for this pattern.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
BlockListType::iterator iterator
RewritePatternSet & add(PDLPatternModule &&pattern)
Add the given PDL pattern to the pattern list.
RewritePatternSet & add(LogicalResult(*implFn)(OpType, PatternRewriter &rewriter), PatternBenefit benefit=1, ArrayRef< StringRef > generatedNames={})
NativePatternListT & getNativePatterns()
Return the native patterns held in this list.
RewritePatternSet & add(std::unique_ptr< RewritePattern > pattern)
Add the given native pattern to the pattern list.
RewritePatternSet(PDLPatternModule &&pattern)
RewritePatternSet & insert(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
MLIRContext * getContext() const
void clear()
Clear out all of the held patterns in this list.
RewritePatternSet(MLIRContext *context)
RewritePatternSet & add()
Add an instance of each of the pattern types 'Ts'.
RewritePatternSet(MLIRContext *context, std::unique_ptr< RewritePattern > pattern)
Construct a RewritePatternSet populated with the given pattern.
RewritePatternSet & insert(PDLPatternModule &&pattern)
Add the given PDL pattern to the pattern list.
RewritePatternSet & insert(std::unique_ptr< RewritePattern > pattern)
Add the given native pattern to the pattern list.
PDLPatternModule & getPDLPatterns()
Return the PDL patterns held in this list.
RewritePatternSet & add(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
RewritePatternSet & insert()
Add an instance of each of the pattern types 'Ts'.
RewritePatternSet & addWithLabel(ArrayRef< StringRef > debugLabels, ConstructorArg &&arg, ConstructorArgs &&...args)
An overload of the above add method that allows for attaching a set of debug labels to the attached p...
RewritePatternSet & insert(LogicalResult(*implFn)(OpType, PatternRewriter &rewriter))
RewritePattern is the common base class for all DAG to DAG replacements.
static std::unique_ptr< T > create(Args &&...args)
This method provides a convenient interface for creating and initializing derived rewrite patterns of...
virtual ~RewritePattern()=default
virtual LogicalResult matchAndRewrite(Operation *op, PatternRewriter &rewriter) const =0
Attempt to match against code rooted at the specified operation, which is the same operation code as ...
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure(Location loc, CallbackT &&reasonCallback)
Used to notify the listener that the IR failed to be rewritten because of a match failure,...
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure(Operation *op, CallbackT &&reasonCallback)
void replaceOpUsesWithIf(Operation *from, ValueRange to, function_ref< bool(OpOperand &)> functor, bool *allUsesReplaced=nullptr)
virtual void eraseBlock(Block *block)
This method erases all operations in a block.
LogicalResult notifyMatchFailure(ArgT &&arg, const Twine &msg)
Block * splitBlock(Block *block, Block::iterator before)
Split the operations starting at "before" (inclusive) out of the given block into a new block,...
virtual void replaceOp(Operation *op, ValueRange newValues)
Replace the results of the given (original) operation with the specified list of values (replacements...
RewriterBase(const OpBuilder &otherBuilder)
void replaceAllUsesWith(ValueRange from, ValueRange to)
void moveBlockBefore(Block *block, Block *anotherBlock)
Unlink this block and insert it right before existingBlock.
void replaceAllUsesWith(Value from, Value to)
Find uses of from and replace them with to.
void mergeBlocks(Block *source, Block *dest, ValueRange argValues=std::nullopt)
Inline the operations of block 'source' into the end of block 'dest'.
virtual void finalizeOpModification(Operation *op)
This method is used to signal the end of an in-place modification of the given operation.
RewriterBase(Operation *op, OpBuilder::Listener *listener=nullptr)
virtual void eraseOp(Operation *op)
This method erases an operation that is known to have no uses.
virtual void cancelOpModification(Operation *op)
This method cancels a pending in-place modification.
void replaceAllUsesWith(Block *from, Block *to)
void replaceUsesWithIf(Value from, Value to, function_ref< bool(OpOperand &)> functor, bool *allUsesReplaced=nullptr)
Find uses of from and replace them with to if the functor returns true.
void replaceAllUsesExcept(Value from, Value to, Operation *exceptedUser)
Find uses of from and replace them with to except if the user is exceptedUser.
RewriterBase(MLIRContext *ctx, OpBuilder::Listener *listener=nullptr)
Initialize the builder.
void moveOpBefore(Operation *op, Operation *existingOp)
Unlink this operation from its current block and insert it right before existingOp which may be in th...
LogicalResult notifyMatchFailure(ArgT &&arg, const char *msg)
void modifyOpInPlace(Operation *root, CallableT &&callable)
This method is a utility wrapper around an in-place modification of an operation.
void moveOpAfter(Operation *op, Operation *existingOp)
Unlink this operation from its current block and insert it right after existingOp which may be in the...
void inlineRegionBefore(Region ®ion, Region &parent, Region::iterator before)
Move the blocks that belong to "region" before the given position in another region "parent".
void replaceOpUsesWithinBlock(Operation *op, ValueRange newValues, Block *block, bool *allUsesReplaced=nullptr)
Find uses of from within block and replace them with to.
virtual void inlineBlockBefore(Block *source, Block *dest, Block::iterator before, ValueRange argValues=std::nullopt)
Inline the operations of block 'source' into block 'dest' before the given position.
void replaceAllOpUsesWith(Operation *from, ValueRange to)
Find uses of from and replace them with to.
virtual void startOpModification(Operation *op)
This method is used to notify the rewriter that an in-place operation modification is about to happen...
OpTy replaceOpWithNewOp(Operation *op, Args &&...args)
Replace the results of the given (original) op with a new op that is created without verification (re...
This class provides an efficient unique identifier for a specific C++ type.
static TypeID getFromOpaquePointer(const void *pointer)
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
use_range getUses() const
Returns a range of all uses, which is useful for iterating over all uses.
Operation * getOwner() const
Return the owner of this operand.
Include the generated interface declarations.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
Base class for listeners.
Kind
The kind of listener.
This class represents a listener that may be used to hook into various actions within an OpBuilder.
virtual void notifyBlockInserted(Block *block, Region *previous, Region::iterator previousIt)
Notify the listener that the specified block was inserted.
virtual void notifyOperationInserted(Operation *op, InsertPoint previous)
Notify the listener that the specified operation was inserted.
OpInterfaceRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting a...
OpInterfaceRewritePattern(MLIRContext *context, PatternBenefit benefit=1)
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...
OpRewritePattern(MLIRContext *context, PatternBenefit benefit=1, ArrayRef< StringRef > generatedNames={})
Patterns must specify the root operation name they match against, and can also specify the benefit of...
This class acts as a special tag that makes the desire to match "any" operation type explicit.
This class acts as a special tag that makes the desire to match any operation that implements a given...
This class acts as a special tag that makes the desire to match any operation that implements a given...
A listener that forwards all notifications to another listener.
void notifyMatchFailure(Location loc, function_ref< void(Diagnostic &)> reasonCallback) override
Notify the listener that the pattern failed to match, and provide a callback to populate a diagnostic...
void notifyOperationInserted(Operation *op, InsertPoint previous) override
Notify the listener that the specified operation was inserted.
void notifyPatternEnd(const Pattern &pattern, LogicalResult status) override
Notify the listener that a pattern application finished with the specified status.
void notifyOperationModified(Operation *op) override
Notify the listener that the specified operation was modified in-place.
void notifyPatternBegin(const Pattern &pattern, Operation *op) override
Notify the listener that the specified pattern is about to be applied at the specified root operation...
void notifyOperationReplaced(Operation *op, Operation *newOp) override
Notify the listener that all uses of the specified operation's results are about to be replaced with ...
void notifyOperationErased(Operation *op) override
Notify the listener that the specified operation is about to be erased.
void notifyBlockErased(Block *block) override
Notify the listener that the specified block is about to be erased.
ForwardingListener(OpBuilder::Listener *listener)
void notifyOperationReplaced(Operation *op, ValueRange replacement) override
Notify the listener that all uses of the specified operation's results are about to be replaced with ...
void notifyBlockInserted(Block *block, Region *previous, Region::iterator previousIt) override
Notify the listener that the specified block was inserted.
virtual void notifyMatchFailure(Location loc, function_ref< void(Diagnostic &)> reasonCallback)
Notify the listener that the pattern failed to match, and provide a callback to populate a diagnostic...
virtual void notifyOperationModified(Operation *op)
Notify the listener that the specified operation was modified in-place.
virtual void notifyOperationErased(Operation *op)
Notify the listener that the specified operation is about to be erased.
virtual void notifyOperationReplaced(Operation *op, Operation *replacement)
Notify the listener that all uses of the specified operation's results are about to be replaced with ...
virtual void notifyBlockErased(Block *block)
Notify the listener that the specified block is about to be erased.
virtual void notifyPatternEnd(const Pattern &pattern, LogicalResult status)
Notify the listener that a pattern application finished with the specified status.
virtual void notifyPatternBegin(const Pattern &pattern, Operation *op)
Notify the listener that the specified pattern is about to be applied at the specified root operation...
virtual void notifyOperationReplaced(Operation *op, ValueRange replacement)
Notify the listener that all uses of the specified operation's results are about to be replaced with ...
static bool classof(const OpBuilder::Listener *base)
OpOrInterfaceRewritePatternBase is a wrapper around RewritePattern that allows for matching and rewri...
LogicalResult matchAndRewrite(Operation *op, PatternRewriter &rewriter) const final
Wrapper around the RewritePattern method that passes the derived op type.
virtual LogicalResult matchAndRewrite(SourceOp op, PatternRewriter &rewriter) const =0
Method that operates on the SourceOp type.