[pypy-svn] r23486 - in pypy/dist/pypy/jit: . test
arigo at codespeak.net
arigo at codespeak.net
Sun Feb 19 18:13:31 CET 2006
Author: arigo
Date: Sun Feb 19 18:13:30 2006
New Revision: 23486
Modified:
pypy/dist/pypy/jit/hintrtyper.py
pypy/dist/pypy/jit/test/test_hint_timeshift.py
Log:
Convertion from GreenRepr to RedRepr, as required by red operations involving a
mixture of red and green arguments. More tests.
Modified: pypy/dist/pypy/jit/hintrtyper.py
==============================================================================
--- pypy/dist/pypy/jit/hintrtyper.py (original)
+++ pypy/dist/pypy/jit/hintrtyper.py Sun Feb 19 18:13:30 2006
@@ -206,6 +206,13 @@
if isinstance(_r, GreenRepr):
PRECOMPUTED_GREEN_REPRS[_r.lowleveltype] = _r
+
+class __extend__(pairtype(GreenRepr, RedRepr)):
+
+ def convert_from_to((r_from, r_to), v, llops):
+ assert r_from.lowleveltype == r_to.original_concretetype
+ return llops.gendirectcall(rtimeshift.REDBOX.ll_make_from_const, v)
+
# ____________________________________________________________
class SomeJITState(annmodel.SomeObject):
Modified: pypy/dist/pypy/jit/test/test_hint_timeshift.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_hint_timeshift.py (original)
+++ pypy/dist/pypy/jit/test/test_hint_timeshift.py Sun Feb 19 18:13:30 2006
@@ -202,3 +202,31 @@
assert res == 27
assert insns['int_add'] == 3
assert insns['int_is_true'] == 3
+
+def test_convert_greenvar_to_redvar():
+ def ll_function(x, y):
+ hint(x, concrete=True)
+ return x - y
+ insns, res = timeshift(ll_function, [70, 4], [0])
+ assert res == 66
+ assert insns['int_sub'] == 1
+ insns, res = timeshift(ll_function, [70, 4], [0, 1])
+ assert res == 66
+ assert insns == {}
+
+def INPROGRESS_test_arith_plus_minus():
+ def ll_plus_minus(encoded_insn, nb_insn, x, y):
+ acc = x
+ pc = 0
+ while pc < nb_insn:
+ op = (encoded_insn >> (pc*4)) & 0xF
+ op = hint(op, concrete=True)
+ if op == 0xA:
+ acc += y
+ elif op == 0x5:
+ acc -= y
+ pc += 1
+ return acc
+ assert ll_plus_minus(0xA5A, 3, 32, 10) == 42
+ insns, res = timeshift(ll_plus_minus, [0xA5A, 3, 32, 10], [0, 1])
+ assert res == 42
More information about the Pypy-commit
mailing list