- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is Implementation of Three Address Code Statements?
There are three implementations used for three address code statements which are as follows −
- Indirect Triples
Quadruple is a structure that contains atmost four fields, i.e., operator, Argument 1, Argument 2, and Result.
|Operator||Argument 1||Argument 2||Result|
For a statement a = b + c, Quadruple Representation places + in the operator field, a in the Argument 1 field, b in Argument 2, and c in Result field.
For example− Consider the Statement
a = b + c * d
First, convert this statement into Three Address code
∴ Three Address code will be
t1 = c ∗ d
t2 = b + t1
a = t2.
After construction of the Three Address code, it will be changed to Quadruple representation as follows−
|Location||Operator||arg 1||arg 2||Result|
The content of fields arg 1, arg 2 and Result are pointers to symbol table entries for names represented by these entries.
This three address code representation contains three (3) fields, i.e., one for operator and two for arguments (i.e., Argument 1 and Argument 2)
|Operator||Argument 1||Argument 2|
In this representation, temporary variables are not used. Instead of temporary variables, we use a number in parenthesis to represent a pointer to that particular record of the symbol table.
For example, consider the statement
a = b + c * d
First of all, it will be converted to Three Address Code
∴ t1 = c ∗ d
t2 = b + t1
a = t2
Triple for this Three Address Code will be −
|Location||Operator||arg 1||arg 2|
Here (0) represents a pointer that refers to the result c * d, which can be used in further statements, i.e., when c * d is added with b. This result will be saved at the position pointer by (1). Pointer (1) will be used further when it is assigned to a.
The indirect triple representation uses an extra array to list the pointers to the triples in the desired order. This is known as indirect triple representation.
Indirect Triple will be
In this, it can only need to refer to a pointer (0), (1), (2)which will further refer pointers(11), (12), (13) respectively & then pointers (11), (12), (13) point to triples that is why this representation is called indirect triple representation.
- Related Articles
- What is Three Address Code?
- What is RPC Implementation?
- What is Implementation of connection less services?
- What is Implementation of LR Parsing Tables?
- What is Implementation of Syntax Directed Translators?
- What is loopback address?
- Implementation of common error-trapping logic for all SQL statements in program
- What is the Microarchitectural implementation of branch processing?
- What is the implementation of a Lexical Analyzer?
- What is Implementation of Simple Stack Allocation Scheme
- What is the CRM Implementation Plan?
- What is operating system design and implementation?
- What is Address Resolution Protocol (ARP)?
- C++ code to find three numbers whose sum is n
- What is the implementation of FX Pipelines in Computer Architecture?