
where t1 and t2 are compiler-generated temporary names.
The use of names for the intermediate values computed by a program allows three-address code to be rearranged easily.
Example: Three-address code is a linearized representation of a syntax
tree or a DAG in which explicit names correspond to the interior nodes of the
graph.
The DAG in Fig. 6.3 is repeated in Fig. 6.8, together with a correspond-
ing three-address code sequence.


Addresses and Instructions
Three-address code is built from two concepts: addresses and instructions. In
object-oriented terms, these concepts correspond to classes, and the various
kinds of addresses and instructions correspond to appropriate subclasses.
Alternatively, three-address code can be implemented using records with fields
for the addresses; records called quadruples and triples.
An address can be one of the following:

Instruction Type | Syntax Example | Description |
---|---|---|
Binary Assignment | x = y op z | Binary arithmetic/logical operations |
Unary Assignment | x = op y | Unary operations (negation, type cast) |
Copy | x = y | Assign value of one variable to another |
Unconditional Jump | goto L | Jumps to a labeled instruction |
Conditional Jump (Boolean) | if x goto L | Jump if condition is true |
Conditional Jump (False) | ifFalse x goto L | Jump if condition is false |
Relational Conditional Jump | if x relop y goto L | Jump if relational condition is true |
Procedure Call / Return | param x , call p, n | Used to call procedures/functions |
Indexed Copy (Array Access) | x = y[i] , x[i] = y | Access or assign array elements |
Address / Pointer Handling | x = &y , x = *y , *x = y | Pointer-based assignments |