Labs ICT
โญ Pro Login

Register Allocation

Mapping variables to CPU registers

Using CPU Registers

Register allocation maps the large number of temporary variables in IR to the limited number of CPU registers. Variables that don't fit go to memory (spilling).

The Problem

Graph Coloring Approach

 R):
     Spill some variables to memory

  Example:
  t1 interferes with t2 โ†’ different registers
  t1 interferes with t3 โ†’ different registers
  t2 and t3 don't interfere โ†’ can share register

๐Ÿงช Quick Quiz

What is register allocation?