[llvm] [bzl][mlir][emitc] Add build targets for EmitC C-API/Python bindings (PR #119610)

Jordan Rupprecht via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 11 12:28:03 PST 2024


https://github.com/rupprecht created https://github.com/llvm/llvm-project/pull/119610

Added by 3c464d23682b0f9e6f70965e8f8f3861c9ba5417

>From b8dfed823f2fbc5819fd0351630ff2aed94bfcb0 Mon Sep 17 00:00:00 2001
From: Jordan Rupprecht <rupprecht at google.com>
Date: Wed, 11 Dec 2024 12:26:40 -0800
Subject: [PATCH] [bzl][mlir][emitc] Add build targets for EmitC C-API/Python
 bindings

Added by 3c464d23682b0f9e6f70965e8f8f3861c9ba5417
---
 .../llvm-project-overlay/mlir/BUILD.bazel     | 18 +++++++++++
 .../mlir/python/BUILD.bazel                   | 30 +++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
index 544becfa30b40f..b5be59051cdfa7 100644
--- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -529,6 +529,24 @@ mlir_c_api_cc_library(
     ],
 )
 
+mlir_c_api_cc_library(
+    name = "CAPIEmitC",
+    srcs = [
+        "lib/CAPI/Dialect/EmitC.cpp",
+    ],
+    hdrs = ["include/mlir-c/Dialect/EmitC.h"],
+    capi_deps = [
+        ":CAPIIR",
+    ],
+    header_deps = [
+        ":EmitCPassIncGen",
+    ],
+    includes = ["include"],
+    deps = [
+        ":EmitCDialect",
+    ],
+)
+
 mlir_c_api_cc_library(
     name = "CAPILinalg",
     srcs = [
diff --git a/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel
index 254cab0db4a5d6..3d7a6164a4fa54 100644
--- a/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel
@@ -539,6 +539,36 @@ filegroup(
     ],
 )
 
+##---------------------------------------------------------------------------##
+# EmitC dialect.
+##---------------------------------------------------------------------------##
+
+gentbl_filegroup(
+    name = "EmitCPyGen",
+    tbl_outs = [
+        (
+            [
+                "-gen-python-op-bindings",
+                "-bind-dialect=emitc",
+            ],
+            "mlir/dialects/_emitc_ops_gen.py",
+        ),
+    ],
+    tblgen = "//mlir:mlir-tblgen",
+    td_file = "mlir/dialects/EmitC.td",
+    deps = [
+        "//mlir:EmitCTdFiles",
+    ],
+)
+
+filegroup(
+    name = "EmitCPyFiles",
+    srcs = [
+        "mlir/dialects/emitc.py",
+        ":EmitCPyGen",
+    ],
+)
+
 ##---------------------------------------------------------------------------##
 # Index dialect.
 ##---------------------------------------------------------------------------##



More information about the llvm-commits mailing list