CS443: Compiler Construction, Fall 2022

Instructor: Stefan Muller,
Office Hours: Monday, 11:00 AM-12:00 (Zoom), Thursday 2:00-3:00 PM (SB 218E)

Lectures: Tue., Thur., 10:00-11:15 AM, Stuart Building 111
  • Section 01: In-person class
  • Section 02: Online

(see Attendance Policy for details)

Course Description     Schedule     Resources     Policies


Course Outcomes

The purpose of this course is to give the student a working knowledge of modern compiler implementation, and practical experience implementing them.

During the class, you will:

  • Learn and implement basic algorithms necessary for modern compiler writing.
  • Understand the theory and implementation of several important compiler optimizations.
  • Learn about standard compiler targets and intermediate representations, including LLVM.
  • Implement (in several phases) a compiler from a subset of a functional language (like ML or Racket) to RISC-V assembly code. In the process, you will also be able to compile a subset of a simple imperative language (like C) to RISC-V.

Prerequisites: CS440

Schedule

Note: this schedule is incomplete, tentative and subject to change.

Readings:
A = Appel
PDB = "Purple Dragon Book", Aho et al.

Topic Notes Readings
Aug. 23 Intro, Review Slides Project 0 (OCaml Basics) Out
25 Parsing Review Slides PDB 2.2, 3, 4.2, 4.3; A 2, 3.1
30 OCaml Overview
Sep. 1 Parsing Algorithms Slides PDB 2.4, 4.4-4.7; A 3.2, 3.3 Project 0 Due, Project 1 (MiniIITRAN Parser) Out
6 Ocamllex and Menhir Code PDB 4.9; A 3.4
8 LLVM Slides
13 Flattening I Slides PDB 6; A 7, 9 Project 1 Due, Project 2 (MiniIITRAN to LLVM) Out
15 Flattening II Slides
20 Flattening III Slides
22 FP and Closures Slides A 15.1-15.2 Project 2 Due, Project 3 (C to LLVM) Out
27 Closure Conversion Slides
29 Environments Slides
Oct. 4 Functional Object Representation Slides  Example
6 Liveness Analysis Slides A 10; PDB 9.2 Project 3 Due, Project 4 (MiniML to MiniC compiler) Out
11 Dataflow Analysis Slides A 17.1-17.4; PDB 9.3
13 Loop Optimizations Slides A 18; PDB 9.6
18 Static Single Assignment Slides A 19.1-19.2
20 Optimization I Slides A 17.3, 19.3; PDB 9.1 Project 4 Due
25 Midterm
27 Optimization II Project 5 (Optimization) Out
Nov. 1 Register Allocation Slides A 11.1-11.2; PDB 8.8
3 Register Allocation
8 RISC-V Slides
10 Instruction Selection Slides A 9; PDB 8.9 Project 5 Due; Project 6 (LLVM to RISC V) Out
15 Calling Conventions Slides A 11.3
17 Memory Management Slides A 13; PDB 7.4-7.7
22 Memory Management
24 Thanksgiving - No class
29 Parallelism and Concurrency Slides
Dec. 1 Compiling OO Languages Slides A 14 Project 6 Due
6 Final, 10:30-12:30

Resources

Textbook:

  • (Recommended) Modern Compiler Implementation in ML by Andrew Appel, Cambridge, 2004.
    (There are also editions in Java and C, but since we're using ML, it makes the most sense to get this one.)
  • If you already have this one from some semesters of CS440 and don't want to get another book, it'll work fine for many of the topics (definitely don't buy it if you don't have it already):
    Compilers: Principles, Techniques and Tools, Second Edition by Alfred Aho, Monica Lam, Ravi Sethi, and Jeffrey Ullman, Addison Wesley, 2006.

Other Resources:

OCaml:

LLVM:

RISC-V:

Misc:

  • Compiler Explorer - a cool tool that lets you test out how different compilers compile different languages.

Policies

Attendance/COVID

Section 01 will meet on campus. Live attendance is encouraged; the ability to hear the material and ask questions live is valuable, and while participation is not an explicit part of your grade, it may be used to "break ties." That said, attendance is not mandatory, and the occasional absence will not count against you and doesn't need to be excused. If you are in Section 01 and are consistently not able to come to lecture for some reason, discuss this with the instructor. I do not currently plan to livestream lectures, but they will be recorded.

Section 02 is an online section; you will watch the lectures online at your leisure but complete the same assignments and exams as the in-person students. For classroom capacity reasons, Section 02 students should not attend in-person without the permission of the instructor.

All of the above is, of course, subject to change depending on the rapidly changing pandemic situation and university/local/state policies. Keep a close eye on this page and your email.

Grading

Final grades will be based on the following:

50%Projects (~7, may not be evenly weighted)
20%Midterm Exam (Oct. 25)
30%Final Exam (Date TBA)

Final letter grades will be assigned at the instructor's discretion based on the difficulty of the homeworks and exams, which is difficult to predict before the semester starts. This should only help you and shouldn't be a source of stress (e.g., barring exceptional circumstances, earning 90% based on the formula above should earn you an A, but if grades were lower than expected and I feel that students with lower final grades learned the material well enough to earn As also, I'll adjust accordingly).

That said, my main grading policy is fairness: asking for a higher grade (without pointing to specific things that have been graded incorrectly) won't succeed, because that wouldn't be fair to the rest of the students.

Late Days/Late Work

Each student has 6 "late days" to use on homeworks over the course of the semester. Using a late day extends the deadline by 24 hours. You do not need to let me know you're using late days; they'll be deducted automatically when you hand in the work.

Important: No more than two late days may be used on any one assignment. Late days may not be used on exams.

After 48 hours, late work will not be accepted without the instructor's permission (and will be granted only for good reasons, e.g., medical emergencies).

For partner assignments, all partners must use late days to submit late.

If you've used up your late days, work up to 2 days late (without prior permission from the instructor) will be accepted with a penalty of 10% per day.

Exams

Section 01 students will take the midterm exam and final exam in person on campus. Section 02 students can take the exam on campus or make arrangements to take the exam remotely. Unless specified otherwise, both exams are open book and open notes.

Collaboration and Using Outside Sources

Unless specified otherwise, projects may be completed in groups of up to 2 students. If working in a group, all students must contribute roughly evenly.

Discussing general course concepts with other students (outside your group) to get a better understanding is permitted (and encouraged!). However, students may not share answers or code and all submitted work must be your own (and your partner's), with the exception that small snippets of debugging or incidental code (e.g., to load a file or pretty-print messages) may be used if appropriately cited in a comment.

For more information about what constitutes academic dishonesty and the policies we are required to follow if we discover dishonesty, please view the university's Code of Academic Honesty.

If you're ever in doubt about whether something would violate the policy, don't hesitate to contact the instructor. It's always better to ask and be sure.

Illinois Tech's Sexual Harassment and Discrimination Information

Illinois Tech prohibits all sexual harassment, sexual misconduct, and gender discrimination by any member of our community. This includes harassment among students, staff, or faculty. Sexual harassment of a student by a faculty member or sexual harassment of an employee by a supervisor is particularly serious. Such conduct may easily create an intimidating, hostile, or offensive environment.

Illinois Tech encourages anyone experiencing sexual harassment or sexual misconduct to speak with the Office of Title IX Compliance for information on support options and the resolution process.

You can report sexual harassment electronically at iit.edu/incidentreport, which may be completed anonymously. You may additionally report by contacting the Title IX Coordinator, Virginia Foster at foster@iit.edu or the Deputy Title IX Coordinator at eespeland@iit.edu.

For confidential support, you may reach Illinois Tech's Confidential Advisor at (773) 907-1062. You can also contact a licensed practitioner in Illinois Tech's Student Health and Wellness Center at student.health@iit.edu or (312)567-7550.

For a comprehensive list of resources regarding counseling services, medical assistance, legal assistance and visa and immigration services, you can visit the Office of Title IX Compliance website at https://www.iit.edu/title-ix/resources.

Disability Accommodations

Reasonable accommodations will be made for students with documented disabilities. To obtain a letter of accommodation, contact the Center for Disability Resources at https://www.iit.edu/cdr.