[pypy-svn] r22785 - in pypy/dist/pypy/jit: . test
pedronis at codespeak.net
pedronis at codespeak.net
Sat Jan 28 14:47:54 CET 2006
Author: pedronis
Date: Sat Jan 28 14:47:52 2006
New Revision: 22785
Modified:
pypy/dist/pypy/jit/hintmodel.py
pypy/dist/pypy/jit/test/test_hint_annotation.py
Log:
(arre, arigo, pedronis)
some hint anntotator tests about looping.
Modified: pypy/dist/pypy/jit/hintmodel.py
==============================================================================
--- pypy/dist/pypy/jit/hintmodel.py (original)
+++ pypy/dist/pypy/jit/hintmodel.py Sat Jan 28 14:47:52 2006
@@ -5,7 +5,7 @@
UNARY_OPERATIONS = "same_as hint".split()
-BINARY_OPERATIONS = "int_add int_sub".split()
+BINARY_OPERATIONS = "int_add int_sub int_gt int_eq".split()
class OriginTreeNode(object):
@@ -91,6 +91,12 @@
int_sub = int_add
+ def int_gt((hs_c1, hs_c2)):
+ origin = getbookkeeper().myorigin()
+ origin.merge(hs_c1.origins)
+ origin.merge(hs_c2.origins)
+ return SomeLLAbstractConstant(lltype.Bool, {origin: True})
+
def union((hs_c1, hs_c2)):
assert hs_c1.concretetype == hs_c2.concretetype
origins = annmodel.setunion(hs_c1.origins, hs_c2.origins)
@@ -102,3 +108,6 @@
def int_add((hs_c1, hs_c2)):
return SomeLLConcreteValue(lltype.Signed)
+
+ def int_eq((hs_c1, hs_c2)):
+ return SomeLLConcreteValue(lltype.Bool)
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 14:47:52 2006
@@ -133,6 +133,29 @@
assert meet(ac1, av1) == av1
assert meet(av1, ac1) == av1
+def test_loop():
+ def ll_function(x, y):
+ while x > 0:
+ y += x
+ x -= 1
+ return y
+ hs = hannotate(ll_function, [int, int])
+ assert isinstance(hs, SomeLLAbstractConstant)
+ assert hs.concretetype == lltype.Signed
+ assert len(hs.origins) == 2
+
+def test_loop1():
+ def ll_function(x, y):
+ while x > 0:
+ x1 = hint(x, concrete=True)
+ if x1 == 7:
+ y += x
+ x -= 1
+ return y
+ hs = hannotate(ll_function, [int, int])
+ assert isinstance(hs, SomeLLAbstractConstant)
+ assert hs.concretetype == lltype.Signed
+ assert len(hs.origins) == 2
More information about the Pypy-commit
mailing list