From 0625bd6472cde014f76bb91c1a0c925d4b6e0eda Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 17 Sep 2007 18:34:04 +0000 Subject: Merge DenseMapKeyInfo & DenseMapValueInfo into DenseMapInfo Add a new DenseMapInfo::isEqual method to allow clients to redefine the equality predicate used when probing the hash table. llvm-svn: 42042 --- llvm/lib/Transforms/Scalar/GVN.cpp | 5 ++++- llvm/lib/Transforms/Scalar/GVNPRE.cpp | 5 ++++- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 18 +++++++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 7f809e73978..c6b50a4002d 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -145,7 +145,7 @@ namespace { } namespace llvm { -template <> struct DenseMapKeyInfo { +template <> struct DenseMapInfo { static inline Expression getEmptyKey() { return Expression(Expression::EMPTY); } @@ -171,6 +171,9 @@ template <> struct DenseMapKeyInfo { return hash; } + static bool isEqual(const Expression &LHS, const Expression &RHS) { + return LHS == RHS; + } static bool isPod() { return true; } }; } diff --git a/llvm/lib/Transforms/Scalar/GVNPRE.cpp b/llvm/lib/Transforms/Scalar/GVNPRE.cpp index d362f54b493..b3d2fe2d5af 100644 --- a/llvm/lib/Transforms/Scalar/GVNPRE.cpp +++ b/llvm/lib/Transforms/Scalar/GVNPRE.cpp @@ -155,7 +155,7 @@ namespace { } namespace llvm { -template <> struct DenseMapKeyInfo { +template <> struct DenseMapInfo { static inline Expression getEmptyKey() { return Expression(Expression::EMPTY); } @@ -181,6 +181,9 @@ template <> struct DenseMapKeyInfo { return hash; } + static bool isEqual(const Expression &LHS, const Expression &RHS) { + return LHS == RHS; + } static bool isPod() { return true; } }; } diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 33489711388..c32457d6704 100644 --- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -39,18 +39,22 @@ STATISTIC(NumSingleStore, "Number of alloca's promoted with a single store"); STATISTIC(NumDeadAlloca, "Number of dead alloca's removed"); STATISTIC(NumPHIInsert, "Number of PHI nodes inserted"); -// Provide DenseMapKeyInfo for all pointers. +// Provide DenseMapInfo for all pointers. namespace llvm { template<> -struct DenseMapKeyInfo > { - static inline std::pair getEmptyKey() { - return std::make_pair((BasicBlock*)-1, ~0U); +struct DenseMapInfo > { + typedef std::pair EltTy; + static inline EltTy getEmptyKey() { + return EltTy(reinterpret_cast(-1), ~0U); } - static inline std::pair getTombstoneKey() { - return std::make_pair((BasicBlock*)-2, 0U); + static inline EltTy getTombstoneKey() { + return EltTy(reinterpret_cast(-2), 0U); } static unsigned getHashValue(const std::pair &Val) { - return DenseMapKeyInfo::getHashValue(Val.first) + Val.second*2; + return DenseMapInfo::getHashValue(Val.first) + Val.second*2; + } + static bool isEqual(const EltTy &LHS, const EltTy &RHS) { + return LHS == RHS; } static bool isPod() { return true; } }; -- cgit v1.2.3