[pypy-commit] pypy reflex-support: (wlav, arigo) Support the simple case of direct_ptradd().

arigo noreply at buildbot.pypy.org
Tue Jul 12 13:39:53 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: reflex-support
Changeset: r45508:ce9c837a3361
Date: 2011-07-12 13:38 +0200
http://bitbucket.org/pypy/pypy/changeset/ce9c837a3361/

Log:	(wlav, arigo) Support the simple case of direct_ptradd().

diff --git a/pypy/jit/codewriter/jtransform.py b/pypy/jit/codewriter/jtransform.py
--- a/pypy/jit/codewriter/jtransform.py
+++ b/pypy/jit/codewriter/jtransform.py
@@ -800,6 +800,13 @@
             result[-1].result = op.result
         return result
 
+    def rewrite_op_direct_ptradd(self, op):
+        from pypy.rpython.lltypesystem import rffi
+        # xxx otherwise, not implemented:
+        assert op.args[0].concretetype == rffi.CCHARP
+        #
+        return SpaceOperation('int_add', [op.args[0], op.args[1]], op.result)
+
     # ----------
     # Long longs, for 32-bit only.  Supported operations are left unmodified,
     # and unsupported ones are turned into a call to a function from
diff --git a/pypy/jit/codewriter/test/test_flatten.py b/pypy/jit/codewriter/test/test_flatten.py
--- a/pypy/jit/codewriter/test/test_flatten.py
+++ b/pypy/jit/codewriter/test/test_flatten.py
@@ -813,6 +813,15 @@
             int_return %i0
         """, transform=True)
 
+    def test_direct_ptradd(self):
+        from pypy.rpython.lltypesystem import rffi
+        def f(p, n):
+            return lltype.direct_ptradd(p, n)
+        self.encoding_test(f, [lltype.nullptr(rffi.CCHARP.TO), 123], """
+            int_add %i0, %i1 -> %i2
+            int_return %i2
+        """, transform=True)
+
 
 def check_force_cast(FROM, TO, operations, value):
     """Check that the test is correctly written..."""


More information about the pypy-commit mailing list