CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
81 lines
3.3 KiB
C++
81 lines
3.3 KiB
C++
//===- mlir-query.cpp - MLIR Query Driver ---------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This is a command line utility that queries a file from/to MLIR using one
|
|
// of the registered queries.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir/IR/Dialect.h"
|
|
#include "mlir/IR/MLIRContext.h"
|
|
#include "mlir/IR/Matchers.h"
|
|
#include "mlir/InitAllDialects.h"
|
|
#include "mlir/Query/Matcher/Registry.h"
|
|
#include "mlir/Query/Matcher/SliceMatchers.h"
|
|
#include "mlir/Tools/mlir-query/MlirQueryMain.h"
|
|
|
|
using namespace mlir;
|
|
|
|
// This is needed because these matchers are defined as overloaded functions.
|
|
using HasOpAttrName = detail::AttrOpMatcher(StringRef);
|
|
using HasOpName = detail::NameOpMatcher(StringRef);
|
|
using IsConstantOp = detail::constant_op_matcher();
|
|
|
|
namespace test {
|
|
#ifdef MLIR_INCLUDE_TESTS
|
|
void registerTestDialect(DialectRegistry &);
|
|
#endif
|
|
} // namespace test
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
DialectRegistry dialectRegistry;
|
|
registerAllDialects(dialectRegistry);
|
|
|
|
query::matcher::Registry matcherRegistry;
|
|
|
|
// Matchers registered in alphabetical order for consistency:
|
|
matcherRegistry.registerMatcher("allOf", query::matcher::internal::allOf);
|
|
matcherRegistry.registerMatcher("anyOf", query::matcher::internal::anyOf);
|
|
matcherRegistry.registerMatcher(
|
|
"getAllDefinitions",
|
|
query::matcher::m_GetAllDefinitions<query::matcher::DynMatcher>);
|
|
matcherRegistry.registerMatcher(
|
|
"getDefinitions",
|
|
query::matcher::m_GetDefinitions<query::matcher::DynMatcher>);
|
|
matcherRegistry.registerMatcher(
|
|
"getDefinitionsByPredicate",
|
|
query::matcher::m_GetDefinitionsByPredicate<query::matcher::DynMatcher,
|
|
query::matcher::DynMatcher>);
|
|
matcherRegistry.registerMatcher(
|
|
"getUsersByPredicate",
|
|
query::matcher::m_GetUsersByPredicate<query::matcher::DynMatcher,
|
|
query::matcher::DynMatcher>);
|
|
matcherRegistry.registerMatcher("hasOpAttrName",
|
|
static_cast<HasOpAttrName *>(m_Attr));
|
|
matcherRegistry.registerMatcher("hasOpName", static_cast<HasOpName *>(m_Op));
|
|
matcherRegistry.registerMatcher("isConstantOp",
|
|
static_cast<IsConstantOp *>(m_Constant));
|
|
matcherRegistry.registerMatcher("isNegInfFloat", m_NegInfFloat);
|
|
matcherRegistry.registerMatcher("isNegZeroFloat", m_NegZeroFloat);
|
|
matcherRegistry.registerMatcher("isNonZero", m_NonZero);
|
|
matcherRegistry.registerMatcher("isOne", m_One);
|
|
matcherRegistry.registerMatcher("isOneFloat", m_OneFloat);
|
|
matcherRegistry.registerMatcher("isPosInfFloat", m_PosInfFloat);
|
|
matcherRegistry.registerMatcher("isPosZeroFloat", m_PosZeroFloat);
|
|
matcherRegistry.registerMatcher("isZero", m_Zero);
|
|
matcherRegistry.registerMatcher("isZeroFloat", m_AnyZeroFloat);
|
|
|
|
#ifdef MLIR_INCLUDE_TESTS
|
|
test::registerTestDialect(dialectRegistry);
|
|
#endif
|
|
MLIRContext context(dialectRegistry);
|
|
|
|
return failed(mlirQueryMain(argc, argv, context, matcherRegistry));
|
|
}
|