Design Issues of RISC                                                                                                                                   Print this page
<< Previous |  First |  Last |  Next >>       

The graph coloring problem is as follows:

Given a graph consisting of nodes and edges, assign colors to nodes such that adjacent nodes have different colors, and do this in such a way as to minimize the number of different colors.

This graph coloring problem is mapped to the register optimization problem of the compiler in the following way:

  • The program is analyzed to build a register interference graph.
  • The nodes of the graph are the symbolic registers.
  • If two symbolic registers are “live” during the same program fragment, then they are joined by an edge to indicate interference.
  • An attempt is then made to color the graph with n colors, where n is the number of register.
  • Nodes that cannot be colored are placed in memory.
  • Load and store must be used to make space for the affected quantities when they are needed.

The part 'a' of Figure 8.3 shows a program with seven symbolic registers to be compiled in three actual registers. Part ‘b' of Figure 8.3 shows the register interference graph. A possible coloring with three colors is shown. Only, a symbolic register E is left uncolored and must be dealt with load and store.

<< Previous |  First |  Last |  Next >>