MLIR
20.0.0git
|
RewritePattern is the common base class for all DAG to DAG replacements. More...
#include "mlir/IR/PatternMatch.h"
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< OperationName > | getGeneratedOps () const |
Return a list of operations that may be generated when rewriting an operation instance with this pattern. More... | |
std::optional< OperationName > | getRootKind () const |
Return the root node that this pattern matches. More... | |
std::optional< TypeID > | getRootInterfaceID () const |
Return the interface ID used to match the root operation of this pattern. More... | |
std::optional< TypeID > | getRootTraitID () 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... | |
MLIRContext * | getContext () 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... | |
RewritePattern is the common base class for all DAG to DAG replacements.
There are two possible usages of this class:
Definition at line 246 of file PatternMatch.h.
|
virtualdefault |
|
inlinestatic |
This method provides a convenient interface for creating and initializing derived rewrite patterns of the given type T
.
Definition at line 276 of file PatternMatch.h.
|
virtual |
Attempt to match against code rooted at the specified operation, which is the same operation code as getRootKind().
Reimplemented in mlir::OpConversionPattern< SourceOp >, mlir::OpConversionPattern< Op >, mlir::OpConversionPattern< OpTy >, mlir::OpConversionPattern< StorageSpecifierInitOp >, mlir::OpConversionPattern< memref::LoadOp >, mlir::OpConversionPattern< memref::StoreOp >, mlir::OpConversionPattern< gpu::SubgroupReduceOp >, mlir::OpConversionPattern< gpu::AllReduceOp >, mlir::OpConversionPattern< SPIRVOp >, mlir::OpConversionPattern< async::YieldOp >, mlir::OpConversionPattern< cf::AssertOp >, mlir::detail::OpOrInterfaceRewritePatternBase< SourceOp >, mlir::ConvertOpToLLVMPattern< SourceOp >, mlir::ConvertOpToLLVMPattern< Op >, mlir::ConvertOpToLLVMPattern< gpu::PrintfOp >, mlir::ConvertOpToLLVMPattern< gpu::GPUFuncOp >, mlir::ConvertOpToLLVMPattern< gpu::ReturnOp >, mlir::ConvertOpToLLVMPattern< memref::TransposeOp >, mlir::ConvertOpToLLVMPattern< gpu::DynamicSharedMemoryOp >, and mlir::ConvertOpToLLVMPattern< cf::AssertOp >.
Definition at line 95 of file PatternMatch.cpp.
Referenced by mlir::ConversionPattern::matchAndRewrite(), matchAndRewrite(), and mlir::OpInterfaceConversionPattern< SourceOp >::matchAndRewrite().
|
inlinevirtual |
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 in SortCommutativeOperands, mlir::HomomorphismSimplification< GetHomomorphismOpOperandFn, GetHomomorphismOpResultFn, GetSourceAlgebraicOpOperandsFn, GetSourceAlgebraicOpResultFn, GetTargetAlgebraicOpResultFn, IsHomomorphismOpFn, IsSourceAlgebraicOpFn, CreateTargetAlgebraicOpFn >, mlir::HomomorphismSimplification< GetEndomorphismOpOperandFn, GetEndomorphismOpResultFn, GetAlgebraicOpOperandsFn, GetAlgebraicOpResultFn, GetAlgebraicOpResultFn, IsEndomorphismOpFn, IsAlgebraicOpFn, detail::CreateAlgebraicOpForEndomorphismSimplification >, mlir::OneToNConversionPattern, mlir::ConversionPattern, and mlir::detail::OpOrInterfaceRewritePatternBase< SourceOp >.
Definition at line 264 of file PatternMatch.h.
References match(), and rewrite().
Referenced by mlir::PatternApplicator::matchAndRewrite().
|
protected |
Inherit the base constructors from Pattern
.
Definition at line 180 of file PatternMatch.cpp.
|
protected |
Inherit the base constructors from Pattern
.
Definition at line 188 of file PatternMatch.cpp.
|
protected |
Inherit the base constructors from Pattern
.
Definition at line 197 of file PatternMatch.cpp.
|
protected |
Inherit the base constructors from Pattern
.
Definition at line 173 of file PatternMatch.cpp.
|
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 90 of file PatternMatch.cpp.
Referenced by matchAndRewrite().