Re:Llvmcpy – Python bindings for LLVM auto-generated from th...
by bmh100 on Friday December 16, 2016 @09:26PM
(#13198797)
Please forgive my ignorance, but how would this be useful? I am not familiar with compilers or what having bindings in Python to a compiler would help.
Re:Llvmcpy – Python bindings for LLVM auto-generated from th...
by thomaslee on Friday December 16, 2016 @09:32PM
(#13198817)
You could, for example, write a compiler in Python that generated native code (or LLVM bitcode to be passed to llc or whatever) via the LLVM API. Writing a compiler in Python vs. C/C++ would be a lot easier in a number of ways.
I'm not aware of any "production grade" compilers that do this, but no hard reason why not, I guess. Seems like it'd be nice for prototyping etc. if nothing else.
Re:Llvmcpy – Python bindings for LLVM auto-generated from th...
by aleclm on Saturday December 17, 2016 @12:56AM
(#13199492)
Final in the sense that hopefully we won't need a fourth one. It should provide the best performance (since the IR is not re-encoded in Python) and I've tried to make it flexible and future proof. llvmlite currently only supports LLVM 3.8, while I quickly tested llvmcpy with 3.4, 3.8 and 3.9 and works flawlessly.
Re:Llvmcpy – Python bindings for LLVM auto-generated from th...
by eliben on Saturday December 17, 2016 @08:30AM
(#13200630)
It looks to be a less complete solution, since it only relies on the LLVM C API which is incomplete. llvmlite digs into the C++ API as well, so while it has more work to do to keep up with changes in LLVM, it's more more feature-complete
Re:Llvmcpy – Python bindings for LLVM auto-generated from th...
by aleclm on Saturday December 17, 2016 @11:54AM
(#13201331)
The LLVM-C API is quite powerful, and I'm planning to upstream some patch to expose additional stuff.
On the other hand, llvmlite doesn't even parse existing IR, it's basically write-only. Plus, representing the IR in Python makes it less memory efficient than using the native representation.
I'm not aware of any "production grade" compilers that do this, but no hard reason why not, I guess. Seems like it'd be nice for prototyping etc. if nothing else.
http://www.llvmpy.org/
try http://llvmlite.pydata.org/en/latest/ explanation why http://llvmlite.pydata.org/en/latest/intro/index.html
LLVM is fantastic but not everyone wants or can use C++ in their project.
I've been doing prototype compilers in Haskell, but Python might also be a nice choice.
The llvmpy page mentions:
> Warning
> This project has been deprecated and is no longer being actively developed. We strongly suggest migrating to llvmlite.
http://llvmlite.pydata.org/en/latest/
aleclm has responded with the correct answer, ignore mine.
Still quite alpha, though.
Is this going to support a larger portion of the LLVM API?