[Mlir-commits] [mlir] [llvm] [MLIR][CAPI] Add MemRef pass bindings to the C API (PR #73949)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Nov 30 07:04:41 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Adam Paszke (apaszke)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/73949.diff
4 Files Affected:
- (modified) mlir/include/mlir-c/Dialect/MemRef.h (+2)
- (modified) mlir/lib/CAPI/Dialect/CMakeLists.txt (+1)
- (added) mlir/lib/CAPI/Dialect/MemRefPasses.cpp (+27)
- (modified) utils/bazel/llvm-project-overlay/mlir/BUILD.bazel (+21-1)
``````````diff
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",
``````````
</details>
https://github.com/llvm/llvm-project/pull/73949
More information about the Mlir-commits
mailing list