[pypy-svn] r62223 - in pypy/branch/pyjitpl5/pypy/jit: backend/llgraph metainterp metainterp/test
arigo at codespeak.net
arigo at codespeak.net
Fri Feb 27 14:34:09 CET 2009
Author: arigo
Date: Fri Feb 27 14:34:08 2009
New Revision: 62223
Modified:
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
Log:
Support for unsigned variables.
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py Fri Feb 27 14:34:08 2009
@@ -9,6 +9,7 @@
from pypy.jit.metainterp.history import (ConstInt, ConstPtr, ConstAddr,
BoxInt, BoxPtr)
from pypy.rpython.lltypesystem import lltype, llmemory, rclass, rstr
+from pypy.rpython.lltypesystem import lloperation
from pypy.rpython.ootypesystem import ootype
from pypy.rpython.module.support import LLSupport, OOSupport
from pypy.rpython.llinterp import LLInterpreter, LLFrame, LLException
@@ -18,6 +19,7 @@
from pypy.jit.backend.llgraph import symbolic
from pypy.rlib.objectmodel import ComputedIntSymbolic
+from pypy.rlib.rarithmetic import r_uint
import py
from pypy.tool.ansi_print import ansi_log
@@ -69,6 +71,15 @@
'int_mul_ovf' : (('int', 'int'), 'int'),
'int_neg_ovf' : (('int',), 'int'),
'bool_not' : (('bool',), 'bool'),
+ 'uint_add' : (('int', 'int'), 'int'),
+ 'uint_sub' : (('int', 'int'), 'int'),
+ 'uint_mul' : (('int', 'int'), 'int'),
+ 'uint_lt' : (('int', 'int'), 'bool'),
+ 'uint_le' : (('int', 'int'), 'bool'),
+ 'uint_eq' : (('int', 'int'), 'bool'),
+ 'uint_ne' : (('int', 'int'), 'bool'),
+ 'uint_gt' : (('int', 'int'), 'bool'),
+ 'uint_ge' : (('int', 'int'), 'bool'),
'new_with_vtable' : (('int', 'ptr'), 'ptr'),
'new' : (('int',), 'ptr'),
'new_array' : (('int', 'int'), 'ptr'),
@@ -573,6 +584,24 @@
# but we don't want this to occur in our case
return LLFrame(graph, args, self.llinterpreter)
+ # ---------- signed/unsigned support ----------
+
+ # for these operations, allow us to be called with unsigned or with
+ # regular signed arguments (which would come e.g. from ConstInt)
+ for _opname in ['uint_add', 'uint_sub', 'uint_mul',
+ 'uint_lt', 'uint_le', 'uint_eq',
+ 'uint_ne', 'uint_gt', 'int_ge',
+ ]:
+ exec py.code.Source("""
+ def op_%s(self, x, y):
+ x = r_uint(x)
+ y = r_uint(y)
+ ophandler = lloperation.LL_OPERATIONS[%r].fold
+ return ophandler(x, y)
+ """ % (_opname, _opname)).compile()
+
+ # ----------------------------------------
+
def op_return(self, value=None):
if self.last_exception is None:
raise ExecutionReturned(value)
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py Fri Feb 27 14:34:08 2009
@@ -473,15 +473,6 @@
serialize_op_unichar_eq = serialize_op_char_eq
serialize_op_unichar_ne = serialize_op_char_ne
- def serialize_op_uint_add(self, op): self._defl(op, 'int_add')
- def serialize_op_uint_sub(self, op): self._defl(op, 'int_sub')
- def serialize_op_uint_lt (self, op): self._defl(op, 'int_lt')
- def serialize_op_uint_le (self, op): self._defl(op, 'int_le')
- def serialize_op_uint_eq (self, op): self._defl(op, 'int_eq')
- def serialize_op_uint_ne (self, op): self._defl(op, 'int_ne')
- def serialize_op_uint_gt (self, op): self._defl(op, 'int_gt')
- def serialize_op_uint_ge (self, op): self._defl(op, 'int_ge')
-
def serialize_op_int_add_nonneg_ovf(self, op):
self.default_serialize_op(op, 'int_add_ovf')
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py Fri Feb 27 14:34:08 2009
@@ -228,6 +228,9 @@
'int_ne', 'int_gt', 'int_ge',
'int_and', 'int_or', 'int_xor',
'int_rshift', 'int_lshift',
+ 'uint_add', 'uint_sub', 'uint_mul',
+ 'uint_lt', 'uint_le', 'uint_eq',
+ 'uint_ne', 'uint_gt', 'int_ge',
]:
exec py.code.Source('''
@arguments("box", "box")
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py Fri Feb 27 14:34:08 2009
@@ -232,6 +232,19 @@
res = self.interp_operations(f, [7])
assert res == 1212
+ def test_r_uint(self):
+ from pypy.rlib.rarithmetic import r_uint
+ myjitdriver = JitDriver(greens = [], reds = ['y'])
+ def f(y):
+ y = r_uint(y)
+ while y > 0:
+ myjitdriver.can_enter_jit(y=y)
+ myjitdriver.jit_merge_point(y=y)
+ y -= 1
+ return y
+ res = self.meta_interp(f, [10])
+ assert res == 0
+
class TestOOtype(BasicTests, OOJitMixin):
pass
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py Fri Feb 27 14:34:08 2009
@@ -272,7 +272,7 @@
if isinstance(TYPE, lltype.Ptr):
return box.getptr(TYPE)
else:
- return box.getint()
+ return lltype.cast_primitive(TYPE, box.getint())
unwrap._annspecialcase_ = 'specialize:arg(0)'
def ll_portal_runner(*args):
@@ -317,7 +317,7 @@
vlist += greens_v
vlist += reds_v
v_result = Variable()
- v_result.concretetype = lltype.Void
+ v_result.concretetype = PORTALFUNC.RESULT
newop = SpaceOperation('direct_call', vlist, v_result)
del origblock.operations[origindex:]
origblock.operations.append(newop)
More information about the Pypy-commit
mailing list