Java Reference
In-Depth Information
2004] in calling this a high-level intermediate representation (HIR). For example, the Java
statement
w=x+y+z;
might be represented in HIR by
I8:I0+I1
I9:I8+I2
The I0 , I1 , and I2 refer to the instruction ids labeling instructions that compute values for
x , y and z , respectively. So the instruction labeled I8 computes the sum of the values for
x and y , and then the instruction labeled I9 sums that with the value for z to produce a
value for w . Think of this as an abstract syntax tree such as that illustrated in Figure 6.8.
The I is a type label, indicating the type is (in this case) an integer.
FIGURE 6.8 (HIR) AST for w=x+y+z .
The instruction for loading a constant is simply the constant itself. For example, consider
block B1 in Figure 6.7. It has just the single instruction
I2:1
which is to say, the temporary I2 (later, I2 will be allocated a register) is loaded with the
constant 1 . 1 is that instruction that loads the constant 1.
Not all instructions generate values. For example, the instruction
6:ifI3<=I5thenB4elseB3
in block B2 produces no value but transfers control to either B4 or B3. Of course, the 6:
has no type associated with it.
As we shall see in Section 6.3.3, HIR lends itself to various optimizations.
Static Single Assignment (SSA) Form
Our HIR employs static single assignment (SSA) form, where for every variable, there is
just one place in the method where that variable is assigned a value. This means that when
a variable is re-assigned in the method, one must create a new version for it.
For example, given the simple sequence
x=3;
x=x+y;
the second assignment to x requires that we create a new version. For example, we might
subscript our variables to distinguish different versions.
 
Search WWH ::




Custom Search