Contents    Page-10    Prev    Next    Page+10    Index   

Quadruples

A quadruple is a ``mini assignment statement'' with at most one operator. X := A + B * C can be represented as:

T1 := B * C
T2 := A + T1
X := T2
        
T1 B * C
T2 A + T1
X T2

The four components of a quadruple are:

  1. Result

  2. Operand 1

  3. Operation

  4. Operand 2
This is sometimes called three-address code since each quadruple involves three variables.

Advantages:

  1. Flat: can be written to a linear file.

  2. Easy to generate (rather poor) code.

  3. Can perform peephole optimization.