[llvm-dev] llvmcpy: yet another Python binding for LLVM

Alessandro Di Federico via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 12 11:44:48 PST 2017


Hi, I wrote yet another [1,2] Python binding for LLVM! I'm doing this
because llvmlite has some serious limitations: 1) it cannot parse an
existing IR, only create new modules [3], 2) it keeps its own
representation of the IR (which is less memory efficient than the LLVM
one), and 3) each llvmlite version supports a single LLVM version.

Considering that my need is to load modules of hundreds of MiB, this
is was kind of a problem.
So I've come up with a "Python API generator". Basically it uses CFFI
[4] to parse the LLVM-C API headers and automatically generate (using
some heuristics) a Pythonic API, with classes, properties and the like.

I've quickly tested it with LLVM 3.4, 3.8 and 3.9, and, for its
simplicity, does a good job. It also supports multiple LLVM
installations (it uses the one of the first llvm-config in path).

I'd be happy to have some feedback, give it a look:

https://rev.ng/llvmcpy

--
Alessandro Di Federico
PhD student at Politecnico di Milano

[1] http://www.llvmpy.org/
[2] https://github.com/numba/llvmlite
[3] https://github.com/numba/llvmlite/issues/157
[4] http://cffi.readthedocs.io/en/latest/


More information about the llvm-dev mailing list