Professional Documents
Culture Documents
Lecture 05
Lecture 05
Instructor:
Mr. Sheraz Babar
1
Lecture 05
2
Three-pass Compiler
Source Front IR Middle IR Back machine
code End End End code
errors
errors
errors
errors
errors
errors
errors
Typical transformations
Discover & propagate some
constant value
9
Optimizer
IR
IR Opt IR Opt IR Opt Opt IR
1 2 3 n
errors
Typical transformations
Move a computation to a less
frequently executed place
10
Optimizer
IR
IR Opt IR Opt IR Opt Opt IR
1 2 3 n
errors
Typical transformations
Specialize some computation
based on context
11
Optimizer
IR
IR Opt IR Opt IR Opt Opt IR
1 2 3 n
errors
Typical transformations
Discover a redundant
computation & remove it
12
Optimizer
IR
IR Opt IR Opt IR Opt Opt IR
1 2 3 n
errors
Typical transformations
Remove useless or
unreachable code
13
Optimizer
IR
IR Opt IR Opt IR Opt Opt IR
1 2 3 n
errors
Typical transformations
Encode an idiom in some
particularly efficient form
14
Role of Run-time System
Memory management
Allocate/deallocate
Garbage collection
Run-time type checking
Error/exception processing
Interface to OS – I/O
Support for parallelism
Parallel threads
Communication and synchronization
15
Related to Compilers
Interpreters (direct execution)
Assemblers
Preprocessors
Text formatters (non-
WYSIWYG)
Analysis tools
16
The End
17