[Mlir-commits] [mlir] 2a547f0 - [MLIR] Fix `mlir-opt --show-dialects` to not require any input (as documented)
Mehdi Amini
llvmlistbot at llvm.org
Thu Mar 14 22:55:43 PDT 2024
Author: Mehdi Amini
Date: 2024-03-14T22:55:25-07:00
New Revision: 2a547f0f6c6b456342b9bfad38787f54f265fc96
URL: https://github.com/llvm/llvm-project/commit/2a547f0f6c6b456342b9bfad38787f54f265fc96
DIFF: https://github.com/llvm/llvm-project/commit/2a547f0f6c6b456342b9bfad38787f54f265fc96.diff
LOG: [MLIR] Fix `mlir-opt --show-dialects` to not require any input (as documented)
Added:
Modified:
mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
index da775f1b3051b3..51504ad58282e1 100644
--- a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
+++ b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
@@ -31,6 +31,7 @@
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Support/FileUtilities.h"
+#include "mlir/Support/LogicalResult.h"
#include "mlir/Support/Timing.h"
#include "mlir/Support/ToolUtilities.h"
#include "mlir/Tools/ParseUtilities.h"
@@ -513,15 +514,19 @@ mlir::registerAndParseCLIOptions(int argc, char **argv,
return std::make_pair(inputFilename.getValue(), outputFilename.getValue());
}
+static LogicalResult printRegisteredDialects(DialectRegistry ®istry) {
+ llvm::outs() << "Available Dialects: ";
+ interleave(registry.getDialectNames(), llvm::outs(), ",");
+ llvm::outs() << "\n";
+ return success();
+}
+
LogicalResult mlir::MlirOptMain(llvm::raw_ostream &outputStream,
std::unique_ptr<llvm::MemoryBuffer> buffer,
DialectRegistry ®istry,
const MlirOptMainConfig &config) {
- if (config.shouldShowDialects()) {
- llvm::outs() << "Available Dialects: ";
- interleave(registry.getDialectNames(), llvm::outs(), ",");
- llvm::outs() << "\n";
- }
+ if (config.shouldShowDialects())
+ return printRegisteredDialects(registry);
// The split-input-file mode is a very specific mode that slices the file
// up into small pieces and checks each independently.
@@ -556,6 +561,9 @@ LogicalResult mlir::MlirOptMain(int argc, char **argv,
MlirOptMainConfig config = MlirOptMainConfig::createFromCLOptions();
+ if (config.shouldShowDialects())
+ return printRegisteredDialects(registry);
+
// When reading from stdin and the input is a tty, it is often a user mistake
// and the process "appears to be stuck". Print a message to let the user know
// about it!
More information about the Mlir-commits
mailing list