diff options
author | Gabor Greif <ggreif@gmail.com> | 2009-01-05 16:05:32 +0000 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2009-01-05 16:05:32 +0000 |
commit | fd095b6389ec7c794e094f2a5dc8851bdc108999 (patch) | |
tree | b8dfad42f12dc67a6b69332c4c026b3cdb2a8ea1 /include | |
parent | 4050a2324ce3c5e292ca8e2e025971766017f0e4 (diff) | |
download | external_llvm-fd095b6389ec7c794e094f2a5dc8851bdc108999.zip external_llvm-fd095b6389ec7c794e094f2a5dc8851bdc108999.tar.gz external_llvm-fd095b6389ec7c794e094f2a5dc8851bdc108999.tar.bz2 |
Get rid of the tagging functions and use PointerIntPair.
This means that we have to include an additional header.
This patch should be functionally equivalent. I cannot outrule any performance
degradation, though I do not expect any.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61694 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Use.h | 45 |
1 files changed, 5 insertions, 40 deletions
diff --git a/include/llvm/Use.h b/include/llvm/Use.h index b4d2c48..7d6bf50 100644 --- a/include/llvm/Use.h +++ b/include/llvm/Use.h @@ -18,6 +18,7 @@ #include "llvm/Support/Casting.h" #include "llvm/ADT/iterator.h" +#include "llvm/ADT/PointerIntPair.h" namespace llvm { @@ -25,46 +26,9 @@ class Value; class User; -//===----------------------------------------------------------------------===// -// Generic Tagging Functions -//===----------------------------------------------------------------------===// - -// We adhere to the following convention: The type of a tagged pointer -// to T is T volatile*. This means that functions that superpose a tag -// on a pointer will be supplied a T* (or T const*) and will return a -// tagged one: T volatile*. Untagging functions do it the other way -// 'round. While this scheme does not prevent dereferencing of tagged -// pointers, proper type annotations do catch most inappropriate uses. - /// Tag - generic tag type for (at least 32 bit) pointers enum Tag { noTag, tagOne, tagTwo, tagThree }; -/// addTag - insert tag bits into an (untagged) pointer -template <typename T, typename TAG> -inline volatile T *addTag(const T *P, TAG Tag) { - return reinterpret_cast<T*>(ptrdiff_t(P) | Tag); -} - -/// stripTag - remove tag bits from a pointer, -/// making it dereferencable -template <ptrdiff_t MASK, typename T> -inline T *stripTag(const volatile T *P) { - return reinterpret_cast<T*>(ptrdiff_t(P) & ~MASK); -} - -/// extractTag - extract tag bits from a pointer -template <typename TAG, TAG MASK, typename T> -inline TAG extractTag(const volatile T *P) { - return TAG(ptrdiff_t(P) & MASK); -} - -/// transferTag - transfer tag bits from a pointer, -/// to an untagged pointer -template <ptrdiff_t MASK, typename T> -inline volatile T *transferTag(const volatile T *From, const T *To) { - return reinterpret_cast<T*>((ptrdiff_t(From) & MASK) | ptrdiff_t(To)); -} - //===----------------------------------------------------------------------===// // Use Class @@ -133,10 +97,11 @@ private: static Use *initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0); Value *Val; - Use *Next, *volatile*Prev; + Use *Next; + PointerIntPair<Use**, 2, PrevPtrTag> Prev; void setPrev(Use **NewPrev) { - Prev = transferTag<fullStopTag>(Prev, NewPrev); + Prev.setPointer(NewPrev); } void addToList(Use **List) { Next = *List; @@ -145,7 +110,7 @@ private: *List = this; } void removeFromList() { - Use **StrippedPrev = stripTag<fullStopTag>(Prev); + Use **StrippedPrev = Prev.getPointer(); *StrippedPrev = Next; if (Next) Next->setPrev(StrippedPrev); } |