Register Allocation

CS 432 — Bottom-up local allocation · Spills
Generated with the assistance of Claude Code (Opus 5.5)
— ← / → one action · Shift+← / → one instruction · Home / End · click a line to jump to it

Listing

Unallocated ILOC on the left, rewritten with physical registers on the right. Gold is the instruction being allocated; red lines are inserted spills and reloads; grey lines mark basic-block boundaries, where every register is free.

No traces loaded — run make regen in tracer/

Physical Registers

Name[R]: the virtual register each physical register holds. Next[R]: the line where that value is read next, or -1 from its allocation until its instruction is done. Taking the lowest-numbered free register is the reference's choice.

Spill Slots

Each spill adds a word to the current function's frame. Slot offsets are the reference's; a slot keeps its value after a reload, but nothing reads it again.

Decaf Source

The example's program.

Algorithm

Highlights

Register numbers, slot offsets, and which free register is chosen are the reference's; another correct allocator may differ.