SlideShare uma empresa Scribd logo
1 de 44
  Course Goals  •  To provide students with an understanding of the  major phases of a compiler.  •  To introduce students to the theory behind the various  phases, including regular expressions, context-free grammars, and finite state automata.  •  To provide students with an understanding of the design and implementation of a compiler.  •  To have the students build a compiler, through type checking and intermediate code generation, for a small language.  •  To provide students with an opportunity to work in a group  on a large project.
  Course Outcomes •  Students will have experience using current compiler generation tools.  •  Students will be familiar with the different phases of compilation.  •  Students will have experience defining and specifying the semantic rules of a programming language
  Prerequisites •  In-depth knowledge of at least one structured programming language.  •  Strong background in algorithms, data structures, and abstract data types, including stacks, binary trees, graphs.  •  Understanding of grammar theories.  •  Understanding of data types and control structures, their design and implementation.  •  Understanding of the design and implementation of subprograms, parameter passing mechanisms, scope.
Major Topics Covered in the Course ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
  Textbook Compilers: Principles, Techniques, and Tools” by Aho, Lam, Sethi, and Ullman, 2 nd  edition.
GRADING Assignements & project:  40 Midterm Exam:  20 Final Exam:  40
Compilers and Interpreters ,[object Object],[object Object],Compiler Error messages Source Program Target Program Input Output
Compilers and Interpreters (cont’d) ,[object Object],[object Object],Interpreter Source Program Input Output Error messages
The Analysis-Synthesis Model of Compilation ,[object Object],[object Object],[object Object]
Preprocessors, Compilers, Assemblers, and Linkers Preprocessor Compiler Assembler Linker Skeletal Source Program Source Program Target Assembly Program Relocatable Object Code Absolute Machine Code Libraries and Relocatable Object Files Try for example: gcc -v myprog.c
The Phases of a Compiler Phase Output Sample Programmer (source code producer) Source string A=B+C; Scanner  (performs  lexical analysis ) Token string ‘ A’ ,  ‘=’ ,  ‘B’ ,  ‘+’ ,  ‘C’ ,  ‘;’ And  symbol table  with names Parser  (performs  syntax analysis  based on the grammar of the programming language) Parse tree or abstract syntax tree ;   |   =  / A  +   /   B  C Semantic analyzer  (type checking,  etc) Annotated parse tree or abstract syntax tree Intermediate code generator Three-address code, quads, or RTL int2fp B  t1 +  t1  C  t2 :=  t2  A Optimizer Three-address code, quads, or RTL int2fp B  t1 +  t1  #2.3  A Code generator Assembly code MOVF  #2.3,r1 ADDF2 r1,r2 MOVF  r2,A Peephole optimizer Assembly code ADDF2 #2.3,r2 MOVF  r2,A
The Grouping of Phases ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Compiler-Construction Tools ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What qualities do you want in a  that compiler you buy  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
High-level View of a Compiler  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Source code Machine code Compiler Errors
Traditional Two-pass Compiler ,[object Object],[object Object],[object Object],[object Object],Source code Front End Errors   Machine code Back End IR
The Front End ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Source code Scanner IR Parser Errors   tokens
The Front End ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Source code Scanner IR Parser Errors   tokens
The Front End ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Source code Scanner IR Parser Errors   tokens
The Front End ,[object Object],[object Object],[object Object],The  AST  summarizes grammatical structure, without including detail about the derivation  + - < id, x > < number, 2 > < id, y >
The Back End Responsibilities Translate IR into target machine code Choose instructions to implement each IR operation Decide which value to keep in registers Ensure conformance with system interfaces Automation has been  much less  successful in the back end Errors   IR Instruction Scheduling Instruction Selection Machine code Register Allocation IR IR
The Back End ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Errors   IR Instruction Scheduling Instruction Selection Machine code Register Allocation IR IR
The Back End ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Errors   IR Instruction Scheduling Instruction Selection Machine code Register Allocation IR IR
The Back End ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Errors   IR Instruction Scheduling Instruction Selection Machine code Register Allocation IR IR
Traditional Three-pass Compiler ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Errors   Source Code Middle End Front End Machine code Back End IR IR
The Optimizer (or Middle End) Modern optimizers are structured as a series of passes Typical Transformations Discover & propagate some constant value Move a computation to a less frequently executed place Discover a redundant computation & remove it Remove useless or unreachable co de Errors   O p t 1 O p t 3 O p t 2 O p t n ... IR IR IR IR IR
The Big Picture ,[object Object],[object Object],[object Object],[object Object],[object Object],Scanner Scanner Generator specifications source code parts of speech tables or code
Lexical Analysis ,[object Object],[object Object],[object Object]
Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Specifying Lexical Patterns  (micro-syntax) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Specifying Lexical Patterns  (micro-syntax)
Regular Expressions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Precedence  is  closure , then  concatenation , then  alternation Ever type  “ rm *.o a.out” ?
Set Operations  (refresher) You need to know these definitions
Examples of Regular Expressions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Regular Expressions  (the point) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Example  S 0  S 2  S 1  r ( 0 | 1 | 2 | …  9 ) accepting state ( 0 | 1 | 2 | …  9 ) Recognizer for  Register
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Example  (continued) S 0  S 2  S 1  r ( 0 | 1 | 2 | …  9 ) accepting state ( 0 | 1 | 2 | …  9 ) Recognizer for  Register
Example  (continued) char    next character; state    s 0 ; call action(state,char); while (char     eof ) state      (state,char); call action(state,char); char    next character; if   (state) =  final  then  report acceptance; else report failure; action(state,char) switch(  (state) ) case  start : word    char; break; case  normal : word    word + char; break; case  final : word    char; break; case  error : report error; break; end; ,[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],What if we need a tighter specification?
Tighter register specification  (continued) ,[object Object],[object Object],[object Object],[object Object],S 0  S 5  S 1  r S 4  S 3  S 6  S 2  0 , 1 , 2 3 0 , 1 4 , 5 , 6 , 7 , 8 , 9 ( 0 | 1 | 2 | …  9 )
Tighter register specification  (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object]

Mais conteúdo relacionado

Mais procurados

Compiler Design
Compiler DesignCompiler Design
Compiler Design
Mir Majid
 
Error detection recovery
Error detection recoveryError detection recovery
Error detection recovery
Tech_MX
 
Spr ch-05-compilers
Spr ch-05-compilersSpr ch-05-compilers
Spr ch-05-compilers
Vasim Pathan
 
Chapter 1 1
Chapter 1 1Chapter 1 1
Chapter 1 1
bolovv
 
Different phases of a compiler
Different phases of a compilerDifferent phases of a compiler
Different phases of a compiler
Sumit Sinha
 

Mais procurados (20)

Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Error detection recovery
Error detection recoveryError detection recovery
Error detection recovery
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Spr ch-05-compilers
Spr ch-05-compilersSpr ch-05-compilers
Spr ch-05-compilers
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler design
 
Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)
 
phases of a compiler
 phases of a compiler phases of a compiler
phases of a compiler
 
Chapter 1 1
Chapter 1 1Chapter 1 1
Chapter 1 1
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture Notes
 
Compiler unit 1
Compiler unit 1Compiler unit 1
Compiler unit 1
 
Compiler Design Introduction
Compiler Design IntroductionCompiler Design Introduction
Compiler Design Introduction
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - Introduction
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Ch1
Ch1Ch1
Ch1
 
Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)
 
Cs6660 compiler design
Cs6660 compiler designCs6660 compiler design
Cs6660 compiler design
 
Different phases of a compiler
Different phases of a compilerDifferent phases of a compiler
Different phases of a compiler
 
Compiler design
Compiler designCompiler design
Compiler design
 

Destaque

OpenOffice++: Improving the Quality of Open Source Software
OpenOffice++: Improving the Quality of Open Source SoftwareOpenOffice++: Improving the Quality of Open Source Software
OpenOffice++: Improving the Quality of Open Source Software
Alexandro Colorado
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler design
Janani Parthiban
 

Destaque (20)

Regular expression (compiler)
Regular expression (compiler)Regular expression (compiler)
Regular expression (compiler)
 
Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.
 
Ss ui lecture 2
Ss ui lecture 2Ss ui lecture 2
Ss ui lecture 2
 
SS UI Lecture 1
SS UI Lecture 1SS UI Lecture 1
SS UI Lecture 1
 
OpenOffice++: Improving the Quality of Open Source Software
OpenOffice++: Improving the Quality of Open Source SoftwareOpenOffice++: Improving the Quality of Open Source Software
OpenOffice++: Improving the Quality of Open Source Software
 
Diab Compiler Quality Overview
Diab Compiler Quality OverviewDiab Compiler Quality Overview
Diab Compiler Quality Overview
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler design
 
Introduction to course
Introduction to courseIntroduction to course
Introduction to course
 
01. introduction
01. introduction01. introduction
01. introduction
 
Unit 1 cd
Unit 1 cdUnit 1 cd
Unit 1 cd
 
Compiler Engineering Lab#1
Compiler Engineering Lab#1Compiler Engineering Lab#1
Compiler Engineering Lab#1
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Compiler construction
Compiler constructionCompiler construction
Compiler construction
 
Compiler Design Tutorial
Compiler Design Tutorial Compiler Design Tutorial
Compiler Design Tutorial
 
compiler and their types
compiler and their typescompiler and their types
compiler and their types
 
Lexical analysis
Lexical analysisLexical analysis
Lexical analysis
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
Parsing
ParsingParsing
Parsing
 

Semelhante a Cpcs302 1

Chapter One
Chapter OneChapter One
Chapter One
bolovv
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
Abha Damani
 

Semelhante a Cpcs302 1 (20)

01. Introduction.ppt
01. Introduction.ppt01. Introduction.ppt
01. Introduction.ppt
 
Compiler design
Compiler designCompiler design
Compiler design
 
Cd econtent link1
Cd econtent link1Cd econtent link1
Cd econtent link1
 
Ch1 (1).ppt
Ch1 (1).pptCh1 (1).ppt
Ch1 (1).ppt
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 
Chapter One
Chapter OneChapter One
Chapter One
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
 
1._Introduction_.pptx
1._Introduction_.pptx1._Introduction_.pptx
1._Introduction_.pptx
 
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
 
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
 
LANGUAGE TRANSLATOR
LANGUAGE TRANSLATORLANGUAGE TRANSLATOR
LANGUAGE TRANSLATOR
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
 
Presentation1
Presentation1Presentation1
Presentation1
 
Presentation1
Presentation1Presentation1
Presentation1
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
 

Último

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Último (20)

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

Cpcs302 1

  • 1.
  • 2. Course Goals • To provide students with an understanding of the major phases of a compiler. • To introduce students to the theory behind the various phases, including regular expressions, context-free grammars, and finite state automata. • To provide students with an understanding of the design and implementation of a compiler. • To have the students build a compiler, through type checking and intermediate code generation, for a small language. • To provide students with an opportunity to work in a group on a large project.
  • 3. Course Outcomes • Students will have experience using current compiler generation tools. • Students will be familiar with the different phases of compilation. • Students will have experience defining and specifying the semantic rules of a programming language
  • 4. Prerequisites • In-depth knowledge of at least one structured programming language. • Strong background in algorithms, data structures, and abstract data types, including stacks, binary trees, graphs. • Understanding of grammar theories. • Understanding of data types and control structures, their design and implementation. • Understanding of the design and implementation of subprograms, parameter passing mechanisms, scope.
  • 5.
  • 6. Textbook Compilers: Principles, Techniques, and Tools” by Aho, Lam, Sethi, and Ullman, 2 nd edition.
  • 7. GRADING Assignements & project: 40 Midterm Exam: 20 Final Exam: 40
  • 8.
  • 9.
  • 10.
  • 11. Preprocessors, Compilers, Assemblers, and Linkers Preprocessor Compiler Assembler Linker Skeletal Source Program Source Program Target Assembly Program Relocatable Object Code Absolute Machine Code Libraries and Relocatable Object Files Try for example: gcc -v myprog.c
  • 12. The Phases of a Compiler Phase Output Sample Programmer (source code producer) Source string A=B+C; Scanner (performs lexical analysis ) Token string ‘ A’ , ‘=’ , ‘B’ , ‘+’ , ‘C’ , ‘;’ And symbol table with names Parser (performs syntax analysis based on the grammar of the programming language) Parse tree or abstract syntax tree ; | = / A + / B C Semantic analyzer (type checking, etc) Annotated parse tree or abstract syntax tree Intermediate code generator Three-address code, quads, or RTL int2fp B t1 + t1 C t2 := t2 A Optimizer Three-address code, quads, or RTL int2fp B t1 + t1 #2.3 A Code generator Assembly code MOVF #2.3,r1 ADDF2 r1,r2 MOVF r2,A Peephole optimizer Assembly code ADDF2 #2.3,r2 MOVF r2,A
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22. The Back End Responsibilities Translate IR into target machine code Choose instructions to implement each IR operation Decide which value to keep in registers Ensure conformance with system interfaces Automation has been much less successful in the back end Errors IR Instruction Scheduling Instruction Selection Machine code Register Allocation IR IR
  • 23.
  • 24.
  • 25.
  • 26.
  • 27. The Optimizer (or Middle End) Modern optimizers are structured as a series of passes Typical Transformations Discover & propagate some constant value Move a computation to a less frequently executed place Discover a redundant computation & remove it Remove useless or unreachable co de Errors O p t 1 O p t 3 O p t 2 O p t n ... IR IR IR IR IR
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36. Set Operations (refresher) You need to know these definitions
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.