COS 320: Compiling Techniques, Spring 2020

Course information

Semester: Spring 2020
Lectures: Tuesday & Thursday 1:30 - 2:50pm
Location: Friend 111
Instructor: Zak Kincaid, zkincaid@cs.princeton.edu.
Teaching assistants: Shaowei Zhu
Office hours: Links: Piazza, Real world OCaml, OCaml manual, OCaml standard library, OCaml style guide.

Description

Understand the design and construction of compilers. Concepts include syntax analysis, semantics, code generation, optimization and run-time systems. Translation of imperative languages (such as C), functional languages (such as ML), and object-oriented languages (such as Java) will be studied. Students will implement a complete compiler for a small language.

Many of the course materials and assignments have been adapted from Steve Zdancewic's CIS 341 at U Penn.

Schedule

This is a tentative schedule that may be changed during the course.
The (optional) readings are from Andrew W. Appel's Modern Compiler Implementation in ML.

Date Topics Readings
Feb 4 Introduction (OCaml slides) Appel 1
Feb 6 X86lite Appel 6
Feb 11 Intermediate representations I (example code)
Feb 13 Intermediate representations II (example code) Appel 8
Feb 18 LLVM I
Feb 20 LLVM II
Feb 25 Lexing (example code) Appel 2
Feb 27 Parsing I (example code) Appel 3
Mar 3 Parsing II (web demo, example code)
Mar 5 Parsing III (web demo)
Mar 10 Midterm review
Mar 12 Midterm
Mar 17,19 Spring break
Mar 24 Types I (example code)
Mar 26 Types II
Mar 31 Types III
Apr 2 Data Flow Analysis & Optimization I Appel 17
Apr 7 Data Flow Analysis & Optimization II (web demo)
Apr 9 Data Flow Analysis & Optimization III
Apr 14 Register Allocation Appel 10
Apr 16 Control flow (web demo)
Apr 21 Loop Optimizations Appel 18
Apr 23 High-level languages I (example code) Appel 13,14,15
Apr 28 High-level languages II
Apr 30 Wrap-up

Assignments

To complete the assignments you will need an installation of OCaml and LLVM. Instructions for installing OCaml are available here. You can download pre-built binaries for LLVM 9.0.0 here; the binaries we will be using are clang and llc.

Grading policies

There will be five assignments during the semester. You are encouraged to work in pairs. Projects that do not compile will receive no credit.

Your final grade will be weighted as follows:
Component Weight
Assignment 1 10%
Assignment 2 12%
Assignment 3 13%
Assignment 4 13%
Assignment 5 12%
Midterm Exam 20%
Final Exam 20%

Late policy

Conduct