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!
- make sure you have Python and Boost.Python installed
- extract Python.tgz (attached) into $LLVM/lib/Python
- cd $LLVM/lib/Python
- export PYTHONPATH=$PYTHONPATH:$LLVM/Debug/bin
- python fibonacci.py
More details are provided in the README.txt within Python.tgz.
Python.tgz (39.1 KB)
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?
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