Compiler Construction (Summer 2025)
General Information
- Lecturer: Prof. Dr. Peter Thiemann
- Assistants: Leonardo Mieschendahl, Marius Weidner
- Lecture: Tuesdays 14-16, R 04 007 Videokonferenz G.-Köhler-Allee 106, Livestream (Zoom Meeting-ID: 661 1930 0692, Password: nsWAD0nCW)
- Exercises: Fridays 14-16, R 04 007 Videokonferenz G.-Köhler-Allee 106, Livestream (Zoom Meeting ID: 631 6286 3480, Passcode: An1SxJdPr)
Lectures & Tutorials
Date | Type | Topic | Material | Recordings |
---|---|---|---|---|
2025-04-22 Tu | Lecture | Organization & Introduction | Book, Chapter 1; Slides | Rec |
2025-04-25 Fr | Lecture | Chapter 2 | Book, Chapter 2; Slides | Rec |
2025-04-29 Tu | Lecture | Chapter 3 | Book, Chapter 3; Slides; Code | Rec |
2025-05-02 Fr | Tutorial | Compiler for \(\mathcal{L}_{var}\) | - | Rec |
2025-05-06 Fr | Lecture | Chapter 4 | Book, Chapter 4 | Rec |
Exercises
Exercises are provided and submitted via GitHub Classroom (follow the invite link).
Exercises will not be graded, but we will provide tests to help you verify the correctness of your work. It is highly recommended to take the exercises seriously, as the exam requires you to extend the compiler from the final sample solution with new features.
Date | Deadline | Topic |
---|---|---|
2025-04-25 | 2025-05-02 | Compiler for \(\mathcal{L}_{var}\) |
Exam
The exam will take place in the computer pools and requires you to extend the compiler implemented in the exercises with new features.
Communication
For communication outside of the lecture, we provide an discord-like chat. The chat requires you to log in with your RZ-Account (same credentials as for Ilias).
Contents
Compiler construction deals with the development and implementation of translation from higher-level programming languages to machine code. This involves several important problems of general interest:
-
Semantic Analysis. A compiler transforms and analyses the tree structure of a program. This phase is specified using attribute grammars.
-
Intermediate Code. A compiler generates machine-independent intermediate code and performs several transformation and optimization steps on it.
-
Memory model and garbage collection. The compiler maps data structures to memory structures. Languages with dynamic types and/or garbage collection require special care.
-
Machine code. Intermediate code is translated to machine code, which undergoes machine-specific optimizations. This involves techniques like tree grammars, dynamic programming and graph coloring.
Compiler construction has a long tradition, so the structure of compilers has been well thought out. Therefore, a compiler can act as an example for a well-structured software system. “Who can write a compiler, can write any program”.
Knowledge about the memory model is helpful when debugging programs written in a low-level programming language (C, C++).
Literature
This lecture is based on the Python version of the book Essentials of Compilation by Jeremy G. Siek.
We will deviate from the book in several ways:
- we use the (unpublished) Python version of the book;
- we compile to the RISC-V processor architecture instead of x86; and
- we use a different Python framework for the exercises.
For this reason, we maintain our own fork of the book, which is mostly ported to use RISC-V instead of x86 instructions.
Our version of the book is available on the GitHub Releases
page. Simply download the book.pdf
file for the most recent release.
To get notified on new releases, we recommend the watch-button on the book’s GitHub repository, select Custom in the dropdown menu, and select Releases.
Additional Literature
- Andrew Appel with Jens Palsberg, Modern Compiler Implementation in Java, 2nd edition. Cambridge University Press, 2002
- Alfred V. Aho, Monica S. Lam, Ravi Sethi, and Jeffrey D. Ullman. Compilers, Principles, Techniques, and Tools (2nd Edition).. Prentice Hall, 2006.
- Andrew W. Appel. Compiling with Continuations. Cambridge University Press, 1992.
- Andrew W. Appel. Modern Compiler Implementation in ML. Cambridge University Press, 1998.
- Christopher W. Fraser and David R. Hanson. A Retargetable C Compiler: Design and Implementation. Benjamin/Cummings, 1995.
- Reinhard Wilhelm and Dieter Maurer. Übersetzerbau – Theorie, Konstruktion, Generierung – 2. Auflage. Lehrbuch. Springer-Verlag, Berlin, Heidelberg, 1996.