Three Address Code: Three address statements are a sequence of statements.
Typically,
the general form A : B op C, where A, & C are either programmer
defined names. Constants or compiler - generated temporary names. Op
stands for any operator, such as a fixed or floating -point arithmatic
operator or a logical operator on Boolean -valued data. Three address
statements usually contain three addresses, two for the operands &
one for the result.
Example : Let us consider the expression A : = -B*(C+D).
We get the following three-address code from the expression :
T1 : = -B
T2 : = C+D
T3 : = T1+T2
A : = T3
The dis-advantages of quadruples over triples - quadruples tend to cluster the symbol table with temporary names. If we use integer codes for temporaries & don't enter temporaries in the symbol table.
The advantages of quadruples over triples : A more benefits of quadruples appear in an optimizing compiler, where we often move statements around. using the quadruple 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