Intermediate Code Generation Lecture Slides
Intermediate Code Generation Lecture Slides
By
Radhika B S
Intermediate Code Generation
2
Three Address Code
3
Three Address Code
4
Three Address Code
5
Three Address Code
6
Quadruples
7
Triples
8
Indirect Triples
● Indirect triples consist of a listing of pointers to triples, rather than a listing of triples themselves.
● With indirect triples, an optimizing compiler can move an instruction by reordering the
instruction list, without a affecting the triples themselves.
9
Types and Declaration
10
11
Translation of Expressions
12
Translation of Expressions
13
Incremental Translation
14
Types Checking
● To do type checking a compiler needs to assign a type expression to each component of the
source program.
● The compiler must then determine that these type expressions conform to a collection of logical
rules that is called the typesystem for the source language.
● A sound type system eliminates the need for dynamic checking for type errors, because it allows
us to determine statically that these errors cannot occur when the target program runs.
15
Rules for Types Checking
● Type synthesis builds up the type of an expression from the types of its subexpressions
● Type inference determines the type of a language construct from the way it is used.
16
Type Conversion
● A compiler may convert one of the operands of an operator to ensure both the operands are of
the same type
● Conversion is said to be explicit/casts if the programmer must write something to cause the
conversion.
17
Type Conversion
18
Type Conversion
19