Operand Descriptors
- In addition to providing a mechanism for communication between
high-level code generation routines, the operand descriptor
type is an essential component of the interface between the
high and low level code-generation modules.
- The type used for operand descriptors should be flexible enough to
handle several possibilities:
- registers
- Since access to values in registers is
generally faster than access to memory, we would like the
code we generate to keep intermediate results in registers
whenever possible.
- memory locations
- Since we will eventually run out of
registers, our compiler may have to store some
intermediate results in memory. Even if this were not the
case, other factors would make it necessary/desirable to
have operand descriptors for memory locations.
- when we process an expression like
x+y
we would like
to produce something like:
rather than
move | x,D1 |
move | y,D2 |
add | D2,D1
|
- To make this possible, the routine that "generates
code" for the sub-expression "y" has to be able
to simply return a descriptor for y where it resides in
memory without producing any code.
- constants
- When processing an expression like
x+1
we would like to produce the code:
rather than
move | x,D1 |
move | #1,D2 |
add | D2,D1
|
Computer Science 434
Department of Computer Science
Williams College