Skip to content

Commit e007d04

Browse files
[mlir:python] Port Python bindings of IRDL to bazel build.
This PR sets up build rules for the Python bindings of the IRDL dialect introduced by llvm#158488. The absence of them does not break the bazel build but some downstream users rely on them. Signed-off-by: Ingo Müller <[email protected]>
1 parent e747223 commit e007d04

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,20 @@ cc_binary(
12111211
],
12121212
)
12131213

1214+
cc_binary(
1215+
name = "_mlirDialectsIRDL.so",
1216+
srcs = ["lib/Bindings/Python/DialectIRDL.cpp"],
1217+
copts = PYBIND11_COPTS,
1218+
features = PYBIND11_FEATURES,
1219+
linkshared = 1,
1220+
linkstatic = 0,
1221+
deps = [
1222+
":CAPIIR",
1223+
":MLIRBindingsPythonNanobindHeadersAndDeps",
1224+
"@nanobind",
1225+
],
1226+
)
1227+
12141228
cc_binary(
12151229
name = "_mlirDialectsLinalg.so",
12161230
srcs = ["lib/Bindings/Python/DialectLinalg.cpp"],

utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,38 @@ filegroup(
537537
],
538538
)
539539

540+
##---------------------------------------------------------------------------##
541+
# IRDL dialect.
542+
##---------------------------------------------------------------------------##
543+
544+
gentbl_filegroup(
545+
name = "IRDLOpsPyGen",
546+
tbl_outs = {
547+
"mlir/dialects/_irdl_enum_gen.py": [
548+
"-gen-python-enum-bindings",
549+
"-bind-dialect=irdl",
550+
],
551+
"mlir/dialects/_irdl_ops_gen.py": [
552+
"-gen-python-op-bindings",
553+
"-bind-dialect=irdl",
554+
],
555+
},
556+
tblgen = "//mlir:mlir-tblgen",
557+
td_file = "mlir/dialects/IRDLOps.td",
558+
deps = [
559+
"//mlir:IRDLTdFiles",
560+
"//mlir:OpBaseTdFiles",
561+
],
562+
)
563+
564+
filegroup(
565+
name = "IRDLPyFiles",
566+
srcs = [
567+
"mlir/dialects/irdl.py",
568+
":IRDLOpsPyGen",
569+
],
570+
)
571+
540572
##---------------------------------------------------------------------------##
541573
# Math dialect.
542574
##---------------------------------------------------------------------------##

0 commit comments

Comments
 (0)