19 #define GEN_PASS_DEF_COMPOSITEFIXEDPOINTPASS
20 #include "mlir/Transforms/Passes.h.inc"
26 struct CompositeFixedPointPass final
27 :
public impl::CompositeFixedPointPassBase<CompositeFixedPointPass> {
28 using CompositeFixedPointPassBase::CompositeFixedPointPassBase;
30 CompositeFixedPointPass(
33 name = std::move(name_);
34 maxIter = maxIterations;
35 populateFunc(dynamicPM);
37 llvm::raw_string_ostream os(pipelineStr);
38 dynamicPM.printAsTextualPipeline(os);
41 LogicalResult initializeOptions(
43 function_ref<LogicalResult(
const Twine &)> errorHandler)
override {
44 if (failed(CompositeFixedPointPassBase::initializeOptions(
options,
49 return errorHandler(
"Failed to parse composite pass pipeline");
54 LogicalResult initialize(
MLIRContext *context)
override {
57 <<
"Invalid maxIterations value: " << maxIter <<
"\n";
63 dynamicPM.getDependentDialects(registry);
66 void runOnOperation()
override {
67 auto op = getOperation();
71 int maxIterVal = maxIter;
73 if (failed(runPipeline(dynamicPM, op)))
74 return signalPassFailure();
76 if (currentIter++ >= maxIterVal) {
77 op->
emitWarning(
"Composite pass \"" + llvm::Twine(name) +
78 "\"+ didn't converge in " + llvm::Twine(maxIterVal) +
92 llvm::StringRef getName()
const override {
return name; }
103 return std::make_unique<CompositeFixedPointPass>(std::move(name),
104 populateFunc, maxIterations);
static llvm::ManagedStatic< PassManagerOptions > options
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
MLIRContext is the top-level object for a collection of MLIR operations.
This class represents a pass manager that runs passes on either a specific operation type,...
A unique fingerprint for a specific operation, and all of it's internal operations (if includeNested ...
InFlightDiagnostic emitWarning(const Twine &message={})
Emit a warning about this operation, reporting up to any diagnostic handlers that may be listening.
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
std::unique_ptr< Pass > createCompositeFixedPointPass(std::string name, llvm::function_ref< void(OpPassManager &)> populateFunc, int maxIterations=10)
Create composite pass, which runs provided set of passes until fixed point or maximum number of itera...
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
LogicalResult parsePassPipeline(StringRef pipeline, OpPassManager &pm, raw_ostream &errorStream=llvm::errs())
Parse the textual representation of a pass pipeline, adding the result to 'pm' on success.