[Mlir-commits] [mlir] [llvm] [MLIR][CAPI] Add MemRef pass bindings to the C API (PR #73949)
Adam Paszke
llvmlistbot at llvm.org
Thu Nov 30 07:04:03 PST 2023
https://github.com/apaszke created https://github.com/llvm/llvm-project/pull/73949
None
>From b43e1c9fbd50829f795b22077ac5a7c2cd806624 Mon Sep 17 00:00:00 2001
From: Adam Paszke <apaszke at google.com>
Date: Thu, 30 Nov 2023 15:03:03 +0000
Subject: [PATCH] [MLIR][CAPI] Add MemRef pass bindings to the C API
---
mlir/include/mlir-c/Dialect/MemRef.h | 2 ++
mlir/lib/CAPI/Dialect/CMakeLists.txt | 1 +
mlir/lib/CAPI/Dialect/MemRefPasses.cpp | 27 +++++++++++++++++++
.../llvm-project-overlay/mlir/BUILD.bazel | 22 ++++++++++++++-
4 files changed, 51 insertions(+), 1 deletion(-)
create mode 100644 mlir/lib/CAPI/Dialect/MemRefPasses.cpp
diff --git a/mlir/include/mlir-c/Dialect/MemRef.h b/mlir/include/mlir-c/Dialect/MemRef.h
index 087a4b3f85b1d80..327fe25143f8e8e 100644
--- a/mlir/include/mlir-c/Dialect/MemRef.h
+++ b/mlir/include/mlir-c/Dialect/MemRef.h
@@ -30,4 +30,6 @@ MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(MemRef, memref);
}
#endif
+#include "mlir/Dialect/MemRef/Transforms/Passes.capi.h.inc"
+
#endif // MLIR_C_DIALECT_MEMREF_H
diff --git a/mlir/lib/CAPI/Dialect/CMakeLists.txt b/mlir/lib/CAPI/Dialect/CMakeLists.txt
index d815eba48d9b9df..b9cafcd299b94f6 100644
--- a/mlir/lib/CAPI/Dialect/CMakeLists.txt
+++ b/mlir/lib/CAPI/Dialect/CMakeLists.txt
@@ -51,6 +51,7 @@ add_mlir_upstream_c_api_library(MLIRCAPIMath
add_mlir_upstream_c_api_library(MLIRCAPIMemRef
MemRef.cpp
+ MemRefPasses.cpp
PARTIAL_SOURCES_INTENDED
LINK_LIBS PUBLIC
diff --git a/mlir/lib/CAPI/Dialect/MemRefPasses.cpp b/mlir/lib/CAPI/Dialect/MemRefPasses.cpp
new file mode 100644
index 000000000000000..ddc95a4f7733526
--- /dev/null
+++ b/mlir/lib/CAPI/Dialect/MemRefPasses.cpp
@@ -0,0 +1,27 @@
+//===- MemRefPasses.cpp - C API for MemRef Dialect Passes ----------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/CAPI/Pass.h"
+#include "mlir/Dialect/MemRef/Transforms/Passes.h"
+#include "mlir/Pass/Pass.h"
+
+// Must include the declarations as they carry important visibility attributes.
+#include "mlir/Dialect/MemRef/Transforms/Passes.capi.h.inc"
+
+using namespace mlir::memref;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "mlir/Dialect/MemRef/Transforms/Passes.capi.cpp.inc"
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
index 6ecf28424ba4a5c..1f20bb4f5aaf428 100644
--- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -551,14 +551,20 @@ mlir_c_api_cc_library(
mlir_c_api_cc_library(
name = "CAPIMemRef",
- srcs = ["lib/CAPI/Dialect/MemRef.cpp"],
+ srcs = [
+ "lib/CAPI/Dialect/MemRef.cpp",
+ "lib/CAPI/Dialect/MemRefPasses.cpp",
+ ],
hdrs = ["include/mlir-c/Dialect/MemRef.h"],
capi_deps = [
":CAPIIR",
],
+ header_deps = [":MemRefPassIncGen"],
includes = ["include"],
deps = [
":MemRefDialect",
+ ":MemRefTransforms",
+ ":Pass",
],
)
@@ -12382,6 +12388,20 @@ gentbl_cc_library(
],
"include/mlir/Dialect/MemRef/Transforms/Passes.h.inc",
),
+ (
+ [
+ "-gen-pass-capi-header",
+ "--prefix=MemRef",
+ ],
+ "include/mlir/Dialect/MemRef/Transforms/Passes.capi.h.inc",
+ ),
+ (
+ [
+ "-gen-pass-capi-impl",
+ "--prefix=MemRef",
+ ],
+ "include/mlir/Dialect/MemRef/Transforms/Passes.capi.cpp.inc",
+ ),
],
tblgen = ":mlir-tblgen",
td_file = "include/mlir/Dialect/MemRef/Transforms/Passes.td",
More information about the Mlir-commits
mailing list