[llvm-commits] [llvm] r49718 - /llvm/branches/ggreif/use-diet/include/llvm/User.h

Gabor Greif ggreif at gmail.com
Tue Apr 15 02:55:28 PDT 2008


Author: ggreif
Date: Tue Apr 15 04:55:11 2008
New Revision: 49718

URL: http://llvm.org/viewvc/llvm-project?rev=49718&view=rev
Log:
actually use addTag and define stripTag

Modified:
    llvm/branches/ggreif/use-diet/include/llvm/User.h

Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49718&r1=49717&r2=49718&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/User.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/User.h Tue Apr 15 04:55:11 2008
@@ -323,10 +323,15 @@
 enum Tag { noTag, tagOne, tagTwo, tagThree };
 
 template <typename T, typename TAG>
-inline T *addTag(T *P, TAG Tag) {
+inline T *addTag(const T *P, TAG Tag) {
     return reinterpret_cast<T*>(ptrdiff_t(P) | Tag);
 }
 
+template <typename T, typename TAG, ptrdiff_t MASK>
+inline T *stripTag(const T *P) {
+  return reinterpret_cast<T*>(ptrdiff_t(P) & ~MASK);
+}
+
 Use *User::allocHungoffUses(unsigned N) const {
   struct AugmentedUse : Use {
     User *ref;
@@ -334,7 +339,7 @@
   };
   Use *Begin = static_cast<Use*>(::operator new(sizeof(Use) * N + sizeof(AugmentedUse) - sizeof(Use)));
   AugmentedUse *End = static_cast<AugmentedUse*>(Begin + N);
-  End->ref = (User*)(ptrdiff_t(this) | tagOne);
+  End->ref = addTag(this, tagOne);
   Use::initTags(Begin, End);
   return Begin;
 }





More information about the llvm-commits mailing list