summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2014-04-15 07:08:40 +0000
committerNick Lewycky <nicholas@mxc.ca>2014-04-15 07:08:40 +0000
commit3cdb5cd00a4656e3e298159c1d0ddf1dd6655787 (patch)
treee363c93671140a28d64bd458709ce3eebbca1fed /llvm/include
parent2617dccea2721fd74677f0a7bcf5a768238421d0 (diff)
downloadbcm5719-llvm-3cdb5cd00a4656e3e298159c1d0ddf1dd6655787.tar.gz
bcm5719-llvm-3cdb5cd00a4656e3e298159c1d0ddf1dd6655787.zip
Add a DenseMapInfo specialization for PointerUnion. In tree user to land shortly.
llvm-svn: 206253
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/ADT/PointerUnion.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h
index 8cbe8d1df75..dafd0e05109 100644
--- a/llvm/include/llvm/ADT/PointerUnion.h
+++ b/llvm/include/llvm/ADT/PointerUnion.h
@@ -15,6 +15,7 @@
#ifndef LLVM_ADT_POINTERUNION_H
#define LLVM_ADT_POINTERUNION_H
+#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/Support/Compiler.h"
@@ -455,6 +456,33 @@ namespace llvm {
::NumLowBitsAvailable
};
};
+
+ // Teach DenseMap how to use PointerUnions as keys.
+ template<typename T, typename U>
+ struct DenseMapInfo<PointerUnion<T, U> > {
+ typedef PointerUnion<T, U> Pair;
+ typedef DenseMapInfo<T> FirstInfo;
+ typedef DenseMapInfo<U> SecondInfo;
+
+ static inline Pair getEmptyKey() {
+ return Pair(FirstInfo::getEmptyKey());
+ }
+ static inline Pair getTombstoneKey() {
+ return Pair(FirstInfo::getTombstoneKey());
+ }
+ static unsigned getHashValue(const Pair &PairVal) {
+ intptr_t key = (intptr_t)PairVal.getOpaqueValue();
+ return DenseMapInfo<intptr_t>::getHashValue(key);
+ }
+ static bool isEqual(const Pair &LHS, const Pair &RHS) {
+ return LHS.template is<T>() == RHS.template is<T>() &&
+ (LHS.template is<T>() ?
+ FirstInfo::isEqual(LHS.template get<T>(),
+ RHS.template get<T>()) :
+ SecondInfo::isEqual(LHS.template get<U>(),
+ RHS.template get<U>()));
+ }
+ };
}
#endif
OpenPOWER on IntegriCloud