We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14
GOVT. E. RAGHVENDRA RAO P.G.
SCIENCE COLLEGE BILASPUR (C.G)
SUBJECT :- Compiler Design
TOPIC :- Quadruples, Triples, and Indirect triples for Intermediate codeure Class :- MSC CS 1th semester GUIDED BY :- SUBMITTED BY :- Mrs. Anamika Vaibhav kaushik mam Quadruples, Triples, and Indirect triples for Intermediate code What is Intermediat e code o Intermediate code is the interface between front end and back end in a compiler o Intermediate code is used to translate the source code into the machine code. Three Address code Three-address code is an intermediate code. It is used by the optimizing compilers.
Each Three address code instruction
has at most three operands. It is a combination of assignment and a binary operator. In Three address code there is at Example: X = Y most one operator on the right hand op Z side of the instruction. Three Address Code Example Given Expression (a+b) * (c+d) + (a+b+c) TAC :- Let t1 = a + b Let t2 = c + d Let t3 = t1 + c Let t4 = t1 * t2 Let t5 = t4 + t3 [The TAC desired] Implementing Three Address Code Commonly used representations for Implementing Three Address Code are :- Quadruples Representations for Triples Three Address Code
Indirect Triples Quadruples
In quadruples representation, each instruction is splitted into
the following 4 different fields- op, arg1, arg2, result Here- • The op field is used for storing the internal code of the operator. • The arg1 and arg2 fields are used for storing the two operands used. • The result field is used for storing the result of the expression. Quadruples Example Triples • The triples have three fields to implement the three address code. The field of triples contains the name of the operator, the first source operand and the second source operand. Statements can be represented by a record with only three fields: op, arg1, and arg2 Avoids the need to enter temporary names into the symbol table • In triples, the results of respective sub-expressions are denoted by the position of expression. Triple is equivalent to DAG while representing expressions. Triples Example Indirect Triples o This representation is an enhancement over triples representation. o It uses an additional instruction array to list the pointers to the triples in the desired order. o Thus, instead of position, pointers are used to store the results. o It allows the optimizers to easily re-position the sub- expression for producing the optimized code. Triples Example Reference • www.slideshare.net • Chatgpt • Youtube Thankyou