M5: Code Generation

This fifth module we begin our transition to talking about code generation (i.e., the backend of the compiler). This module will be split into two parts:

  • Part 1 (Intermediate Representations and Procedure Abstraction) - will provide an overview of the memory layout for programs and provide an overview of the intermediate representation for the language.

  • Part 2 (Native Code Generation) - will look at implementing the necessary code for performing native code generation for our language. Specifically looking at translating canonical LLVM IR trees into ARM64 assembly code.

Pre-recorded Lectures and/or Required Readings

The pre-recorded lectures are available here: M5 Videos. You can also find the videos under the “Panopto” tab on the MPCS 51300 canvas site.

  • 5.0: Introduction to Code Generation

  • 5.1: Intermediate Representations and Control Flow

  • 5.2: Introduction to LLVM

  • 5.3: LLVM IR Instructions (Part 1)

  • 5.4: Arm Overview & Instructions

  • 5.5: Stack Register Allocation and LLVM to ARM translation

The slides/code presented in these videos are accessible in the upstream repository under the m5/resources directories. Please reach out to me if you do not have access to this repository.

Supplementary Resources

  • Engineering a Compiler readings:
    • Chapter 6.1 - 6.4

  • Engineering a Compiler readings:
    • Chapter 13.1 - 13.4

Synchronous Session (Remote)

You will find the links to the Zoom sessions on Canvas. As a reminder here are the dates and times for the synchronous session for this module:

  • No synchronous session for July 19th class. Please refer to the recorded videos above.

  • Dates/Times
    • Section 1: Wednesday July 26th @ 5:30pm-7:00pm

  • Discussion Outline
    • LLVM memory allocation

    • LLVM I/O

    • LLVM calling and branching

    • Introduction to ARM [if time permits]

  • Dates/Times
    • Section 1: Wednesday August 2nd @ 5:30pm-7:00pm

  • Discussion Outline
    • Procedure call standard ARM64

    • C runtime on ARM64

    • Writing and running a simple Arm program

    • Stack register allocation[if time permits]


Assignments are always due on Thursday evenings.