[PATCH] D74865: [MLIR] add show-dialects option for mlir-opt
Stephen Neuendorffer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 19 13:29:56 PST 2020
stephenneuendorffer created this revision.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a project: LLVM.
stephenneuendorffer added a child revision: D74866: [MLIR] Workaround for broken dependencies with building libMLIR.so.
Display the list of dialects known to mlir-opt. This is useful
for ensuring that linkage has happened correctly, for instance.
Depends on D73130 <https://reviews.llvm.org/D73130>
Repository:
rG LLVM Github Monorepo
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.245503.patch
Type: text/x-patch
Size: 1385 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200219/bb953975/attachment.bin>
More information about the llvm-commits
mailing list