[PSA] Migrating `mlir-opt`-like tools to use `MlirOptMainConfig`

If you’re using the MlirOptMain(int argc, char **argv, ...) entry point you won’t be affected, otherwise I refactored the long list of options for these APIs:

/// Perform the core processing behind `mlir-opt`.
/// This API is deprecated, use the MlirOptMainConfig version above instead.
LogicalResult MlirOptMain(llvm::raw_ostream &outputStream,
                          std::unique_ptr<llvm::MemoryBuffer> buffer,
                          const PassPipelineCLParser &passPipeline,
                          DialectRegistry &registry, bool splitInputFile,
                          bool verifyDiagnostics, bool verifyPasses,
                          bool allowUnregisteredDialects,
                          bool preloadDialectsInContext = false,
                          bool emitBytecode = false, bool explicitModule = true,
                          bool dumpPassPipeline = false);

/// Perform the core processing behind `mlir-opt`.
/// This API is deprecated, use the MlirOptMainConfig version above instead.
LogicalResult MlirOptMain(
    llvm::raw_ostream &outputStream, std::unique_ptr<llvm::MemoryBuffer> buffer,
    PassPipelineFn passManagerSetupFn, DialectRegistry &registry,
    bool splitInputFile, bool verifyDiagnostics, bool verifyPasses,
    bool allowUnregisteredDialects, bool preloadDialectsInContext = false,
    bool emitBytecode = false, bool explicitModule = true);

into a helper configuration MlirOptMainConfig. Please migrate to use this instead of the APIs above

You can take example on the implementation of MlirOptMain(int argc, char **argv, ...) to see how to use it. It also exposes a fluent API if needed:

  // Setup the configuration for the main function.
  MlirOptMainConfig config;
  config.setPassPipelineParser(passPipeline)
      .splitInputFile(splitInputFile)
      .verifyDiagnostics(verifyDiagnostics)
      .verifyPasses(verifyPasses)
      .allowUnregisteredDialects(allowUnregisteredDialects)
      .preloadDialectsInContext(preloadDialectsInContext)
      .emitBytecode(emitBytecode)
      .useExplicitModule(explicitModule)
      .dumpPassPipeline(dumpPassPipeline);

Also preloadDialectInContext has been deprecated for >1y and will be removed (I’ll write another PSA for this as well).

Just a reminder: this will likely go away this week.

I was travelling and that fell through, but the revision is up now: ⚙ D149038 Remove deprecated entry point for MlirOptMain