37#include "llvm/ADT/StringRef.h"
38#include "llvm/Remarks/RemarkFormat.h"
39#include "llvm/Support/CommandLine.h"
40#include "llvm/Support/Debug.h"
41#include "llvm/Support/InitLLVM.h"
42#include "llvm/Support/LogicalResult.h"
43#include "llvm/Support/ManagedStatic.h"
44#include "llvm/Support/Process.h"
45#include "llvm/Support/Regex.h"
46#include "llvm/Support/SourceMgr.h"
47#include "llvm/Support/ThreadPool.h"
48#include "llvm/Support/ToolOutputFile.h"
54class BytecodeVersionParser :
public cl::parser<std::optional<int64_t>> {
56 BytecodeVersionParser(cl::Option &o)
57 : cl::parser<std::optional<int64_t>>(o) {}
59 bool parse(cl::Option &o, StringRef , StringRef arg,
60 std::optional<int64_t> &v) {
62 if (getAsSignedInteger(arg, 10, w))
63 return o.error(
"Invalid argument '" + arg +
64 "', only integer is supported.");
73 MlirOptMainConfigCLOptions() {
79 static cl::opt<bool,
true> allowUnregisteredDialects(
80 "allow-unregistered-dialect",
81 cl::desc(
"Allow operation with no registered dialects"),
82 cl::location(allowUnregisteredDialectsFlag), cl::init(
false));
84 static cl::opt<bool,
true> dumpPassPipeline(
85 "dump-pass-pipeline", cl::desc(
"Print the pipeline that will be run"),
86 cl::location(dumpPassPipelineFlag), cl::init(
false));
88 static cl::opt<bool,
true> emitBytecode(
89 "emit-bytecode", cl::desc(
"Emit bytecode when generating output"),
90 cl::location(emitBytecodeFlag), cl::init(
false));
92 static cl::opt<bool,
true> elideResourcesFromBytecode(
93 "elide-resource-data-from-bytecode",
94 cl::desc(
"Elide resources when generating bytecode"),
95 cl::location(elideResourceDataFromBytecodeFlag), cl::init(
false));
97 static cl::opt<std::optional<int64_t>,
true,
98 BytecodeVersionParser>
100 "emit-bytecode-version",
101 cl::desc(
"Use specified bytecode when generating output"),
102 cl::location(emitBytecodeVersion), cl::init(std::nullopt));
104 static cl::opt<std::string,
true> irdlFile(
106 cl::desc(
"IRDL file to register before processing the input"),
107 cl::location(irdlFileFlag), cl::init(
""), cl::value_desc(
"filename"));
110 diagnosticVerbosityLevel(
111 "mlir-diagnostic-verbosity-level",
112 cl::desc(
"Choose level of diagnostic information"),
113 cl::location(diagnosticVerbosityLevelFlag),
114 cl::init(VerbosityLevel::ErrorsWarningsAndRemarks),
116 clEnumValN(VerbosityLevel::ErrorsOnly,
"errors",
"Errors only"),
117 clEnumValN(VerbosityLevel::ErrorsAndWarnings,
"warnings",
118 "Errors and warnings"),
119 clEnumValN(VerbosityLevel::ErrorsWarningsAndRemarks,
"remarks",
120 "Errors, warnings and remarks")));
122 static cl::opt<bool,
true> disableDiagnosticNotes(
123 "mlir-disable-diagnostic-notes", cl::desc(
"Disable diagnostic notes."),
124 cl::location(disableDiagnosticNotesFlag), cl::init(
false));
126 static cl::opt<bool,
true> explicitModule(
127 "no-implicit-module",
128 cl::desc(
"Disable implicit addition of a top-level module op during "
130 cl::location(useExplicitModuleFlag), cl::init(
false));
132 static cl::opt<bool,
true> listPasses(
133 "list-passes", cl::desc(
"Print the list of registered passes and exit"),
134 cl::location(listPassesFlag), cl::init(
false));
136 static cl::opt<bool,
true> runReproducer(
137 "run-reproducer", cl::desc(
"Run the pipeline stored in the reproducer"),
138 cl::location(runReproducerFlag), cl::init(
false));
140 static cl::opt<bool,
true> showDialects(
142 cl::desc(
"Print the list of registered dialects and exit"),
143 cl::location(showDialectsFlag), cl::init(
false));
145 static cl::opt<std::string,
true> splitInputFile{
147 llvm::cl::ValueOptional,
148 cl::callback([&](
const std::string &str) {
153 cl::desc(
"Split the input file into chunks using the given or "
154 "default marker and process each chunk independently"),
155 cl::location(splitInputFileFlag),
158 static cl::opt<std::string,
true> outputSplitMarker(
159 "output-split-marker",
160 cl::desc(
"Split marker to use for merging the ouput"),
166 "verify-diagnostics", llvm::cl::ValueOptional,
167 cl::desc(
"Check that emitted diagnostics match expected-* lines on "
168 "the corresponding line"),
169 cl::location(verifyDiagnosticsFlag),
171 clEnumValN(SourceMgrDiagnosticVerifierHandler::Level::All,
173 "Check all diagnostics (expected, unexpected, "
177 clEnumValN(SourceMgrDiagnosticVerifierHandler::Level::All,
"",
178 "Check all diagnostics (expected, unexpected, "
181 SourceMgrDiagnosticVerifierHandler::Level::OnlyExpected,
182 "only-expected",
"Check only expected diagnostics"))};
184 static cl::opt<bool,
true> verifyPasses(
186 cl::desc(
"Run the verifier after each transformation pass"),
187 cl::location(verifyPassesFlag), cl::init(
true));
189 static cl::opt<bool,
true> disableVerifyOnParsing(
190 "mlir-very-unsafe-disable-verifier-on-parsing",
191 cl::desc(
"Disable the verifier on parsing (very unsafe)"),
192 cl::location(disableVerifierOnParsingFlag), cl::init(
false));
194 static cl::opt<bool,
true> verifyRoundtrip(
196 cl::desc(
"Round-trip the IR after parsing and ensure it succeeds"),
197 cl::location(verifyRoundtripFlag), cl::init(
false));
199 static cl::list<std::string> passPlugins(
200 "load-pass-plugin", cl::desc(
"Load passes from plugin library"));
202 static cl::opt<std::string,
true>
203 generateReproducerFile(
204 "mlir-generate-reproducer",
206 "Generate an mlir reproducer at the provided filename"
207 " (no crash required)"),
208 cl::location(generateReproducerFileFlag), cl::init(
""),
209 cl::value_desc(
"filename"));
211 static cl::OptionCategory remarkCategory(
213 "Filter remarks by regular expression (llvm::Regex syntax).");
217 llvm::cl::desc(
"Specify the format for remark output."),
218 cl::location(remarkFormatFlag),
219 llvm::cl::value_desc(
"format"),
220 llvm::cl::init(RemarkFormat::REMARK_FORMAT_STDOUT),
221 llvm::cl::values(clEnumValN(RemarkFormat::REMARK_FORMAT_STDOUT,
223 "Print as emitRemark to command-line"),
224 clEnumValN(RemarkFormat::REMARK_FORMAT_YAML,
"yaml",
226 clEnumValN(RemarkFormat::REMARK_FORMAT_BITSTREAM,
227 "bitstream",
"Print bitstream file")),
228 llvm::cl::cat(remarkCategory)};
232 llvm::cl::desc(
"Specify the policy for remark output."),
233 cl::location(remarkPolicyFlag),
234 llvm::cl::value_desc(
"format"),
235 llvm::cl::init(RemarkPolicy::REMARK_POLICY_ALL),
236 llvm::cl::values(clEnumValN(RemarkPolicy::REMARK_POLICY_ALL,
"all",
237 "Print all remarks"),
238 clEnumValN(RemarkPolicy::REMARK_POLICY_FINAL,
"final",
239 "Print final remarks")),
240 llvm::cl::cat(remarkCategory)};
242 static cl::opt<std::string,
true> remarksAll(
244 cl::desc(
"Show all remarks: passed, missed, failed, analysis"),
245 cl::location(remarksAllFilterFlag), cl::init(
""),
246 cl::cat(remarkCategory));
248 static cl::opt<std::string,
true> remarksFile(
249 "remarks-output-file",
251 "Output file for yaml and bitstream remark formats. Default is "
252 "mlir-remarks.yaml or mlir-remarks.bitstream"),
253 cl::location(remarksOutputFileFlag), cl::init(
""),
254 cl::cat(remarkCategory));
256 static cl::opt<std::string,
true> remarksPassed(
257 "remarks-filter-passed", cl::desc(
"Show passed remarks"),
258 cl::location(remarksPassedFilterFlag), cl::init(
""),
259 cl::cat(remarkCategory));
261 static cl::opt<std::string,
true> remarksFailed(
262 "remarks-filter-failed", cl::desc(
"Show failed remarks"),
263 cl::location(remarksFailedFilterFlag), cl::init(
""),
264 cl::cat(remarkCategory));
266 static cl::opt<std::string,
true> remarksMissed(
267 "remarks-filter-missed", cl::desc(
"Show missed remarks"),
268 cl::location(remarksMissedFilterFlag), cl::init(
""),
269 cl::cat(remarkCategory));
271 static cl::opt<std::string,
true> remarksAnalyse(
272 "remarks-filter-analyse", cl::desc(
"Show analysis remarks"),
273 cl::location(remarksAnalyseFilterFlag), cl::init(
""),
274 cl::cat(remarkCategory));
277 passPlugins.setCallback([&](
const std::string &pluginPath) {
280 errs() <<
"Failed to load passes from '" << pluginPath
281 <<
"'. Request ignored.\n";
284 plugin.get().registerPassRegistryCallbacks();
287 static cl::list<std::string> dialectPlugins(
288 "load-dialect-plugin", cl::desc(
"Load dialects from plugin library"));
289 this->dialectPlugins = std::addressof(dialectPlugins);
291 static PassPipelineCLParser passPipeline(
"",
"Compiler passes to run",
"p");
292 setPassPipelineParser(passPipeline);
296 void setDialectPluginsCallback(DialectRegistry ®istry);
300 cl::list<std::string> *dialectPlugins =
nullptr;
308 bool showNotes =
true)
309 : ScopedDiagnosticHandler(ctx) {
310 setHandler([verbosityLevel, showNotes](Diagnostic &
diag) {
311 auto severity =
diag.getSeverity();
319 if (verbosityLevel == VerbosityLevel::ErrorsOnly)
324 if (verbosityLevel == VerbosityLevel::ErrorsOnly ||
325 verbosityLevel == VerbosityLevel::ErrorsAndWarnings)
335 llvm_unreachable(
"Unknown diagnostic severity");
356 auto errorHandler = [&](
const Twine &msg) {
357 emitError(UnknownLoc::get(pm.getContext())) << msg;
365 llvm::errs() <<
"\n";
372void MlirOptMainConfigCLOptions::setDialectPluginsCallback(
374 dialectPlugins->setCallback([&](
const std::string &pluginPath) {
377 errs() <<
"Failed to load dialect plugin from '" << pluginPath
378 <<
"'. Request ignored.\n";
381 plugin.get().registerDialectRegistryCallbacks(registry);
387 registry.
insert<irdl::IRDLDialect>();
391 std::string errorMessage;
392 std::unique_ptr<MemoryBuffer> file =
openInputFile(irdlFile, &errorMessage);
394 emitError(UnknownLoc::get(&ctx)) << errorMessage;
401 sourceMgr.AddNewSourceBuffer(std::move(file), SMLoc());
426 StringRef irdlFile =
config.getIrdlFile();
427 if (!irdlFile.empty() && failed(
loadIRDLDialects(irdlFile, roundtripContext)))
430 std::string testType = (useBytecode) ?
"bytecode" :
"textual";
435 llvm::raw_string_ostream ostream(buffer);
439 <<
"failed to write bytecode, cannot verify round-trip.\n";
448 &fallbackResourceMap);
450 if (!roundtripModule) {
451 op->
emitOpError() <<
"failed to parse " << testType
452 <<
" content back, cannot verify round-trip.\n";
459 std::string reference, roundtrip;
461 llvm::raw_string_ostream ostreamref(reference);
462 op->
print(ostreamref,
464 llvm::raw_string_ostream ostreamrndtrip(roundtrip);
465 roundtripModule.
get()->print(
469 if (reference != roundtrip) {
473 <<
" roundTrip testing roundtripped module differs "
474 "from reference:\n<<<<<<Reference\n"
475 << reference <<
"\n=====\n"
476 << roundtrip <<
"\n>>>>>roundtripped\n";
486 return success(succeeded(txtStatus) && succeeded(bcStatus));
497 const std::shared_ptr<llvm::SourceMgr> &sourceMgr,
515 &fallbackResourceMap);
516 if (
config.shouldRunReproducer())
522 sourceMgr, parseConfig, !
config.shouldUseExplicitModule());
528 if (
config.shouldVerifyRoundtrip() &&
535 config.getRemarksAllFilter(),
config.getRemarksPassedFilter(),
536 config.getRemarksMissedFilter(),
config.getRemarksAnalyseFilter(),
537 config.getRemarksFailedFilter()};
541 auto createPolicy = [&
config]()
542 -> std::unique_ptr<mlir::remark::detail::RemarkEmittingPolicyBase> {
544 return std::make_unique<mlir::remark::RemarkEmittingPolicyAll>();
546 return std::make_unique<mlir::remark::RemarkEmittingPolicyFinal>();
548 llvm_unreachable(
"Invalid remark policy");
551 switch (
config.getRemarkFormat()) {
554 ctx,
nullptr, createPolicy(), cats,
true )))
559 std::string file =
config.getRemarksOutputFile().empty()
560 ?
"mlir-remarks.yaml"
561 :
config.getRemarksOutputFile();
563 ctx, file, llvm::remarks::Format::YAML, createPolicy(), cats)))
569 std::string file =
config.getRemarksOutputFile().empty()
570 ?
"mlir-remarks.bitstream"
571 :
config.getRemarksOutputFile();
573 ctx, file, llvm::remarks::Format::Bitstream, createPolicy(), cats)))
585 if (
config.shouldRunReproducer() && failed(reproOptions.
apply(pm)))
587 if (failed(
config.setupPassPipeline(pm)))
591 if (failed(pm.
run(*op)))
595 if (!
config.getReproducerFilename().empty()) {
599 config.getReproducerFilename());
604 if (
config.shouldEmitBytecode()) {
606 if (
auto v =
config.bytecodeVersionToEmit())
608 if (
config.shouldElideResourceDataFromBytecode())
613 if (
config.bytecodeVersionToEmit().has_value())
615 <<
"bytecode version while not emitting bytecode";
617 &fallbackResourceMap);
623 engine->getRemarkEmittingPolicy()->finalize();
632 llvm::MemoryBufferRef sourceBuffer,
635 llvm::ThreadPoolInterface *threadPool) {
637 auto sourceMgr = std::make_shared<SourceMgr>();
640 sourceMgr->AddNewSourceBuffer(
641 llvm::MemoryBuffer::getMemBuffer(sourceBuffer,
644 sourceMgr->AddNewSourceBuffer(std::move(ownedBuffer), SMLoc());
654 StringRef irdlFile =
config.getIrdlFile();
660 if (
config.shouldVerifyDiagnostics())
668 if (!
config.shouldVerifyDiagnostics()) {
670 DiagnosticFilter diagnosticFilter(&context,
671 config.getDiagnosticVerbosityLevel(),
672 config.shouldShowNotes());
694 std::string helpHeader = (toolName +
"\nAvailable Dialects: ").str();
696 llvm::raw_string_ostream os(helpHeader);
698 [&](
auto name) { os << name; });
703std::pair<std::string, std::string>
705 static cl::opt<std::string> inputFilename(
706 cl::Positional, cl::desc(
"<input file>"), cl::init(
"-"));
708 static cl::opt<std::string> outputFilename(
"o", cl::desc(
"Output filename"),
709 cl::value_desc(
"filename"),
711 cl::ParseCommandLineOptions(argc, argv, helpHeader);
712 return std::make_pair(inputFilename.getValue(), outputFilename.getValue());
715std::pair<std::string, std::string>
717 llvm::StringRef toolName,
724 llvm::outs() <<
"Available Dialects: ";
726 llvm::outs() <<
"\n";
736 std::unique_ptr<llvm::MemoryBuffer> buffer,
739 if (
config.shouldShowDialects())
742 if (
config.shouldListPasses())
749 ThreadPoolInterface *threadPool =
nullptr;
760 sourceMgr.AddNewSourceBuffer(
761 llvm::MemoryBuffer::getMemBuffer(buffer->getMemBufferRef(),
768 sourceMgr, &threadPoolCtx,
config.verifyDiagnosticsLevel());
769 auto chunkFn = [&](std::unique_ptr<MemoryBuffer> chunkBuffer,
770 llvm::MemoryBufferRef sourceBuffer,
raw_ostream &os) {
772 os, std::move(chunkBuffer), sourceBuffer,
config, registry,
773 config.shouldVerifyDiagnostics() ? &sourceMgrHandler :
nullptr,
777 llvm::MemoryBuffer::getMemBuffer(buffer->getMemBufferRef(),
779 chunkFn, outputStream,
config.inputSplitMarker(),
780 config.outputSplitMarker());
781 if (
config.shouldVerifyDiagnostics() && failed(sourceMgrHandler.
verify()))
787 llvm::StringRef inputFilename,
788 llvm::StringRef outputFilename,
791 InitLLVM y(argc, argv);
795 if (
config.shouldShowDialects())
798 if (
config.shouldListPasses())
804 if (inputFilename ==
"-" &&
805 sys::Process::FileDescriptorIsDisplayed(fileno(stdin)))
806 llvm::errs() <<
"(processing input from stdin now, hit ctrl-c/ctrl-d to "
810 std::string errorMessage;
813 llvm::errs() << errorMessage <<
"\n";
819 llvm::errs() << errorMessage <<
"\n";
834 std::string inputFilename, outputFilename;
835 std::tie(inputFilename, outputFilename) =
838 return MlirOptMain(argc, argv, inputFilename, outputFilename, registry);
static ManagedStatic< DebugConfigCLOptions > clOptionsConfig
static LogicalResult printRegisteredDialects(DialectRegistry ®istry)
LogicalResult loadIRDLDialects(StringRef irdlFile, MLIRContext &ctx)
static LogicalResult doVerifyRoundTrip(Operation *op, const MlirOptMainConfig &config, bool useBytecode)
static LogicalResult processBuffer(raw_ostream &os, std::unique_ptr< MemoryBuffer > ownedBuffer, llvm::MemoryBufferRef sourceBuffer, const MlirOptMainConfig &config, DialectRegistry ®istry, SourceMgrDiagnosticVerifierHandler *verifyHandler, llvm::ThreadPoolInterface *threadPool)
Parses the memory buffer.
static LogicalResult printRegisteredPassesAndReturn()
static LogicalResult performActions(raw_ostream &os, const std::shared_ptr< llvm::SourceMgr > &sourceMgr, MLIRContext *context, const MlirOptMainConfig &config)
Perform the actions on the input file indicated by the command line flags within the specified contex...
static std::string diag(const llvm::Value &value)
This class provides management for the lifetime of the state used when printing the IR.
This class contains the configuration used for the bytecode writer.
void setElideResourceDataFlag(bool shouldElideResourceData=true)
Set a boolean flag to skip emission of resources into the bytecode file.
void setDesiredBytecodeVersion(int64_t bytecodeVersion)
Set the desired bytecode version to emit.
Facilities for time measurement and report printing to an output stream.
static llvm::Expected< DialectPlugin > load(const std::string &filename)
Attempts to load a dialect plugin from a given file.
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
auto getDialectNames() const
Return the names of dialects known to this registry.
A fallback map containing external resources not explicitly handled by another parser/printer.
MLIRContext is the top-level object for a collection of MLIR operations.
void appendDialectRegistry(const DialectRegistry ®istry)
Append the contents of the given dialect registry to the registry associated with this context.
void disableMultithreading(bool disable=true)
Set the flag specifying if multi-threading is disabled by the context.
void setThreadPool(llvm::ThreadPoolInterface &pool)
Set a new thread pool to be used in this context.
void enableMultithreading(bool enable=true)
remark::detail::RemarkEngine * getRemarkEngine()
Returns the remark engine for this context, or nullptr if none has been set.
void printOpOnDiagnostic(bool enable)
Set the flag specifying if we should attach the operation to diagnostics emitted via Operation::emit.
const DialectRegistry & getDialectRegistry()
Return the dialect registry associated with this context.
llvm::ThreadPoolInterface & getThreadPool()
Return the thread pool used by this context.
bool isMultithreadingEnabled()
Return true if multi-threading is enabled by the context.
void allowUnregisteredDialects(bool allow=true)
Enables creating operations in unregistered dialects.
bool allowsUnregisteredDialects()
Return true if we allow to create operation for unregistered dialects.
Configuration options for the mlir-opt tool.
static MlirOptMainConfig createFromCLOptions()
Create a new config with the default set from the CL options.
std::function< LogicalResult(PassManager &)> passPipelineCallback
The callback to populate the pass manager.
static void registerCLOptions(DialectRegistry &dialectRegistry)
Register the options as global LLVM command line options.
bool shouldDumpPassPipeline() const
MlirOptMainConfig & setPassPipelineParser(const PassPipelineCLParser &parser)
Set the parser to use to populate the pass manager.
@ Implicit
Implicit nesting behavior.
iterator_range< pass_iterator > getPasses()
static StringRef getAnyOpAnchorName()
Return the string name used to anchor op-agnostic pass managers that operate generically on any viabl...
Set of flags used to control the behavior of the various IR print methods (e.g.
A wrapper class that allows for printing an operation with a custom AsmState, useful to act as a "str...
Operation is the basic unit of execution within MLIR.
void print(raw_ostream &os, const OpPrintingFlags &flags={})
MLIRContext * getContext()
Return the context this operation is associated with.
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
This class acts as an owning reference to an op, and will automatically destroy the held op on destru...
OpTy get() const
Allow accessing the internal op.
This class represents a configuration for the MLIR assembly parser.
The main pass manager and pipeline builder.
MLIRContext * getContext() const
Return an instance of the context.
LogicalResult run(Operation *op)
Run the passes within this manager on the provided operation.
void enableVerifier(bool enabled=true)
Runs the verifier after each individual pass.
void enableTiming(TimingScope &timingScope)
Add an instrumentation to time the execution of passes and the computation of analyses.
This class implements a command-line parser for MLIR passes.
LogicalResult addToPipeline(OpPassManager &pm, function_ref< LogicalResult(const Twine &)> errorHandler) const
Adds the passes defined by this parser entry to the given pass manager.
static llvm::Expected< PassPlugin > load(const std::string &filename)
Attempts to load a pass plugin from a given file.
This diagnostic handler is a simple RAII class that registers and erases a diagnostic handler on a gi...
This class is a utility diagnostic handler for use with llvm::SourceMgr.
This class is a utility diagnostic handler for use with llvm::SourceMgr that verifies that emitted di...
void registerInContext(MLIRContext *ctx)
Register this handler with the given context.
LogicalResult verify()
Returns the status of the handler and verifies that all expected diagnostics were emitted.
TimingScope getRootScope()
Get the root timer of this timing manager wrapped in a TimingScope for convenience.
An RAII-style wrapper around a timer that ensures the timer is properly started and stopped.
TimingScope nest(Args... args)
Create a nested timing scope.
void stop()
Manually stop the timer early.
static DebugConfig createFromCLOptions()
Create a new config with the default set from the CL options.
static void registerCLOptions()
Register the options as global LLVM command line options.
static void registerCLOptions()
Register the command line options for debug counters.
This is a RAII class that installs the debug handlers on the context based on the provided configurat...
The OpAsmOpInterface, see OpAsmInterface.td for more details.
llvm::LogicalResult loadDialects(ModuleOp op)
Load all the dialects defined in the module.
QueryRef parse(llvm::StringRef line, const QuerySession &qs)
Include the generated interface declarations.
std::pair< std::string, std::string > parseCLIOptions(int argc, char **argv, llvm::StringRef helpHeader)
Parse command line options.
LogicalResult applyPassManagerCLOptions(PassManager &pm)
Apply any values provided to the pass manager options that were registered with 'registerPassManagerO...
const char *const kDefaultSplitMarker
void registerDefaultTimingManagerCLOptions()
Register a set of useful command-line options that can be used to configure a DefaultTimingManager.
std::unique_ptr< llvm::ToolOutputFile > openOutputFile(llvm::StringRef outputFilename, std::string *errorMessage=nullptr)
Open the file specified by its name for writing.
std::string registerCLIOptions(llvm::StringRef toolName, DialectRegistry ®istry)
Register basic command line options.
const FrozenRewritePatternSet GreedyRewriteConfig config
void printRegisteredPasses()
Prints the passes that were previously registered and stored in passRegistry.
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::string makeReproducer(StringRef anchorName, const llvm::iterator_range< OpPassManager::pass_iterator > &passes, Operation *op, StringRef outputFile, bool disableThreads=false, bool verifyPasses=false)
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
void registerMLIRContextCLOptions()
Register a set of useful command-line options that can be used to configure various flags within the ...
std::unique_ptr< llvm::MemoryBuffer > openInputFile(llvm::StringRef inputFilename, std::string *errorMessage=nullptr)
Open the file specified by its name for reading.
LogicalResult splitAndProcessBuffer(std::unique_ptr< llvm::MemoryBuffer > originalBuffer, ChunkBufferHandler processChunkBuffer, raw_ostream &os, llvm::StringRef inputSplitMarker=kDefaultSplitMarker, llvm::StringRef outputSplitMarker="")
Splits the specified buffer on a marker (// ----- by default), processes each chunk independently acc...
LogicalResult parseSourceString(llvm::StringRef sourceStr, Block *block, const ParserConfig &config, StringRef sourceName="", LocationAttr *sourceFileLoc=nullptr)
This parses the IR string and appends parsed operations to the given block.
void registerAsmPrinterCLOptions()
Register a set of useful command-line options that can be used to configure various flags within the ...
void registerPassManagerCLOptions()
Register a set of useful command-line options that can be used to configure a pass manager.
LogicalResult parseSourceFile(const llvm::SourceMgr &sourceMgr, Block *block, const ParserConfig &config, LocationAttr *sourceFileLoc=nullptr)
This parses the file specified by the indicated SourceMgr and appends parsed operations to the given ...
void applyDefaultTimingManagerCLOptions(DefaultTimingManager &tm)
Apply any values that were registered with 'registerDefaultTimingManagerOptions' to a DefaultTimingMa...
OwningOpRef< Operation * > parseSourceFileForTool(const std::shared_ptr< llvm::SourceMgr > &sourceMgr, const ParserConfig &config, bool insertImplicitModule)
This parses the file specified by the indicated SourceMgr.
@ 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.
LogicalResult writeBytecodeToFile(Operation *op, raw_ostream &os, const BytecodeWriterConfig &config={})
Write the bytecode for the given operation to the provided output stream.
void attachResourceParser(ParserConfig &config)
Attach an assembly resource parser to 'config' that collects the MLIR reproducer configuration into t...
LogicalResult apply(PassManager &pm) const
Apply the reproducer options to 'pm' and its context.