Notice: For the latest information and guidance on Purdue's response to COVID-19 please visit:

Intro to Compilers: Code Generation


Credit Hours:


Learning Objective:

After completing this course, you will be able to:
  • Explain how functions work in programming languages and how to generate code for them
  • Explain the purpose of type checking and how to implement it
  • Explain basic local optimizations: common sub-expression elimination and dead code elimination
  • Explain local and global register allocation
  • Build a compiler that supports functions, type checking, and register allocation


This course covers advanced compiler topics: generating code for functions, performing type checking to avoid bugs, performing basic compiler optimizations, and performing register allocation. We will cover the theoretical basis of many of these optimizations as well as how they are implemented in compilers. Students will extend the basic compiler constructed in ECE 595.1 to add these advanced features to their compiler that translates C code into RISC-V assembly.
Fall 2021 Syllabus

Topics Covered:

Code generation
Type systems and type checking
Compiler optimization


Comfort with programming, especially data structures and recursion. Experience with object oriented programming will also be beneficial. To enroll in this course, students must have completed the first course in this series, Introduction to Compilers: Compiler Basics

Applied / Theory:

50 / 50


2 problem sets


Students will extend a C-to-RiscV compiler to support function calls, type checking, and register allocation.


1 exam


There is no required text for this class. However, students may find the book Engineering a Compiler, by Cooper and Torczon (2nd edition, Morgan Kauffman, ISBN: 978-0120884780) helpful.

Computer Requirements:

A computer that can install and run the latest versions of Java and a Git client

Other Requirements:

Students will be asked to install versions of ANTLR ( and will be required to access GitHub through a suitable Git client

ProEd Minimum Requirements: