Python bindings for LLVM API

Hi,

I would like to share my experimental LLVM API Python bindings with the LLVM
enthusiasts. I have created Boost.Python wrappers largely for the VMCore
interface and other selected interfaces (e.g. ExecutionEngine). The
bindings provide direct runtime access to the LLVM bytecode and JIT
execution features from Python.

The bindings are complete enough so that one can e.g. run the Fibonacci JIT
demo in Python (see fibonacci.py in the package). Other than this, the
bindings have seen very little testing: caveat emptor!

Quick start:
- make sure you have Python and Boost.Python installed
- extract Python.tgz (attached) into $LLVM/lib/Python
- cd $LLVM/lib/Python
- make
- export PYTHONPATH=$PYTHONPATH:$LLVM/Debug/bin
- python fibonacci.py

More details are provided in the README.txt within Python.tgz.

BR, Jarno

Python.tgz (39.1 KB)

Jarno,

This looks like it could be very valuable - thanks for making it available. Just out of curiosity, do you have any specific uses in mind for which you created these bindings?

--Vikram
http://www.cs.uiuc.edu/~vadve
http://llvm.cs.uiuc.edu/

Hi,

Vikram wrote:

This looks like it could be very valuable - thanks for making it
available. Just out of curiosity, do you have any specific uses in
mind for which you created these bindings?

Well, obviously the Python interface can be used to experiment with the
JITter in Python. I was thinking that you could even write passes in Python
someday -- I had some success with hello_pass.py (also included).

As to the motivation for writing the bindings, I simply chose that as a
means to teach myself about the LLVM API and also about Boost.Python.
However, I noticed that this is no gentle learning approach since the API
must be understood quite thoroughly in order to be able to create Python
bindings that don't crash due to memory ownership problems. Fortunately
Boost.Python allows sophisticated annotation of ownership policies on a
function-by-function basis.

Cheers,
Jarno