COS 320: Compiling Techniques, Spring 2019

Course information

Semester: Spring 2019
Lectures: Tuesday & Thursday 1:30 - 2:50pm
Location: Friend Center 008
Instructor: Zak Kincaid, zkincaid@cs.princeton.edu.
Teaching assistants: Chirag Bharadwaj and Qinshi Wang
Undergraduate graders: Benjamin Huang
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.

Date Topics Readings
Feb 5 Introduction Appel 1
Feb 7 OCaml RWO 1-9
Feb 12 X86lite Appel 6
Feb 14 Intermediate representations I (example code)
Feb 19 Intermediate representations II (example code) Appel 8
Feb 21 LLVM I (LLVMlite spec)
Feb 26 LLVM II
Feb 28 Lexing (example code) Appel 2
Mar 5 Parsing I (example code) Appel 3
Mar 7 Parsing II (example code)
Mar 12 Parsing III
Mar 14 Midterm
Mar 19,21 Spring break
Mar 26 Types I (example code)
Mar 28 Types II
Apr 2 Types III
Apr 4 Data Flow Analysis & Optimization I Appel 17
Apr 9 Cancelled
Apr 11 Data Flow Analysis & Optimization II
Apr 16 Data Flow Analysis & Optimization III
Apr 18 Register Allocation Appel 10
Apr 23 Control flow
Apr 25 Loop Optimizations Appel 18
Apr 30 First-class functions & Object-orientation Appel 14,15
May 2 Wrap-up

Assignments

To complete the assignments you will need an installation of OCaml and LLVM. The easiest way to get started is to use the COS 320 virtual machine (SHA-256: e92d7c2fd25a241bf8b43662e71b689a4841f44dee88a37b5cb30e7bb871f024). You will need to install VirtualBox to run the VM. The username and password for the machine is cos320.
If you would like to set up an OCaml dev environment on your own machine, instructions from COS 326 are available here.

Grading policies

There will be six assignments during the semester. The first assignment will be an introduction to (or refresher for) the OCaml language, which must be completed individually. For the remaining five assignments, 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
Homework 60%
Midterm Exam 20%
Final Exam 20%

Late policy

Conduct