[pypy-dev] Re: LLVM and PyPy

Chris Lattner sabre at nondot.org
Sun Nov 2 17:56:34 CET 2003

> > We already have the capability of doing function-at-a-time code
> > generation: what is basic-block at a time generation used for?  How do you
> > do global optimizations like register allocation?
> It is central to Psyco, the Python just-in-time specializer
> (http://psyco.sourceforge.net) whose techniques we plan to integrate with
> PyPy.  Unlike other environments like Self, which collects execution profiles

Ok, makes sense.

> > That would be great!  We've tossed around the idea of creating C bindings
> > for LLVM, which would make interfacing from other languages easier than

> Well, as the C++ API is nice and clean it is probably simpler to bind it
> directly to Python.  We would probably go for Boost-Python, which makes C++
> objects directly accessible to Python.  But nothing is sure about this; maybe

Ok, I didn't know the boost bindings allowed calling C++ code from python.
In retrospect, that makes a lot of sense.  :)

> 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?  The main
interface for executing LLVM code is the ExecutionEngine interface:

There are concrete implementations of this interface for the JIT and for
the interpreter.  Note that we will probably need to add some additional
methods to this class to enable all of the functionality that you need
(that's not a problem though :).

> Is it possible to extract from LLVM the required code
> only, and link it with the final executable?  In my experience, there are a
> few limitations of C that require explicit assembly code, like building calls
> dynamically (i.e. the caller's equivalent of varargs).

What do you mean by the "required code only"?  LLVM itself is very
modular, you only have to link the libraries in that you use.  It's also
very easy to slice and dice LLVM code from programs or functions, etc.
For example, the simple 'extract' tool rips a function out of a module
(this is typically useful only when debugging though)...



More information about the Pypy-dev mailing list