CS443: Compiler Construction, Fall 2024

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

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

(see Attendance Policy for details)

Course Description     Schedule     Assignments     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.

All readings are in Appel.

Topic Notes Readings
Aug. 20 Intro, Review Slides
22 OCaml overview Project 0 Out
27 Regular expressions and finite automata Slides Ch. 2
29 Grammars and LL Parsing Algorithms Slides Ch. 3.1-3.3 Project 0 Due
Sep. 3 LR Parsing (Video Lecture) Slides
5 No class - instructor out of town
Sep. 10 Ocamllex and Menhir Code Ch. 2.5, 3.4 Project 1 Out
12 LLVM Slides
17 Flattening I Slides Ch. 7, 9 Project 2 Out
19 Flattening II Slides Project 1 Due
24 Flattening III Slides
26 FP and Closures Slides Ch. 15.1-15.2 Project 2 Due, Project 3 Out
Oct. 1 Closure Conversion Slides Ch 15.5
3 Environments and Functional Object Representation Slides
8 Liveness Analysis Slides Ch. 10
10 Dataflow Analysis Slides Ch. 17.1-17.4 Project 3 Due
15 Midterm
17 Loop Optimizations Slides Ch. 18
22 Static Single Assignment Slides Ch. 19.1-19.2
24 Optimization I Slides Ch. 17.3, 19.3
29 Optimization II (Cont'd)
31 Register Allocation Slides Ch. 11.1-11.2
Nov. 5 Register Allocation (Cont'd)
7 RISC-V Slides
12 Instruction Selection Slides Ch. 9
14 Calling Conventions Slides Ch. 11.3
19 Memory Management Slides Ch. 13
21 Memory Management
26 Parallelism and Concurrency Slides
28 Thanksgiving - No class

Assignments

Assignment Github Link Due
Project 0 https://classroom.github.com/a/PmLB5yVX Sep. 3, 11:59 PM
Project 1 https://classroom.github.com/a/9bm9V4rl Sep. 19, 11:59 PM
Project 2 https://classroom.github.com/a/ulz9CB1z Sep. 26, 11:59 PM
Project 3 https://classroom.github.com/a/ulz9CB1z Oct. 10, 11:59 PM
Project 4 https://classroom.github.com/a/ulz9CB1z Oct. 31, 11:59 PM
Project 5 https://classroom.github.com/a/ulz9CB1z Nov. 12, 11:59 PM
Project 6 https://classroom.github.com/a/ulz9CB1z Nov. 27, 11:59 PM

Resources

Textbook:

  • (Recommended) Modern Compiler Implementation in ML by Andrew Appel, Cambridge, 2004.
    (Available on Amazon and as an ebook.)
    (There are also editions in Java and C, but since we're using ML, it makes the most sense to get this one.)
  • OCaml Programming: Correct + Efficient + Beautiful, Fall 2022 edition. (Creative Commons License)

Other Resources:

OCaml:

LLVM:

RISC-V:

Misc:

Policies

Attendance

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.

Grading

Final grades will be based on the following:

50%Projects (may not be evenly weighted)
20%Midterm Exam (Oct. 15)
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: the pair may use a late day as long as at least one partner has a positive number of late days remaining. A late day is deducted from each partner that has a positive number of late days.

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 (but need not do the same type of work).

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.

The above policy applies whether the code comes from a person (e.g., on Stack Overflow) or a generative AI tool (e.g., ChatGPT). That is, for example, you may ask ChatGPT for a small snippet of code to pretty-print an error message in OCaml, but should add a comment clearly showing what code came from ChatGPT.

Regardless of the source of the code, you are responsible for the compilation, correctness, and safety of any code you submit.

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 using the reporting form, which may be completed anonymously. You may additionally report by contacting the Title IX Coordinator, Virginia Foster at foster@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.