11.6.5 Register Assignment and Reassignment
Register Allocation prioritizes which variables to be kept in registers
Register Assignment (the other side) Which actual registers to use
May depend on the machine
Registers allocated and then freed
Register spill: when we remove a value
we'd really like to keep in a register, but can't
Small constants
Stored value same
Variables and expressions not "live"
Heuristics
Algorithm
Belady's Algorithm adapted for Register Allocation
If the required value is already in a register, then leave it there.
Create A Node
Else if there is an acceptable register, use it
Else use that register whose value won't be used for the longest
time (spill the value)
|