My Project
Public Member Functions | List of all members
mlir::ConversionPattern Class Reference

#include <DialectConversion.h>

Inheritance diagram for mlir::ConversionPattern:
Inheritance graph
[legend]
Collaboration diagram for mlir::ConversionPattern:
Collaboration graph
[legend]

Public Member Functions

 ConversionPattern (StringRef rootName, PatternBenefit benefit, MLIRContext *ctx)
 
virtual void rewrite (Operation *op, ArrayRef< Value > operands, ConversionPatternRewriter &rewriter) const
 
virtual void rewrite (Operation *op, ArrayRef< Value > properOperands, ArrayRef< Block *> destinations, ArrayRef< ArrayRef< Value >> operands, ConversionPatternRewriter &rewriter) const
 
virtual PatternMatchResult matchAndRewrite (Operation *op, ArrayRef< Value > properOperands, ArrayRef< Block *> destinations, ArrayRef< ArrayRef< Value >> operands, ConversionPatternRewriter &rewriter) const
 Hook for derived classes to implement combined matching and rewriting. More...
 
virtual PatternMatchResult matchAndRewrite (Operation *op, ArrayRef< Value > operands, ConversionPatternRewriter &rewriter) const
 Hook for derived classes to implement combined matching and rewriting. More...
 
PatternMatchResult matchAndRewrite (Operation *op, PatternRewriter &rewriter) const final
 Attempt to match and rewrite the IR root at the specified operation. More...
 
- Public Member Functions inherited from mlir::RewritePattern
virtual void rewrite (Operation *op, std::unique_ptr< PatternState > state, PatternRewriter &rewriter) const
 
virtual void rewrite (Operation *op, PatternRewriter &rewriter) const
 
PatternMatchResult match (Operation *op) const override
 
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

Base class for the conversion patterns that require type changes. Specific conversions must derive this class and implement least one rewrite method. NOTE: These conversion patterns can only be used with the 'apply*' methods below.

Constructor & Destructor Documentation

◆ ConversionPattern()

mlir::ConversionPattern::ConversionPattern ( StringRef  rootName,
PatternBenefit  benefit,
MLIRContext ctx 
)
inline

Construct an ConversionPattern. rootName must correspond to the canonical name of the first operation matched by the pattern.

Member Function Documentation

◆ matchAndRewrite() [1/3]

virtual PatternMatchResult mlir::ConversionPattern::matchAndRewrite ( Operation op,
ArrayRef< Value properOperands,
ArrayRef< Block *>  destinations,
ArrayRef< ArrayRef< Value >>  operands,
ConversionPatternRewriter rewriter 
) const
inlinevirtual

Hook for derived classes to implement combined matching and rewriting.

Reimplemented in mlir::OpConversionPattern< SourceOp >.

◆ matchAndRewrite() [2/3]

virtual PatternMatchResult mlir::ConversionPattern::matchAndRewrite ( Operation op,
ArrayRef< Value operands,
ConversionPatternRewriter rewriter 
) const
inlinevirtual

Hook for derived classes to implement combined matching and rewriting.

Reimplemented in mlir::OpConversionPattern< SourceOp >, mlir::GPUIndexIntrinsicOpLowering< Op, XOp, YOp, ZOp >, and mlir::OpToFuncCallLowering< SourceOp >.

◆ matchAndRewrite() [3/3]

PatternMatchResult ConversionPattern::matchAndRewrite ( Operation op,
PatternRewriter rewriter 
) const
finalvirtual

Attempt to match and rewrite the IR root at the specified operation.

Reimplemented from mlir::RewritePattern.

◆ rewrite() [1/2]

virtual void mlir::ConversionPattern::rewrite ( Operation op,
ArrayRef< Value operands,
ConversionPatternRewriter rewriter 
) const
inlinevirtual

Hook for derived classes to implement rewriting. op is the (first) operation matched by the pattern, operands is a list of rewritten values that are passed to this operation, rewriter can be used to emit the new operations. This function must be reimplemented if the ConversionPattern ever needs to replace an operation that does not have successors. This function should not fail. If some specific cases of the operation are not supported, these cases should not be matched.

Reimplemented in mlir::OpConversionPattern< SourceOp >.

◆ rewrite() [2/2]

virtual void mlir::ConversionPattern::rewrite ( Operation op,
ArrayRef< Value properOperands,
ArrayRef< Block *>  destinations,
ArrayRef< ArrayRef< Value >>  operands,
ConversionPatternRewriter rewriter 
) const
inlinevirtual

Hook for derived classes to implement rewriting. op is the (first) operation matched by the pattern, properOperands is a list of rewritten values that are passed to the operation itself, destinations is a list of (potentially rewritten) successor blocks, operands is a list of lists of rewritten values passed to each of the successors, co-indexed with destinations, rewriter can be used to emit the new operations. It must be reimplemented if the ConversionPattern ever needs to replace a terminator operation that has successors. This function should not fail the pass. If some specific cases of the operation are not supported, these cases should not be matched.

Reimplemented in mlir::OpConversionPattern< SourceOp >.


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