|
31 | 31 | #include "mlir/Pass/Pass.h"
|
32 | 32 | #include "mlir/Pass/PassManager.h"
|
33 | 33 | #include "mlir/Support/FileUtilities.h"
|
| 34 | +#include "mlir/Support/LogicalResult.h" |
34 | 35 | #include "mlir/Support/Timing.h"
|
35 | 36 | #include "mlir/Support/ToolUtilities.h"
|
36 | 37 | #include "mlir/Tools/ParseUtilities.h"
|
@@ -513,15 +514,19 @@ mlir::registerAndParseCLIOptions(int argc, char **argv,
|
513 | 514 | return std::make_pair(inputFilename.getValue(), outputFilename.getValue());
|
514 | 515 | }
|
515 | 516 |
|
| 517 | +static LogicalResult printRegisteredDialects(DialectRegistry ®istry) { |
| 518 | + llvm::outs() << "Available Dialects: "; |
| 519 | + interleave(registry.getDialectNames(), llvm::outs(), ","); |
| 520 | + llvm::outs() << "\n"; |
| 521 | + return success(); |
| 522 | +} |
| 523 | + |
516 | 524 | LogicalResult mlir::MlirOptMain(llvm::raw_ostream &outputStream,
|
517 | 525 | std::unique_ptr<llvm::MemoryBuffer> buffer,
|
518 | 526 | DialectRegistry ®istry,
|
519 | 527 | const MlirOptMainConfig &config) {
|
520 |
| - if (config.shouldShowDialects()) { |
521 |
| - llvm::outs() << "Available Dialects: "; |
522 |
| - interleave(registry.getDialectNames(), llvm::outs(), ","); |
523 |
| - llvm::outs() << "\n"; |
524 |
| - } |
| 528 | + if (config.shouldShowDialects()) |
| 529 | + return printRegisteredDialects(registry); |
525 | 530 |
|
526 | 531 | // The split-input-file mode is a very specific mode that slices the file
|
527 | 532 | // up into small pieces and checks each independently.
|
@@ -556,6 +561,9 @@ LogicalResult mlir::MlirOptMain(int argc, char **argv,
|
556 | 561 |
|
557 | 562 | MlirOptMainConfig config = MlirOptMainConfig::createFromCLOptions();
|
558 | 563 |
|
| 564 | + if (config.shouldShowDialects()) |
| 565 | + return printRegisteredDialects(registry); |
| 566 | + |
559 | 567 | // When reading from stdin and the input is a tty, it is often a user mistake
|
560 | 568 | // and the process "appears to be stuck". Print a message to let the user know
|
561 | 569 | // about it!
|
|
0 commit comments