mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-27 22:55:15 +00:00
Add a DenseMapInfo specialization for PointerUnion. In tree user to land shortly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206253 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0b6cb7104b
commit
9393eb354f
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user