11.6.4 Register Allocation by Graph Coloring
Using data flow of uses and definitions of variables, set up
use-def chains:
Two program quantities cannot share the same register if their
use-def chains overlap.
Called Overlapping lifetimes
Algorithm
Register Allocation by Coloring
For each program quantity to be allocated to a register,
Create A Node
Draw an arc between nodes whose lifetimes overlap
Colorgraph(n)
Called an Interference Graph
If n registers, and graph can be colored with n
colors, registers can be assigned.
An NP-Complete Problem
|