This topic-based on Compiler Design Subject, III B.Tech-CSE Students, Intermediate Code Generation is the 3rd module of compiler design subject, these topics totally related to the second subjective assignment of Academic Writing in Swayam online course.
1. SUBJECTIVE ASSIGNMENT – 2AW
NAME: Dr.S.Dhanalakshmi
APPLICATION NUMBER: a4131826e72b11e9994823b41d67a0f0
COURSE NAME: ACADEMIC WRITING
AFFILIATION:
Professor,
Dept of Computer Science and Engineering,
Malla Reddy Engineering College (Autonomous),
Hyderabad - 500100, Telangana, India.
2. Subject Name: Compiler Design
Branch & Sem : III B.Tech (CSE) & I Sem
Topic : Intermediate Code Generation
(Compiler Design subject contains 5 modules, this
topic belongs to 3rd module)
3. Intermediate Code Generation
• Intermediate code is the interface between front end and back
end in a compiler source language are confined to the front end
and the details of target machines to the back end
• An intermediate code form of source program is an internal
form of a program created by the compiler while translating the
program created by the compiler from a high –level language to
assembly code(or)object code(machine code).
Parser
Static
Checker
Intermediate
Code Generator
Code
Generator
Front end Back end
5. 1. SYNTAX TREE
• The parse tree itself is a useful intermediate-language representation for a
source program, especially in optimizing compilers where the
intermediate code needs to extensively restructure.
• A parse tree, however, often contains redundant information which can be
eliminated, Thus producing a more economical representation of the
source Program. One such variant of a parse tree is what is called an
(abstract) syntax tree, a tree in which each leaf represents an operand and
each interior node an operator.
Ex: a:= b*-c + b*-c
6. Graphical Representations - DAG
• A syntax tree depicts the natural hierarchical structure of
source program. A DAG (Directed Acyclic Graph) gives the
same information but in a more compact way because
common sub-expressions are identified.
• DAG is the common sub expression in the given expression is
called directed acyclic graph.
:=
+
-b
c
*
a
7. 2. Postfix Notation
• Postfix notation is a linearized representation of a
syntax tree; it is a list of the nodes of the in which a
node appears immediately after its children.
The postfix notation for the syntax tree in the fig is
• a:= b c uminus + b c uminus * + assign
9. 3.Three address code (3AC)
• In a three address code there is at most one
operator at the right side of an instruction
Example a:= b *- c + b* - c
t1 = – c
t2 = b * t1
t3 = – c
t4 = b * t3
t5 = t2 + t4
a:= t5
10. Three address codes
Implementations
• Quadruples
– Has four fields: op, arg1, arg2 and result
• Triples
– Temporaries are not used and instead references
to instructions are made
• Indirect triples
– In addition to triples we use a list of pointers to
triples
11.
12.
13. FEEDBACK
SIR/MADAM, its really very nice and interesting topics for those you are doing
research work, completed research work peoples. I think that you did a great
job sir, excellent work sir. I really think you have a super power in academic
writing. Your approach also very marvelous. Many times, I send mail to your
mailid, for the clarification related to assessment or topics, you replied that in
positive behaviour, its really appreciatable.