- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
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 −
- Quadruples
- Triples
- Indirect Triples
Quadruples
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−
Quadruple
Location | Operator | arg 1 | arg 2 | Result |
---|---|---|---|---|
(0) | * | c | d | t2 |
(1) | + | b | t1 | t1 |
(2) | = | t2 | A |
The content of fields arg 1, arg 2 and Result are pointers to symbol table entries for names represented by these entries.
Triples
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 −
Triple
Location | Operator | arg 1 | arg 2 |
---|---|---|---|
(0) | ∗ | C | d |
(1) | + | B | (0) |
(2) | = | A | (1) |
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.
Indirect Triples
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?
