[llvm-commits] [llvm] r56186 - in /llvm/branches/ggreif/use-diet: include/llvm/Use.h include/llvm/Value.h lib/VMCore/Use.cpp

Gabor Greif ggreif at gmail.com
Sat Sep 13 04:32:19 PDT 2008


Author: ggreif
Date: Sat Sep 13 06:32:17 2008
New Revision: 56186

URL: http://llvm.org/viewvc/llvm-project?rev=56186&view=rev
Log:
prepare the Use interface for using the waymarking algorithm

Modified:
    llvm/branches/ggreif/use-diet/include/llvm/Use.h
    llvm/branches/ggreif/use-diet/include/llvm/Value.h
    llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp

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

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Sat Sep 13 06:32:17 2008
@@ -80,7 +80,7 @@
 
   /// Destructor - Only for zap()
   inline ~Use() {
-    if (Val) removeFromList();
+    if (Val1) removeFromList();
   }
 
   /// Default ctor - This leaves the Use completely uninitialized.  The only thing
@@ -90,13 +90,26 @@
   enum PrevPtrTag { zeroDigitTag = noTag
                   , oneDigitTag = tagOne
                   , stopTag = tagTwo
-                  , fullStopTag = tagThree };
+                  , fullStopTag = tagThree
+                  , tagMask = tagThree };
 
+  enum NextPtrTag { zeroDigitTagN = tagTwo
+                  , oneDigitTagN = tagOne
+                  , stopTagN = noTag
+                  , fullStopTagN = tagThree
+                  , tagMaskN = tagThree };
+
+  inline Value *getFastValueMaybe() const;
 public:
 
 
-  operator Value*() const { return Val; }
-  Value *get() const { return Val; }
+  operator Value*() const { return get(); }
+  Value *get() const {
+    if (Value *V = getFastValueMaybe())
+      return V;
+    else
+      return Val1; // for now :-)
+    }
   User *getUser() const;
   const Use* getImpliedUser() const;
   static Use *initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0);
@@ -109,16 +122,16 @@
     return RHS;
   }
   const Use &operator=(const Use &RHS) {
-    set(RHS.Val);
+    set(RHS.Val1);
     return *this;
   }
 
-        Value *operator->()       { return Val; }
-  const Value *operator->() const { return Val; }
+        Value *operator->()       { return get(); }
+  const Value *operator->() const { return get(); }
 
   Use *getNext() const { return Next; }
 private:
-  Value *Val;
+  Value *Val1;
   Use *Next, **Prev;
 
   void setPrev(Use **NewPrev) {
@@ -207,6 +220,13 @@
   unsigned getOperandNo() const;
 };
 
+Value *Use::getFastValueMaybe() const {
+  if (fullStopTagN == extractTag<NextPtrTag, tagMaskN>(Next)) {
+    return reinterpret_cast<Value*>(stripTag<fullStopTagN>(Next));
+  }
+  return 0;
+}
+
 
 template<> struct simplify_type<value_use_iterator<User> > {
   typedef User* SimpleType;

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

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Value.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Value.h Sat Sep 13 06:32:17 2008
@@ -233,13 +233,13 @@
 }
 
 void Use::init(Value *V, User *user) {
-  Val = V;
+  Val1 = V;
   if (V) V->addUse(*this);
 }
 
 void Use::set(Value *V) {
-  if (Val) removeFromList();
-  Val = V;
+  if (Val1) removeFromList();
+  Val1 = V;
   if (V) V->addUse(*this);
 }
 

Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp?rev=56186&r1=56185&r2=56186&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Sat Sep 13 06:32:17 2008
@@ -20,8 +20,8 @@
 //===----------------------------------------------------------------------===//
 
 void Use::swap(Use &RHS) {
-  Value *V1(Val);
-  Value *V2(RHS.Val);
+  Value *V1(Val1);
+  Value *V2(RHS.Val1);
   if (V1 != V2) {
     if (V1) {
       removeFromList();
@@ -29,17 +29,17 @@
 
     if (V2) {
       RHS.removeFromList();
-      Val = V2;
+      Val1 = V2;
       V2->addUse(*this);
     } else {
-      Val = 0;
+      Val1 = 0;
     }
 
     if (V1) {
-      RHS.Val = V1;
+      RHS.Val1 = V1;
       V1->addUse(RHS);
     } else {
-      RHS.Val = 0;
+      RHS.Val1 = 0;
     }
   }
 }
@@ -52,7 +52,7 @@
   const Use *Current = this;
 
   while (true) {
-    unsigned Tag = extractTag<PrevPtrTag, fullStopTag>((Current++)->Prev);
+    unsigned Tag = extractTag<PrevPtrTag, tagMask>((Current++)->Prev);
     switch (Tag) {
       case zeroDigitTag:
       case oneDigitTag:
@@ -62,7 +62,7 @@
         ++Current;
         ptrdiff_t Offset = 1;
         while (true) {
-          unsigned Tag = extractTag<PrevPtrTag, fullStopTag>(Current->Prev);
+          unsigned Tag = extractTag<PrevPtrTag, tagMask>(Current->Prev);
           switch (Tag) {
             case zeroDigitTag:
             case oneDigitTag:
@@ -89,7 +89,7 @@
   ptrdiff_t Count = Done;
   while (Start != Stop) {
     --Stop;
-    Stop->Val = 0;
+    Stop->Val1 = 0;
     if (!Count) {
       Stop->Prev = reinterpret_cast<Use**>(Done == 0 ? fullStopTag : stopTag);
       ++Done;





More information about the llvm-commits mailing list