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

Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compilerAbha Damani
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction Sarmad Ali
 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assemblerBansari Shah
 
Compiler Design
Compiler DesignCompiler Design
Compiler DesignMir Majid
 
Software Cost Estimation Techniques
Software Cost Estimation TechniquesSoftware Cost Estimation Techniques
Software Cost Estimation TechniquesSanthi thi
 
Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loaderbabyparul
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler ConstructionAhmed Raza
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)omercomail
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - IntroductionMuhammad Sanaullah
 
C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17manjurkts
 
Von neumann architecture
Von neumann architectureVon neumann architecture
Von neumann architectureAbdullaShakib1
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design BasicsAkhil Kaushik
 
Software Engineering Assignment
Software Engineering AssignmentSoftware Engineering Assignment
Software Engineering AssignmentSohaib Latif
 
SRS(software requirement specification)
SRS(software requirement specification)SRS(software requirement specification)
SRS(software requirement specification)Akash Kumar Dhameja
 

What's hot (20)

Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
Compiler Design Unit 1
Compiler Design Unit 1Compiler Design Unit 1
Compiler Design Unit 1
 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Compiler1
Compiler1Compiler1
Compiler1
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Software Cost Estimation Techniques
Software Cost Estimation TechniquesSoftware Cost Estimation Techniques
Software Cost Estimation Techniques
 
Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loader
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)
 
Compilers
CompilersCompilers
Compilers
 
System software-loaders
System software-loadersSystem software-loaders
System software-loaders
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - Introduction
 
C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17
 
Loaders
LoadersLoaders
Loaders
 
Von neumann architecture
Von neumann architectureVon neumann architecture
Von neumann architecture
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Software Engineering Assignment
Software Engineering AssignmentSoftware Engineering Assignment
Software Engineering Assignment
 
SRS(software requirement specification)
SRS(software requirement specification)SRS(software requirement specification)
SRS(software requirement specification)
 

Viewers also liked

Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial IntelligenceGirish Naik
 
Artificial Intelligence Presentation
Artificial Intelligence PresentationArtificial Intelligence Presentation
Artificial Intelligence Presentationlpaviglianiti
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial IntelligenceNeil Mathew
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligenceu053675
 
artificial intelligence
artificial intelligenceartificial intelligence
artificial intelligencevallibhargavi
 

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 Source Code Optimization Object Code

Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxdawod yimer
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introductionRana Ehtisham Ul Haq
 
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.pdfDrIsikoIsaac
 
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.pdfDrIsikoIsaac
 
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.docxvenkatapranaykumarGa
 
Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02Tirumala Rao
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdfAkarTaher
 
Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)guest91cc85
 
Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)guest251d9a
 
Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02Anil Thakral
 
Ch 1.pptx
Ch 1.pptxCh 1.pptx
Ch 1.pptxwoldu2
 
1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdfSemsemSameer1
 
Language translators
Language translatorsLanguage translators
Language translatorsAditya Sharat
 

Similar to Compiler Source Code Optimization Object Code (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
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
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
 

Recently uploaded

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Recently uploaded (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 

Compiler Source Code Optimization Object Code

  • 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.