Why Intermediate Representation is important???
Front end translates a program into intermediate representation.Its good to translate in IR because now we can use different back ends to convert the same code in different destination language ,so it give an ease to the construction of different compiler.Thats why every compiler programmer wants its middle phase to be intermediate representation.
hence benefits of IR are
1:Retargeting (as explained above)
2:Now we can use machine independent optimizer to optimize the produced intermediate code as the produced intermediate code is neither in source language form nor in destination language form .
figure showing intermediate code generator
kinds of IR are:
1:syntax tree
2:three address code
3:postfix
Syntax tree:
it depicts the hierarchical structure of source program
Postfix:
it is a lineralised representation of syntax tree
Three addess code:
A three address code is a sequence of statements of general form:
Z=x op y
Front end translates a program into intermediate representation.Its good to translate in IR because now we can use different back ends to convert the same code in different destination language ,so it give an ease to the construction of different compiler.Thats why every compiler programmer wants its middle phase to be intermediate representation.
hence benefits of IR are
1:Retargeting (as explained above)
2:Now we can use machine independent optimizer to optimize the produced intermediate code as the produced intermediate code is neither in source language form nor in destination language form .
figure showing intermediate code generator
kinds of IR are:
1:syntax tree
2:three address code
3:postfix
Syntax tree:
it depicts the hierarchical structure of source program
Postfix:
it is a lineralised representation of syntax tree
Three addess code:
A three address code is a sequence of statements of general form:
Z=x op y
In some books IR techniques are divided in following category
1:high level representation
2:low level representation
High level Representation is further divided into following:
1:Abstract syntax tree
2:Directed Acyclic Graph
3:P-code
Low level Representation
1:Three Address code
/* I will discuss three address code in detail in next of my posts */
No comments:
Post a Comment