[llvm-commits] [llvm] r48923 - /llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp

Gabor Greif ggreif at gmail.com
Fri Mar 28 11:09:05 PDT 2008


Author: ggreif
Date: Fri Mar 28 13:09:04 2008
New Revision: 48923

URL: http://llvm.org/viewvc/llvm-project?rev=48923&view=rev
Log:
first writeup. does not compile yet

Added:
    llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp

Added: 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=48923&view=auto

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (added)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Fri Mar 28 13:09:04 2008
@@ -0,0 +1,50 @@
+//===-- Use.cpp - Implement the Use class -------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the algoritm for finding the User of a Use.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Use.h"
+
+namespace llvm {
+
+//===----------------------------------------------------------------------===//
+//                         Use getImpliedUser Implementation
+//===----------------------------------------------------------------------===//
+
+const Use *Use::getImpliedUser() const {
+
+    bool StopEncountered = false;
+    ptrdiff_t Offset = 0;
+    const Use *Current = this;
+
+    while (true) 
+    {
+        unsigned Tag = unsigned(Current->Val) & 0x3;
+        switch (Tag)
+        {
+            case 0:
+            case 1:   // digits
+                if (StopEncountered)
+                    Offset = (Offset << 1) + Tag;
+                break;
+            case 0x2: // stop
+                if (StopEncountered)
+                    return Current + Offset;
+                StopEncountered = true;
+                break;
+            case 0x3: // full stop
+                return Current + 1;
+        }
+
+        ++Current;
+    }
+}
+}





More information about the llvm-commits mailing list