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

Gabor Greif ggreif at gmail.com
Mon Apr 7 09:53:00 PDT 2008


Author: ggreif
Date: Mon Apr  7 11:52:59 2008
New Revision: 49341

URL: http://llvm.org/viewvc/llvm-project?rev=49341&view=rev
Log:
add functionality for initial encoding of tags

Modified:
    llvm/branches/ggreif/use-diet/include/llvm/Use.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=49341&r1=49340&r2=49341&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Mon Apr  7 11:52:59 2008
@@ -41,7 +41,7 @@
     if (Val) removeFromList();
   }
 
-  /// Default ctor - This leaves the Use completely unitialized.  The only thing
+  /// Default ctor - This leaves the Use completely uninitialized.  The only thing
   /// that is valid to do with this use is to call the "init" method.
   inline Use() : Val(0) {}
 
@@ -50,6 +50,7 @@
   Value *get() const { return Val; }
   User *getUser() const { return U; }
   const Use* getImpliedUser() const;
+  void initTags(Use* start, Use* stop, ptrdiff_t done = 0);
 
   inline void set(Value *Val);
 

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=49341&r1=49340&r2=49341&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Mon Apr  7 11:52:59 2008
@@ -19,31 +19,51 @@
 //                         Use getImpliedUser Implementation
 //===----------------------------------------------------------------------===//
 
+enum ValuePtrTag { zeroDigitTag = 0, oneDigitTag = 1, stopTag = 0x2, fullStopTag = 0x3 };
+
 const Use *Use::getImpliedUser() const {
   bool StopEncountered = false;
   ptrdiff_t Offset = 0;
   const Use *Current = this;
-  enum { stop = 0x2, fullstop = 0x3 };
 
   while (true) {
     unsigned Tag = unsigned(Current->Val) & 0x3;
     switch (Tag)
       {
-      case 0:
-      case 1:   // digits
-	if (StopEncountered)
-	  Offset = (Offset << 1) + Tag;
-	break;
-      case stop:
-	if (StopEncountered)
-	  return Current + Offset;
-	StopEncountered = true;
-	break;
-      case fullstop:
-	return Current + 1;
+      case zeroDigitTag:
+      case oneDigitTag:
+        if (StopEncountered)
+          Offset = (Offset << 1) + Tag;
+        break;
+      case stopTag:
+        if (StopEncountered)
+          return Current + Offset;
+        StopEncountered = true;
+        break;
+      case fullStopTag:
+        return Current + 1;
       }
 
     ++Current;
   }
 }
+
+void Use::initTags(Use* start, Use* stop, ptrdiff_t done) {
+    ptrdiff_t Count = 0;
+    while (start != stop) 
+    {
+        --stop;
+        if (!Count) {
+            stop->Val = reinterpret_cast<Value*>(done == 0 ? fullStopTag : stopTag);
+            ++done;
+            Count = done;
+        } else {
+            stop->Val = reinterpret_cast<Value*>(Count & 1);
+            Count >>= 1;
+            ++done;
+        }
+    }
+}
+
+
 }





More information about the llvm-commits mailing list