|Simple register allocation for assembly firstname.lastname@example.org (Falk Hueffner) (2003-01-07)|
|Re: Simple register allocation for assembly email@example.com (2003-01-12)|
|Re: Simple register allocation for assembly firstname.lastname@example.org (Christian Bau) (2003-01-17)|
|Re: Simple register allocation for assembly email@example.com (Rob Thorpe) (2003-01-17)|
|Re: Simple register allocation for assembly firstname.lastname@example.org (2003-01-25)|
|Re: Simple register allocation for assembly email@example.com (2003-01-27)|
|From:||Christian Bau <firstname.lastname@example.org>|
|Date:||17 Jan 2003 19:41:36 -0500|
|Posted-Date:||17 Jan 2003 19:41:36 EST|
email@example.com (journeyman) wrote:
> [ with respect to a simple register allocator ]
> Okay, you've striped out the hard part of of register allocation,
> which is what to do when you don't have enough registers. But, you're
> still left with a not-completely-trivial problem.
> A basic algorithm for register allocation is to compute the live range
> of the register candidates, and construct an interference graph that
> links together candidates that are live at the same time. Then you
> assign "colors" to each node. If you can color the graph using only n
> colors, you can allocate the candidates using only n registers.
> You compute the live range by propagating backwards information about
> values used, and propagating forward information about values defined.
> A candidate is live at any point in the program when it's been defined
> and will be used. This is a standard dataflow algorithm.
> Unfortunately, graph-coloring is NP-complete, so it gets expensive
> real fast as the size of your interference graph gets larger.
> Production allocators use heuristics to select the colors.
What is NP-complete is graph-coloring with the absolutely minimum
number of colors. If you don't insist on getting the best possible
solution, graph coloring is much easier. Take the next variable, try
if it can use any of the existing colors, and create a new color only
Return to the
Search the comp.compilers archives again.