|
6.3.5 ArraysArray references are often translated to intermediate code with an array operator and two children. The left child is the name of the array, and the right child is the subscript expression. Thus,
as an abstract syntax tree would be
and as quadruples would be
Using the notation, the code generator would have to compute the array offset for machines which do not have an indexing addressing mode. The alternative is to expand the intermediate representation. Using "( )" to mean "contents of" and "addr" to mean "address of," the quadruples for "Temp = List[i]" would be:
Similarly, if the array reference is on the left-hand side of an assignment statement as in "List[i] = Temp", low-level quadruples would be:
Even if a machine has an indexing addressing mode, translating array references into their low-level format may allow optimizations (for example, if the array subscript were a common subexpression). Send questions and comments to: Karen Lemone |