MLIR
21.0.0git
|
This class contains all of the data related to a pattern, but does not contain any methods or logic for the actual matching. More...
#include "mlir/IR/PatternMatch.h"
Classes | |
struct | MatchAnyOpTypeTag |
This class acts as a special tag that makes the desire to match "any" operation type explicit. More... | |
struct | MatchInterfaceOpTypeTag |
This class acts as a special tag that makes the desire to match any operation that implements a given interface explicit. More... | |
struct | MatchTraitOpTypeTag |
This class acts as a special tag that makes the desire to match any operation that implements a given trait explicit. More... | |
Public Member Functions | |
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) |
Protected Member Functions | |
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... | |
This class contains all of the data related to a pattern, but does not contain any methods or logic for the actual matching.
This class is solely used to interface with the metadata of a pattern, such as the benefit or root operation.
Definition at line 73 of file PatternMatch.h.
|
protected |
Construct a pattern with a certain benefit that matches the operation with the given root name.
Definition at line 39 of file PatternMatch.cpp.
|
protected |
Construct a pattern that may match any operation type.
generatedNames
contains the names of operations that may be generated during a successful rewrite. MatchAnyOpTypeTag
is just a tag to ensure that the "match any" behavior is what the user actually desired, MatchAnyOpTypeTag()
should always be supplied here.
Definition at line 47 of file PatternMatch.cpp.
|
protected |
Construct a pattern that may match any operation that implements the interface defined by the provided interfaceID
.
generatedNames
contains the names of operations that may be generated during a successful rewrite. MatchInterfaceOpTypeTag
is just a tag to ensure that the "match
interface" behavior is what the user actually desired, MatchInterfaceOpTypeTag()
should always be supplied here.
Definition at line 54 of file PatternMatch.cpp.
|
protected |
Construct a pattern that may match any operation that implements the trait defined by the provided traitID
.
generatedNames
contains the names of operations that may be generated during a successful rewrite. MatchTraitOpTypeTag
is just a tag to ensure that the "match trait" behavior is what the user actually desired, MatchTraitOpTypeTag()
should always be supplied here.
Definition at line 63 of file PatternMatch.cpp.
|
inline |
Add the provided debug labels to this pattern.
Definition at line 150 of file PatternMatch.h.
|
inline |
Definition at line 153 of file PatternMatch.h.
|
inline |
Return the benefit (the inverse of "cost") of matching this pattern.
The benefit of a Pattern is always static - rewrites that may have dynamic benefit can be instantiated multiple times (different Pattern instances) for each benefit that they may return, and be guarded by different match condition predicates.
Definition at line 123 of file PatternMatch.h.
Referenced by mlir::PatternApplicator::applyCostModel(), mlir::PatternApplicator::applyDefaultCostModel(), and mlir::PatternApplicator::matchAndRewrite().
|
inline |
Return the MLIRContext used to create this pattern.
Definition at line 134 of file PatternMatch.h.
Referenced by mlir::ConvertToLLVMPattern::copyUnrankedDescriptors(), mlir::ConvertToLLVMPattern::getIntPtrType(), mlir::ConvertToLLVMPattern::getVoidPtrType(), and mlir::ConvertToLLVMPattern::getVoidType().
|
inline |
Return the set of debug labels attached to this pattern.
Definition at line 147 of file PatternMatch.h.
|
inline |
Return a readable name for this pattern.
This name should only be used for debugging purposes, and may be empty.
Definition at line 140 of file PatternMatch.h.
Referenced by mlir::PatternApplicator::matchAndRewrite(), and mlir::ApplyPatternAction::print().
|
inline |
Return a list of operations that may be generated when rewriting an operation instance with this pattern.
Definition at line 90 of file PatternMatch.h.
|
inline |
Return the interface ID used to match the root operation of this pattern.
If the pattern does not use an interface ID for deciding the root match, this returns std::nullopt.
Definition at line 103 of file PatternMatch.h.
References mlir::TypeID::getFromOpaquePointer().
|
inline |
Return the root node that this pattern matches.
Patterns that can match multiple root types return std::nullopt.
Definition at line 94 of file PatternMatch.h.
References mlir::OperationName::getFromOpaquePointer().
Referenced by logImpossibleToMatch().
|
inline |
Return the trait ID used to match the root operation of this pattern.
If the pattern does not use a trait ID for deciding the root match, this returns std::nullopt.
Definition at line 112 of file PatternMatch.h.
References mlir::TypeID::getFromOpaquePointer().
|
inline |
Returns true if this pattern is known to result in recursive application, i.e.
this pattern may generate IR that also matches this pattern, but is known to bound the recursion. This signals to a rewrite driver that it is safe to apply this pattern recursively to generated IR.
Definition at line 129 of file PatternMatch.h.
|
inline |
Set the human readable debug name used for this pattern.
This name will only be used for debugging purposes.
Definition at line 144 of file PatternMatch.h.
|
inlineprotected |
Set the flag detailing if this pattern has bounded rewrite recursion or not.
Definition at line 202 of file PatternMatch.h.