Quardruples : Quadruples representation the three - address code by using four fields
These are -
OP, ARG1, ARG2 & RESULT.
Implementation of quadruples : Let us consider the following three - address code :
T1 : = -B
T2 : = C+D
T3 : = T1+T2
A : = T3
These statement are represented by quadruples as shown in fig . (a)
SL NO | OP | ARG1 | ARG2 | RESULT |
---|---|---|---|---|
(0) | Uminus | B | - | T1 |
(1) | + | C | D | T2 |
(2) | * | T1 | T2 | T3 |
(3) | := | T3 | - | A |
Fig. (a) quadruple representation of three -address statements.
Triple : Triple representation the three address code by using three fields.
These are -
OP, ARG1, ARG2.
So, we use parenthesized number to represent pointer into the triple
structure.while symbol-table pointers are represented by names
themselves.
Implementation of quadruples : Let us consider the following three - address code :
T1 : = -B
T2 : = C+D
T3 : = T1+T2
A : = T3
These statement are represented by quadruples as shown in fig . (a)
Fig. (b) triple representation of three -address statements.
The benefits of quadruples over triples in optimizing compiler : A more benefits of quadruples appear in an optimizing compiler, where we often move statements around.
Using the quadruples notation, the symbol table interposes an extra degree of indirection between the computation of a value & its use. If we move a statement computing A, the statements using A require no change. However, in the triples notation, moving a statements that defines a temporary value requires us to change all pointers to that statements in the ARG1 & ARG2 arrays. This problem makes triples difficult to use in an optimizing compiler.
SL NO | OP | ARG1 | ARG2 |
---|---|---|---|
(0) | Uminus | B | - |
(1) | + | C | D |
(2) | * | (0) | (1) |
(3) | := | A | (2) |
Fig. (b) triple representation of three -address statements.
The benefits of quadruples over triples in optimizing compiler : A more benefits of quadruples appear in an optimizing compiler, where we often move statements around.
Using the quadruples notation, the symbol table interposes an extra degree of indirection between the computation of a value & its use. If we move a statement computing A, the statements using A require no change. However, in the triples notation, moving a statements that defines a temporary value requires us to change all pointers to that statements in the ARG1 & ARG2 arrays. This problem makes triples difficult to use in an optimizing compiler.
0 comments:
Post a Comment