COS 320: Compiling Techniques, Spring 2022

Course information

Semester: Spring 2022
Lectures: Monday & Wednesday 11:00am - 12:20pm
Location: Friend 008
Instructor: Zak Kincaid,
Teaching assistant: Nicolas Koh
Undergraduate Grader: Ruijie Fang
Office hours: Links: Canvas, Ed, Gradescope, Real world OCaml, OCaml manual, OCaml standard library, OCaml style guide.


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.


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

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


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 Weight
Assignment 1 10%
Assignment 2 12%
Assignment 3 13%
Assignment 4 13%
Assignment 5 12%
Midterm Exam 20%
Final Exam 20%

Late policy