[pypy-commit] pypy s390x-backend: passing float_operations (includes arith, compare, neg, abs and conversion to integer and back

plan_rich noreply at buildbot.pypy.org
Fri Nov 20 09:21:27 EST 2015


Author: Richard Plangger <planrichi at gmail.com>
Branch: s390x-backend
Changeset: r80794:cb6631d78b5c
Date: 2015-11-20 15:21 +0100
http://bitbucket.org/pypy/pypy/changeset/cb6631d78b5c/

Log:	passing float_operations (includes arith, compare, neg, abs and
	conversion to integer and back

diff --git a/rpython/jit/backend/test/runner_test.py b/rpython/jit/backend/test/runner_test.py
--- a/rpython/jit/backend/test/runner_test.py
+++ b/rpython/jit/backend/test/runner_test.py
@@ -419,7 +419,9 @@
 
     def test_float_operations(self):
         from rpython.jit.metainterp.test.test_executor import get_float_tests
+        from rpython.jit.metainterp.resoperation import opname
         for opnum, boxargs, rettype, retvalue in get_float_tests(self.cpu):
+            print("testing", opname[opnum])
             res = self.execute_operation(opnum, boxargs, rettype)
             if rettype == 'float':
                 res = longlong.getrealfloat(res)
diff --git a/rpython/jit/backend/zarch/conditions.py b/rpython/jit/backend/zarch/conditions.py
--- a/rpython/jit/backend/zarch/conditions.py
+++ b/rpython/jit/backend/zarch/conditions.py
@@ -12,7 +12,8 @@
 NO = loc.imm(0xe) # NO overflow
 ANY = loc.imm(0xf)
 
-FP_CUTOFF = loc.imm(0x1) # 4.4 => 4, 4.5 => 4
+FP_ROUND_DEFAULT = loc.imm(0x0)
+FP_TOWARDS_ZERO = loc.imm(0x5)
 
 cond_none = loc.imm(0x0)
 
diff --git a/rpython/jit/backend/zarch/helper/regalloc.py b/rpython/jit/backend/zarch/helper/regalloc.py
--- a/rpython/jit/backend/zarch/helper/regalloc.py
+++ b/rpython/jit/backend/zarch/helper/regalloc.py
@@ -190,7 +190,7 @@
 def prepare_unary_op(self, op):
     a0 = op.getarg(0)
     assert not isinstance(a0, ConstInt)
-    l0 = self.ensure_reg(a0)
+    l0 = self.ensure_reg(a0, force_in_reg=True)
     res = self.force_result_in_reg(op, a0)
     self.free_op_vars()
     return [l0,]
diff --git a/rpython/jit/backend/zarch/instructions.py b/rpython/jit/backend/zarch/instructions.py
--- a/rpython/jit/backend/zarch/instructions.py
+++ b/rpython/jit/backend/zarch/instructions.py
@@ -217,6 +217,10 @@
     'CDBR':    ('rre',   ['\xB3','\x19']),
     'CEB':     ('rxe',   ['\xED','\x09'], 'r,bidl,-'),
     'CDB':     ('rxe',   ['\xED','\x19'], 'r,bidl,-'),
+
+    # complement & positive
+    'LPDBR':    ('rre',   ['\xB3','\x10']),
+    'LCDBR':    ('rre',   ['\xB3','\x13']),
 }
 
 # MISC
diff --git a/rpython/jit/backend/zarch/opassembler.py b/rpython/jit/backend/zarch/opassembler.py
--- a/rpython/jit/backend/zarch/opassembler.py
+++ b/rpython/jit/backend/zarch/opassembler.py
@@ -185,9 +185,17 @@
     emit_float_gt = gen_emit_cmp_op(c.GT, fp=True)
     emit_float_ge = gen_emit_cmp_op(c.GE, fp=True)
 
+    def emit_float_neg(self, op, arglocs, regalloc):
+        l0, = arglocs
+        self.mc.LCDBR(l0, l0)
+
+    def emit_float_abs(self, op, arglocs, regalloc):
+        l0, = arglocs
+        self.mc.LPDBR(l0, l0)
+
     def emit_cast_float_to_int(self, op, arglocs, regalloc):
         f0, r0 = arglocs
-        self.mc.CGDBR(r0, f0, c.FP_CUTOFF)
+        self.mc.CGDBR(r0, c.FP_TOWARDS_ZERO, f0)
 
     def emit_cast_int_to_float(self, op, arglocs, regalloc):
         r0, f0 = arglocs
diff --git a/rpython/jit/backend/zarch/regalloc.py b/rpython/jit/backend/zarch/regalloc.py
--- a/rpython/jit/backend/zarch/regalloc.py
+++ b/rpython/jit/backend/zarch/regalloc.py
@@ -696,6 +696,9 @@
     prepare_float_gt = helper.prepare_float_cmp_op
     prepare_float_ge = helper.prepare_float_cmp_op
 
+    prepare_float_neg = helper.prepare_unary_op
+    prepare_float_abs = helper.prepare_unary_op
+
 
     prepare_cast_ptr_to_int = helper.prepare_same_as
     prepare_cast_int_to_ptr = helper.prepare_same_as
diff --git a/rpython/jit/metainterp/test/test_executor.py b/rpython/jit/metainterp/test/test_executor.py
--- a/rpython/jit/metainterp/test/test_executor.py
+++ b/rpython/jit/metainterp/test/test_executor.py
@@ -281,8 +281,8 @@
     yield (rop.FLOAT_NEG, [15.9], 'float', -15.9)
     yield (rop.FLOAT_ABS, [-5.9], 'float', 5.9)
     yield (rop.FLOAT_ABS, [15.9], 'float', 15.9)
+    yield (rop.CAST_FLOAT_TO_INT, [5.9], 'int', 5)
     yield (rop.CAST_FLOAT_TO_INT, [-5.9], 'int', -5)
-    yield (rop.CAST_FLOAT_TO_INT, [5.9], 'int', 5)
     yield (rop.CAST_INT_TO_FLOAT, [123], 'float', 123.0)
     yield (rop.CAST_INT_TO_FLOAT, [-123], 'float', -123.0)
 


More information about the pypy-commit mailing list