Contents    Page-10    Prev    Next    Page+10    Index   

Simple Register Allocation

Note that there may be several classes of registers, e.g., integer data registers, index registers, floating point registers.

A very simple register allocation algorithm is:

  1. At the beginning of a statement, mark all registers as not used.

  2. When a register is requested,
    1. If there is an unused register, mark it used and return the register number.

    2. Otherwise, punt.

On a machine with 8 or more registers, this algorithm will almost always work. However, we need to handle the case of running out of registers.