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;
233 const bool hasFilters =
358 std::pair<std::string, std::string>
367 LogicalResult
MlirOptMain(llvm::raw_ostream &outputStream,
368 std::unique_ptr<llvm::MemoryBuffer> buffer,
375 LogicalResult
MlirOptMain(
int argc,
char **argv, llvm::StringRef toolName,
384 LogicalResult
MlirOptMain(
int argc,
char **argv, llvm::StringRef inputFilename,
385 llvm::StringRef outputFilename,
399 return r.succeeded() ? EXIT_SUCCESS : EXIT_FAILURE;
static LogicalResult emit(SolverOp solver, const SMTEmissionOptions &options, mlir::raw_indented_ostream &stream)
Emit the SMT operations in the given 'solver' to the 'stream'.
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
Configuration options for the mlir-opt tool.
tracing::DebugConfig & getDebugConfig()
std::string getRemarksAnalyseFilter() const
Set the remark analyse filters.
std::string getRemarksMissedFilter() const
Set the remark missed filters.
bool shouldEmitRemarks() const
Checks if any remark filters are set.
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
SourceMgrDiagnosticVerifierHandler::Level verifyDiagnosticsLevel() const
std::optional< int64_t > bytecodeVersionToEmit() const
bool shouldShowNotes() 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.
VerbosityLevel diagnosticVerbosityLevelFlag
Verbosity level of diagnostic information.
std::vector< tracing::BreakpointManager * > logActionLocationFilter
Location Breakpoints to filter the action logging.
bool emitBytecodeFlag
Emit bytecode instead of textual assembly when generating output.
std::string getRemarksOutputFile() const
Set the remark output file.
bool shouldShowDialects() const
MlirOptMainConfig & verifyDiagnostics(SourceMgrDiagnosticVerifierHandler::Level verify)
Set whether to check that emitted diagnostics match expected-* lines on the corresponding line.
MlirOptMainConfig & splitInputFile(std::string splitMarker=kDefaultSplitMarker)
Set the marker on which to split the input into chunks and process each chunk independently.
std::string getRemarksFailedFilter() const
Set the remark failed filters.
bool disableDiagnosticNotesFlag
Show the notes in diagnostic information.
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.
SourceMgrDiagnosticVerifierHandler::Level verifyDiagnosticsFlag
Set whether to check that emitted diagnostics match expected-* lines on the corresponding line.
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.
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.
std::string remarksOutputFileFlag
Remark file to output to.
bool shouldVerifyOnParsing() const
std::string getRemarksAllFilter() const
Set the remark format to use.
bool shouldElideResourceDataFromBytecode() const
bool shouldEmitBytecode() const
tracing::DebugConfig debugConfig
Configuration for the debugging hooks.
RemarkFormat remarkFormatFlag
Remark format.
StringRef outputSplitMarker() const
MlirOptMainConfig & setPassPipelineSetupFn(std::function< LogicalResult(PassManager &)> callback)
Set the callback to populate the pass manager.
RemarkFormat getRemarkFormat() const
Set the reproducer output filename.
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).
std::string remarksAllFilterFlag
Remark filters.
bool verifyRoundtripFlag
Verify that the input IR round-trips perfectly.
std::string remarksPassedFilterFlag
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.
std::string remarksAnalyseFilterFlag
static void registerCLOptions(DialectRegistry &dialectRegistry)
Register the options as global LLVM command line options.
bool shouldAllowUnregisteredDialects() const
bool shouldUseExplicitModule() const
VerbosityLevel getDiagnosticVerbosityLevel() const
bool shouldRunReproducer() const
Return true if the reproducer should be run.
bool elideResourceDataFromBytecodeFlag
Elide resources when generating bytecode.
MlirOptMainConfig & allowUnregisteredDialects(bool allow)
Options.
std::string remarksFailedFilterFlag
bool shouldDumpPassPipeline() const
bool shouldVerifyDiagnostics() const
bool useExplicitModuleFlag
Use an explicit top-level module op during parsing.
const tracing::DebugConfig & getDebugConfig() const
std::string remarksMissedFilterFlag
std::string getRemarksPassedFilter() const
Set the remark passed filters.
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.
const FrozenRewritePatternSet GreedyRewriteConfig config
LogicalResult MlirOptMain(llvm::raw_ostream &outputStream, std::unique_ptr< llvm::MemoryBuffer > buffer, DialectRegistry ®istry, const MlirOptMainConfig &config)
Perform the core processing behind mlir-opt.
@ REMARK_FORMAT_BITSTREAM
std::pair< std::string, std::string > registerAndParseCLIOptions(int argc, char **argv, llvm::StringRef toolName, DialectRegistry ®istry)
Register and parse command line options.
VerbosityLevel
enum class to indicate the verbosity level of the diagnostic filter.
@ ErrorsWarningsAndRemarks
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...