00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef LLVM_SUPPORT_POINTERLIKETYPETRAITS_H
00016 #define LLVM_SUPPORT_POINTERLIKETYPETRAITS_H
00017
00018 #include "llvm/Support/DataTypes.h"
00019
00020 namespace llvm {
00021
00025 template <typename T>
00026 class PointerLikeTypeTraits {
00027
00028
00029
00030 };
00031
00032
00033 template<typename T>
00034 class PointerLikeTypeTraits<T*> {
00035 public:
00036 static inline void *getAsVoidPointer(T* P) { return P; }
00037 static inline T *getFromVoidPointer(void *P) {
00038 return static_cast<T*>(P);
00039 }
00040
00047 enum { NumLowBitsAvailable = 2 };
00048 };
00049
00050
00051 template<typename T>
00052 class PointerLikeTypeTraits<const T*> {
00053 typedef PointerLikeTypeTraits<T*> NonConst;
00054
00055 public:
00056 static inline const void *getAsVoidPointer(const T* P) {
00057 return NonConst::getAsVoidPointer(const_cast<T*>(P));
00058 }
00059 static inline const T *getFromVoidPointer(const void *P) {
00060 return NonConst::getFromVoidPointer(const_cast<void*>(P));
00061 }
00062 enum { NumLowBitsAvailable = NonConst::NumLowBitsAvailable };
00063 };
00064
00065
00066 template<>
00067 class PointerLikeTypeTraits<uintptr_t> {
00068 public:
00069 static inline void *getAsVoidPointer(uintptr_t P) {
00070 return reinterpret_cast<void*>(P);
00071 }
00072 static inline uintptr_t getFromVoidPointer(void *P) {
00073 return reinterpret_cast<uintptr_t>(P);
00074 }
00075
00076 enum { NumLowBitsAvailable = 0 };
00077 };
00078
00079 }
00080
00081 #endif