[pypy-svn] r22769 - in pypy/dist/pypy/jit: . test

pedronis at codespeak.net pedronis at codespeak.net
Sat Jan 28 12:39:09 CET 2006


Author: pedronis
Date: Sat Jan 28 12:39:07 2006
New Revision: 22769

Modified:
   pypy/dist/pypy/jit/hintmodel.py
   pypy/dist/pypy/jit/test/test_hint_annotation.py
Log:
(arre, arigo, pedronis)

started support for variables (as SomeLLAbstractValue).




Modified: pypy/dist/pypy/jit/hintmodel.py
==============================================================================
--- pypy/dist/pypy/jit/hintmodel.py	(original)
+++ pypy/dist/pypy/jit/hintmodel.py	Sat Jan 28 12:39:07 2006
@@ -34,9 +34,6 @@
     def __init__(self, T):
         self.concretetype = T
 
-class SomeLLAbstractVariable(SomeLLAbstractValue):
-    pass
-
 class SomeLLAbstractConstant(SomeLLAbstractValue):
 
     def __init__(self, T, origins):
@@ -57,12 +54,21 @@
 class __extend__(SomeLLAbstractConstant):
 
     def hint(hs_c1, hs_flags):
+        if hs_flags.const.get('variable', False):
+            return SomeLLAbstractValue(hs_c1.concretetype)
         assert hs_flags.const['concrete']
         for o in hs_c1.origins:
             for o1 in o.visit():
                 o1.fixed = True
         return SomeLLConcreteValue(hs_c1.concretetype)
 
+
+class __extend__(pairtype(SomeLLAbstractValue, SomeLLAbstractValue)):
+
+    def int_add((hs_v1, hs_v2)):
+        return SomeLLAbstractValue(lltype.Signed)
+
+
 class __extend__(pairtype(SomeLLAbstractConstant, SomeLLAbstractConstant)):
 
     def int_add((hs_c1, hs_c2)):

Modified: pypy/dist/pypy/jit/test/test_hint_annotation.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_hint_annotation.py	(original)
+++ pypy/dist/pypy/jit/test/test_hint_annotation.py	Sat Jan 28 12:39:07 2006
@@ -1,6 +1,6 @@
 from pypy.translator.translator import TranslationContext, graphof
 from pypy.jit.hintannotator import HintAnnotator
-from pypy.jit.hintmodel import SomeLLAbstractConstant, SomeLLConcreteValue, OriginTreeNode
+from pypy.jit.hintmodel import *
 from pypy.rpython.lltypesystem import lltype
 from pypy.rpython.objectmodel import hint
 
@@ -71,3 +71,12 @@
             assert not o.origins
     assert hs.concretetype == lltype.Signed
  
+def test_simple_variable():
+    def ll_function(x,y):
+        x = hint(x, variable=True) # special hint only for testing purposes!!!
+        return x + y
+    hs = hannotate(ll_function, [int, int])
+    assert type(hs) is  SomeLLAbstractValue
+    assert hs.concretetype == lltype.Signed
+    
+    



More information about the Pypy-commit mailing list