[Mlir-commits] [mlir] ed87d9d - Change the implementation of mlir::hash_value(Identifier) to be consistent
Chris Lattner
llvmlistbot at llvm.org
Sat Apr 11 22:00:39 PDT 2020
Author: Chris Lattner
Date: 2020-04-11T21:59:48-07:00
New Revision: ed87d9d6434fa3a7dc6f53f1fc5da30994e125fc
URL: https://github.com/llvm/llvm-project/commit/ed87d9d6434fa3a7dc6f53f1fc5da30994e125fc
DIFF: https://github.com/llvm/llvm-project/commit/ed87d9d6434fa3a7dc6f53f1fc5da30994e125fc.diff
LOG: Change the implementation of mlir::hash_value(Identifier) to be consistent
with DenseMapInfo<mlir::Identifier>::getHashValue. NFC.
Adjust a few variable names to follow MLIR convention while here NFC.
Added:
Modified:
mlir/include/mlir/IR/Identifier.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/Identifier.h b/mlir/include/mlir/IR/Identifier.h
index fae92facc4d1..a6bfc6ca94b8 100644
--- a/mlir/include/mlir/IR/Identifier.h
+++ b/mlir/include/mlir/IR/Identifier.h
@@ -96,9 +96,9 @@ inline bool operator!=(StringRef lhs, Identifier rhs) { return !rhs.is(lhs); }
// Make identifiers hashable.
inline llvm::hash_code hash_value(Identifier arg) {
- return llvm::hash_value(arg.strref());
+ // Identifiers are uniqued, so we can just hash the pointer they contain.
+ return llvm::hash_value(static_cast<const void *>(arg.data()));
}
-
} // end namespace mlir
namespace llvm {
@@ -113,11 +113,11 @@ struct DenseMapInfo<mlir::Identifier> {
auto pointer = llvm::DenseMapInfo<const void *>::getTombstoneKey();
return mlir::Identifier::getFromOpaquePointer(pointer);
}
- static unsigned getHashValue(mlir::Identifier Val) {
- return DenseMapInfo<const void *>::getHashValue(Val.data());
+ static unsigned getHashValue(mlir::Identifier val) {
+ return DenseMapInfo<const void *>::getHashValue(val.data());
}
- static bool isEqual(mlir::Identifier LHS, mlir::Identifier RHS) {
- return LHS == RHS;
+ static bool isEqual(mlir::Identifier lhs, mlir::Identifier rhs) {
+ return lhs == rhs;
}
};
@@ -127,11 +127,11 @@ struct DenseMapInfo<mlir::Identifier> {
template <>
struct PointerLikeTypeTraits<mlir::Identifier> {
public:
- static inline void *getAsVoidPointer(mlir::Identifier I) {
- return const_cast<void *>(I.getAsOpaquePointer());
+ static inline void *getAsVoidPointer(mlir::Identifier i) {
+ return const_cast<void *>(i.getAsOpaquePointer());
}
- static inline mlir::Identifier getFromVoidPointer(void *P) {
- return mlir::Identifier::getFromOpaquePointer(P);
+ static inline mlir::Identifier getFromVoidPointer(void *p) {
+ return mlir::Identifier::getFromOpaquePointer(p);
}
static constexpr int NumLowBitsAvailable = 2;
};
More information about the Mlir-commits
mailing list