SlideShare a Scribd company logo
1 of 27
A compiler is a computer program (or set of 
programs) that transforms source code written 
in a programming language (the source 
language) into another computer language 
(the target language, often having a binary 
form known as object code).
Source 
code 
Optimizing 
Object 
code
The term decompiler is most commonly applied 
to a program which translates executable 
programs (the output from a compiler) into 
source code in a (relatively) high level 
language which, when compiled, will produce 
an executable whose behavior is the same as 
the original executable program
1. Lexical analysis: in a compiler linear 
analysis is called lexical analysis or scanning 
2. Preprocessor: in addition to a compiler 
several other programs may be required to 
create and executable target program. A 
source program may be divided into 
modules stored in spa rate files. The task of 
collection the source program is sometimes 
entrusted to distinct program called a 
preprocessing.
3. Parsing: hierarchical analysis is called parsing or 
syntax analysis. 
4. Semantic analysis: is the phase in which the 
compiler adds semantic information to the parse 
tree and builds the symbol table. This phase 
performs semantic checks such as type checking 
(checking for type errors), or object binding 
(associating variable and function references with 
their definitions), or definite assignment (requiring 
all local variables to be initialized before use), 
rejecting incorrect programs or issuing warnings.
5. Code generation: the final phase of the 
compiler is the generation of target code 
consisting normally of relocatable machine 
code or assembly code. 
6. Code optimization: the code optimization 
phase attempts to improve the 
intermediate code, so that faster-running 
machine code will result.
Compilers bridge source programs in high-level 
languages with the underlying hardware. 
A compiler requires : 
1) Determining the correctness of the syntax of 
programs. 
2) Generating correct and efficient object code. 
3) Run-time organization. 
4) Formatting output according to assembler and/or 
linker conventions.
The front end 
The middle 
end 
The back end
1. The front end: 
checks whether the program is correctly written 
in terms of the programming language syntax and 
semantics. Here legal and illegal programs are 
recognized. Errors are reported, if any, in a useful 
way. Type checking is also performed by collecting 
type information. The frontend then generates an 
intermediate representation or IR of the source 
code for processing by the middle-end.
2. The middle end: 
Is where optimization takes place. Typical 
transformations for optimization are removal of 
useless or unreachable code, discovery and 
propagation of constant values, relocation of 
computation to a less frequently executed place 
(e.g., out of a loop), or specialization of 
computation based on the context. The middle-end 
generates another IR for the following 
backend. Most optimization efforts are focused on 
this part.
3. The back end: 
Is responsible for translating the IR from the middle-end 
into assembly code. The target instruction(s) are 
chosen for each IR instruction. Register allocation 
assigns processor registers for the program variables 
where possible. The backend utilizes the hardware by 
figuring out how to keep parallel execution units busy, 
filling delay slots, and so on.
 One classification of compilers is by the platform 
on which their generated code executes. This is 
known as the target platform. 
 The output of a compiler that produces code for a 
virtual machine (VM) may or may not be executed 
on the same platform as the compiler that 
produced it. For this reason such compilers are not 
usually classified as native or cross compilers.
 EQN, a preprocessor for typesetting 
mathematics 
 Compilers for Pascal 
 The C compilers 
 The Fortran H compilers. 
 The Bliss/11 compiler. 
 Modula – 2 optimization compiler.
Compiler 
Passes 
Single Pass Multi Pass
A single pass compiler makes a single pass over 
the source text, parsing, analyzing, and 
generating code all at once.
let var n: 
integer; 
var c: char 
in begin 
c := ‘&’; 
n := n+1 
end 
PUSH 2 
LOADL 38 
STORE 1[SB] 
LOAD 0[SB] 
LOADL 1 
CALL add 
STORE 0[SB] 
POP 2 
Ident HALT 
N 
c 
Type 
Int 
char 
Address 
0[SB] 
1[SB]
A multi pass compiler makes several passes 
over the program. The output of a preceding 
phase is stored in a data structure and used by 
subsequent phases.
Automatic parallelization: 
The last one of which implies automation when 
used in context, refers to converting sequential 
code into multi-threaded or vectorized (or even 
both) code in order to utilize multiple 
processors simultaneously in a shared-memory 
multiprocessor (SMP) machine.
The compiler usually conducts two passes of analysis 
before actual parallelization in order to determine the 
following: 
 Is it safe to parallelize the loop? Answering this 
question needs accurate dependence analysis and 
alias analysis 
 Is it worthwhile to parallelize it? This answer 
requires a reliable estimation (modeling) of the 
program workload and the capacity of the parallel 
system.
The Fortran code below can be auto-parallelized by a 
compiler because each iteration is independent of the 
others, and the final result of array z will be correct 
regardless of the execution order of the other 
iterations. 
do i=n ,1 
z(i) = x(i) + y(i( 
enddo
On the other hand, the following code cannot be 
auto-parallelized, because the value of z(i) depends 
on the result of the previous iteration, z(i-1). 
do i=2, n 
z(i) = z(i-1)*2 
enddo
This does not mean that the code cannot be 
parallelized. Indeed, it is equivalent to 
do i=2, n 
z(i) = z(1)*2**(i-1) 
enddo
Automatic parallelization by compilers or tools is very 
difficult due to the following reasons: 
 Dependence analysis is hard for code using indirect 
addressing, pointers, recursion, and indirect 
function calls. 
 loops have an unknown number of iterations. 
 Accesses to global resources are difficult to 
coordinate in terms of memory allocation, I/O, and 
shared variables.
Due to the inherent difficulties in full automatic 
parallelization, several easier approaches exist to get 
a parallel program in higher quality. They are: 
 Allow programmers to add "hints" to their 
programs to guide compiler parallelization. 
 Build an interactive system between programmers 
and parallelizing tools/compilers. 
 Hardware-supported speculative multithreading.

More Related Content

What's hot

Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loader
babyparul
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Mir Majid
 

What's hot (20)

Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Types of Compilers
Types of CompilersTypes of Compilers
Types of Compilers
 
Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loader
 
Malware Static Analysis
Malware Static AnalysisMalware Static Analysis
Malware Static Analysis
 
Presentation On Com Dcom
Presentation On Com DcomPresentation On Com Dcom
Presentation On Com Dcom
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
 
Black box and white box testing
Black box and white box testingBlack box and white box testing
Black box and white box testing
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Risk analysis
Risk analysisRisk analysis
Risk analysis
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
Unit 8
Unit 8Unit 8
Unit 8
 
Introduction to MPI
Introduction to MPI Introduction to MPI
Introduction to MPI
 
Virus
VirusVirus
Virus
 
Basic Dynamic Analysis of Malware
Basic Dynamic Analysis of MalwareBasic Dynamic Analysis of Malware
Basic Dynamic Analysis of Malware
 
Introduction to Hacking
Introduction to HackingIntroduction to Hacking
Introduction to Hacking
 
Function Point Analysis (FPA) by Dr. B. J. Mohite
Function Point Analysis (FPA) by Dr. B. J. MohiteFunction Point Analysis (FPA) by Dr. B. J. Mohite
Function Point Analysis (FPA) by Dr. B. J. Mohite
 
9: OllyDbg
9: OllyDbg9: OllyDbg
9: OllyDbg
 
Unit 7
Unit 7Unit 7
Unit 7
 
Address Binding Scheme
Address Binding SchemeAddress Binding Scheme
Address Binding Scheme
 
Malware analysis
Malware analysisMalware analysis
Malware analysis
 

Viewers also liked (8)

Parallel concepts1
Parallel concepts1Parallel concepts1
Parallel concepts1
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
Artificial Intelligence Presentation
Artificial Intelligence PresentationArtificial Intelligence Presentation
Artificial Intelligence Presentation
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
artificial intelligence
artificial intelligenceartificial intelligence
artificial intelligence
 
Artificial inteligence
Artificial inteligenceArtificial inteligence
Artificial inteligence
 

Similar to Compiler presentaion

2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
venkatapranaykumarGa
 
Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02
Anil Thakral
 
Language translators
Language translatorsLanguage translators
Language translators
Aditya Sharat
 

Similar to Compiler presentaion (20)

Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptx
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
 
How a Compiler Works ?
How a Compiler Works ?How a Compiler Works ?
How a Compiler Works ?
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Chapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdf
 
unit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdfunit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdf
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
 
Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
 
Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)
 
Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)
 
Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02
 
Ch 1.pptx
Ch 1.pptxCh 1.pptx
Ch 1.pptx
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 
1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf
 
Language translators
Language translatorsLanguage translators
Language translators
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

Compiler presentaion

  • 1.
  • 2. A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code).
  • 4. The term decompiler is most commonly applied to a program which translates executable programs (the output from a compiler) into source code in a (relatively) high level language which, when compiled, will produce an executable whose behavior is the same as the original executable program
  • 5.
  • 6. 1. Lexical analysis: in a compiler linear analysis is called lexical analysis or scanning 2. Preprocessor: in addition to a compiler several other programs may be required to create and executable target program. A source program may be divided into modules stored in spa rate files. The task of collection the source program is sometimes entrusted to distinct program called a preprocessing.
  • 7. 3. Parsing: hierarchical analysis is called parsing or syntax analysis. 4. Semantic analysis: is the phase in which the compiler adds semantic information to the parse tree and builds the symbol table. This phase performs semantic checks such as type checking (checking for type errors), or object binding (associating variable and function references with their definitions), or definite assignment (requiring all local variables to be initialized before use), rejecting incorrect programs or issuing warnings.
  • 8. 5. Code generation: the final phase of the compiler is the generation of target code consisting normally of relocatable machine code or assembly code. 6. Code optimization: the code optimization phase attempts to improve the intermediate code, so that faster-running machine code will result.
  • 9. Compilers bridge source programs in high-level languages with the underlying hardware. A compiler requires : 1) Determining the correctness of the syntax of programs. 2) Generating correct and efficient object code. 3) Run-time organization. 4) Formatting output according to assembler and/or linker conventions.
  • 10. The front end The middle end The back end
  • 11. 1. The front end: checks whether the program is correctly written in terms of the programming language syntax and semantics. Here legal and illegal programs are recognized. Errors are reported, if any, in a useful way. Type checking is also performed by collecting type information. The frontend then generates an intermediate representation or IR of the source code for processing by the middle-end.
  • 12. 2. The middle end: Is where optimization takes place. Typical transformations for optimization are removal of useless or unreachable code, discovery and propagation of constant values, relocation of computation to a less frequently executed place (e.g., out of a loop), or specialization of computation based on the context. The middle-end generates another IR for the following backend. Most optimization efforts are focused on this part.
  • 13. 3. The back end: Is responsible for translating the IR from the middle-end into assembly code. The target instruction(s) are chosen for each IR instruction. Register allocation assigns processor registers for the program variables where possible. The backend utilizes the hardware by figuring out how to keep parallel execution units busy, filling delay slots, and so on.
  • 14.  One classification of compilers is by the platform on which their generated code executes. This is known as the target platform.  The output of a compiler that produces code for a virtual machine (VM) may or may not be executed on the same platform as the compiler that produced it. For this reason such compilers are not usually classified as native or cross compilers.
  • 15.  EQN, a preprocessor for typesetting mathematics  Compilers for Pascal  The C compilers  The Fortran H compilers.  The Bliss/11 compiler.  Modula – 2 optimization compiler.
  • 16. Compiler Passes Single Pass Multi Pass
  • 17. A single pass compiler makes a single pass over the source text, parsing, analyzing, and generating code all at once.
  • 18. let var n: integer; var c: char in begin c := ‘&’; n := n+1 end PUSH 2 LOADL 38 STORE 1[SB] LOAD 0[SB] LOADL 1 CALL add STORE 0[SB] POP 2 Ident HALT N c Type Int char Address 0[SB] 1[SB]
  • 19. A multi pass compiler makes several passes over the program. The output of a preceding phase is stored in a data structure and used by subsequent phases.
  • 20.
  • 21. Automatic parallelization: The last one of which implies automation when used in context, refers to converting sequential code into multi-threaded or vectorized (or even both) code in order to utilize multiple processors simultaneously in a shared-memory multiprocessor (SMP) machine.
  • 22. The compiler usually conducts two passes of analysis before actual parallelization in order to determine the following:  Is it safe to parallelize the loop? Answering this question needs accurate dependence analysis and alias analysis  Is it worthwhile to parallelize it? This answer requires a reliable estimation (modeling) of the program workload and the capacity of the parallel system.
  • 23. The Fortran code below can be auto-parallelized by a compiler because each iteration is independent of the others, and the final result of array z will be correct regardless of the execution order of the other iterations. do i=n ,1 z(i) = x(i) + y(i( enddo
  • 24. On the other hand, the following code cannot be auto-parallelized, because the value of z(i) depends on the result of the previous iteration, z(i-1). do i=2, n z(i) = z(i-1)*2 enddo
  • 25. This does not mean that the code cannot be parallelized. Indeed, it is equivalent to do i=2, n z(i) = z(1)*2**(i-1) enddo
  • 26. Automatic parallelization by compilers or tools is very difficult due to the following reasons:  Dependence analysis is hard for code using indirect addressing, pointers, recursion, and indirect function calls.  loops have an unknown number of iterations.  Accesses to global resources are difficult to coordinate in terms of memory allocation, I/O, and shared variables.
  • 27. Due to the inherent difficulties in full automatic parallelization, several easier approaches exist to get a parallel program in higher quality. They are:  Allow programmers to add "hints" to their programs to guide compiler parallelization.  Build an interactive system between programmers and parallelizing tools/compilers.  Hardware-supported speculative multithreading.