[pypy-dev] Re: [LLVMdev] Re: LLVM and PyPy

Armin Rigo arigo at tunes.org
Tue Nov 4 15:10:53 CET 2003


Hello Chris,

On Sun, Nov 02, 2003 at 10:56:34AM -0600, Chris Lattner wrote:
> > driving LLVM from LLVM code is closer to our needs.  Is there a specific
> > interface to do that?
> 
> Sure, what exactly do you mean by driving LLVM code from LLVM?

Writing LLVM code that contains calls to the LLVM framework's compilation
routines.  Sorry if this is a newbie question, but are we supposed to be able
to use all the classes like ExecutionEngine from LLVM code produced by our
tools (as opposed to by the C++ front-end) ? Or would that be a real hack ?

In other words, can we write a JIT in LLVM code ? I understand this is not
what you have in mind for Java, for example, where you'd rather write the JIT
*for* but not *in* LLVM code.  In PyPy we are considering generating different 
versions of the low-level code:

The first is a regular Python interpreter (I), similar to the general design
of interpreters written in C.  It is the direct translation of the Python
source code of PyPy.

Now consider a clever meta-interpreter (M) that interprets (I) with as
argument an input user program (P) in Python.  Note that we include the user
program's runtime arguments in (P).  Using feed-back, (M) could specialize (I)
to some partial information about (P); a typical choice is the user code and
the type of the user variables, but in general it is a more dynamic part of
(P).  Now consider (M) itself and specialize it statically for its first
argument (I) for optimization.  The result is efficient low-level code that
can dynamically instrument and compile any user program (P).  This efficient
low-level code can also be written by hand; it is what I did in Psyco.  Now
that I know exactly how such code must be written it is not difficult to
actually generate it out of the regular Python source code of (I), i.e. PyPy.  
We won't actually write (M).


A bientot,

Armin.



More information about the Pypy-dev mailing list