Introduction to LLVMΒΆ
(This is a very basic introduction to LLVM; for more information see llvm.org.)
LLVM is a compiler infrastructure that uses an Intermediate Representation to separate front ends and back ends; the former can produce IR from which the latter can produce target-specific binaries. In addition, the Intermediate Representation is designed to facilitate Target-Independent Optimisation, which in practice covers most optimisations such as inlining, constant propagation, common expression elimination, loop unrolling etc.
The Loci compiler is an LLVM front-end and hence generates LLVM IR, which substantially reduces the development effort for the compiler and simplifies integration with the rest of the ‘programming ecosystem’. For example, it’s possible to use clang (a C/C++/Objective-C compiler that is also an LLVM front-end) to generate LLVM IR, link this with IR generated by LOCIC, improve the resulting code using a wide range of modern optimisations and then produce x86_64 assembly code.
There are also substantial side benefits, such as LLVM’s support for generating target-specific debugging information, producing correct exception unwinding tables and verifying generated code with its relatively strong typing system.