Andrey Semashev wrote:
I wouldn't say Boost.Python is a fair comparison though as it is a binding to another programming language.
The LLVM code representation is a programming language. The "LLVM Language Reference Manual" can be found at http://www.llvm.org/docs/LangRef.html. But you're right, the comparison is not perfect.
This includes integrating C++ into Python
The comparison is strong in this direction. Given a boost::python::object p, p[i] generates an Python API call to index p at i. Given a proposed boost::llvm::value object v, v[i] generates an LLVM API call to index v at i.
as well as the other way around.
It's true, the original (more limited) proposed includes nothing for this direction. If, however, the proposal is expanded along the lines several have suggested, then some features would be added. For example, the library could load LLVM code from disk, link it against dynamic code, optimize the combination (mainly to inline functions), JIT-compile it, and run the result in the host program. In fact, this usage pattern might be commonplace, since most languages come with a runtime library. (The Curry compiler I wrote does this, except it writes an executable to disk rather than JITing code).
I think your proposed library is rather incomplete. I mean, tools for building the intermediate bitcode are useful, but there has to be a way to use that bitcode somehow in terms of the library. You refer to LLVM API for that, but that immediately breaks the abstraction you've built with your library.
Yes, I agree. The library must target people who want to dynamically compile (and use!) code without learning the gory details of LLVM.
Another question I had is this. Does your library only offer generation of the intermediate bitcode or also something else?
No. I don't think anything else is needed. The bitcode can easily be converted to assembly.
Does it offer tools for traversal, analysis and transformation of the bitcode?
These tasks are the main focus of LLVM. I think anyone who wants to do these things should learn LLVM and use its API. The proposed library should focus on (easily) constructing programs dynamically, since that task seems to have been mostly neglected by the LLVM community.
Does it support reading the (high-level) code from some sort of input?
The Clang library does.
For instance, can I build a static analyzer tool for C/C++ with your library?
For that, I think you would use Clang to compile C/C++ into bitcode and then perform the static analysis using the LLVM API. LLVM is beautiful for these things. -Andy