
260 An Introduction to Compiler Construction in a Java World
At the end of the linear scan allocation, all intervals have been assigned physical registers
and the LIR now looks as follows:
B0
B1
0: LDC [1] $t0
5: MOVE $a0 $t1
10: MOVE $t0 $t2
B2
15: LDC [0] $t0
20: BRANCH [ LE ] $t1 $t0 B4
B3
25: LDC [ -1] $t0
30: ADD $t1 $t0 $t3
35: MUL $t2 $t1 $t0
40: MOVE $t0 $t2
45: MOVE $t3 $t1
50: BRANCH B2
B4
55: MOVE $t2 $v0
60: RETURN $v0
Now, if no register is free to be assigned to current even for a portion of its lifetime, then
we must spill some interval to a memory location on the stack frame. We use Algorithm
7.6 [Wimmer, 2004] to select an interval for spilling