Author: Armin Rigo <[email protected]>
Branch:
Changeset: r67900:e12176e1a61c
Date: 2013-11-09 17:33 +0100
http://bitbucket.org/pypy/pypy/changeset/e12176e1a61c/
Log: Support ptradd() with types different than CCHARP.
diff --git a/rpython/jit/codewriter/jtransform.py
b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -1162,10 +1162,19 @@
v_result)
def rewrite_op_direct_ptradd(self, op):
- # xxx otherwise, not implemented:
- assert op.args[0].concretetype == rffi.CCHARP
+ v_shift = op.args[1]
+ assert v_shift.concretetype == lltype.Signed
+ ops = []
#
- return SpaceOperation('int_add', [op.args[0], op.args[1]], op.result)
+ if op.args[0].concretetype != rffi.CCHARP:
+ v_prod = varoftype(lltype.Signed)
+ by = llmemory.sizeof(op.args[0].concretetype.TO.OF)
+ c_by = Constant(by, lltype.Signed)
+ ops.append(SpaceOperation('int_mul', [v_shift, c_by], v_prod))
+ v_shift = v_prod
+ #
+ ops.append(SpaceOperation('int_add', [op.args[0], v_shift], op.result))
+ return ops
# ----------
# Long longs, for 32-bit only. Supported operations are left unmodified,
diff --git a/rpython/jit/codewriter/test/test_flatten.py
b/rpython/jit/codewriter/test/test_flatten.py
--- a/rpython/jit/codewriter/test/test_flatten.py
+++ b/rpython/jit/codewriter/test/test_flatten.py
@@ -993,6 +993,16 @@
int_return %i2
""", transform=True)
+ def test_direct_ptradd_2(self):
+ def f(p, n):
+ return lltype.direct_ptradd(p, n + 2)
+ self.encoding_test(f, [lltype.nullptr(rffi.SHORTP.TO), 123], """
+ int_add %i1, $2 -> %i2
+ int_mul %i2, $<ItemOffset <SHORT> 1> -> %i3
+ int_add %i0, %i3 -> %i4
+ int_return %i4
+ """, transform=True)
+
def test_convert_float_bytes(self):
from rpython.rlib.longlong2float import float2longlong, longlong2float
def f(x):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit