13 #ifndef MLIR_TOOLS_MLIROPT_MLIROPTMAIN_H
14 #define MLIR_TOOLS_MLIROPT_MLIROPTMAIN_H
18 #include "llvm/ADT/StringRef.h"
30 class DialectRegistry;
31 class PassPipelineCLParser;
282 std::pair<std::string, std::string>
291 LogicalResult
MlirOptMain(llvm::raw_ostream &outputStream,
292 std::unique_ptr<llvm::MemoryBuffer> buffer,
299 LogicalResult
MlirOptMain(
int argc,
char **argv, llvm::StringRef toolName,
308 LogicalResult
MlirOptMain(
int argc,
char **argv, llvm::StringRef inputFilename,
309 llvm::StringRef outputFilename,
323 return r.succeeded() ? EXIT_SUCCESS : EXIT_FAILURE;
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
Configuration options for the mlir-opt tool.
tracing::DebugConfig & getDebugConfig()
static MlirOptMainConfig createFromCLOptions()
Create a new config with the default set from the CL options.
std::string splitInputFileFlag
Split the input file based on the given marker into chunks and process each chunk independently.
bool shouldVerifyPasses() const
StringRef inputSplitMarker() const
bool shouldVerifyRoundtrip() const
std::optional< int64_t > bytecodeVersionToEmit() const
bool disableVerifierOnParsingFlag
Disable the verifier on parsing.
std::optional< int64_t > emitBytecodeVersion
Emit bytecode at given version.
StringRef getReproducerFilename() const
Reproducer file generation (no crash required).
std::string irdlFileFlag
IRDL file to register before processing the input.
std::vector< tracing::BreakpointManager * > logActionLocationFilter
Location Breakpoints to filter the action logging.
bool emitBytecodeFlag
Emit bytecode instead of textual assembly when generating output.
bool shouldShowDialects() const
MlirOptMainConfig & splitInputFile(std::string splitMarker=kDefaultSplitMarker)
Set the marker on which to split the input into chunks and process each chunk independently.
std::string generateReproducerFileFlag
The reproducer output filename (no crash required).
MlirOptMainConfig & outputSplitMarker(std::string splitMarker=kDefaultSplitMarker)
Set whether to merge the output chunks into one file using the given marker.
std::function< LogicalResult(PassManager &)> passPipelineCallback
The callback to populate the pass manager.
bool dumpPassPipelineFlag
Print the pipeline that will be run.
bool verifyPassesFlag
Run the verifier after each transformation pass.
bool enableDebuggerActionHookFlag
Enable the Debugger action hook: Debugger can intercept MLIR Actions.
MlirOptMainConfig & verifyRoundtrip(bool verify)
Set whether to run the verifier after each transformation pass.
MlirOptMainConfig & setIrdlFile(StringRef file)
Set the IRDL file to load before processing the input.
MlirOptMainConfig & verifyPasses(bool verify)
Set whether to run the verifier after each transformation pass.
bool shouldVerifyOnParsing() const
bool shouldElideResourceDataFromBytecode() const
bool shouldEmitBytecode() const
tracing::DebugConfig debugConfig
Configuration for the debugging hooks.
StringRef outputSplitMarker() const
MlirOptMainConfig & setPassPipelineSetupFn(std::function< LogicalResult(PassManager &)> callback)
Set the callback to populate the pass manager.
MlirOptMainConfig & showDialects(bool show)
Show the registered dialects before trying to load the input file.
bool runReproducerFlag
Enable running the reproducer.
MlirOptMainConfig & dumpPassPipeline(bool dump)
Print the pass-pipeline as text before executing.
MlirOptMainConfig & verifyOnParsing(bool verify)
Set whether to run the verifier on parsing.
MlirOptMainConfig & runReproducer(bool enableReproducer)
Enable running the reproducer information stored in resources (if present).
MlirOptMainConfig & verifyDiagnostics(bool verify)
Set whether to check that emitted diagnostics match expected-* lines on the corresponding line.
bool verifyRoundtripFlag
Verify that the input IR round-trips perfectly.
bool verifyDiagnosticsFlag
Set whether to check that emitted diagnostics match expected-* lines on the corresponding line.
bool allowUnregisteredDialectsFlag
Allow operation with no registered dialects.
MlirOptMainConfig & useExplicitModule(bool useExplicitModule)
Disable implicit addition of a top-level module op during parsing.
LogicalResult setupPassPipeline(PassManager &pm) const
Populate the passmanager, if any callback was set.
MlirOptMainConfig & setEmitBytecodeVersion(int64_t version)
Set the bytecode version to emit.
static void registerCLOptions(DialectRegistry &dialectRegistry)
Register the options as global LLVM command line options.
bool shouldAllowUnregisteredDialects() const
bool shouldUseExplicitModule() const
bool shouldRunReproducer() const
Return true if the reproducer should be run.
bool elideResourceDataFromBytecodeFlag
Elide resources when generating bytecode.
MlirOptMainConfig & allowUnregisteredDialects(bool allow)
Options.
bool shouldDumpPassPipeline() const
bool shouldVerifyDiagnostics() const
bool useExplicitModuleFlag
Use an explicit top-level module op during parsing.
const tracing::DebugConfig & getDebugConfig() const
bool shouldListPasses() const
bool showDialectsFlag
Show the registered dialects before trying to load the input file.
MlirOptMainConfig & listPasses(bool list)
List the registered passes and return.
MlirOptMainConfig & setDebugConfig(tracing::DebugConfig config)
Set the debug configuration to use.
StringRef getIrdlFile() const
bool listPassesFlag
List the registered passes and return.
std::string outputSplitMarkerFlag
Merge output chunks into one file using the given marker.
MlirOptMainConfig & emitBytecode(bool emit)
Set the output format to bytecode instead of textual IR.
MlirOptMainConfig & setPassPipelineParser(const PassPipelineCLParser &parser)
Set the parser to use to populate the pass manager.
The main pass manager and pipeline builder.
This class implements a command-line parser for MLIR passes.
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Include the generated interface declarations.
const char *const kDefaultSplitMarker
int asMainReturnCode(LogicalResult r)
Helper wrapper to return the result of MlirOptMain directly from main.
LogicalResult MlirOptMain(llvm::raw_ostream &outputStream, std::unique_ptr< llvm::MemoryBuffer > buffer, DialectRegistry ®istry, const MlirOptMainConfig &config)
Perform the core processing behind mlir-opt.
std::pair< std::string, std::string > registerAndParseCLIOptions(int argc, char **argv, llvm::StringRef toolName, DialectRegistry ®istry)
Register and parse command line options.
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...