MLIR  19.0.0git
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
mlir::RewritePattern Class Reference

RewritePattern is the common base class for all DAG to DAG replacements. More...

#include "mlir/IR/PatternMatch.h"

+ Inheritance diagram for mlir::RewritePattern:

Public Member Functions

virtual ~RewritePattern ()=default
 
virtual void rewrite (Operation *op, PatternRewriter &rewriter) const
 Rewrite the IR rooted at the specified operation with the result of this pattern, generating any new operations with the specified builder. More...
 
virtual LogicalResult match (Operation *op) const
 Attempt to match against code rooted at the specified operation, which is the same operation code as getRootKind(). More...
 
virtual LogicalResult matchAndRewrite (Operation *op, PatternRewriter &rewriter) const
 Attempt to match against code rooted at the specified operation, which is the same operation code as getRootKind(). More...
 
- Public Member Functions inherited from mlir::Pattern
ArrayRef< OperationNamegetGeneratedOps () const
 Return a list of operations that may be generated when rewriting an operation instance with this pattern. More...
 
std::optional< OperationNamegetRootKind () const
 Return the root node that this pattern matches. More...
 
std::optional< TypeIDgetRootInterfaceID () const
 Return the interface ID used to match the root operation of this pattern. More...
 
std::optional< TypeIDgetRootTraitID () const
 Return the trait ID used to match the root operation of this pattern. More...
 
PatternBenefit getBenefit () const
 Return the benefit (the inverse of "cost") of matching this pattern. More...
 
bool hasBoundedRewriteRecursion () const
 Returns true if this pattern is known to result in recursive application, i.e. More...
 
MLIRContextgetContext () const
 Return the MLIRContext used to create this pattern. More...
 
StringRef getDebugName () const
 Return a readable name for this pattern. More...
 
void setDebugName (StringRef name)
 Set the human readable debug name used for this pattern. More...
 
ArrayRef< StringRef > getDebugLabels () const
 Return the set of debug labels attached to this pattern. More...
 
void addDebugLabels (ArrayRef< StringRef > labels)
 Add the provided debug labels to this pattern. More...
 
void addDebugLabels (StringRef label)
 

Static Public Member Functions

template<typename T , typename... Args>
static std::unique_ptr< T > create (Args &&...args)
 This method provides a convenient interface for creating and initializing derived rewrite patterns of the given type T. More...
 

Protected Member Functions

 Pattern (StringRef rootName, PatternBenefit benefit, MLIRContext *context, ArrayRef< StringRef > generatedNames={})
 Inherit the base constructors from Pattern. More...
 
 Pattern (MatchAnyOpTypeTag tag, PatternBenefit benefit, MLIRContext *context, ArrayRef< StringRef > generatedNames={})
 Inherit the base constructors from Pattern. More...
 
 Pattern (MatchInterfaceOpTypeTag tag, TypeID interfaceID, PatternBenefit benefit, MLIRContext *context, ArrayRef< StringRef > generatedNames={})
 Inherit the base constructors from Pattern. More...
 
 Pattern (MatchTraitOpTypeTag tag, TypeID traitID, PatternBenefit benefit, MLIRContext *context, ArrayRef< StringRef > generatedNames={})
 Inherit the base constructors from Pattern. More...
 
- Protected Member Functions inherited from mlir::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. More...
 
 Pattern (MatchAnyOpTypeTag tag, PatternBenefit benefit, MLIRContext *context, ArrayRef< StringRef > generatedNames={})
 Construct a pattern that may match any operation type. More...
 
 Pattern (MatchInterfaceOpTypeTag tag, TypeID interfaceID, PatternBenefit benefit, MLIRContext *context, ArrayRef< StringRef > generatedNames={})
 Construct a pattern that may match any operation that implements the interface defined by the provided interfaceID. More...
 
 Pattern (MatchTraitOpTypeTag tag, TypeID traitID, PatternBenefit benefit, MLIRContext *context, ArrayRef< StringRef > generatedNames={})
 Construct a pattern that may match any operation that implements the trait defined by the provided traitID. More...
 
void setHasBoundedRewriteRecursion (bool hasBoundedRecursionArg=true)
 Set the flag detailing if this pattern has bounded rewrite recursion or not. More...
 

Detailed Description

RewritePattern is the common base class for all DAG to DAG replacements.

There are two possible usages of this class:

Definition at line 245 of file PatternMatch.h.

Constructor & Destructor Documentation

◆ ~RewritePattern()

virtual mlir::RewritePattern::~RewritePattern ( )
virtualdefault

Member Function Documentation

◆ create()

template<typename T , typename... Args>
static std::unique_ptr<T> mlir::RewritePattern::create ( Args &&...  args)
inlinestatic

This method provides a convenient interface for creating and initializing derived rewrite patterns of the given type T.

Definition at line 275 of file PatternMatch.h.

◆ match()

LogicalResult RewritePattern::match ( Operation op) const
virtual

◆ matchAndRewrite()

virtual LogicalResult mlir::RewritePattern::matchAndRewrite ( Operation op,
PatternRewriter rewriter 
) const
inlinevirtual

◆ Pattern() [1/4]

Pattern::Pattern
protected

Inherit the base constructors from Pattern.

Definition at line 179 of file PatternMatch.cpp.

◆ Pattern() [2/4]

Pattern::Pattern
protected

Inherit the base constructors from Pattern.

Definition at line 187 of file PatternMatch.cpp.

◆ Pattern() [3/4]

Pattern::Pattern
protected

Inherit the base constructors from Pattern.

Definition at line 196 of file PatternMatch.cpp.

◆ Pattern() [4/4]

Pattern::Pattern
protected

Inherit the base constructors from Pattern.

Definition at line 172 of file PatternMatch.cpp.

◆ rewrite()

void RewritePattern::rewrite ( Operation op,
PatternRewriter rewriter 
) const
virtual

Rewrite the IR rooted at the specified operation with the result of this pattern, generating any new operations with the specified builder.

If an unexpected error is encountered (an internal compiler error), it is emitted through the normal MLIR diagnostic hooks and the IR is left in a valid state.

Reimplemented in mlir::detail::OpOrInterfaceRewritePatternBase< SourceOp >.

Definition at line 89 of file PatternMatch.cpp.


The documentation for this class was generated from the following files: