9. Code generation
Finally the front end of a compiler has to generate intermediate code.
Since we don't aim at developing a new back end for our compiler, the choice of an intermediate representation language is determined by the choice of an already available back end.
The LLVM compiler infrastructure is a collection of source code that implements static back ends for the X86, X86-64, PowerPC, PowerPC-64, ARM, Thumb, SPARC, Alpha, and IA-64 architectures.
LLVM uses a virtual instruction set that provides type safety, low-level operations and flexibility.
· assemble a LLVM program ( .ll file ) into LLVM bitcode ( .bc file )
· compile LLVM bitcode into Intel assembly language for the x86 architecture ( .s file )
· run LLVM bitcode .
The LLVM code generator for mjava is specified in mjava.cup.
In this first implementation, we have only considered non object-oriented mjava programs, such as Fact.mjava, where no class instance is created and all the methods are called internally to their declaring classes.
You can also try to compile and run the other mjava programs stored in the CodeGenerator/source directory, or to write and test your own mjava programs.