forked from OSchip/llvm-project
[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
This commit is contained in:
parent
b26c88e3c6
commit
01b209679f
|
@ -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
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue