|
A while ago we wrote a binding to LLVM in Lua. Not to be confused with llvm-lua, which converts Lua bytecode to LLVM IR. Instead, this was for generating code on-the-fly, using LLVM's API for generating intermediate representation (IR). LLVM IR isn't quite assembly, but it's close; and the optimizations are admirable. It's also pretty fast to compile from the IR level. However, in the end generating code at this low level wasn't scaling well, so we shifted the project toward compiling C/C++ via the Clang front-end to LLVM. The resultant JITted code is just as fast, and it has the advantage of being able to hook into existing library code much more easily. It's currently living in the LuaAV repository but should be easy enough to lift out [1]. That said, the Clang solution isn't perfect either: the compilation time is quite a lot longer (especially parsing large template-filled C++ headers). At some point I'm planning to revisit the raw LLVM IR bindings, because the speed to compile is so much faster; I'll post results if they become clean enough to be worth looking at. BTW One major caveat with LLVM is that it is *big*. Expect many megabytes of library dependency... Graham On Jan 4, 2011, at 6:26 PM, beo wulf wrote:
|