From f385167b85abf9cb63a0bec94732d7185ee74e36 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 31 Mar 2009 21:28:39 +0000 Subject: [PATCH] teach PointerLikeTypeTraits that all pointers to pointers may only be 4-byte aligned. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68147 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/PointerLikeTypeTraits.h | 14 ++++++++++++++ include/llvm/Use.h | 11 ----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/include/llvm/Support/PointerLikeTypeTraits.h b/include/llvm/Support/PointerLikeTypeTraits.h index c5f79ccb835..226dacf3611 100644 --- a/include/llvm/Support/PointerLikeTypeTraits.h +++ b/include/llvm/Support/PointerLikeTypeTraits.h @@ -58,6 +58,20 @@ public: enum { NumLowBitsAvailable = 3 }; }; +// Pointers to pointers are only 4-byte aligned on 32-bit systems. +template +class PointerLikeTypeTraits { +public: + static inline void *getAsVoidPointer(T** P) { return P; } + static inline T **getFromVoidPointer(void *P) { + return static_cast(P); + } + enum { NumLowBitsAvailable = 2 }; +}; + + + + // Provide PointerLikeTypeTraits for uintptr_t. template<> class PointerLikeTypeTraits { diff --git a/include/llvm/Use.h b/include/llvm/Use.h index 53df699e703..32cdd1b95dd 100644 --- a/include/llvm/Use.h +++ b/include/llvm/Use.h @@ -29,17 +29,6 @@ class Use; /// Tag - generic tag type for (at least 32 bit) pointers enum Tag { noTag, tagOne, tagTwo, tagThree }; -// Use** is only 4-byte aligned. -template<> -class PointerLikeTypeTraits { -public: - static inline void *getAsVoidPointer(Use** P) { return P; } - static inline Use **getFromVoidPointer(void *P) { - return static_cast(P); - } - enum { NumLowBitsAvailable = 2 }; -}; - //===----------------------------------------------------------------------===// // Use Class //===----------------------------------------------------------------------===//