[Mlir-commits] [mlir] d9d7cb4 - [mlir] Specialize DenseMapInfo and PointerLikeTypeTraits for mlir::TypedValue
Eugene Zhulenev
llvmlistbot at llvm.org
Sun Jul 2 16:08:57 PDT 2023
Author: Eugene Zhulenev
Date: 2023-07-02T16:08:53-07:00
New Revision: d9d7cb4f360d809c09aaacd612c9bab952619a4d
URL: https://github.com/llvm/llvm-project/commit/d9d7cb4f360d809c09aaacd612c9bab952619a4d
DIFF: https://github.com/llvm/llvm-project/commit/d9d7cb4f360d809c09aaacd612c9bab952619a4d.diff
LOG: [mlir] Specialize DenseMapInfo and PointerLikeTypeTraits for mlir::TypedValue
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D154310
Added:
Modified:
mlir/include/mlir/IR/Value.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h
index 780e047d15b710..a8415ff780bce7 100644
--- a/mlir/include/mlir/IR/Value.h
+++ b/mlir/include/mlir/IR/Value.h
@@ -529,6 +529,18 @@ struct DenseMapInfo<mlir::OpResult> : public DenseMapInfo<mlir::Value> {
return reinterpret_cast<mlir::detail::OpResultImpl *>(pointer);
}
};
+template <typename T>
+struct DenseMapInfo<mlir::detail::TypedValue<T>>
+ : public DenseMapInfo<mlir::Value> {
+ static mlir::detail::TypedValue<T> getEmptyKey() {
+ void *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
+ return mlir::Value::getFromOpaquePointer(pointer);
+ }
+ static mlir::detail::TypedValue<T> getTombstoneKey() {
+ void *pointer = llvm::DenseMapInfo<void *>::getTombstoneKey();
+ return mlir::Value::getFromOpaquePointer(pointer);
+ }
+};
/// Allow stealing the low bits of a value.
template <>
@@ -561,6 +573,14 @@ struct PointerLikeTypeTraits<mlir::OpResult>
return reinterpret_cast<mlir::detail::OpResultImpl *>(pointer);
}
};
+template <typename T>
+struct PointerLikeTypeTraits<mlir::detail::TypedValue<T>>
+ : public PointerLikeTypeTraits<mlir::Value> {
+public:
+ static inline mlir::detail::TypedValue<T> getFromVoidPointer(void *pointer) {
+ return mlir::Value::getFromOpaquePointer(pointer);
+ }
+};
/// Add support for llvm style casts. We provide a cast between To and From if
/// From is mlir::Value or derives from it.
More information about the Mlir-commits
mailing list