My Project
Public Member Functions | List of all members
mlir::OpRewritePattern< SourceOp > Struct Template Reference

#include <PatternMatch.h>

Inheritance diagram for mlir::OpRewritePattern< SourceOp >:
Inheritance graph
[legend]
Collaboration diagram for mlir::OpRewritePattern< SourceOp >:
Collaboration graph
[legend]

Public Member Functions

 OpRewritePattern (MLIRContext *context, PatternBenefit benefit=1)
 
void rewrite (Operation *op, std::unique_ptr< PatternState > state, PatternRewriter &rewriter) const final
 Wrappers around the RewritePattern methods that pass the derived op type. More...
 
void rewrite (Operation *op, PatternRewriter &rewriter) const final
 
PatternMatchResult match (Operation *op) const final
 
PatternMatchResult matchAndRewrite (Operation *op, PatternRewriter &rewriter) const final
 
virtual void rewrite (SourceOp op, std::unique_ptr< PatternState > state, PatternRewriter &rewriter) const
 
virtual void rewrite (SourceOp op, PatternRewriter &rewriter) const
 
virtual PatternMatchResult match (SourceOp op) const
 
virtual PatternMatchResult matchAndRewrite (SourceOp op, PatternRewriter &rewriter) const
 
- Public Member Functions inherited from mlir::RewritePattern
ArrayRef< OperationNamegetGeneratedOps () const
 
- Public Member Functions inherited from mlir::Pattern
PatternBenefit getBenefit () const
 
OperationName getRootKind () const
 
virtual ~Pattern ()
 
PatternMatchResult matchSuccess (std::unique_ptr< PatternState > state={}) const
 This method indicates that a match was found and has the specified cost. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from mlir::Pattern
static PatternMatchResult matchFailure ()
 This method indicates that no match was found. More...
 
- Protected Member Functions inherited from mlir::RewritePattern
 RewritePattern (StringRef rootName, PatternBenefit benefit, MLIRContext *context)
 
 RewritePattern (StringRef rootName, ArrayRef< StringRef > generatedNames, PatternBenefit benefit, MLIRContext *context)
 
- Protected Member Functions inherited from mlir::Pattern
 Pattern (StringRef rootName, PatternBenefit benefit, MLIRContext *context)
 
- Protected Attributes inherited from mlir::RewritePattern
SmallVector< OperationName, 2 > generatedOps
 

Detailed Description

template<typename SourceOp>
struct mlir::OpRewritePattern< SourceOp >

OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an instance of a derived operation class as opposed to a raw Operation.

Constructor & Destructor Documentation

◆ OpRewritePattern()

template<typename SourceOp>
mlir::OpRewritePattern< SourceOp >::OpRewritePattern ( MLIRContext context,
PatternBenefit  benefit = 1 
)
inline

Patterns must specify the root operation name they match against, and can also specify the benefit of the pattern matching.

Member Function Documentation

◆ match() [1/2]

template<typename SourceOp>
PatternMatchResult mlir::OpRewritePattern< SourceOp >::match ( Operation op) const
inlinefinalvirtual

Attempt to match against code rooted at the specified operation, which is the same operation code as getRootKind(). On failure, this returns a None value. On success, it returns a (possibly null) pattern-specific state wrapped in an Optional. This state is passed back into the rewrite function if this match is selected.

Reimplemented from mlir::RewritePattern.

◆ match() [2/2]

template<typename SourceOp>
virtual PatternMatchResult mlir::OpRewritePattern< SourceOp >::match ( SourceOp  op) const
inlinevirtual

◆ matchAndRewrite() [1/2]

template<typename SourceOp>
PatternMatchResult mlir::OpRewritePattern< SourceOp >::matchAndRewrite ( Operation op,
PatternRewriter rewriter 
) const
inlinefinalvirtual

Attempt to match against code rooted at the specified operation, which is the same operation code as getRootKind(). If successful, this function will automatically perform the rewrite.

Reimplemented from mlir::RewritePattern.

◆ matchAndRewrite() [2/2]

template<typename SourceOp>
virtual PatternMatchResult mlir::OpRewritePattern< SourceOp >::matchAndRewrite ( SourceOp  op,
PatternRewriter rewriter 
) const
inlinevirtual

◆ rewrite() [1/4]

template<typename SourceOp>
void mlir::OpRewritePattern< SourceOp >::rewrite ( Operation op,
std::unique_ptr< PatternState state,
PatternRewriter rewriter 
) const
inlinefinalvirtual

Wrappers around the RewritePattern methods that pass the derived op type.

Reimplemented from mlir::RewritePattern.

◆ rewrite() [2/4]

template<typename SourceOp>
void mlir::OpRewritePattern< SourceOp >::rewrite ( Operation op,
PatternRewriter rewriter 
) const
inlinefinalvirtual

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 from mlir::RewritePattern.

◆ rewrite() [3/4]

template<typename SourceOp>
virtual void mlir::OpRewritePattern< SourceOp >::rewrite ( SourceOp  op,
std::unique_ptr< PatternState state,
PatternRewriter rewriter 
) const
inlinevirtual

Rewrite and Match methods that operate on the SourceOp type. These must be overridden by the derived pattern class.

◆ rewrite() [4/4]

template<typename SourceOp>
virtual void mlir::OpRewritePattern< SourceOp >::rewrite ( SourceOp  op,
PatternRewriter rewriter 
) const
inlinevirtual

The documentation for this struct was generated from the following file: