14 #ifndef MLIR_REWRITE_PATTERNAPPLICATOR_H
15 #define MLIR_REWRITE_PATTERNAPPLICATOR_H
22 class PatternRewriter;
25 class PDLByteCodeMutableState;
35 static constexpr StringLiteral
tag =
"apply-pattern";
36 static constexpr StringLiteral
desc =
37 "Encapsulate the application of rewrite patterns";
39 void print(raw_ostream &os)
const override {
73 function_ref<LogicalResult(
const Pattern &)> onSuccess = {});
96 std::unique_ptr<detail::PDLByteCodeMutableState> mutableByteCodeState;
This is the type of Action that is dispatched when a pattern is applied.
ApplyPatternAction(ArrayRef< IRUnit > irUnits, const Pattern &pattern)
static constexpr StringLiteral desc
void print(raw_ostream &os) const override
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.
This class manages the application of a group of rewrite patterns, with a user-provided cost model.
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.
StringRef getDebugName() const
Return a readable name for this pattern.
CRTP Implementation of an action.
ArrayRef< IRUnit > irUnits
Set of IR units (operations, regions, blocks, values) that are associated with this action.
void walk(Operation *op, function_ref< void(Region *)> callback, WalkOrder order)
Walk all of the regions, blocks, or operations nested under (and including) the given operation.
Include the generated interface declarations.
llvm::function_ref< Fn > function_ref