[ELF] Reorder SectionBase/InputSectionBase members
[llvm-project.git] / mlir / tools / mlir-query / mlir-query.cpp
blob0ed4f94d5802b0990fe967e15b8a002e66140df1
1 //===- mlir-query.cpp - MLIR Query Driver ---------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This is a command line utility that queries a file from/to MLIR using one
10 // of the registered queries.
12 //===----------------------------------------------------------------------===//
14 #include "mlir/IR/Dialect.h"
15 #include "mlir/IR/MLIRContext.h"
16 #include "mlir/IR/Matchers.h"
17 #include "mlir/InitAllDialects.h"
18 #include "mlir/Query/Matcher/Registry.h"
19 #include "mlir/Tools/mlir-query/MlirQueryMain.h"
21 using namespace mlir;
23 // This is needed because these matchers are defined as overloaded functions.
24 using HasOpAttrName = detail::AttrOpMatcher(StringRef);
25 using HasOpName = detail::NameOpMatcher(StringRef);
26 using IsConstantOp = detail::constant_op_matcher();
28 namespace test {
29 #ifdef MLIR_INCLUDE_TESTS
30 void registerTestDialect(DialectRegistry &);
31 #endif
32 } // namespace test
34 int main(int argc, char **argv) {
36 DialectRegistry dialectRegistry;
37 registerAllDialects(dialectRegistry);
39 query::matcher::Registry matcherRegistry;
41 // Matchers registered in alphabetical order for consistency:
42 matcherRegistry.registerMatcher("hasOpAttrName",
43 static_cast<HasOpAttrName *>(m_Attr));
44 matcherRegistry.registerMatcher("hasOpName", static_cast<HasOpName *>(m_Op));
45 matcherRegistry.registerMatcher("isConstantOp",
46 static_cast<IsConstantOp *>(m_Constant));
47 matcherRegistry.registerMatcher("isNegInfFloat", m_NegInfFloat);
48 matcherRegistry.registerMatcher("isNegZeroFloat", m_NegZeroFloat);
49 matcherRegistry.registerMatcher("isNonZero", m_NonZero);
50 matcherRegistry.registerMatcher("isOne", m_One);
51 matcherRegistry.registerMatcher("isOneFloat", m_OneFloat);
52 matcherRegistry.registerMatcher("isPosInfFloat", m_PosInfFloat);
53 matcherRegistry.registerMatcher("isPosZeroFloat", m_PosZeroFloat);
54 matcherRegistry.registerMatcher("isZero", m_Zero);
55 matcherRegistry.registerMatcher("isZeroFloat", m_AnyZeroFloat);
57 #ifdef MLIR_INCLUDE_TESTS
58 test::registerTestDialect(dialectRegistry);
59 #endif
60 MLIRContext context(dialectRegistry);
62 return failed(mlirQueryMain(argc, argv, context, matcherRegistry));