0% found this document useful (0 votes)
103 views4 pages

Compiler Design Unit-1 - 3

The document discusses single pass and multi-pass compilers. A single pass compiler combines all compiler phases into a single pass through the source code, while a multi-pass compiler divides the phases into two or more passes. Multi-pass compilers are slower but more efficient and allow for better optimization. They solve issues with single pass compilers like limited context for expressions and inability to reprocess the code. The document outlines the typical phases in the first and second passes of a multi-pass compiler.

Uploaded by

sreethu7856
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views4 pages

Compiler Design Unit-1 - 3

The document discusses single pass and multi-pass compilers. A single pass compiler combines all compiler phases into a single pass through the source code, while a multi-pass compiler divides the phases into two or more passes. Multi-pass compilers are slower but more efficient and allow for better optimization. They solve issues with single pass compilers like limited context for expressions and inability to reprocess the code. The document outlines the typical phases in the first and second passes of a multi-pass compiler.

Uploaded by

sreethu7856
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

COMPILER DESIGN (KCS-502)

UNIT-1 (Lecture-3)
Example to process as code segment through phases of compiler:

RAVIKANT NIRALA Page 1


COMPILER DESIGN (KCS-502)

Compiler Design - Passes


We already know about all the Phases of Compiler design, now the Compiler Passes.
A Compiler pass refers to the traversal of a compiler through the entire program. Compiler pass
are two types: Single Pass Compiler, and Two Pass Compiler or Multi Pass Compiler.

1. Single Pass: If we combine or group all the phases of compiler design in a single module
known as single pass compiler.

In above diagram there are all 6 phases are grouped in a single module, some points of single
pass compiler is as:
1. A one pass/single pass compiler is that type of compiler that passes through the part of each
compilation unit exactly once.
2. Single pass compiler is faster and smaller than the multi pass compiler.
3. As a disadvantage of single pass compiler is that it is less efficient in comparison with
multipass compiler.
4. Single pass compiler is one that processes the input exactly once, so going directly from
lexical analysis to code generator, and then going back for the next read.

Note: Single pass compiler almost never done, early Pascal compiler did this as an introduction.

Problems with single pass compiler:


1. We can not optimize very well due to the context of expressions are limited.
2. As we can’t backup and process, it again so grammar should be limited or simplified.

RAVIKANT NIRALA Page 2


COMPILER DESIGN (KCS-502)

2. Two Pass or Multi pass: A Two pass/multi-pass Compiler is a type of compiler that
processes the source code or abstract syntax tree of a program multiple times. In multipass
Compiler we divide phases in two pass as:

1. First Pass: is refers as


(a) Front end
(b) Analytic part
(c) Platform independent
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.
2. Second Pass: is refers as
(a) Back end
(b) Synthesis Part
(c) Platform Dependent
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.

RAVIKANT NIRALA Page 3


COMPILER DESIGN (KCS
(KCS-502)

With multi-pass Compiler we can solve these 2 basic problems:


1. If we want to design a compiler for different programming language for same machine. In
this case for each programming language there is requirement of making Front end/first
pass for each of them and only one Back end/second pass as:

2. If we want to design a compiler for same programming language for different


machine/system. In this case we make different Back end for different Machine/system
and make only one Front end for same programming language as:

Differences between Single Pass and Multipass Compilers:

PARAMETERS SINGLE PASS MULTI PASS

Speed Fast Slow

Memory More Less

Time Less More

Portability No Yes

RAVIKANT NIRALA Page 4

You might also like