aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-03-04 12:02:57 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-03-04 12:02:57 +0000
commited7692a136a9bcf513b91b7b5eb33a1e2d83e7ee (patch)
tree699f358d3fdc8138b9aa7cadf8427eb2473c739e /lib/VMCore
parent528f0bbe19553dfadedca040df13a389daa7593d (diff)
downloadexternal_llvm-ed7692a136a9bcf513b91b7b5eb33a1e2d83e7ee.zip
external_llvm-ed7692a136a9bcf513b91b7b5eb33a1e2d83e7ee.tar.gz
external_llvm-ed7692a136a9bcf513b91b7b5eb33a1e2d83e7ee.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/LLVMContextImpl.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/VMCore/LLVMContextImpl.h b/lib/VMCore/LLVMContextImpl.h
index a29bba2..f98526d 100644
--- a/lib/VMCore/LLVMContextImpl.h
+++ b/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;