[llvm] Add mlir-query bazel rules (PR #116063)

Jeremy Kun via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 13 07:08:57 PST 2024


https://github.com/j2kun created https://github.com/llvm/llvm-project/pull/116063

I noticed there's no bazel query for `mlir-query`, unlike the other MLIR tools, so adding one.

>From bcdf709d0d937aab01b4b9ca80cb355c9e99f674 Mon Sep 17 00:00:00 2001
From: Jeremy Kun <j2kun at users.noreply.github.com>
Date: Wed, 13 Nov 2024 07:08:00 -0800
Subject: [PATCH] Add mlir-query bazel rules

---
 .../llvm-project-overlay/mlir/BUILD.bazel     | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
index 2543ed8113f377..8507cde6196540 100644
--- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -14028,6 +14028,64 @@ cc_binary(
     ],
 )
 
+cc_library(
+    name = "MlirQueryUtils",
+    srcs = glob(
+        [
+            "lib/Query/Matcher/*.cpp",
+            "lib/Query/Matcher/*.h",
+            "lib/Query/*.cpp",
+            "lib/Query/*.h",
+        ],
+    ),
+    hdrs = glob(
+        [
+            "include/mlir/Query/Matcher/*.h",
+            "include/mlir/Query/*.h",
+        ],
+    ),
+    includes = ["include"],
+    deps = [
+        ":IR",
+        ":Reducer",
+        ":Rewrite",
+        ":FuncDialect",
+        "//llvm:LineEditor",
+        "//llvm:Support",
+    ],
+)
+
+cc_library(
+    name = "MlirQueryLib",
+    srcs = ["lib/Tools/mlir-query/MlirQueryMain.cpp"],
+    hdrs = ["include/mlir/Tools/mlir-query/MlirQueryMain.h"],
+    includes = ["include"],
+    deps = [
+        ":IR",
+        ":MlirQueryUtils",
+        ":Parser",
+        ":Support",
+        "//llvm:LineEditor",
+        "//llvm:Support",
+    ],
+)
+
+cc_binary(
+    name = "mlir-query",
+    srcs = ["tools/mlir-query/mlir-query.cpp"],
+    includes = ["include"],
+    local_defines = ["MLIR_INCLUDE_TESTS"],
+    stamp = 0,
+    deps = [
+        ":AllPassesAndDialects",
+        ":MlirQueryLib",
+        ":MlirQueryUtils",
+        ":IR",
+        "//llvm:Support",
+        "//mlir/test:TestDialect",
+    ],
+)
+
 cc_library(
     name = "PDLLODS",
     srcs = glob(



More information about the llvm-commits mailing list