[PATCH] D74865: [MLIR] add show-dialects option for mlir-opt
Stephen Neuendorffer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 20 14:11:50 PST 2020
stephenneuendorffer edited the summary of this revision.
stephenneuendorffer updated this revision to Diff 245742.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74865/new/
https://reviews.llvm.org/D74865
Files:
mlir/tools/mlir-opt/mlir-opt.cpp
Index: mlir/tools/mlir-opt/mlir-opt.cpp
===================================================================
--- mlir/tools/mlir-opt/mlir-opt.cpp
+++ mlir/tools/mlir-opt/mlir-opt.cpp
@@ -11,6 +11,8 @@
//===----------------------------------------------------------------------===//
#include "mlir/Analysis/Passes.h"
+#include "mlir/IR/Dialect.h"
+#include "mlir/IR/MLIRContext.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Support/FileUtilities.h"
@@ -47,6 +49,11 @@
cl::desc("Run the verifier after each transformation pass"),
cl::init(true));
+static cl::opt<bool>
+ showDialects("show-dialects",
+ cl::desc("Print the list of registered dialects"),
+ cl::init(false));
+
int main(int argc, char **argv) {
InitLLVM y(argc, argv);
@@ -57,6 +64,15 @@
// Parse pass names in main to ensure static initialization completed.
cl::ParseCommandLineOptions(argc, argv, "MLIR modular optimizer driver\n");
+ MLIRContext context;
+ if(showDialects) {
+ llvm::outs() << "Registered Dialects:\n";
+ for(Dialect *dialect : context.getRegisteredDialects()) {
+ llvm::outs() << dialect->getNamespace() << "\n";
+ }
+ return 0;
+ }
+
// Set up the input file.
std::string errorMessage;
auto file = openInputFile(inputFilename, &errorMessage);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74865.245742.patch
Type: text/x-patch
Size: 1385 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200220/1a17cbed/attachment.bin>
More information about the llvm-commits
mailing list