[pypy-svn] r74581 - in pypy/branch/blackhole-improvement/pypy/jit/codewriter: . test

arigo at codespeak.net arigo at codespeak.net
Wed May 19 17:26:35 CEST 2010


Author: arigo
Date: Wed May 19 17:26:34 2010
New Revision: 74581

Modified:
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/liveness.py
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_liveness.py
Log:
Oups.  Missing an important case.


Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/liveness.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/liveness.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/liveness.py	Wed May 19 17:26:34 2010
@@ -1,4 +1,5 @@
 from pypy.objspace.flow.model import Variable, SpaceOperation, c_last_exception
+from pypy.jit.codewriter.flatten import ListOfKind
 
 
 # Some instruction require liveness information (the ones that can end up
@@ -34,7 +35,10 @@
             if op.opname.startswith('G_'):
                 block.operations.insert(i, _livespaceop(alive))
             for v in op.args:
-                alive.add(v)
+                if isinstance(v, ListOfKind):
+                    alive.update(v)
+                else:
+                    alive.add(v)
 
 def _livespaceop(alive):
     livevars = [v for v in alive if isinstance(v, Variable)]

Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_liveness.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_liveness.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_liveness.py	Wed May 19 17:26:34 2010
@@ -1,7 +1,7 @@
 from pypy.jit.codewriter import support
 from pypy.jit.codewriter.liveness import compute_liveness
 from pypy.jit.codewriter.test.test_flatten import fake_regallocs
-from pypy.jit.codewriter.flatten import flatten_graph
+from pypy.jit.codewriter.flatten import flatten_graph, ListOfKind
 from pypy.jit.codewriter.format import assert_format
 from pypy.objspace.flow.model import SpaceOperation
 
@@ -13,10 +13,15 @@
         return self.rtyper.annotator.translator.graphs
 
     def add_G_prefix(self, graph):
-        """Add a 'G_' prefix to the opnames 'int_add' and 'int_mul'."""
+        """Add a 'G_' prefix to the opnames 'int_add' and 'int_mul'.
+        Turn the arguments of float_add into a ListOfKind()."""
         def with_prefix(op):
             if op.opname in ('int_add', 'int_mul'):
                 return SpaceOperation('G_' + op.opname, op.args, op.result)
+            if op.opname == 'float_add':
+                return SpaceOperation(op.opname,
+                                      [ListOfKind('float', op.args)],
+                                      op.result)
             return op
         #
         for block in graph.iterblocks():
@@ -134,3 +139,15 @@
             L1:
             int_return %i1
         """, switches_require_liveness=True)
+
+    def test_list_of_kind(self):
+        def f(x, y, z, t):
+            return (x + y) * (z + t)
+        self.encoding_test(f, [5, 6, 3.2, 4.3], """
+            -live- %f0, %f1
+            G_int_add %i0, %i1, %i2
+            float_add F[%f0, %f1], %f2
+            cast_int_to_float %i2, %f3
+            float_mul %f3, %f2, %f4
+            float_return %f4
+        """)



More information about the Pypy-commit mailing list