[pypy-commit] pypy jit-codewriter-force-cast-refactor: First pass at handling conversions from longlong to some other int.

alex_gaynor noreply at buildbot.pypy.org
Sun Aug 28 00:47:17 CEST 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: jit-codewriter-force-cast-refactor
Changeset: r46834:7a27b8efd0d5
Date: 2011-08-27 18:47 -0400
http://bitbucket.org/pypy/pypy/changeset/7a27b8efd0d5/

Log:	First pass at handling conversions from longlong to some other int.

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
@@ -805,6 +805,25 @@
             assert False
 
     def _int_to_int_cast(self, v_arg, v_result):
+        longlong_arg = longlong.is_longlong(v_arg)
+        longlong_res = longlong.is_longlong(v_result)
+
+        if longlong_arg and longlong_res:
+            return
+        elif longlong_arg:
+            v = varoftype(lltype.Signed)
+            op1 = self.rewrite_operation(
+                SpaceOperation('truncate_longlong_to_int', [v_arg], v)
+            )
+            op2 = SpaceOperation('force_cast', [v], v_result)
+            oplist = self.rewrite_operation(op2)
+            if not oplist:
+                op1.result = v
+                oplist = []
+            return [op1] + oplist
+        elif longlong_res:
+            assert False
+
         size1, unsigned1 = rffi.size_and_sign(v_arg.concretetype)
         size2, unsigned2 = rffi.size_and_sign(v_result.concretetype)
         assert size1 <= rffi.sizeof(lltype.Signed)


More information about the pypy-commit mailing list