14 #ifndef MLIR_TRANSFORMS_GREEDYPATTERNREWRITEDRIVER_H_
15 #define MLIR_TRANSFORMS_GREEDYPATTERNREWRITEDRIVER_H_
54 useTopDownTraversal = use;
63 return regionSimplificationLevel;
67 regionSimplificationLevel = level;
78 maxIterations = iterations;
86 maxNumRewrites = limit;
121 this->listener = listener;
136 cseConstants = enable;
142 bool useTopDownTraversal =
false;
145 int64_t maxIterations = 10;
150 bool cseConstants =
true;
178 GreedyRewriteConfig
config = GreedyRewriteConfig(),
182 LLVM_DEPRECATED(
"Use applyPatternsGreedily() instead",
"applyPatternsGreedily")
220 bool anyRegionChanged =
false;
226 anyRegionChanged |= regionChanged;
230 return failure(failed);
234 LLVM_DEPRECATED(
"Use applyPatternsGreedily() instead",
"applyPatternsGreedily")
274 const FrozenRewritePatternSet &
patterns,
275 GreedyRewriteConfig
config = GreedyRewriteConfig(),
276 bool *
changed =
nullptr,
bool *allErased =
nullptr);
280 "applyOpPatternsGreedily")
285 bool *
changed =
nullptr,
bool *allErased =
nullptr) {
This class represents a frozen set of patterns that can be processed by a pattern applicator.
This class allows control over how the GreedyPatternRewriteDriver works.
static constexpr int64_t kNoLimit
bool isFoldingEnabled() const
Whether this should fold while greedily rewriting.
GreedyRewriteConfig & setListener(RewriterBase::Listener *listener)
bool isConstantCSEEnabled() const
If set to "true", constants are CSE'd (even across multiple regions that are in a parent-ancestor rel...
GreedyRewriteConfig & setUseTopDownTraversal(bool use=true)
GreedyRewriteStrictness getStrictness() const
Strict mode can restrict the ops that are added to the worklist during the rewrite.
GreedyRewriteConfig & setStrictness(GreedyRewriteStrictness mode)
bool getUseTopDownTraversal() const
This specifies the order of initial traversal that populates the rewriters worklist.
GreedyRewriteConfig & setScope(Region *scope)
Region * getScope() const
Only ops within the scope are added to the worklist.
GreedyRewriteConfig & setMaxIterations(int64_t iterations)
RewriterBase::Listener * getListener() const
An optional listener that should be notified about IR modifications.
int64_t getMaxNumRewrites() const
This specifies the maximum number of rewrites within an iteration.
GreedyRewriteConfig & setRegionSimplificationLevel(GreedySimplifyRegionLevel level)
GreedyRewriteConfig & setMaxNumRewrites(int64_t limit)
int64_t getMaxIterations() const
This specifies the maximum number of times the rewriter will iterate between applying patterns and si...
GreedyRewriteConfig & enableConstantCSE(bool enable=true)
GreedySimplifyRegionLevel getRegionSimplificationLevel() const
Perform control flow optimizations to the region tree after applying all patterns.
GreedyRewriteConfig & enableFolding(bool enable=true)
Operation is the basic unit of execution within MLIR.
MutableArrayRef< Region > getRegions()
Returns the regions held by this operation.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Include the generated interface declarations.
const FrozenRewritePatternSet GreedyRewriteConfig bool * changed
GreedySimplifyRegionLevel
@ Aggressive
Run extra simplificiations (e.g.
@ Normal
Run the normal simplification (e.g. dead args elimination).
@ Disabled
Disable region control-flow simplification.
const FrozenRewritePatternSet GreedyRewriteConfig config
LogicalResult applyPatternsGreedily(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...
LogicalResult applyOpPatternsGreedily(ArrayRef< Operation * > ops, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config=GreedyRewriteConfig(), bool *changed=nullptr, bool *allErased=nullptr)
Rewrite the specified ops by repeatedly applying the highest benefit patterns in a greedy worklist dr...
LLVM_DEPRECATED("Use applyOpPatternsGreedily() instead", "applyOpPatternsGreedily") inline LogicalResult applyOpPatternsAndFold(ArrayRef< Operation * > ops
Same as applyOpPatternsGreedily with folding.
const FrozenRewritePatternSet & patterns
LogicalResult applyPatternsAndFoldGreedily(Region ®ion, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config=GreedyRewriteConfig(), bool *changed=nullptr)
Same as applyPatternsAndGreedily above with folding.
GreedyRewriteStrictness
This enum controls which ops are put on the worklist during a greedy pattern rewrite.
@ ExistingOps
Only pre-existing ops are processed.
@ ExistingAndNewOps
Only pre-existing and newly created ops are processed.
@ AnyOp
No restrictions wrt. which ops are processed.