Course syllabus

Latest news

The oral exams take place in EDIT 5452.

27 May: Students are to sign up for an oral exam time slot using this doodle poll.

3 May: Lectures 7 and 8 swapped places. The Lectures list below is up-to-date.

29 April: Troels Henriksen will visit Chalmers and will give a talk about compiler:
Where and when: EDIT Analysen; 10:00 - 11:00, Friday, 3 May 2019
Talk title: Compiler transformations for a GPU-targeting purely functional array language

24 April: I'm pleased to announce that Raphael Isemann and Alex Gerdes will give guest lectures in this course on 28 May.

22 April: Here are some interesting slides about compilers by Graydon Hoare.

3 April: The slides for Lecture 4 have been updated. There were errors in the LLVM code examples for getelementptr. The errors have been fixed and the description of getelementptr has been improved.

26 March: All students are to sign up to Fire. Those who want to work in pairs (recommended), are to create groups of two in the Fire system. Find a partner with the same level of ambition and expertise as you, and make sure you agree on the implementation language (Haskell, Java or C++) that you will use.

Course design

  • The course consists of a single project: constructing a compiler for a small Java-like programming language in groups of one to two students. Groups of two are recommended.
  • To pass this course, students must pass three assignments in the Fire system, and a short oral exam during exam week. 
  • The assignments test your ability to produce a working compiler, and determine your grade for this course. Make sure that your compiler passes the testsuite before submitting. Deadlines are strict; extensions will only be granted under exceptional circumstances, and even then only if requested before the deadline in question has passed.
  • The individual oral exam tests that all group members have been actively involved in the project and share a full understanding of the compiler. You will be asked to present your compiler to the examiner, who will then ask you some questions about it. Someone else did X, I worked on Y instead is not considered a valid answer.
  • You must hand in your final assignment before being allowed to take the oral exam. No exceptions to this rule will be considered.
  • Your grade is determined by the extensions you implement in your assignments. Your performance at the oral exam will not affect your grade other than passing or failing. 

Useful links

Lectures in EL41 at 13:15-15:00

  26 March: Introduction, project overview: new slides

  29 March: Software engineering for compilers: new slides

    2 April: LLVM: tools, language: new slides (tar.gz: code from demo)

    5 April: Code generation for LLVM: new slides (updated 3 April, tar.gz: code from demo)

    9 April: Project extensions: arrays, dynamic structures, objects: new slides​

    3 May: Code generation for x86: new slides

    7 May: Control flow graphs, data analysis: new slides​

  10 May: Functions: new slides​

  14 May: Verified compilers: new slides​

  28 May: Guest lecture: Alex's new slides​

Teachers

Main lecturer and examiner for the course: Magnus Myreen myreen@chalmers.se EDIT 5452

Teaching assistant: Oskar Abrahamsson aboskar@chalmers.se EDIT 5461

Course evaluation

Notes from last year's course evaluation meeting.

The student representatives for this course are: Johan Andersson, Oscar Hansson, Robert Krook, Magnus Linderholm Wamby, Jesper Mass, Naga Charan Meda.

Learning objectives and syllabus

The official course syllabus documents: Chalmers and GU.

In short, this course teaches students about compilers and how to develop them. The course is based around a project where participants build a compiler for a small programming language called Javalette. Javalette is an imperative language, a subset of C and of Java. The finished compiler includes a frontend (lexer, parser and type-checker) and at least one backend, generating LLVM code. Optional extensions include source language extensions and a backend targetting x86 assembly.

By completing this course, students will learn concepts and techniques such as grammars, lexers, parsers, abstract syntax, type systems, syntax-directed translation and code analysis. All of these techniques are used in state-of-the-art compilers. 

Grading

To pass the course and get grade 3 (or G, if you are a GU student), you need to:

  • submit working solutions in all submissions,
  • implement at least one language extension in submission C, and
  • pass the oral exam.

 For higher grades, you need to implement optional extensions in submission C:

  • for grade 4, you need to earn 3 credits in submission C;
  • for grade 5 (VG for GU students), you need to earn 5 credits in submission C .

Your performance at the oral exam will not affect your grade other than passing or failing. The purpose of the oral exam is to check whether the code you handed in is indeed your code.

Resources: literature, software, testsuite

Books

Software tools

Many software tools are available, in particular for front ends. We give just a few links.

Common interface to all the above: BNF Converter. Flex/Bison and Alex/Happy are installed on the Linux computers in lab rooms. If you prefer to work in Java, download JLex/CUP.

Testsuite

For your and our convenience, we provide a testsuite to help verify the correctness of your compiler, in the form of a collection of Javalette test programs and a driver program that runs your compiler on these test programs. Unpack the archive in some suitable directory and follow these instructions.

Documentation for project languages

Javalette. This language only exists as source language for the project in this course, even though it is strongly similar to subsets of C and Java. See the project description. The syntax of the base language is specified by the BNFC source file Javalette.cf. You may use this as the basis for your project. On the other hand, if you already have a BNFC file for a similar language (e.g. from the Programming Language Technology course), you might prefer that, if you have supporting code for e.g. type-checking. But you must then make sure to modify it to fit the description of Javalette.

LLVM. Downloadable software, documentation and tutorials are available at the LLVM home page. In particular, you will need to consult the LLVM Language Reference Manual and the LLVM Command Guide. The LLVM tools are available on the Studat Linux machines. The input/output routines are implemented in runtime.ll.

x86 assembly language. Two books are available for free download: Paul Carter: PC Assembly tutorial and Jonathan Bartlett: Programming from the ground up. The input/output routines are implemented for 64-but x86 in runtime.s.

Course summary:

Date Details Due