1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 20:12:56 +02:00

teach SmallPtrSet that PointerIntPair is "basically a pointer".

llvm-svn: 67970
This commit is contained in:
Chris Lattner 2009-03-29 00:18:42 +00:00
parent 9b435e06e4
commit c512533ea0

View File

@ -21,6 +21,8 @@ namespace llvm {
template<typename T>
struct DenseMapInfo;
template<typename>
class PointerLikeTypeInfo;
/// PointerIntPair - This class implements a pair of a pointer and small
/// integer. It is designed to represent this in the space required by one
@ -62,6 +64,10 @@ public:
void *getOpaqueValue() const { return reinterpret_cast<void*>(Value); }
void setFromOpaqueValue(void *Val) { Value = reinterpret_cast<intptr_t>(Val);}
static PointerIntPair getFromOpaqueValue(void *V) {
PointerIntPair P; P.setFromOpaqueValue(V); return P;
}
bool operator==(const PointerIntPair &RHS) const {return Value == RHS.Value;}
bool operator!=(const PointerIntPair &RHS) const {return Value != RHS.Value;}
bool operator<(const PointerIntPair &RHS) const {return Value < RHS.Value;}
@ -89,5 +95,19 @@ struct DenseMapInfo<PointerIntPair<PointerTy, IntBits, IntType> > {
static bool isPod() { return true; }
};
// Teach SmallPtrSet that PointerIntPair is "basically a pointer".
template<typename PointerTy, unsigned IntBits, typename IntType>
class PointerLikeTypeInfo<PointerIntPair<PointerTy, IntBits, IntType> > {
public:
static inline void *
getAsVoidPointer(const PointerIntPair<PointerTy, IntBits, IntType> &P) {
return P.getOpaqueValue();
}
static inline PointerIntPair<PointerTy, IntBits, IntType>
getFromVoidPointer(void *P) {
return PointerIntPair<PointerTy, IntBits, IntType>::getFromOpaqueValue(P);
}
};
} // end namespace llvm
#endif