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

pedronis at codespeak.net pedronis at codespeak.net
Sat Jan 28 11:49:27 CET 2006


Author: pedronis
Date: Sat Jan 28 11:49:25 2006
New Revision: 22766

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

union for SomeLLAbstractConstants with simple test



Modified: pypy/dist/pypy/jit/hintmodel.py
==============================================================================
--- pypy/dist/pypy/jit/hintmodel.py	(original)
+++ pypy/dist/pypy/jit/hintmodel.py	Sat Jan 28 11:49:25 2006
@@ -3,9 +3,9 @@
 from pypy.jit.hintbookkeeper import getbookkeeper
 from pypy.rpython.lltypesystem import lltype
 
-UNARY_OPERATIONS = "".split()
+UNARY_OPERATIONS = "same_as".split()
 
-BINARY_OPERATIONS = "int_add".split()
+BINARY_OPERATIONS = "int_add int_sub".split()
 
 class OriginTreeNode(object):
 
@@ -31,6 +31,10 @@
         SomeLLAbstractValue.__init__(self, T)
         self.origins = origins
 
+class __extend__(SomeLLAbstractValue):
+
+    def same_as(hs_v1):
+        return hs_v1
 
 class __extend__(pairtype(SomeLLAbstractConstant, SomeLLAbstractConstant)):
 
@@ -40,3 +44,9 @@
         origin.merge(hs_c2.origins)
         return SomeLLAbstractConstant(lltype.Signed, {origin: True})
 
+    int_sub = int_add
+
+    def union((hs_c1, hs_c2)):
+        assert hs_c1.concretetype == hs_c2.concretetype
+        origins = annmodel.setunion(hs_c1.origins, hs_c2.origins)
+        return SomeLLAbstractConstant(hs_c1.concretetype, origins)

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 11:49:25 2006
@@ -25,3 +25,15 @@
     assert isinstance(hs, SomeLLAbstractConstant)
     assert len(hs.origins) == 1
     assert hs.concretetype == lltype.Signed
+
+def test_join():
+    def ll_function(cond, x,y):
+        if cond:
+            z = x+y
+        else:
+            z = x-y
+        return z
+    hs = hannotate(ll_function, [bool, int, int])
+    assert isinstance(hs, SomeLLAbstractConstant)
+    assert len(hs.origins) == 2
+    assert hs.concretetype == lltype.Signed



More information about the Pypy-commit mailing list