Thursday, March 24, 2016

Briefly describes quadruples, triples in representation of three address statements. What ate the benefits of quadruples over triples in optimizing compiler?

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) 


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.
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SOLVE

Related Posts:

  • Define different types of translation with example  Different types of translation with example :  A translation is an input/output mapping. Generally three types of translation scheme are used - Three Address Statements Quadruples & Triples Three Ad… Read More
  • What is String(Word)? String(Word) : A string (word) is a finite sequence of symbols of that string . Example : abc, 01110 are the examples of string If You want to learn about the technology, computer science & engineering, web programmi… Read More
  • What is the way to represent 3-address code? Write down the advantage & disadvantage of quadruples over triples? 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. … Read More
  • What is Lexema?  Lexema : A lexema is a sequence of characters in the source program that is matched by the pattern for a token. Example : For Pascal statement -  Cons pi = 3.1416; Here, the sub-string pi is a lexema for the… Read More
  • What is Symbol? Symbol : A symbol is an abstract entity set we shall not define formally; just an point & line are not defined in geometry. Example :  Letter & digits are examples of symbol. If You want to learn about the t… Read More

0 comments:

Post a Comment