20 #define GEN_PASS_DEF_CANONICALIZER
21 #include "mlir/Transforms/Passes.h.inc"
28 struct Canonicalizer :
public impl::CanonicalizerBase<Canonicalizer> {
29 Canonicalizer() =
default;
38 this->disabledPatterns = disabledPatterns;
39 this->enabledPatterns = enabledPatterns;
44 LogicalResult initialize(
MLIRContext *context)
override {
53 dialect->getCanonicalizationPatterns(owningPatterns);
55 op.getCanonicalizationPatterns(owningPatterns, context);
57 patterns = std::make_shared<FrozenRewritePatternSet>(
58 std::move(owningPatterns), disabledPatterns, enabledPatterns);
61 void runOnOperation()
override {
62 LogicalResult converged =
65 if (testConvergence && failed(converged))
69 std::shared_ptr<const FrozenRewritePatternSet> patterns;
75 return std::make_unique<Canonicalizer>();
83 return std::make_unique<Canonicalizer>(config, disabledPatterns,
This class allows control over how the GreedyPatternRewriteDriver works.
int64_t maxIterations
This specifies the maximum number of times the rewriter will iterate between applying patterns and si...
bool useTopDownTraversal
This specifies the order of initial traversal that populates the rewriters worklist.
int64_t maxNumRewrites
This specifies the maximum number of rewrites within an iteration.
GreedySimplifyRegionLevel enableRegionSimplification
Perform control flow optimizations to the region tree after applying all patterns.
MLIRContext is the top-level object for a collection of MLIR operations.
std::vector< Dialect * > getLoadedDialects()
Return information about all IR dialects loaded in the context.
ArrayRef< RegisteredOperationName > getRegisteredOperations()
Return a sorted array containing the information about all registered operations.
This is a "type erased" representation of a registered operation.
Include the generated interface declarations.
LogicalResult applyPatternsAndFoldGreedily(Region ®ion, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config=GreedyRewriteConfig(), bool *changed=nullptr)
Rewrite ops in the given region, which must be isolated from above, by repeatedly applying the highes...
std::unique_ptr< Pass > createCanonicalizerPass()
Creates an instance of the Canonicalizer pass, configured with default settings (which can be overrid...