Indiana University, Fall 2024
High-level programming languages like Racket and Python make it easier to program compared to low-level languages such as x86 assembly code. But how do high-level languages work? There's a big gap between them and machine instructions for modern computers. In this class you learn how to translate Racket or Python programs (your choice!) all the way to x86 assembly language.
Traditionally, compiler courses teach one phase of the compiler at a time, such as parsing, semantic analysis, and register allocation. The problem with that approach is it is difficult to understand how the whole compiler fits together and why each phase is designed the way it is. Instead, each week we implement a progressively larger subset of the input language. The very first subset is a tiny language of integer arithmetic, and by the time we are done the language includes first-class functions.
Prerequisites: Fluency in Racket or Python is highly recommended as students will do a lot of programming in one of those languages. Prior knowledge of an assembly language helps, but is not required.
Textbook: Essentials of Compilation: An Incremental Approach in Racket/Python
-
The Racket version of the textbook for the course is available at the IU bookstore and from many book sellers, links to those here. The PDF is also available for free here.
-
The Python version of the textbook for the course is available at the IU bookstore and from many book sellers, links to those here. The PDF is also available for free here.
If you have suggestions for improvement, please either send an email to Jeremy or, even better, make edits to a branch of the book and perform a pull request. The book is at the following location on github:
https://github.com/IUCompilerCourse/Essentials-of-Compilation
Lecture: Tuesdays and Thursdays 3:00-4:15pm, Informatics Building (Myles Brand Hall), Room I 107.
Office hours
- Jeremy Siek (jsiek): Mondays 2-3pm, Fridays 1-2pm, in Luddy 3014 (or nearby).
- Darshal Shetty (dcshetty): Wednesdays 1:30-2:30pm, Fridays 12:00-1:00pm, in Luddy 3014 (or nearby).
Topics:
-
Instruction Selection
-
Register Allocation
-
Static type checking
-
Conditional control flow
-
Mutable data
-
Garbage collection
-
Procedures and calling conventions
-
First-class functions and closure conversion
-
Dynamic typing
-
Generics
Grading:
Course grades are based on the following items. For the weighting, see the Canvas panel on the right-hand side of this web page. Grading will take into account any technology problems that arrise, i.e., you won't fail the class because your internet went out.
- Assignments (40%)
- Midterm Exam (25%)
- Final Exam (35%)
Assignments:
Organize into teams of 2-4 students. Assignments will be due bi-weekly on Mondays at 11:59pm. Teams that include one or more graduate students are required to complete one challenge exercise per assignment.
Assignment descriptions are posted on Canvas. Turn in your
assignments by submitting your code to the autograder. There is a
Racket and Python version of each assignment. Submit your compiler
file, either compiler.rkt
or compiler.py
depending on the language
you are using.
Assignments will be graded based on how many test cases they succeed on. Partial credit will be given for each "pass" of the compiler. Some of the tests are in the public support code (see Resources below). The testing will be done on a linux (ubuntu) machine. The testing will include both new tests and all of the tests from prior assignments.
You may request feedback on your assignments prior to the due date. Just submit your work to the autograder and send us email.
Students are responsible for understanding the entire assignment and all of the code that their team produces. The midterm and final exam are designed to test a student's understanding of the assignments.
Students are free to discuss and get help on the assignments from anyone or anywhere. When posting questions on Slack, it is OK to post your code.
In contrast, for quizzes and exams, students are asked to work alone. The quizzes and exams are closed book.
Late assignment policy: Assignments may be turned in up to one week late with a penalty of 10%.
Slack Chat/Messaging: Workspace (signup using your iu email address).
Schedule
Day | Lecture Topic | Assignment Due Aug. 27 | Introduction | Aug. 29 | From Lvar to x86 | Sep. 3 | Example Compilation from Lvar to x86 | Sep. 5 | Register Allocation, Introduction and Liveness | Sep. 10 | Register Allocation: graph coloring | Integers and Variables, submit in Racket or Python Sep. 12 | Code Review: Integers and Variables Sep. 17 | L_If language, type checking, and x86_If | Integers and Variables, late deadline Sep. 19 | Conditionals and Explicate Control Sep. 24 | Conditionals: Select Instr., Reg. Alloc., Opt. Jumps | Register Allocation, submit in Racket or Python Sep. 26 | Code Review: Register Allocation Oct. 1 | Loops and Dataflow Analysis | Register Allocation, late deadline Oct. 3 | Loops: RCO, Explicate, Challenge Oct. 8 | Tuples and Garbage Collection | Booleans and Conditionals, submit in Racket or Python Oct. 10 | Code Review: Conditionals Oct. 15 | Tuples and GC, cont'd | Booleans and Conditionals, late deadline Oct. 17 | Arrays, Structs, Generational GC Oct. 22 | Review for Midterm Exam | Loops, submit in Racket or Python Oct. 24 | Midterm Exam in class Oct. 29 | Code Review: Loops | Loops, late deadline Oct. 31 | Compiling Functions to x86 Nov. 5 | Compiling Functions, cont'd | Tuples, submit in Racket or Python Nov. 7 | Code Review: Tuples Nov. 12 | Lexically Scoped Functions | Tuples, late deadline Nov. 14 | Dynamic Typing Nov. 19 | Gradual Typing | Functions, submit in Racket or Python Nov. 21 | Code Review: Functions Nov. 22 | | Proposal for Final Project Nov. 24 - Dec. 1 | Thanksgiving Break Dec. 3 | Generics | Functions, late deadline Dec. 5 | Objects Dec. 10 | Inlining Dec. 12 | Review for Final Exam Dec. 13 | | Final Project (no late submissions). See canvas for details. Dec. 19 | Final Exam 3-5pm
Resources:
-
Practice exams:
- Midterm from 2022: Python, Python with solutions, Racket, Racket with solutions
- Final from 2022: Python, Python with solutions, Racket, Racket with solutions
- Final from 2021: Python, Python with solutions, Racket, Racket with solutions
-
Lecture videos recorded from the 2020 course.
-
Github repository for the support code and test suites
-
Uniprocessor Garbage Collection Techniques by Wilson.
-
Fast and Effective Procedure Inlining by Waddell and Dybvig.
Bias-Based Incident Reporting.
Bias-based incident reports can be made by students, faculty and staff. Any act of discrimination or harassment based on race, ethnicity, religious affiliation, gender, gender identity, sexual orientation or disability can be reported through any of the options:
-
email biasincident@indiana.edu or incident@indiana.edu;
-
call the Dean of Students Office at (812) 855-8188 or
-
use the IU mobile App (m.iu.edu). Reports can be made anonymously.
Dean on Call.
The Dean of Students office provides support for students dealing with serious or emergency situations after 5 p.m. in which an immediate response is needed and which cannot wait until the next business day. Faculty or staff who are concerned about a student’s welfare should feel free to call the Dean on Call at (812) 856-7774. This number is not to be given to students or families but is for internal campus use only. If someone is in immediate danger or experiencing an emergency, call 911.
Boost.
Indiana University has developed an award-winning smartphone app to help students stay on top of their schoolwork in Canvas. The app is called “Boost,” it is available for free to all IU students, and it integrates with Canvas to provide reminders about deadlines and other helpful notifications. For more information, see https://kb.iu.edu/d/atud.
Counseling and Psychological Services.
CAPS has expanded their services. For information about the variety of services offered to students by CAPS visit: http://healthcenter.indiana.edu/counseling/index.shtml.
Disability Services for Students (DSS).
The process to establish accommodations for a student with a disability is a responsibility shared by the student and the DSS Office. Only DSS approved accommodations should be utilized in the classroom. After the student has met with DSS, it is the student’s responsibility to share their accommodations with the faculty member. For information about support services or accommodations available to students with disabilities and for the procedures to be followed by students and instructors, please visit: https://studentaffairs.indiana.edu/disability-services-students/.
Reporting Conduct and Student Wellness Concerns.
All members of the IU community including faculty and staff may report student conduct and wellness concerns to the Division of Student Affairs using an online form located at https://studentaffairs.indiana.edu/dean-students/student-concern/index.shtml.
Students needing additional financial or other assistance.
The Student Advocates Office (SAO) can help students work through personal and academic problems as well as financial difficulties and concerns. SAO also assists students working through grade appeals and withdrawals from all classes. SAO also has emergency funds for IU students experiencing emergency financial crisis https://studentaffairs.indiana.edu/student- advocates/.
Disruptive Students.
If instructors are confronted by threatening behaviors from students their first obligation is to insure the immediate safety of the classroom. When in doubt, call IU Police at 9-911 from any campus phone or call (812) 855-4111 from off-campus for immediate or emergency situations. You may also contact the Dean of Students Office at (812) 855-8188. For additional guidance in dealing with difficult student situations: https://ufc.iu.edu/doc/policies/disruptive-students.pdf.
Academic Misconduct.
If you suspect that a student has cheated, plagiarized or otherwise committed academic misconduct, refer to the Code of Student Rights, Responsibilities and Conduct: http://studentcode.iu.edu/.
Sexual Misconduct.
As your instructor, one of my responsibilities is to create a positive learning environment for all students. Title IX and IU’s Sexual Misconduct Policy prohibit sexual misconduct in any form, including sexual harassment, sexual assault, stalking, and dating and domestic violence. If you have experienced sexual misconduct, or know someone who has, the University can help.
If you are seeking help and would like to speak to someone confidentially, you can make an appointment with:
-
The Sexual Assault Crisis Services (SACS) at (812) 855-8900 (counseling services)
-
Confidential Victim Advocates (CVA) at (812) 856-2469 (advocacy and advice services)
-
IU Health Center at (812) 855-4011 (health and medical services)
It is also important that you know that Title IX and University policy require me to share any information brought to my attention about potential sexual misconduct, with the campus Deputy Title IX Coordinator or IU’s Title IX Coordinator. In that event, those individuals will work to ensure that appropriate measures are taken and resources are made available. Protecting student privacy is of utmost concern, and information will only be shared with those that need to know to ensure the University can respond and assist. I encourage you to visit stopsexualviolence.iu.edu to learn more.