Welcome to Compiler Programming!¶
This site aims to bring together practical knowledge regarding the design and implementation of optimizing compilers and interpreters for Programming Languages.
There are a number of books on Compilers and Interpreters however only a very few of them are accompanied by source code that implements the topics covered by the book. See below for a list of useful learning projects that do include source code.
In recent years, thanks to LLVM, new programming language design has become a fertile space. New Language implementations tend to focus on the language front-end, leveraging LLVM as the back-end for code optimization and code generation. While this is beneficial if you only care about the language design aspects, it is unhelpful for the industry as a whole, because the back-end of an optimizing compiler is a very interesting component, with a rich history of algorithms and data structures, and is a subject worthy of study on its own.
We will cover both front-end and back-end techniques. We will implement a small scale language as a way to learn various techniques, see what the common challenges are and how to address them. Language design not being our goal, we will keep the language as simple as possible so that it allows us to focus on important implementation issues.
Initially we will start with a procedural language. Later we will add features such as closures from functional languages and classes and objects from OOP languages. We will also look at advanced front end techniques such as type inference and generics.
The language will be statically typed to start with because this allows us to investigate the traditional compiler optimization pipeline. Dyamically typed languages have their own interesting engineering problems. We will eventually look at gradual typing and dynamic typing.
Implementation and Discussions¶
The EeZee programming language implementation will serve as the playground for exploring various compilation techniques.
This site is maintained in github too, and is generated using Sphinx.
We have a Discussion Forum.
Preliminaries¶
Basic Front-End techniques¶
Basic Back-end techniques¶
Stack based vs register based Intermediate Representation
Control flow graphs and Basic Blocks
Bytecode VM with simple garbage collection
Basic Optimization techniques¶
Dominators and Control Flow Graph
Static Single Assignment
Data Flow Analysis, Type Lattices, Abstract Interpretation
Peephole Optimizations
Sea of Nodes Representation
Code generation and Register Allocation
Language Tools¶
Debuggers
Language IDEs
Advanced Front-end techniques¶
Type inference
Classes and objects
Closures
Exception handling
Gradual typing
Generics
Some Useful Learning Resources¶
Book Reviews¶
- Compiler Books
- Dragon Books
- Engineering a Compiler, 2nd Ed. Cooper & Torczon. 2012.
- Modern Compiler Implementation in C. Appel. 1998. (Tiger book)
- Crafting a Compiler. Fischer, LeBlanc, Cytron. 2010.
- Building an Optimizing Compiler. Bob Morgan. 1998.
- Advanced Compiler Design & Implementation. Muchnick. 1997.
- Retargetable C Compiler, A: Design and Implementation. Hanson & Fraser. 1995.
- Program Flow Analysis: Theory and Applications. Editors Muchnick, Jones. 1981.
- Other Book Reviews
Compiler Jobs¶
A listing of compiler, language and runtime teams for people looking for compiler jobs.