[pypy-svn] r26859 - in pypy/dist/pypy/translator: . backendopt backendopt/test c llvm test

arigo at codespeak.net arigo at codespeak.net
Sat May 6 13:21:29 CEST 2006


Author: arigo
Date: Sat May  6 13:21:27 2006
New Revision: 26859

Modified:
   pypy/dist/pypy/translator/backendopt/all.py
   pypy/dist/pypy/translator/backendopt/test/test_propagate.py
   pypy/dist/pypy/translator/c/funcgen.py
   pypy/dist/pypy/translator/c/node.py
   pypy/dist/pypy/translator/driver.py
   pypy/dist/pypy/translator/interactive.py
   pypy/dist/pypy/translator/llvm/genllvm.py
   pypy/dist/pypy/translator/test/test_interactive.py
Log:
Don't to SSI_to_SSA() at the end of backendopt.all().  Instead, the C
back-end does it on the graph at the very last minute.  This allows the
extra code introduced by GC and exception transforms to benefit from it
too.



Modified: pypy/dist/pypy/translator/backendopt/all.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/all.py	(original)
+++ pypy/dist/pypy/translator/backendopt/all.py	Sat May  6 13:21:27 2006
@@ -2,7 +2,6 @@
 from pypy.translator.backendopt import removenoops
 from pypy.translator.backendopt.inline import auto_inlining
 from pypy.translator.backendopt.malloc import remove_simple_mallocs
-from pypy.translator.backendopt.ssa import SSI_to_SSA
 from pypy.translator.backendopt.propagate import propagate_all
 from pypy.translator.backendopt.stat import print_statistics
 from pypy.translator.backendopt.merge_if_blocks import merge_if_blocks
@@ -16,7 +15,6 @@
 def backend_optimizations(translator, raisingop2direct_call_all=False,
                                       inline_threshold=1,
                                       mallocs=True,
-                                      ssa_form=True,
                                       merge_if_blocks_to_switch=True,
                                       propagate=False,
                                       heap2stack=False,
@@ -93,8 +91,4 @@
         print "after if-to-switch:"
         print_statistics(translator.graphs[0], translator)
 
-    if ssa_form:
-        for graph in translator.graphs:
-            SSI_to_SSA(graph)
-
     translator.checkgraphs()

Modified: pypy/dist/pypy/translator/backendopt/test/test_propagate.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_propagate.py	(original)
+++ pypy/dist/pypy/translator/backendopt/test/test_propagate.py	Sat May  6 13:21:27 2006
@@ -12,7 +12,7 @@
     t.buildrtyper().specialize()
     if all_opts:
         backend_optimizations(t, inline_threshold=inline_threshold,
-                              ssa_form=False, propagate=False) 
+                              propagate=False) 
     graph = graphof(t, fn)
     if conftest.option.view:
         t.view()
@@ -234,7 +234,7 @@
     
 def test_call_list_default_argument():
     graph, t = get_graph(call_list_default_argument, [int])
-    backend_optimizations(t, propagate=True, ssa_form=False) 
+    backend_optimizations(t, propagate=True) 
     for i in range(10):
         check_graph(graph, [i], call_list_default_argument(i), t)
     if conftest.option.view:

Modified: pypy/dist/pypy/translator/c/funcgen.py
==============================================================================
--- pypy/dist/pypy/translator/c/funcgen.py	(original)
+++ pypy/dist/pypy/translator/c/funcgen.py	Sat May  6 13:21:27 2006
@@ -9,6 +9,7 @@
 from pypy.rpython.lltypesystem.lltype import UnsignedLongLong, Char, UniChar
 from pypy.rpython.lltypesystem.lltype import pyobjectptr, ContainerType
 from pypy.rpython.lltypesystem.lltype import Struct, Array, FixedSizeArray
+from pypy.translator.backendopt.ssa import SSI_to_SSA
 
 PyObjPtr = Ptr(PyObject)
 LOCALVAR = 'l_%s'
@@ -101,9 +102,10 @@
             #    for op in block.operations:
             #        op.args = tuple(op.args)
             self.db.gctransformer.inline_helpers(newgraph)
-            self.collect_var_and_types()
         else:
             self.oldgraph = self.graph
+        SSI_to_SSA(self.graph)
+        self.collect_var_and_types()
         self.blocknum = {}
         for block in self.graph.iterblocks():
             self.blocknum[block] = len(self.blocknum)

Modified: pypy/dist/pypy/translator/c/node.py
==============================================================================
--- pypy/dist/pypy/translator/c/node.py	(original)
+++ pypy/dist/pypy/translator/c/node.py	Sat May  6 13:21:27 2006
@@ -585,7 +585,10 @@
 
     def funcgen_implementation(self, funcgen):
         funcgen.implementation_begin()
-        yield '%s {' % cdecl(self.implementationtypename, funcgen.name(self.name))
+        # recompute implementationtypename as the argnames may have changed
+        argnames = funcgen.argnames()
+        implementationtypename = self.db.gettype(self.T, argnames=argnames)
+        yield '%s {' % cdecl(implementationtypename, funcgen.name(self.name))
         #
         # declare the local variables
         #

Modified: pypy/dist/pypy/translator/driver.py
==============================================================================
--- pypy/dist/pypy/translator/driver.py	(original)
+++ pypy/dist/pypy/translator/driver.py	Sat May  6 13:21:27 2006
@@ -206,7 +206,7 @@
     def task_backendopt(self):
         from pypy.translator.backendopt.all import backend_optimizations
         opt = self.options
-        backend_optimizations(self.translator, ssa_form=opt.backend != 'llvm',
+        backend_optimizations(self.translator,
                               merge_if_blocks_to_switch=opt.merge_if_blocks)
     #
     task_backendopt = taskdef(task_backendopt, 

Modified: pypy/dist/pypy/translator/interactive.py
==============================================================================
--- pypy/dist/pypy/translator/interactive.py	(original)
+++ pypy/dist/pypy/translator/interactive.py	Sat May  6 13:21:27 2006
@@ -138,7 +138,7 @@
 
     def backendopt(self, argtypes=None, **kwds):
         self.update_options(argtypes, kwds)
-        self.ensure_backend()
+        #self.ensure_backend()
         self.driver.backendopt()
 
     def backendopt_c(self, argtypes=None, **kwds):

Modified: pypy/dist/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/genllvm.py	(original)
+++ pypy/dist/pypy/translator/llvm/genllvm.py	Sat May  6 13:21:27 2006
@@ -314,9 +314,9 @@
     t.buildannotator().build_types(function, annotation)
     t.buildrtyper().specialize()
     if optimize:
-        backend_optimizations(t, ssa_form=False)
+        backend_optimizations(t)
     else:
-        backend_optimizations(t, ssa_form=False,
+        backend_optimizations(t,
                               inline_threshold=0,
                               mallocs=False,
                               merge_if_blocks_to_switch=False,

Modified: pypy/dist/pypy/translator/test/test_interactive.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_interactive.py	(original)
+++ pypy/dist/pypy/translator/test/test_interactive.py	Sat May  6 13:21:27 2006
@@ -52,7 +52,7 @@
     t.backendopt_c()
 
     t = Translation(f, [int, int])
-    py.test.raises(Exception, "t.backendopt()")
+    t.backendopt()
 
 def test_simple_source():
     def f(x, y):



More information about the Pypy-commit mailing list