[Mlir-commits] [mlir] 01b2096 - [MLIR] add show-dialects option for mlir-opt
Stephen Neuendorffer
llvmlistbot at llvm.org
Thu Feb 27 10:45:13 PST 2020
Author: Stephen Neuendorffer
Date: 2020-02-27T10:43:39-08:00
New Revision: 01b209679f69cc42e96f05a3c37ba06480094819
URL: https://github.com/llvm/llvm-project/commit/01b209679f69cc42e96f05a3c37ba06480094819
DIFF: https://github.com/llvm/llvm-project/commit/01b209679f69cc42e96f05a3c37ba06480094819.diff
LOG: [MLIR] add show-dialects option for mlir-opt
Display the list of dialects known to mlir-opt. This is useful
for ensuring that linkage has happened correctly, for instance.
Differential Revision: https://reviews.llvm.org/D74865
Added:
mlir/test/mlir-opt/commandline.mlir
Modified:
mlir/tools/mlir-opt/mlir-opt.cpp
Removed:
################################################################################
diff --git a/mlir/test/mlir-opt/commandline.mlir b/mlir/test/mlir-opt/commandline.mlir
new file mode 100644
index 000000000000..eb34738b36ef
--- /dev/null
+++ b/mlir/test/mlir-opt/commandline.mlir
@@ -0,0 +1,17 @@
+// RUN: mlir-opt --show-dialects | FileCheck %s
+// CHECK: Registered Dialects:
+// CHECK: affine
+// CHECK: fxpmath
+// CHECK: gpu
+// CHECK: linalg
+// CHECK: llvm
+// CHECK: loop
+// CHECK: nvvm
+// CHECK: omp
+// CHECK: quant
+// CHECK: rocdl
+// CHECK: sdbm
+// CHECK: spv
+// CHECK: std
+// CHECK: test
+// CHECK: vector
diff --git a/mlir/tools/mlir-opt/mlir-opt.cpp b/mlir/tools/mlir-opt/mlir-opt.cpp
index dd957a59aa30..b344056a0f19 100644
--- a/mlir/tools/mlir-opt/mlir-opt.cpp
+++ b/mlir/tools/mlir-opt/mlir-opt.cpp
@@ -13,6 +13,8 @@
#include "mlir/Analysis/Passes.h"
#include "mlir/InitAllDialects.h"
#include "mlir/InitAllPasses.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"
@@ -118,6 +120,11 @@ void registerTestPasses() {
createTestMemRefDependenceCheckPass();
}
+static cl::opt<bool>
+ showDialects("show-dialects",
+ cl::desc("Print the list of registered dialects"),
+ cl::init(false));
+
int main(int argc, char **argv) {
registerAllDialects();
registerAllPasses();
@@ -131,6 +138,15 @@ int main(int argc, char **argv) {
// 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);
More information about the Mlir-commits
mailing list