CS415 Compilers
Overview of the Course
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Critical Facts
Welcome to CS415 Compilers
Topics in the design of programming language translators,
includi
CS415 Compilers
Instruction Scheduling
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Instruction Scheduling (Engineers View)
The Problem
Given a code fragment for some target machine and the
l
CS415 Compilers
Procedure Abstractions
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Example: Dynamic vs. Static Views
0
int r () cfw_ / declaration
int d, s;
1 int q (x,y) / declaration
int x
CS415 Compilers
Procedure Abstractions
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Review - Activation Record Basics
Space for parameters to
the current routine
parameters
Saved register con
CS415 Compilers
Register Allocation
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Review: The Back End
IR
Instruction
Selection
IR
Register
Allocation
IR
Machine
code
Instruction
Scheduling
Er
CS415 Compilers
Register Allocation
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Review: ILOC
Register allocation on basic blocks in ILOC (local register allocation)
Pseudo-code for a simple
CS415 Compilers
Instruction Scheduling
and
Introduction to Lexical Analysis
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Review: The Back End
IR
Instruction
Selection
IR
Register
Allocation
I
CS415 Compilers
Instruction Scheduling
and
Lexical Analysis
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Instruction Scheduling (Engineers View)
The Problem
Given a code fragment for some tar
CS415 Compilers
Syntax Analysis
Top-Down Parsing
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Announcements
Midterm on Wednesday, March 8
closed book, closed notes
covers everything up to (
CS415 Compilers
Instruction Scheduling
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Register Allocation
The General Task
At each point in the code, pick the values to keep in registers
Inse
CS415 Compilers
Register Allocation and
Introduction to Instruction Scheduling
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Announcement
First homework out
Due tomorrow 11:59pm EST.
Sakai su
CS415 Compilers
Lexical Analysis
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Review: Automating Scanner Construction
RE NFA (Thompsons construction)
Build an NFA for each term
Combine them
CS415 Compilers
Syntax Analysis
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Limits of Regular Languages
Not all languages are regular
RLs CFLs CSLs
You cannot construct DFAs to recognize the
CS415 Compilers
Lexical Analysis
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
The Front End
Source
code
Front
End
IR
Back
End
Machine
code
Errors
The purpose of the front end is to deal with
CS415 Compilers
Overview of the Course
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Critical Facts
Welcome to CS415 Compilers
Topics in the design of programming language translators,
includi
CS415 Compilers
Register Allocation
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Review: The Back End
IR
Instruction
Selection
IR
Register
Allocation
IR
Instruction
Scheduling
Machine
code
Er
CS415 Compilers
Common Subexpression Elimination,
Procedure Abstractions
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Roadmap
Project 3: Has been posted; due on May 6
Final exam: May 9 (con
CS415 Compilers
Compiler Optimizations:
Vectorization/Parallelization,
Common Subexpression Elimination,
Procedure Abstractions
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Roadmap
Project 2
CS415 Compilers
Compiler Optimizations:
Vectorization/Parallelization and
Common Subexpression Elimination
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Review - Compiler Optimization
Source
C
CS415 Compilers
Lexical Analysis
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
First Programming Project
Instruction Scheduling Project has been posted
Due dates: code - March 2, report - Marc
CS415 Compilers
Lexical Analysis
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Review: Automating Scanner Construction
RE NFA (Thompsons construction)
Build an NFA for each term
Combine them
CS415 Compilers
Syntax Analysis
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Parsing
(Syntax Analysis)
EAC Chapters 3.1 - 3.2
cs415, spring 12
1
Review: The Front End
Source
code
Scanner
toke
CS415 Compilers
Syntax Analysis
Top-Down Parsing
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Top-Down Parsing
(Syntax Analysis)
EAC Chapters 3.1 3.3
cs415, spring 12
1
Parsing Techniques: To
CS415 Compilers
Syntax Analysis
Top-Down Parsing
Introduction to Bottom-up Parsing
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Top-Down Parsing
(Syntax Analysis)
EAC Chapters 3.1 3.3
cs415,
CS415 Compilers
Syntax Analysis
Bottom-up Parsing
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Quick Roadmap before Break
Midterm on Wednesday, March 7
closed book, closed notes
covers eve
CS415 Compilers
Syntax Analysis
Bottom-up Parsing
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Parsing
(Syntax Analysis)
EAC Chapters 3.4
cs415, spring 12
1
Parsing Techniques: Bottom-up pars
CS415 Compilers
Syntax Analysis
Bottom-up Parsing
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Parsing
(Syntax Analysis)
EAC Chapters 3.4
cs415, spring 12
1
Parsing Techniques: Bottom-up pars
CS415 Compilers
Syntax Analysis
Bottom-up Parsing
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Review - LR(k) items
The LR(1) table construction algorithm uses LR(1) items to
represent valid
CS415 Compilers
Error Recovery
Semantic Analysis:
Attribute Grammars and
Syntax-Directed Translation
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Review - LALR(1) versus LR(1)
Example:
LR(0)
CS415 Compilers
Attribute Grammars,
Syntax-Directed Translation
These slides are based on slides copyrighted by
Keith Cooper, Ken Kennedy & Linda Torczon at Rice
University
Project Session
Second project will come out next week
Meeting to discuss project