[llvm-commits] [llvm] r48879 - /llvm/branches/ggreif/use-diet/include/llvm/User.h
Gabor Greif
ggreif at gmail.com
Thu Mar 27 07:20:05 PDT 2008
Author: ggreif
Date: Thu Mar 27 09:20:02 2008
New Revision: 48879
URL: http://llvm.org/viewvc/llvm-project?rev=48879&view=rev
Log:
added the algorithm for decoding
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=48879&r1=48878&r2=48879&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/User.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/User.h Thu Mar 27 09:20:02 2008
@@ -130,6 +130,21 @@
Printing <test> gives: "1s100000s11010s10100s1111s1010s110s11s1S"
+The reverse algorithm computes the
+length of the string just by examining
+a certain prefix:
+
+> pref :: [Char] -> Int
+> pref "S" = 1
+> pref ('s':rest) = decode 1 0 rest
+> pref (_:rest) = 1 + pref rest
+>
+> decode walk acc ('0':rest) = decode (walk + 1) (acc * 2) rest
+> decode walk acc ('1':rest) = decode (walk + 1) (acc * 2 + 1) rest
+> decode walk acc _ = walk + acc
+>
+
+Now, as expected, printing <pref test> gives 40.
To maintain the invariant that the 2 LSBits of each Value* in Use
More information about the llvm-commits
mailing list