-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MLIR][CAPI] Add MemRef pass bindings to the C API #73949
Open
apaszke
wants to merge
1
commit into
llvm:main
Choose a base branch
from
apaszke:piper_export_cl_586663811
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-mlir Author: Adam Paszke (apaszke) ChangesFull diff: https://github.com/llvm/llvm-project/pull/73949.diff 4 Files Affected:
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",
|
You can test this locally with the following command:git-clang-format --diff 5234fe31547737f4fc9d312946cb647968734da1 b43e1c9fbd50829f795b22077ac5a7c2cd806624 -- mlir/lib/CAPI/Dialect/MemRefPasses.cpp mlir/include/mlir-c/Dialect/MemRef.h View the diff from clang-format here.diff --git a/mlir/lib/CAPI/Dialect/MemRefPasses.cpp b/mlir/lib/CAPI/Dialect/MemRefPasses.cpp
index ddc95a4f77..9928470e6e 100644
--- a/mlir/lib/CAPI/Dialect/MemRefPasses.cpp
+++ b/mlir/lib/CAPI/Dialect/MemRefPasses.cpp
@@ -24,4 +24,3 @@ extern "C" {
#ifdef __cplusplus
}
#endif
-
|
ftynse
approved these changes
Nov 30, 2023
Comment on lines
+12391
to
+12404
( | ||
[ | ||
"-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", | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need equivalent cmake changes?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.