This repo contains the solutions for the Compiler Design course at ETH Zurich. In this course, we built a fully functional compiler from scratch in OCaml. We use a fictional C-like programming language called OAT as a source, LLVMlite as an intermediate representation language, and X86lite. All of these consist of simplified subsets of the languages they are named after.
Here is a non-exhaustive list of what was implemented for each assignment:
- Introduction to OCaml2.
- Simulator, Assembler, and Loader for X86lite.
- Compiler for LLVMlite to X86lite
- Lexer and Parser. Basic compiler for OAT to LLVMlite with support to basic variable types and functions.
- Typechecker for OAT. Add support for structs, function pointers, and advanced initialization and casting of variables.
- Optimizations based on Dataflow analysis. Alias analysis, dead code elimination, constant propagation, and register allocation.
Each assignment has a README explaining how to run and test them. Assignments 5 and 6 have complete compilers.