Skip to content

Assignments 10 frame

Mugundan edited this page Nov 27, 2026 · 1 revision

Stage 9: Frame Lowering

Relevant source files

The following files were used as context for generating this wiki page:

Give every function a correct stack frame.

Purpose and Scope

Real emitPrologue/emitEpilogue, eliminateFrameIndex, frame pointer support, large offsets.

Read First

Tasks

  1. Prologue addi sp, sp, -N; epilogue before the first terminator.
  2. eliminateFrameIndex rewrites (FI, off) to (sp|fp, off + objectOffset + stackSize).
  3. hasFPImpl for variable-sized objects and -frame-pointer=all; save/restore r11.
  4. Offsets beyond simm16: requiresRegisterScavenging, build the address with lui/ori/add in a scavenged register.
  5. Dynamic alloca (DYNAMIC_STACKALLOC expanded).

Tests

Local array of 16 words, a 100 KB local array, a dynamic alloca, and the stage-8 spill test. Compare -stop-before=prolog-epilog and -stop-after=prolog-epilog MIR.

Done When

  • Stack stays 8-byte aligned
  • Large frame compiles
  • -frame-pointer=all works

Stretch

CFI directives (CFI) and shrink wrapping.

Next: stage 10. All Toy code and expected output on this page are illustrative, not LLVM source and not tool output; your exact output may differ.

Start here

Computer Organization & Architecture

Hexagon ISA

Operating Systems

C++ for LLVM Development

LLVM IR

SelectionDAG

Backend Assignments

Target Bring-up

Calling Conventions

Frame Lowering

MC Layer

Register Allocation

Scheduling

Clone this wiki locally