2 votes 2 votes Why do we use Three Address Code generally in intermediate Code Generation phase of compiler ? Compiler Design compiler-design compilation-phases descriptive + – ankitgupta.1729 asked Nov 12, 2017 • retagged Jun 22, 2022 by Lakshman Bhaiya ankitgupta.1729 993 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes http://www.geeksforgeeks.org/intermediate-code-generation-in-compiler-design/ Please refer to this link for detailed understanding :) Namit Dhupar answered Nov 12, 2017 Namit Dhupar comment Share Follow See all 2 Comments See all 2 2 Comments reply ankitgupta.1729 commented Nov 12, 2017 reply Follow Share I am asking why only 3-address code, why not 2-address code, 4-address code?? What is the advantage of 3-Address code over other codes?? 0 votes 0 votes Namit Dhupar commented Nov 12, 2017 i edited by Namit Dhupar Nov 12, 2017 reply Follow Share Let me try to explain my best.. This is because 3 address codes like ( t1 := x + y ) they are the linear representation of all the Syntax Directed translation trees , such that we take a Var(1) and the equate(=) with... another variable V(2) [Operation] V(3) Ex = E = E + T.... (The Nomenclature of the first variable from the right production is same as the parent variable, we consider them as 2 separate operands.... there fore obviously in any kind of arithmetic operation, we use 3 variables ( 2 for operation and 1 for storage) hence Three address Codes... if you start considering a fourth address, then you must define a separate production grammar for it where this 4th address is now the 3rd address! For Example I have a sample equation E = E + T * F ( 4 address code ) Now to rewrite the following equation for parsing through a Syntax Directed tree, we must conver this in the form 1 votes 1 votes Please log in or register to add a comment.