0% found this document useful (0 votes)
267 views15 pages

3-One Pass and Multi Pass Compiler

This document discusses one pass, two pass, and multi pass compilers. A one pass compiler performs all compilation tasks in a single pass. A two pass compiler separates tasks into a front end analysis part and a back end synthesis part, requiring two passes. A multi pass compiler may have additional middle end optimization passes between the front and back ends. Passes implement phases of the compilation process, taking input and producing output representations.

Uploaded by

sherlock holmes
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)
267 views15 pages

3-One Pass and Multi Pass Compiler

This document discusses one pass, two pass, and multi pass compilers. A one pass compiler performs all compilation tasks in a single pass. A two pass compiler separates tasks into a front end analysis part and a back end synthesis part, requiring two passes. A multi pass compiler may have additional middle end optimization passes between the front and back ends. Passes implement phases of the compilation process, taking input and producing output representations.

Uploaded by

sherlock holmes
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/ 15

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Compiler Design
KCS502
by
DR PARUL YADAV

Institute of Engineering and Technology, Lucknow


Lecture 2:
ONE PASS AND MULTI PASS COMPILER
Contents
• One Pass Compiler
• Two Pass Compiler
• Multi Pass Compiler
• Phases and Passes
Single Pass Compiler
Two Pass Compiler

Front End/ Analysis Part: Back End/ Synthesis Part:


• Lexical Analyzer • Code Generator
• Syntax Analyzer • Code Optimizer
• Semantic Analyzer
Two Pass Compiler

Front End/ Analysis Part:


• Breaks the source program into constituent pieces and imposes grammatical structure
on them

• Uses this structure to create an IR of the source program

• If it detects source program as syntactically ill formed or semantically unsound, it must


provide informative messages so that the user can take the corrective action.

• Also collects information about the source program and stores it in symbol table, which
is passed along with the IR to the synthesis phase
Two Pass Compiler

Back End/ Synthesis Part:

• Constructs the desired target program from IR and the information in the symbol table
Multi Pass Compiler
Multi Pass Compiler
Multi Pass Compiler Middle End:
• Performs optimization like
 Removal of useless or
unreachable code
 Discovering and propagating
constant values
 Relocation of computation to
a less frequently executed place
(out of loop)
 specializing a computation
based on the context
• Most optimization efforts are
focused on this part.
•Enable generic optimizations to be
shared between versions of compiler
supporting different languages and
target processes
Multi Pass Compiler Back End:
• Performs more optimizations that
are for a particular computer like
 Inline expansion
 Dead code elimination
 Constant propagation
 Loop transformation etc.
• Variables are selected for the
registers
• Generates code for a particular
processor and OS
• Involves resources and storage
decisions

Optimization is optional.
Phases and Passes

Phase:

Logically cohesive operation that


takes as input one representation
and produces as output another
representation
Phases and Passes
Pass:

In an implementation of compiler
portions of one or more phases are
combined into modules, called as
Pass.

Pass reads the source program or


the output of the previous pass,
makes the transformations, writes
the output into the intermediate
file which may then be used by a
subsequent pass.
Difference between One Pass and Multi
Pass Compiler

You might also like