[llvm] [mlir:python] Port Python bindings of IRDL to bazel build. (PR #159721)
Ingo Müller via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 19 01:37:34 PDT 2025
https://github.com/ingomueller-net created https://github.com/llvm/llvm-project/pull/159721
This PR sets up build rules for the Python bindings of the IRDL dialect introduced by #158488. The absence of them does not break the bazel build but some downstream users rely on them.
>From e007d044d22068da37f79829287768a447523214 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ingo=20M=C3=BCller?= <ingomueller at google.com>
Date: Fri, 19 Sep 2025 08:26:39 +0000
Subject: [PATCH] [mlir:python] Port Python bindings of IRDL to bazel build.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This PR sets up build rules for the Python bindings of the IRDL dialect
introduced by #158488. The absence of them does not break the bazel
build but some downstream users rely on them.
Signed-off-by: Ingo Müller <ingomueller at google.com>
---
.../llvm-project-overlay/mlir/BUILD.bazel | 14 ++++++++
.../mlir/python/BUILD.bazel | 32 +++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
index 4681a02ad50ba..089f284d3182a 100644
--- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -1211,6 +1211,20 @@ cc_binary(
],
)
+cc_binary(
+ name = "_mlirDialectsIRDL.so",
+ srcs = ["lib/Bindings/Python/DialectIRDL.cpp"],
+ copts = PYBIND11_COPTS,
+ features = PYBIND11_FEATURES,
+ linkshared = 1,
+ linkstatic = 0,
+ deps = [
+ ":CAPIIR",
+ ":MLIRBindingsPythonNanobindHeadersAndDeps",
+ "@nanobind",
+ ],
+)
+
cc_binary(
name = "_mlirDialectsLinalg.so",
srcs = ["lib/Bindings/Python/DialectLinalg.cpp"],
diff --git a/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel
index 016794d30b349..a6e8c515f0874 100644
--- a/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel
@@ -537,6 +537,38 @@ filegroup(
],
)
+##---------------------------------------------------------------------------##
+# IRDL dialect.
+##---------------------------------------------------------------------------##
+
+gentbl_filegroup(
+ name = "IRDLOpsPyGen",
+ tbl_outs = {
+ "mlir/dialects/_irdl_enum_gen.py": [
+ "-gen-python-enum-bindings",
+ "-bind-dialect=irdl",
+ ],
+ "mlir/dialects/_irdl_ops_gen.py": [
+ "-gen-python-op-bindings",
+ "-bind-dialect=irdl",
+ ],
+ },
+ tblgen = "//mlir:mlir-tblgen",
+ td_file = "mlir/dialects/IRDLOps.td",
+ deps = [
+ "//mlir:IRDLTdFiles",
+ "//mlir:OpBaseTdFiles",
+ ],
+)
+
+filegroup(
+ name = "IRDLPyFiles",
+ srcs = [
+ "mlir/dialects/irdl.py",
+ ":IRDLOpsPyGen",
+ ],
+)
+
##---------------------------------------------------------------------------##
# Math dialect.
##---------------------------------------------------------------------------##
More information about the llvm-commits
mailing list