diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2012-03-04 12:02:57 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2012-03-04 12:02:57 +0000 |
| commit | 71bd7d1e5408bc52fdb96a63efc23023233aeba3 (patch) | |
| tree | d533c10f1a79629b8c2ca43dc542cdd605714777 /llvm/lib/VMCore | |
| parent | ca99ad3f0dfd67d8c3f0873e90afc27ff11c8545 (diff) | |
| download | bcm5719-llvm-71bd7d1e5408bc52fdb96a63efc23023233aeba3.tar.gz bcm5719-llvm-71bd7d1e5408bc52fdb96a63efc23023233aeba3.zip | |
Replace the hashing functions on APInt and APFloat with overloads of the
new hash_value infrastructure, and replace their implementations using
hash_combine. This removes a complete copy of Jenkin's lookup3 hash
function (which is both significantly slower and lower quality than the
one implemented in hash_combine) along with a somewhat scary xor-only
hash function.
Now that APInt and APFloat can be passed directly to hash_combine,
simplify the rest of the LLVMContextImpl hashing to use the new
infrastructure.
llvm-svn: 152004
Diffstat (limited to 'llvm/lib/VMCore')
| -rw-r--r-- | llvm/lib/VMCore/LLVMContextImpl.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/VMCore/LLVMContextImpl.h b/llvm/lib/VMCore/LLVMContextImpl.h index a29bba2f3b4..f98526de650 100644 --- a/llvm/lib/VMCore/LLVMContextImpl.h +++ b/llvm/lib/VMCore/LLVMContextImpl.h @@ -52,12 +52,14 @@ struct DenseMapAPIntKeyInfo { bool operator!=(const KeyTy& that) const { return !this->operator==(that); } + friend hash_code hash_value(const KeyTy &Key) { + return hash_combine(Key.type, Key.val); + } }; static inline KeyTy getEmptyKey() { return KeyTy(APInt(1,0), 0); } static inline KeyTy getTombstoneKey() { return KeyTy(APInt(1,1), 0); } static unsigned getHashValue(const KeyTy &Key) { - return DenseMapInfo<void*>::getHashValue(Key.type) ^ - Key.val.getHashValue(); + return static_cast<unsigned>(hash_value(Key)); } static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) { return LHS == RHS; @@ -75,6 +77,9 @@ struct DenseMapAPFloatKeyInfo { bool operator!=(const KeyTy& that) const { return !this->operator==(that); } + friend hash_code hash_value(const KeyTy &Key) { + return hash_combine(Key.val); + } }; static inline KeyTy getEmptyKey() { return KeyTy(APFloat(APFloat::Bogus,1)); @@ -83,7 +88,7 @@ struct DenseMapAPFloatKeyInfo { return KeyTy(APFloat(APFloat::Bogus,2)); } static unsigned getHashValue(const KeyTy &Key) { - return Key.val.getHashValue(); + return static_cast<unsigned>(hash_value(Key)); } static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) { return LHS == RHS; |

