SlideShare a Scribd company logo
1 of 16
Download to read offline
Compilers
CS 346
3 – 0 – 0 – 6
Monday – Tuesday – Wednesday
9.00 --- 9.55 10.00 --- 10.55 11.00 --- 11.55
Arijit Sur
Office: H-103
Department of Computer Science and Engineering
Email: arijit@iitg.ernet.in
Ph: 2361
Instructors: Dr. A. Sur and Dr. A. Sarkar
Syllabus
• Overview of different phases of a compiler: front-end; back-end;
• Lexical analysis: specification of tokens, recognition of tokens, input
buffering, automatic tools;
• Syntax analysis: context free grammars, top down and bottom up parsing
techniques, construction of efficient parsers, syntax-directed translation,
automatic tools;
• Semantic analysis: declaration processing, type checking, symbol tables,• Semantic analysis: declaration processing, type checking, symbol tables,
error recovery;
• Intermediate code generation: run-time environments, translation of
language constructs;
• Code generation: flow-graphs, register allocation, code-generation
algorithms;
• Introduction to code optimization techniques.
8-Jan-15 CS346 Lecture 1 2
Books
• Text Book
– Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman,
Compilers: Principles, Techniques, and Tools, 2nd Edition,
Prentice Hall, 2009
• Reference Books
– V. Raghavan, Principles of Compiler Design, McGrawHill, 2010
– C.N. Fischer, R.J. Le Blanc, Crafting a Compiler with C, Pearson
Education, 2009
– K. D. Cooper, L. Torczon, Engineering a Compiler, Morgan
Kaufmann Publishers, 2004
– Allen Holub, Compiler Design in C, Prentice-Hall software series,
1990
8-Jan-15 CS346 Lecture 1 3
Grades
• 2 Quiz s
– 20% of grade
• Mid-Semester
– 30% of grade
• End-Semester
– 50% of grade
• Attendance below 75% --- F Grade
• Random Attendance
8-Jan-15 CS346 Lecture 1 4
8-Jan-15 CS346 Lecture 1 6
Basic Blocks of Computing System
8-Jan-15 CS346 Lecture 1 7
Program Execution: Layered Architecture
High Level Language
Program
Assembly Language
Program
Compiler
Assembler +
temp = v[k];
v[k] = v[k+1];
v[k+1] = temp;
lw $15, 0($2)
lw $16, 4($2)
sw $16, 0($2)
sw $15, 4($2)
Machine Language
Program
Control Signal
Specification
Assembler +
Linker + Loader
Machine Interpretation
sw $15, 4($2)
0000 1001 1100 0110 1010 1111 0101 1000
1010 1111 0101 1000 0000 1001 1100 0110
1100 0110 1010 1111 0101 1000 0000 1001
0101 1000 0000 1001 1100 0110 1010 1111
°
°
ALUOP[0:3] <= InstReg[9:11] & MASK
8-Jan-15 CS346 Lecture 1 8
Architecture of Computing System
Compiler
Operating
System
Application
Instruction Set
Architecture
Firmware
I/O systemInstr. Set Proc.
Digital Design
Circuit Design
Architecture
Datapath & Control
Layout
8-Jan-15 CS346 Lecture 1 9
Definitions
• What is a compiler?
– A program that accepts as input a program text in a certain language and
produces as output a program text in another language, while preserving the
meaning of that text (Grune et al, 2000).
– A program that reads a program written in one language (source language)
and translates it into an equivalent program in another language (target
language) (Aho et al)
– Report errors of source language which are detected during the
8-Jan-15 CS346 Lecture 1 10
– Report errors of source language which are detected during the
translation process
• What is an interpreter?
– A program that reads a source program and produces the results of executing
this source.
• We deal with compilers! Many of these issues arise with interpreters!
Compiler Vs. Interpreter
Compiler
Source Program
Interpreter
Source Program
Input
Output
Target Program
Target ProgramInput Output
Translator
Source Program
Intermediate
Program
Input
Virtual
Machine Output
A Hybrid Compiler
Examples
• C is typically compiled
• Lisp is typically interpreted
• Java is compiled to bytecodes, which are then interpreted
• source-to-source compiler, transcompiler, or transpiler :
– C++ to C
– High Performance Fortran (HPF) to Fortran (parallelising compiler)
8-Jan-15 12
– High Performance Fortran (HPF) to Fortran (parallelising compiler)
• Cross Compilers (wiki)
– A cross compiler is a compiler capable of
reading executable code for a platform other than the one on
which the compiler is running. For example, a compiler that runs
on a Windows 7 PC but generates code that runs
on Android Smartphone is a cross compiler.
CS346 Lecture 1
Qualities of a Good Compiler
What qualities would you want in a compiler?
– generates correct code (first and foremost!)
– generates fast code
– conforms to the specifications of the input language
– copes with essentially arbitrary input size, variables,
8-Jan-15 13
– copes with essentially arbitrary input size, variables,
etc.
– compilation time (linearly)proportional to size of source
– good diagnostics
– consistent optimisations
– works well with the debugger
CS346 Lecture 1
Principles of Compilation
The compiler must:
• preserve the meaning of the program being compiled.
• “improve” the source code in some way.
Other issues (depending on the setting):
8-Jan-15 14
Other issues (depending on the setting):
• Speed (of compiled code)
• Space (size of compiled code)
• Feedback (information provided to the user)
• Debugging (transformations obscure the relationship source code vs target)
• Compilation time efficiency (fast or slow compiler?)
CS346 Lecture 1
Applications
• Most common use: translate a high-level program to object code
– Program Translation: binary translation, hardware synthesis, …
• Optimizations for computer architectures:
– Improve program performance, take into account hardware parallelism, etc…
• Interpreters: e.g., BASIC, Lisp etc.
8-Jan-15 15
• Software productivity tools
– Debugging aids: e.g., purify
• Text formatters, just-in-time compilation for Java, power
management, global distributed computing, …
Key: Ability to extract properties of a source program (analysis) and
transform it to construct a target program (synthesis)
CS346 Lecture 1
Lecture1 introduction compilers

More Related Content

What's hot (20)

Lexical analyzer generator lex
Lexical analyzer generator lexLexical analyzer generator lex
Lexical analyzer generator lex
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01
 
Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler Design
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
Compiler design
Compiler designCompiler design
Compiler design
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
1.10. pumping lemma for regular sets
1.10. pumping lemma for regular sets1.10. pumping lemma for regular sets
1.10. pumping lemma for regular sets
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
 
Parsing
ParsingParsing
Parsing
 
Lex
LexLex
Lex
 
Yacc
YaccYacc
Yacc
 
Semantic analysis
Semantic analysisSemantic analysis
Semantic analysis
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
 
Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6
 

Viewers also liked (20)

roshan.ppt
roshan.pptroshan.ppt
roshan.ppt
 
Lecture2 general structure of a compiler
Lecture2 general structure of a compilerLecture2 general structure of a compiler
Lecture2 general structure of a compiler
 
Lecture6 syntax analysis_2
Lecture6 syntax analysis_2Lecture6 syntax analysis_2
Lecture6 syntax analysis_2
 
تعرف إلى-الهندسة المعلوماتية
تعرف إلى-الهندسة المعلوماتيةتعرف إلى-الهندسة المعلوماتية
تعرف إلى-الهندسة المعلوماتية
 
Lecture5 syntax analysis_1
Lecture5 syntax analysis_1Lecture5 syntax analysis_1
Lecture5 syntax analysis_1
 
ف 2 الدرس الأول والثانى والثالث
ف 2 الدرس الأول والثانى والثالثف 2 الدرس الأول والثانى والثالث
ف 2 الدرس الأول والثانى والثالث
 
Symbolic Automata = Automata + SMT solvers at ExCape14
Symbolic Automata = Automata + SMT solvers at ExCape14Symbolic Automata = Automata + SMT solvers at ExCape14
Symbolic Automata = Automata + SMT solvers at ExCape14
 
Lecture3 lexical analysis
Lecture3 lexical analysisLecture3 lexical analysis
Lecture3 lexical analysis
 
DFA minimization algorithms in map reduce
DFA minimization algorithms in map reduceDFA minimization algorithms in map reduce
DFA minimization algorithms in map reduce
 
DFA Minimization
DFA MinimizationDFA Minimization
DFA Minimization
 
Lecture4 lexical analysis2
Lecture4 lexical analysis2Lecture4 lexical analysis2
Lecture4 lexical analysis2
 
Isdn
IsdnIsdn
Isdn
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
Forouzan isdn
Forouzan isdnForouzan isdn
Forouzan isdn
 
optimization of DFA
optimization of DFAoptimization of DFA
optimization of DFA
 
Integrated service digital network
Integrated service digital networkIntegrated service digital network
Integrated service digital network
 
Basic ISDN
Basic ISDNBasic ISDN
Basic ISDN
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Isdn
IsdnIsdn
Isdn
 
Isdn networking
Isdn networkingIsdn networking
Isdn networking
 

Similar to Lecture1 introduction compilers

Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processorsRebaz Najeeb
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compilerIffat Anjum
 
Introduction_to_Programming.pptx
Introduction_to_Programming.pptxIntroduction_to_Programming.pptx
Introduction_to_Programming.pptxPmarkNorcio
 
Lecture1 compilers
Lecture1 compilersLecture1 compilers
Lecture1 compilersAftab Ahmad
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming languageVasavi College of Engg
 
introduction to computer vision and image processing
introduction to computer vision and image processingintroduction to computer vision and image processing
introduction to computer vision and image processingpakboy12
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction Sarmad Ali
 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction Thapar Institute
 
Compiler an overview
Compiler  an overviewCompiler  an overview
Compiler an overviewamudha arul
 
X-CS-8.0 Programming in C Language 2022-2023.pdf
X-CS-8.0 Programming in C Language 2022-2023.pdfX-CS-8.0 Programming in C Language 2022-2023.pdf
X-CS-8.0 Programming in C Language 2022-2023.pdfAlefya1
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterHossam Hassan
 
Bsc cs 1 fit u-2 application and system software
Bsc cs 1 fit u-2 application and system softwareBsc cs 1 fit u-2 application and system software
Bsc cs 1 fit u-2 application and system softwareRai University
 
Bba i-introduction to computer-u-2- application and system software
Bba  i-introduction to computer-u-2- application and system softwareBba  i-introduction to computer-u-2- application and system software
Bba i-introduction to computer-u-2- application and system softwareRai University
 

Similar to Lecture1 introduction compilers (20)

Compilers.pptx
Compilers.pptxCompilers.pptx
Compilers.pptx
 
Introduction to Compiler
Introduction to CompilerIntroduction to Compiler
Introduction to Compiler
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Introduction_to_Programming.pptx
Introduction_to_Programming.pptxIntroduction_to_Programming.pptx
Introduction_to_Programming.pptx
 
Lecture1 compilers
Lecture1 compilersLecture1 compilers
Lecture1 compilers
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
introduction to computer vision and image processing
introduction to computer vision and image processingintroduction to computer vision and image processing
introduction to computer vision and image processing
 
Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
 
Compiler design
Compiler designCompiler design
Compiler design
 
Cd econtent link1
Cd econtent link1Cd econtent link1
Cd econtent link1
 
Chapter 4 computer language
Chapter 4 computer languageChapter 4 computer language
Chapter 4 computer language
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction
 
Compiler an overview
Compiler  an overviewCompiler  an overview
Compiler an overview
 
X-CS-8.0 Programming in C Language 2022-2023.pdf
X-CS-8.0 Programming in C Language 2022-2023.pdfX-CS-8.0 Programming in C Language 2022-2023.pdf
X-CS-8.0 Programming in C Language 2022-2023.pdf
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals master
 
Bsc cs 1 fit u-2 application and system software
Bsc cs 1 fit u-2 application and system softwareBsc cs 1 fit u-2 application and system software
Bsc cs 1 fit u-2 application and system software
 
Bba i-introduction to computer-u-2- application and system software
Bba  i-introduction to computer-u-2- application and system softwareBba  i-introduction to computer-u-2- application and system software
Bba i-introduction to computer-u-2- application and system software
 
CD U1-5.pptx
CD U1-5.pptxCD U1-5.pptx
CD U1-5.pptx
 

More from Mahesh Kumar Chelimilla (14)

Lecture11 syntax analysis_7
Lecture11 syntax analysis_7Lecture11 syntax analysis_7
Lecture11 syntax analysis_7
 
Lecture10 syntax analysis_6
Lecture10 syntax analysis_6Lecture10 syntax analysis_6
Lecture10 syntax analysis_6
 
Lecture9 syntax analysis_5
Lecture9 syntax analysis_5Lecture9 syntax analysis_5
Lecture9 syntax analysis_5
 
Lecture8 syntax analysis_4
Lecture8 syntax analysis_4Lecture8 syntax analysis_4
Lecture8 syntax analysis_4
 
Lecture7 syntax analysis_3
Lecture7 syntax analysis_3Lecture7 syntax analysis_3
Lecture7 syntax analysis_3
 
Transportlayer tanenbaum
Transportlayer tanenbaumTransportlayer tanenbaum
Transportlayer tanenbaum
 
Network layer tanenbaum
Network layer tanenbaumNetwork layer tanenbaum
Network layer tanenbaum
 
Forouzan x25
Forouzan x25Forouzan x25
Forouzan x25
 
Forouzan ppp
Forouzan pppForouzan ppp
Forouzan ppp
 
Forouzan frame relay
Forouzan frame relayForouzan frame relay
Forouzan frame relay
 
Forouzan data link_2
Forouzan data link_2Forouzan data link_2
Forouzan data link_2
 
Forouzan data link_1
Forouzan data link_1Forouzan data link_1
Forouzan data link_1
 
Forouzan atm
Forouzan atmForouzan atm
Forouzan atm
 
Datalinklayer tanenbaum
Datalinklayer tanenbaumDatalinklayer tanenbaum
Datalinklayer tanenbaum
 

Recently uploaded

Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 

Recently uploaded (20)

Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 

Lecture1 introduction compilers

  • 1. Compilers CS 346 3 – 0 – 0 – 6 Monday – Tuesday – Wednesday 9.00 --- 9.55 10.00 --- 10.55 11.00 --- 11.55 Arijit Sur Office: H-103 Department of Computer Science and Engineering Email: arijit@iitg.ernet.in Ph: 2361 Instructors: Dr. A. Sur and Dr. A. Sarkar
  • 2. Syllabus • Overview of different phases of a compiler: front-end; back-end; • Lexical analysis: specification of tokens, recognition of tokens, input buffering, automatic tools; • Syntax analysis: context free grammars, top down and bottom up parsing techniques, construction of efficient parsers, syntax-directed translation, automatic tools; • Semantic analysis: declaration processing, type checking, symbol tables,• Semantic analysis: declaration processing, type checking, symbol tables, error recovery; • Intermediate code generation: run-time environments, translation of language constructs; • Code generation: flow-graphs, register allocation, code-generation algorithms; • Introduction to code optimization techniques. 8-Jan-15 CS346 Lecture 1 2
  • 3. Books • Text Book – Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman, Compilers: Principles, Techniques, and Tools, 2nd Edition, Prentice Hall, 2009 • Reference Books – V. Raghavan, Principles of Compiler Design, McGrawHill, 2010 – C.N. Fischer, R.J. Le Blanc, Crafting a Compiler with C, Pearson Education, 2009 – K. D. Cooper, L. Torczon, Engineering a Compiler, Morgan Kaufmann Publishers, 2004 – Allen Holub, Compiler Design in C, Prentice-Hall software series, 1990 8-Jan-15 CS346 Lecture 1 3
  • 4. Grades • 2 Quiz s – 20% of grade • Mid-Semester – 30% of grade • End-Semester – 50% of grade • Attendance below 75% --- F Grade • Random Attendance 8-Jan-15 CS346 Lecture 1 4
  • 5.
  • 7. Basic Blocks of Computing System 8-Jan-15 CS346 Lecture 1 7
  • 8. Program Execution: Layered Architecture High Level Language Program Assembly Language Program Compiler Assembler + temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) Machine Language Program Control Signal Specification Assembler + Linker + Loader Machine Interpretation sw $15, 4($2) 0000 1001 1100 0110 1010 1111 0101 1000 1010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111 ° ° ALUOP[0:3] <= InstReg[9:11] & MASK 8-Jan-15 CS346 Lecture 1 8
  • 9. Architecture of Computing System Compiler Operating System Application Instruction Set Architecture Firmware I/O systemInstr. Set Proc. Digital Design Circuit Design Architecture Datapath & Control Layout 8-Jan-15 CS346 Lecture 1 9
  • 10. Definitions • What is a compiler? – A program that accepts as input a program text in a certain language and produces as output a program text in another language, while preserving the meaning of that text (Grune et al, 2000). – A program that reads a program written in one language (source language) and translates it into an equivalent program in another language (target language) (Aho et al) – Report errors of source language which are detected during the 8-Jan-15 CS346 Lecture 1 10 – Report errors of source language which are detected during the translation process • What is an interpreter? – A program that reads a source program and produces the results of executing this source. • We deal with compilers! Many of these issues arise with interpreters!
  • 11. Compiler Vs. Interpreter Compiler Source Program Interpreter Source Program Input Output Target Program Target ProgramInput Output Translator Source Program Intermediate Program Input Virtual Machine Output A Hybrid Compiler
  • 12. Examples • C is typically compiled • Lisp is typically interpreted • Java is compiled to bytecodes, which are then interpreted • source-to-source compiler, transcompiler, or transpiler : – C++ to C – High Performance Fortran (HPF) to Fortran (parallelising compiler) 8-Jan-15 12 – High Performance Fortran (HPF) to Fortran (parallelising compiler) • Cross Compilers (wiki) – A cross compiler is a compiler capable of reading executable code for a platform other than the one on which the compiler is running. For example, a compiler that runs on a Windows 7 PC but generates code that runs on Android Smartphone is a cross compiler. CS346 Lecture 1
  • 13. Qualities of a Good Compiler What qualities would you want in a compiler? – generates correct code (first and foremost!) – generates fast code – conforms to the specifications of the input language – copes with essentially arbitrary input size, variables, 8-Jan-15 13 – copes with essentially arbitrary input size, variables, etc. – compilation time (linearly)proportional to size of source – good diagnostics – consistent optimisations – works well with the debugger CS346 Lecture 1
  • 14. Principles of Compilation The compiler must: • preserve the meaning of the program being compiled. • “improve” the source code in some way. Other issues (depending on the setting): 8-Jan-15 14 Other issues (depending on the setting): • Speed (of compiled code) • Space (size of compiled code) • Feedback (information provided to the user) • Debugging (transformations obscure the relationship source code vs target) • Compilation time efficiency (fast or slow compiler?) CS346 Lecture 1
  • 15. Applications • Most common use: translate a high-level program to object code – Program Translation: binary translation, hardware synthesis, … • Optimizations for computer architectures: – Improve program performance, take into account hardware parallelism, etc… • Interpreters: e.g., BASIC, Lisp etc. 8-Jan-15 15 • Software productivity tools – Debugging aids: e.g., purify • Text formatters, just-in-time compilation for Java, power management, global distributed computing, … Key: Ability to extract properties of a source program (analysis) and transform it to construct a target program (synthesis) CS346 Lecture 1