CS502: Compiler Design

Offering: Aug-Dec 2021 (Virtually over GMeet).

Communication: Primarily on Slack (Join here using your @students ID).

About the course

“I had a running compiler and nobody would touch it. … they carefully told me, computers could only do arithmetic; they could not do programs.”

- Grace Hopper 

A compiler is a fundamental software necessary to translate computer programs to a form that can be executed on intended machines. Designing a compiler involves learning several aspects of computer science: logic, formalism, mathematics, data structures, algorithms, programming, and so on. This course is intended as a primer to the various stages typical in the design of standard compilers, starting with the front-end stages of compilation, and giving a peek into the back-end and some recent advancements in the area. At the end of the course, students should be able to appreciate the underlying concepts in compiler design, and be motivated to learn the art of analyzing and transforming programs for performance.

An FAQ for the offering (accessible only to IIT Mandi students) can be found here: CS502 Fall21 FAQ.

Textbooks:

1. Alfred V. Aho, Monica Lam, Ravi Sethi and Jeffrey D. Ullman. “Compilers: Principles, Techniques, and Tools”, Second Edition, Pearson Education, 2007.
2. Andrew W. Appel. “Modern Compiler Implementation in Java”, Second Edition, Cambridge University Press, 2002.

References:

1. Keith D. Cooper and Linda Torczon. “Engineering a Compiler”, Second Edition, Morgan Kaufmann, 2011.
2. Y. N. Srikant and Priti Shankar. “The Compiler Design Handbook”, Second Edition, CRC Press, 2007.

Course structure

  • Credits: 3-0-2-4.

  • Prerequisites: CS202 (Data Structures and Algorithms) and CS304 (Formal Languages and Automata Theory). Or consent of teacher.

  • Audience: Elective for CSE and EE students.

  • Instructor: Manas Thakur.

  • TA: Aditya Anand (s20007).

  • Slot: H (Tue 11am, Thu 10am, Fri 1pm).

Outline:

1. Introduction (INT)
2. Lexical analysis (LEX)
3. Syntax analysis (SYN)
4. Semantic analysis (SEM)
5. Intermediate code generation (ICG)
6. Runtime environments (RTE)
7. Code generation and optimization (CGO)
8. Advanced topics (Interprocedural Analysis, Optimizations using Machine Learning, Just-in-time Compilation)

Schedule

// Will keep getting populated as the course progresses.

Dates Topic(s) Remarks
Aug 10, 12, 13 INT, LEX
Aug 17, 19 LEX, SYN Aug 19 is Friday schedule
Lab hours on Aug 19
Aug 24, 26, 27 SYN
Aug 31; Sep 2, 3 SYN A1 due on Sep 4
Sep 7, 9, 10 SEM Lab hours on Sep 10
Sep 14, 16, 17 SEM, ICG
Sep 21, 23, 24 ICG A2 due on Sep 24
Sep 28, 30; Oct 1 RTE Mid sem on Sep 28
Lab hours on Oct 1
Oct 5, 7, 8 CO IoR on 5
Oct 12 Doubts A3 due on Oct 18
Oct 14-19 are no-instruction days
Oct 21, 22 CO Lab hours on Oct 22
Oct 26, 28, 29 CO
Nov 2, 5 IPA, OML A4 due on Nov 6
Nov 9, 10, 11, 12 CG Nov 10 is Thursday schedule
CoR on 12
Nov 16, 18 CG, JIT Nov 16 is Friday schedule
A5 due on Nov 20
Nov 23, 24 JIT, LDT Last day of teaching on Nov 24 (Thursday schedule)
Dec 4 End sem on Dec 4

Evaluation

Theory (55%):

  • Mid sem (25)

  • End sem (30)

Practice (45%):

  • A1 (05): LEX/SYN (Helping Pooh)

  • A2 (08): SEM (Making Honey Eatable)

  • A3 (12): ICG (Honey, I Shrunk the Code)

  • A4 (13): CGO (Honey, Are You Alive?)

  • A5 (07): CGO (Honey the Pooh)