Brussels / 2 & 3 February 2019


Roll your own compiler with LLVM

Easy IR generation

A close look at IR code generation inside a Modula-2 compiler.

With LLVM, one of the main tasks of an compiler engineer is to design the IR code generation from an abstract syntax tree (AST). How easy is it? Although I have worked with and on LLVM for several years now I have not yet written an compiler from scratch. So I began to work on my own compiler for an simple yet powerful language: Modula-2. In this talk I introduce the architecture of the m2lang compiler. My main focus is the generation of basic blocks and IR code from the AST. I show which general patterns emerged and which areas of the languages caused trouble. I also give hints when it is useful to introduce yet another intermediate language between the AST and the IR.


Photo of Kai Nacke Kai Nacke