14#ifndef MLIR_REWRITE_PATTERNAPPLICATOR_H
15#define MLIR_REWRITE_PATTERNAPPLICATOR_H
35 static constexpr StringLiteral
tag =
"apply-pattern";
36 static constexpr StringLiteral
desc =
37 "Encapsulate the application of rewrite patterns";
40 os <<
"`" <<
tag <<
" pattern: " << pattern.getDebugName();
73 function_ref<LogicalResult(
const Pattern &)> onSuccess = {});
96 std::unique_ptr<detail::PDLByteCodeMutableState> mutableByteCodeState;
ApplyPatternAction(ArrayRef< IRUnit > irUnits, const Pattern &pattern)
static constexpr StringLiteral desc
void print(raw_ostream &os) const override
tracing::ActionImpl< ApplyPatternAction > Base
static constexpr StringLiteral tag
This class represents a frozen set of patterns that can be processed by a pattern applicator.
Operation is the basic unit of execution within MLIR.
void walkAllPatterns(function_ref< void(const Pattern &)> walk)
Walk all of the patterns within the applicator.
void applyCostModel(CostModel model)
Apply a cost model to the patterns within this applicator.
LogicalResult matchAndRewrite(Operation *op, PatternRewriter &rewriter, function_ref< bool(const Pattern &)> canApply={}, function_ref< void(const Pattern &)> onFailure={}, function_ref< LogicalResult(const Pattern &)> onSuccess={})
Attempt to match and rewrite the given op with any pattern, allowing a predicate to decide if a patte...
PatternApplicator(const FrozenRewritePatternSet &frozenPatternList)
function_ref< PatternBenefit(const Pattern &)> CostModel
The cost model dynamically assigns a PatternBenefit to a particular pattern.
void applyDefaultCostModel()
Apply the default cost model that solely uses the pattern's static benefit.
This class represents the benefit of a pattern match in a unitless scheme that ranges from 0 (very li...
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
This class contains all of the data related to a pattern, but does not contain any methods or logic f...
PatternBenefit getBenefit() const
Return the benefit (the inverse of "cost") of matching this pattern.
CRTP Implementation of an action.
ArrayRef< IRUnit > irUnits
Set of IR units (operations, regions, blocks, values) that are associated with this action.
Include the generated interface declarations.
const FrozenRewritePatternSet & patterns
llvm::DenseMap< KeyT, ValueT, KeyInfoT, BucketT > DenseMap
llvm::function_ref< Fn > function_ref