Compiler Construction
Lecturer: Muhammad Fayyaz
Website: fayyazfayzi.com
Email:
[email protected]Course Objectives
At the end of the course we will understand the overall
structure of a compiler
know significant details of a number of important
techniques commonly used.
aware of the way in which language features raise
challenges for compiler builders.
Course Syllabus
Principles of Compilation
Compiler Structure
High-Level View of Translation
Desirable Properties of a Compiler, Scanners, Parsers, Context-
Sensitive Analysis Intermediate Representations.
The Procedure Abstraction, Code Shape, Code Optimization,
Data-Flow Analysis, Scalar Optimizations, Instruction Selection,
Instruction Scheduling, Register Allocation.
Implementation of a prototype compiler (Lab Assignment for
the Semester)
Textbook(s)
Engineering a Compiler, Second Edition by Keith
Cooper and Linda Torczon, Morgan Kaufmann;
2ndEdition (February 21, 2011). ISBN-10: 012088478X
Reference Material
Compilers: Principles, Techniques, and Tools By Alfred V. Aho,
Ravi Sethi, Jeffrey D.Ullman, Contributor Jeffrey D. Ullman ,
Prentice Hall; 2ndEdition (2006). ISBN-10: 0321486811
Modern Compiler Design, By Dick Grune, Henri E. Bal, Ceriel J.
H. Jacobs, Koen G.Langendoen, Springer; 2ndEdition. (2012).
ISBN-10: 1461446988
Modern Compiler Implementation in C, By Andrew W. Appel,
Maia Ginsburg, Contributor Maia Ginsburg, Cambridge
University Press, (2004). ISBN-10: 0521607655
Why Study This Course
Learn the programming paradigm
Learn how programming language APIs work
Learn programming framework and how they work
Learn how IDE and Compilers work
Learn Programming methodologies
Learn Application Design Patterns
Learn to develop Testing Tools and how they work
Learn Documenting Tools and how they work
Learn the basics of Modeling languages.
Why Take this Course
Reason #1: Understand compilers and languages
Understand the code structure
Understand language semantics
Understand relation between source code and
generated machine code
Become a better programmer
Why Take this Course
Reason #2: Nice balance of theory and practice
Theory
Mathematical models: regular expressions,
automata, grammars, graphs
Algorithms that use these models
Why Take this Course
Reason #2: Nice balance of theory and practice
Practice
Apply theoretical notions to build a real compiler
Why Take this Course
Reason #3: programming experience
write a large program which manipulates complex data
structures
learn more about C++ and Intel x86
What are Compilers
Compilers are computer programs that translate a program
written in one language into a program written in another
language.
A compiler is a large software system, with many internal
components and algorithms and complex interactions
between them.
The study of compiler construction is an introduction to
techniques for the translation and improvement of programs,
and a practical exercise in software engineering.
Examples
Typical Compilers:
VC, VC++, GCC, JavaC
FORTRAN, Pascal, VB(?)
Translators
Word to PDF
PDF to Postscript
Typical Compilation
Source Program
Compiler
Target Program
Source Code
int expr( int n )
{
int d;
d = 4*n*n*(n+1)*(n+1);
return d;
}
The Fundamental Principles of Compilation
Compilers are large, complex, carefully engineered objects.
There are two fundamental principles that a compiler writer
must keep in mind at all times. The first principle is inviolable:
1. The compiler must preserve the meaning of the program being
compiled.
2. The compiler must improve the input program in some
discernible way.
Thanks…!