Literature and Resources

We recommend the following course book:

  • Keith D. Cooper & Linda Torczon. Engineering a Compiler. Second Edition, Morgan Kaufmann, 2012. 

The book is available for free online, using your KTH account. See this link.

Cigrid

Cigrid is a simple subset of C/C++ designed for learning compilers. The Cigrid language is used throughout the whole course as the source language that is compiled into x86 assembler code. You can find the latest Cigrid reference manual here Download Cigrid reference manual here.

X86-64 Reference Sheet

To make it simpler to find information about the x86-64 assembly instruction set architecture, we have created a Download x86-64 reference sheet

suitable for this course. Note that this sheet only shows a subset of all instructions. The complete instruction set can be found here Links to an external site..

Development Languages and Environments

You will do a lot of coding in this course and we strongly suggest that you do your work in a language that promotes a functional style of programming. In the beginning of this course, we will give a crash course in functional programming in OCaml Links to an external site.. If you are not already fluent in any of the other languages, we strongly recommend that you do the exercises in OCaml Links to an external site..

The languages that will be supported in the automatic grading system are: OCaml Links to an external site., Haskell Links to an external site., and Rust Links to an external site.. We will also support the use of Java and C/C++, but we do not recommend that you use these languages in this course, even if it is formally allowed.

C/C++ Resources

The Cigrid language is a subset of C/C++. Hence, it is good to have basic understanding of these languages. However, you do not need to understand the object-oriented aspects of C++. Here are some relevant links: 

Unix Commands

This course assumes that you have basic understanding in using a Unix command shell. If you are unfamiliar with Unix, please take a look at this ubuntu command line tutorial Links to an external site., or the website linuxcommand.org Links to an external site.. In general, we recommend that you develop using Linux or MacOS. However, other platforms are possible to use, by executing programs using Vagrant (see below).

Vagrant

We recommend that you use Vagrant Links to an external site. when compiling and running the assignments. Vagrant is a tool that makes it possible to compile and run programs using a Linux environment, while still editing your source code files in your host operating system (e.g. MacOS, Linux, or Windows). To learn about the fundamentals of Vagrant, see this getting started guide Links to an external site.

We have prepared a specific Vagrant setup file for the course. In particular, it is important to use this setup when solving the assignments for Module 2 and 3. Please see the course webpage Vagrant, located in the left menu in Canvas.

Parsing

Assembler Resources

The focus on this course is on compiling to x86 assembler. Here are a few useful resources: