COS 320: Compiling Techniques, Spring 2024

Course information

Semester: Spring 2024
Lectures: Tuesday & Thursday 1:30pm - 2:50pm
Location: Friend Center 008
Instructor: Zak Kincaid, zkincaid@cs.princeton.edu.
Teaching assistant: Shaowei Zhu
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 341 at U Penn.

Schedule

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

Date Topics Readings
Jan 30 Introduction (OCaml slides) Appel 1
Feb 1 X86lite Appel 6
Feb 6 Intermediate representations I (example code)
Feb 8 Intermediate representations II (example code) Appel 8
Feb 13 LLVM I
Feb 15 LLVM II
Feb 20 Lexing (example code) Appel 2
Feb 22 Parsing I (example code) Appel 3
Feb 27 Parsing II (web demo, example code)
Feb 29 Parsing III (web demo)
Mar 5 Midterm review
Mar 7 Midterm
Mar 12,14 Spring break
Mar 19 Types I (example code)
Mar 21 Types II
Mar 26 Types III
Mar 28 Data Flow Analysis & Optimization I Appel 17
Apr 2 Data Flow Analysis & Optimization II (web demo)
Apr 4 Data Flow Analysis & Optimization III
Apr 9 Register Allocation Appel 10
Apr 11 Control flow (web demo)
Apr 16 Loop Optimizations Appel 18
Apr 18 High-level languages I (example code) Appel 13,14,15
Apr 23 High-level languages II
Apr 25 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 12, 11:00pm 10%
Hw2: LLVMlite Monday February 26, 11:00pm 12%
HW3: Compiling Oat v.1 Monday March 25, 11:00pm 13%
HW4: Compiling Oat v.2 Monday April 15m, 11:00pm 13%
HW5: Dataflow Analysis and Register Allocation Tuesday May 7, 5:00pm (Dean's date) 12%
Midterm Exam Tuesday March 7 (in class) 20%
Final Exam TBD 20%

Late policy

Conduct