[Mlir-commits] [mlir] d138c89 - [mlir] Forward arguments of `pair` in `SubElementInterface::replaceImmediateSubElementsImpl`
Hideto Ueno
llvmlistbot at llvm.org
Wed Jul 12 22:07:51 PDT 2023
Author: Hideto Ueno
Date: 2023-07-12T22:07:27-07:00
New Revision: d138c8914822a3e2c3277ba30caf2215632134b6
URL: https://github.com/llvm/llvm-project/commit/d138c8914822a3e2c3277ba30caf2215632134b6
DIFF: https://github.com/llvm/llvm-project/commit/d138c8914822a3e2c3277ba30caf2215632134b6.diff
LOG: [mlir] Forward arguments of `pair` in `SubElementInterface::replaceImmediateSubElementsImpl`
`SubElementInterface::replaceImmediateSubElementsImpl` specializes tuples so that
arguments are forwarded to type getter. However currently pairs are not supported even though
an example in documents uses a pair as a key type. This patch adds support for pairs as well.
Reviewed By: Mogball
Differential Revision: https://reviews.llvm.org/D155043
Added:
Modified:
mlir/include/mlir/IR/AttrTypeSubElements.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/AttrTypeSubElements.h b/mlir/include/mlir/IR/AttrTypeSubElements.h
index 8382162d9a373b..3105040b876317 100644
--- a/mlir/include/mlir/IR/AttrTypeSubElements.h
+++ b/mlir/include/mlir/IR/AttrTypeSubElements.h
@@ -400,6 +400,12 @@ template <typename T>
struct is_tuple : public std::false_type {};
template <typename... Ts>
struct is_tuple<std::tuple<Ts...>> : public std::true_type {};
+
+template <typename T>
+struct is_pair : public std::false_type {};
+template <typename... Ts>
+struct is_pair<std::pair<Ts...>> : public std::true_type {};
+
template <typename T, typename... Ts>
using has_get_method = decltype(T::get(std::declval<Ts>()...));
template <typename T, typename... Ts>
@@ -462,7 +468,8 @@ auto replaceImmediateSubElementsImpl(T derived, ArrayRef<Attribute> &replAttrs,
} else {
// Functor used to build the replacement on success.
auto buildReplacement = [&](auto newKey, MLIRContext *ctx) {
- if constexpr (is_tuple<decltype(key)>::value) {
+ if constexpr (is_tuple<decltype(key)>::value ||
+ is_pair<decltype(key)>::value) {
return std::apply(
[&](auto &&...params) {
return constructSubElementReplacement<T>(
More information about the Mlir-commits
mailing list