Chapter 5 - ICG
Chapter 5 - ICG
Postfix notation
The postfix notation is practical for an intermediate representation as the operands are found just before the
operator. In fact, the postfix notation is a linearized representation of a syntax tree.
Example:
1 + 2 * 3 will be represented in the postfix notation as 1 2 + 3 *
Three address code
The three-address code is a sequence of statements of the form: X
:= Y op Z
Backpatching
The main problem for generating code for control statements in a single pass is that, during one single pass,
we may not know the labels where the control must go at the time the jump statements are generated. We
can solve this problem by generating jump statements where the targets are temporarily left unspecified.
Each such statement will be put on a list of goto statements whose labels will be filled when determined.
We call this backpatching and it is widely used in three-address code generation. Backpatching is a
technique for generating code for boolean expressions and statements in one pass. The idea is to maintain
lists of incomplete jumps, where all the jump instructions on a list have the same target. When the target
becomes known, all the instructions on its list are completed by filling in the target.