COS 320: Compiling Techniques, Spring 2026

Course information

Semester: Spring 2026
Lectures: Tuesday & Thursday 1:20pm - 2:40pm
Location: Briger Hall Room A102
Instructor: Zak Kincaid, zkincaid@cs.princeton.edu.
Teaching assistant: Vivienne Goyal
Office hours: Links: Canvas, Ed, Gradescope, 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 5521 at U Penn.

Schedule

Materials below the dotted red line have not yet been updated for Spring 2026.
The (optional) readings are from Andrew W. Appel's Modern Compiler Implementation in ML.

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

Assignments

There are five OCaml programming assignments in the course, which we recommmend you complete with a partner. Through these assignments you will gradually build a compiler for a small programming language. These assignments are time consuming so it would be wise to start early. Instructions for obtaining, completing, and submitting homework assignments can be found here.

Grading policies

There will be five assignments during the semester, along with a midterm and a final. Your final grade will be weighted as follows:
Component Date Weight
HW1: x86lite Monday February 9, 11:00pm 10%
HW2: LLVMlite Monday February 23, 11:00pm 12%
HW3: Compiling Oat v.1 Monday March 23, 11:00pm 13%
HW4: Compiling Oat v.2 Monday April 13, 11:00pm 13%
HW5: Dataflow Analysis and Register Allocation Tuesday May 5, 5:00pm (Dean's date) 12%
Midterm Exam Thursday March 5 (in class) 20%
Final Exam TBD 20%

Late policy

Conduct