[pypy-svn] r12426 - pypy/dist/pypy/translator
cfbolz at codespeak.net
cfbolz at codespeak.net
Wed May 18 02:35:27 CEST 2005
Author: cfbolz
Date: Wed May 18 02:35:27 2005
New Revision: 12426
Modified:
pypy/dist/pypy/translator/translator.py
Log:
issue50 resolved
Added llvm and llvmcompile methods to the translator.
Updated the documentation string to mention genllvm and genc.
Removed the t.pyrex from the docstring.
Modified: pypy/dist/pypy/translator/translator.py
==============================================================================
--- pypy/dist/pypy/translator/translator.py (original)
+++ pypy/dist/pypy/translator/translator.py Wed May 18 02:35:27 2005
@@ -11,8 +11,9 @@
t.view() # control flow graph
print t.source() # original source
- print t.pyrex() # pyrex translation
+ print t.c() # C translation
print t.cl() # common lisp translation
+ print t.llvm() # LLVM translation
t.simplify() # flow graph simplification
a = t.annotate([int]) # pass the list of args types
@@ -22,7 +23,9 @@
t.call(arg) # call original function
t.dis() # bytecode disassemble
- f = t.compile() # pyrex compilation
+ t.specialize() # use low level operations (for C only)
+ f = t.ccompile() # C compilation
+ f = t.llvmcompile() # LLVM compilation
assert f(arg) == t.call(arg) # sanity check
Some functions are provided for the benefit of interactive testing.
@@ -192,6 +195,17 @@
out = StringIO()
genc = GenC(out, self)
return out.getvalue()
+
+ def llvm(self):
+ """llvm(self) -> LLVM translation
+
+ Returns LLVM translation.
+ """
+ from pypy.translator.llvm import genllvm
+ if self.annotator is None:
+ raise genllvm.CompileError, "function has to be annotated."
+ gen = genllvm.LLVMGenerator(self)
+ return str(gen)
def generatecode(self, gencls, input_arg_types, func):
if input_arg_types is None:
@@ -258,6 +272,17 @@
include_dirs=[os.path.join(autopath.this_dir, 'genc')])
return getattr(mod, self.entrypoint.func_name)
+ def llvmcompile(self, optimize=True):
+ """llvmcompile(self, optimize=True) -> LLVM translation
+
+ Returns LLVM translation with or without optimization.
+ """
+ from pypy.translator.llvm import genllvm
+ if self.annotator is None:
+ raise genllvm.CompileError, "function has to be annotated."
+ gen = genllvm.LLVMGenerator(self)
+ return gen.compile(optimize)
+
def call(self, *args):
"""Calls underlying Python function."""
return self.entrypoint(*args)
More information about the Pypy-commit
mailing list