[pypy-svn] pypy jit-longlong: Remove OS_LLONG_NEG, and generate it as a LLONG_SUB(0, x).

arigo commits-noreply at bitbucket.org
Sun Jan 9 12:17:46 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: jit-longlong
Changeset: r40511:dbb1e8ab1794
Date: 2011-01-09 12:10 +0100
http://bitbucket.org/pypy/pypy/changeset/dbb1e8ab1794/

Log:	Remove OS_LLONG_NEG, and generate it as a LLONG_SUB(0, x).

diff --git a/pypy/jit/codewriter/test/test_longlong.py b/pypy/jit/codewriter/test/test_longlong.py
--- a/pypy/jit/codewriter/test/test_longlong.py
+++ b/pypy/jit/codewriter/test/test_longlong.py
@@ -63,9 +63,32 @@
         self.do_check('ullong_is_true', EffectInfo.OS_LLONG_IS_TRUE,
                       [lltype.SignedLongLong], lltype.Bool)
 
+    def test_llong_neg(self):
+        T = lltype.SignedLongLong
+        v = varoftype(T)
+        v_result = varoftype(T)
+        op = SpaceOperation('llong_neg', [v], v_result)
+        tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
+        oplist = tr.rewrite_operation(op)
+        assert len(oplist) == 2
+        assert oplist[0].opname == 'residual_call_irf_f'
+        assert oplist[0].args[0].value == 'llong_from_int'
+        assert oplist[0].args[1] == 'calldescr-84'
+        assert list(oplist[0].args[2]) == [const(0)]
+        assert list(oplist[0].args[3]) == []
+        assert list(oplist[0].args[4]) == []
+        v_x = oplist[0].result
+        assert isinstance(v_x, Variable)
+        assert oplist[1].opname == 'residual_call_irf_f'
+        assert oplist[1].args[0].value == 'llong_sub'
+        assert oplist[1].args[1] == 'calldescr-71'
+        assert list(oplist[1].args[2]) == []
+        assert list(oplist[1].args[3]) == []
+        assert list(oplist[1].args[4]) == [v_x, v]
+        assert oplist[1].result == v_result
+
     def test_unary_op(self):
         for opname, oopspecindex in [
-                ('llong_neg',      EffectInfo.OS_LLONG_NEG),
                 ('llong_invert',   EffectInfo.OS_LLONG_INVERT),
                 ('ullong_invert',  EffectInfo.OS_LLONG_INVERT),
                 ]:

diff --git a/pypy/jit/codewriter/support.py b/pypy/jit/codewriter/support.py
--- a/pypy/jit/codewriter/support.py
+++ b/pypy/jit/codewriter/support.py
@@ -232,10 +232,6 @@
 def _ll_1_llong_is_true(xll):
     return bool(xll)
 
-def _ll_1_llong_neg(xll):
-    y = -r_ulonglong(xll)
-    return u_to_longlong(y)
-
 def _ll_1_llong_invert(xll):
     y = ~r_ulonglong(xll)
     return u_to_longlong(y)

diff --git a/pypy/jit/codewriter/effectinfo.py b/pypy/jit/codewriter/effectinfo.py
--- a/pypy/jit/codewriter/effectinfo.py
+++ b/pypy/jit/codewriter/effectinfo.py
@@ -48,7 +48,6 @@
     OS_LIBFFI_CALL              = 62
     #
     OS_LLONG_IS_TRUE            = 67
-    OS_LLONG_NEG                = 68
     OS_LLONG_INVERT             = 69
     OS_LLONG_ADD                = 70
     OS_LLONG_SUB                = 71

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
@@ -827,7 +827,6 @@
 
     for _op, _oopspec in [('llong_is_true', 'IS_TRUE'),
                           ('ullong_is_true','IS_TRUE'),
-                          ('llong_neg',     'NEG'),
                           ('llong_invert',  'INVERT'),
                           ('ullong_invert', 'INVERT'),
                           ('llong_lt',      'LT'),
@@ -876,6 +875,11 @@
                 return oplist
         ''' % (_op, _oopspec.lower(), _oopspec)).compile()
 
+    def rewrite_op_llong_neg(self, op):
+        args = [Constant(0, lltype.SignedLongLong), op.args[0]]
+        op1 = SpaceOperation('llong_sub', args, op.result)
+        return self.rewrite_operation(op1)
+
     def rewrite_op_cast_primitive(self, op):
         fromll = self._is_longlong(op.args[0].concretetype)
         toll   = self._is_longlong(op.result.concretetype)


More information about the Pypy-commit mailing list