Contents
Page-10
Prev
Next
Page+10
Index
Reusing Register Contents
Many instructions can be eliminated by reusing variable values that are
already in registers:[We assume that there are no
aliases
for variables.]
- Initially, set the contents of each register to NULL.
- When a simple variable is loaded, set the contents
of the register to point to its symbol table entry.
- When a register is requested, if possible choose an unused register
that has no contents marked.
- 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.
- When a register is changed by an operation, set its contents
to NULL.
- 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.
- When a Label is encountered, set the contents of all registers
to NULL.
- The condition code contents can be reused also.