Contents    Page-10    Prev    Next    Page+10    Index   

Reusing Register Contents

Used Contents

Many instructions can be eliminated by reusing variable values that are already in registers:[We assume that there are no aliases for variables.]

  1. Initially, set the contents of each register to NULL.

  2. When a simple variable is loaded, set the contents of the register to point to its symbol table entry.

  3. When a register is requested, if possible choose an unused register that has no contents marked.

  4. When a variable is to be loaded, if it is contained in an unused register, just mark the register used. This saves a Load instruction.

  5. When a register is changed by an operation, set its contents to NULL.

  6. When a value is stored into a variable, set the contents of any register whose contents is that variable to NULL. Then mark the register from which it was stored as containing that variable.

  7. When a Label is encountered, set the contents of all registers to NULL.

  8. The condition code contents can be reused also.