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);
40 [&]() { os <<
","; });
43 LogicalResult initializeOptions(
45 function_ref<LogicalResult(
const Twine &)> errorHandler)
override {
46 if (failed(CompositeFixedPointPassBase::initializeOptions(
options,
51 return errorHandler(
"Failed to parse composite pass pipeline");
56 LogicalResult initialize(
MLIRContext *context)
override {
59 <<
"Invalid maxIterations value: " << maxIter <<
"\n";
65 dynamicPM.getDependentDialects(registry);
68 void runOnOperation()
override {
69 auto op = getOperation();
73 int maxIterVal = maxIter;
75 if (failed(runPipeline(dynamicPM, op)))
76 return signalPassFailure();
78 if (currentIter++ >= maxIterVal) {
79 op->emitWarning(
"Composite pass \"" + llvm::Twine(name) +
80 "\"+ didn't converge in " + llvm::Twine(maxIterVal) +
94 llvm::StringRef getName()
const override {
return name; }
105 return std::make_unique<CompositeFixedPointPass>(std::move(name),
106 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 ...
The abstract base pass class.
void printAsTextualPipeline(raw_ostream &os)
Prints out the pass in the textual representation of pipelines.
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.