Compiler Passes
PRESENTATION BY • SANJAY SINGH
Agenda
 Pass
 Single Pass Compiler
 Two Pass Compiler
 Multi Pass Compiler
 Comparisons
 Conclusion
Pass
• A pass refers to the traversal of a compiler through the entire program.
• Pass is a group of phases implemented together.
• Majorly, there are three types of compilers:
1. Single Pass Compilers
2. Two Pass Compilers
3. Multi Pass Compilers
Single Pass Compiler
• When we merge all the phases of compiler
design in a single module, then it is called a single
pass compiler.
• A single pass compiler runs the source code only
one time.
• In single pass Compiler source code directly
transforms into machine code.
• It is also called a "Narrow compiler. It has limited
scope
Two Pass Compiler
• A processor that runs through the program to be translated twice is
considered a two-pass compiler.
• First Pass : is refers as
 Front End
 Analytic Part
 Platform Independent
• Second Pass : is refers as
 Back End
 Synthesis Part
 Platform Dependent
Lexical Analysis
Syntax Analysis
Semantic Analysis
Intermediate Code
Generation
Code Optimization
Target Code Generation
Multi Pass Compiler
• The multi-pass compiler processes the source code
several times.
• It divided a large program into multiple small programs
and process them. It develops multiple intermediate
codes.
• All of these multi-pass take the output of the previous
phase as an input.
• It is also known as ‘Wide Compiler’. As it can scan every
portion of the program.
Comparisons
SINGLE PASS COMPILER
1. Uses more space than multi pass
compilers.
2. Faster than multi pass as there is no
reading and writing of intermediate
files.
3. Less efficient code optimization and
code generation.
4. Example – Pascal & Tiny C
MULTI PASS COMPILER
1. Uses less space than single pass
compilers.
2. Slower than single pass compiler,
due to reading and writing of
intermediate files.
3. Better code optimization and code
generation.
4. Example – Java, GCC
Conclusion
 If we want to design a compiler for different programming language for same
machine, there is requirement of making Front end/first pass for each of
them and only one Back end/second pass.
 If we want to design a compiler for same programming language for different
machine/system, we make different Back end for different Machine/system
and make only one Front end for same programming language.
Thank You

Passes of Compiler.pptx

  • 1.
  • 2.
    Agenda  Pass  SinglePass Compiler  Two Pass Compiler  Multi Pass Compiler  Comparisons  Conclusion
  • 3.
    Pass • A passrefers to the traversal of a compiler through the entire program. • Pass is a group of phases implemented together. • Majorly, there are three types of compilers: 1. Single Pass Compilers 2. Two Pass Compilers 3. Multi Pass Compilers
  • 4.
    Single Pass Compiler •When we merge all the phases of compiler design in a single module, then it is called a single pass compiler. • A single pass compiler runs the source code only one time. • In single pass Compiler source code directly transforms into machine code. • It is also called a "Narrow compiler. It has limited scope
  • 5.
    Two Pass Compiler •A processor that runs through the program to be translated twice is considered a two-pass compiler. • First Pass : is refers as  Front End  Analytic Part  Platform Independent • Second Pass : is refers as  Back End  Synthesis Part  Platform Dependent Lexical Analysis Syntax Analysis Semantic Analysis Intermediate Code Generation Code Optimization Target Code Generation
  • 6.
    Multi Pass Compiler •The multi-pass compiler processes the source code several times. • It divided a large program into multiple small programs and process them. It develops multiple intermediate codes. • All of these multi-pass take the output of the previous phase as an input. • It is also known as ‘Wide Compiler’. As it can scan every portion of the program.
  • 7.
    Comparisons SINGLE PASS COMPILER 1.Uses more space than multi pass compilers. 2. Faster than multi pass as there is no reading and writing of intermediate files. 3. Less efficient code optimization and code generation. 4. Example – Pascal & Tiny C MULTI PASS COMPILER 1. Uses less space than single pass compilers. 2. Slower than single pass compiler, due to reading and writing of intermediate files. 3. Better code optimization and code generation. 4. Example – Java, GCC
  • 8.
    Conclusion  If wewant to design a compiler for different programming language for same machine, there is requirement of making Front end/first pass for each of them and only one Back end/second pass.  If we want to design a compiler for same programming language for different machine/system, we make different Back end for different Machine/system and make only one Front end for same programming language.
  • 9.

Editor's Notes

  • #5 When the source code is processed, it is scanned and then the token is extracted. The tree structure is built after analysing the syntax in each line. The code is generated after the semantic part. This process is repeated for each and every line until the program is compiled.
  • #6 In first pass the included phases are as Lexical analyzer, syntax analyzer, semantic analyzer, intermediate code generator are work as front end and analytic part means all phases analyze the High level language and convert them three address code and first pass is platform independent because the output of first pass is as three address code which is useful for every system and the requirement is to change the code optimization and code generator phase which are comes to the second pass. In second Pass the included phases are as Code optimization and Code generator are work as back end and the synthesis part refers to taking input as three address code and convert them into Low level language/assembly language and second pass is platform dependent because final stage of a typical compiler converts the intermediate representation of program into an executable set of instructions which is dependent on the system.