[pypy-svn] r20556 - pypy/branch/somepbc-refactoring/pypy/translator/llvm

arigo at codespeak.net arigo at codespeak.net
Fri Dec 2 00:10:10 CET 2005


Author: arigo
Date: Fri Dec  2 00:10:09 2005
New Revision: 20556

Modified:
   pypy/branch/somepbc-refactoring/pypy/translator/llvm/genllvm.py
Log:
(pedronis, arigo)

Fixed a bit the interface in genllvm -- we need to pass
an entry point.  It would be nice if the back-ends could
converge to some common base interface :-/



Modified: pypy/branch/somepbc-refactoring/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/translator/llvm/genllvm.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/translator/llvm/genllvm.py	Fri Dec  2 00:10:09 2005
@@ -15,7 +15,6 @@
 from pypy.translator.llvm.externs2ll import setup_externs, generate_llfile
 from pypy.translator.llvm.gc import GcPolicy
 from pypy.translator.llvm.exception import ExceptionPolicy
-from pypy.translator.translator import Translator
 from pypy.translator.llvm.log import log
 
 class GenLLVM(object):
@@ -270,12 +269,13 @@
         for s in stats:
             log('STATS %s' % str(s))
 
-def genllvm(translator, gcpolicy=None, exceptionpolicy=None, standalone=False,
+def genllvm(translator, entry_point, gcpolicy=None,
+            exceptionpolicy=None, standalone=False,
             log_source=False, logging=False, **kwds):
 
     gen = GenLLVM(translator, gcpolicy, exceptionpolicy,
                   standalone, logging=logging)
-    filename = gen.gen_llvm_source()
+    filename = gen.gen_llvm_source(entry_point)
 
     if log_source:
         log(open(filename).read())
@@ -283,16 +283,17 @@
     return gen.compile_llvm_source(**kwds)
 
 def genllvm_compile(function, annotation, view=False, **kwds):
-    t = Translator(function)
-    a = t.annotate(annotation)
-    a.simplify()
-    t.specialize()
-    t.backend_optimizations(ssa_form=False)
+    from pypy.translator.translator import TranslationContext
+    from pypy.translator.backendopt.all import backend_optimizations
+    t = TranslationContext()
+    t.buildannotator().build_types(function, annotation)
+    t.buildrtyper().specialize()
+    backend_optimizations(t, ssa_form=False)
     
     # note: this is without policy transforms
     if view:
         t.view()
-    return genllvm(t, **kwds)
+    return genllvm(t, function, **kwds)
 
 def compile_function(function, annotation, **kwds):
     """ Helper - which get the compiled module from CPython. """



More information about the Pypy-commit mailing list