Compiler Summary Mooly Sagiv html://www.math.tau.ac.il/~msagiv/courses/wcc03.html.

Slides:



Advertisements
Similar presentations
CPSC 388 – Compiler Design and Construction
Advertisements

1 Compiler Construction Intermediate Code Generation.
Recap Roman Manevich Mooly Sagiv. Outline Subjects Studied Questions & Answers.
Mooly Sagiv and Roman Manevich School of Computer Science
Semantic analysis Parsing only verifies that the program consists of tokens arranged in a syntactically-valid combination, we now move on to semantic analysis,
Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3.
Recap Mooly Sagiv. Outline Subjects Studied Questions & Answers.
1 Semantic Processing. 2 Contents Introduction Introduction A Simple Compiler A Simple Compiler Scanning – Theory and Practice Scanning – Theory and Practice.
Bottom-Up Syntax Analysis Mooly Sagiv Textbook:Modern Compiler Design Chapter (modified)
Bottom-Up Syntax Analysis Mooly Sagiv html:// Textbook:Modern Compiler Design Chapter
FE.1 CSE4100 Final Exam Advice and Hints Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University of Connecticut 191 Auditorium.
Run time vs. Compile time
Environments and Evaluation
Syntax Analysis Mooly Sagiv html:// Textbook:Modern Compiler Design Chapter 2.2 (Partial) Hashlama 11:00-14:00.
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
The environment of the computation Declarations introduce names that denote entities. At execution-time, entities are bound to values or to locations:
Compiler Construction Recap Rina Zviel-Girshin and Ohad Shacham School of Computer Science Tel-Aviv University.
Syntax Analysis Mooly Sagiv Textbook:Modern Compiler Design Chapter 2.2 (Partial)
Bottom-Up Syntax Analysis Mooly Sagiv html:// Textbook:Modern Compiler Implementation in C Chapter 3.
2.2 A Simple Syntax-Directed Translator Syntax-Directed Translation 2.4 Parsing 2.5 A Translator for Simple Expressions 2.6 Lexical Analysis.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
CISC 471 First Exam Review Game Questions. Overview 1 Draw the standard phases of a compiler for compiling a high level language to machine code, showing.
1 Semantic Analysis Aaron Bloomfield CS 415 Fall 2005.
Compiler Construction
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style COMPILER DESIGN Review Joey Paquet,
The TINY sample language and it’s compiler
Joey Paquet, Lecture 12 Review. Joey Paquet, Course Review Compiler architecture –Lexical analysis, syntactic analysis, semantic.
COMPILERS Symbol Tables hussein suleman uct csc3003s 2007.
Interpretation Environments and Evaluation. CS 354 Spring Translation Stages Lexical analysis (scanning) Parsing –Recognizing –Building parse tree.
Review 1.Lexical Analysis 2.Syntax Analysis 3.Semantic Analysis 4.Code Generation 5.Code Optimization.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
Activation Records (in Tiger) CS 471 October 24, 2007.
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
Chapter 2. Design of a Simple Compiler J. H. Wang Sep. 21, 2015.
Joey Paquet, 2000, Lecture 10 Introduction to Code Generation and Intermediate Representations.
Introduction to Code Generation and Intermediate Representations
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Muhammad Idrees, Lecturer University of Lahore 1 Top-Down Parsing Top down parsing can be viewed as an attempt to find a leftmost derivation for an input.
Introduction CPSC 388 Ellen Walker Hiram College.
Compiler Principles Fall Compiler Principles Lecture 6: Parsing part 5 Roman Manevich Ben-Gurion University.
Week 6(10.7): The TINY sample language and it ’ s compiler The TINY + extension of TINY Week 7 and 8(10.14 and 10.21): The lexical of TINY + Implement.
Compiler Introduction 1 Kavita Patel. Outlines 2  1.1 What Do Compilers Do?  1.2 The Structure of a Compiler  1.3 Compilation Process  1.4 Phases.
1 A Simple Syntax-Directed Translator CS308 Compiler Theory.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 1 Ahmed Ezzat.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Prologue Sung-Dong Kim, Dept. of Computer Engineering, Hansung University.
2016/7/9Page 1 Lecture 11: Semester Review COMP3100 Dept. Computer Science and Technology United International College.
LECTURE 10 Semantic Analysis. REVIEW So far, we’ve covered the following: Compilation methods: compilation vs. interpretation. The overall compilation.
Compiler Summary Lexical analysis—scanner – String of characters  token – Finite automata. Syntactical analysis – parser – Sequence of tokens –> language.
Lecture 9 Symbol Table and Attributed Grammars
Chapter 1 Introduction.
A Simple Syntax-Directed Translator
Constructing Precedence Table
Introduction to Parsing
Programming Languages Translator
Compiler Construction (CS-636)
Textbook:Modern Compiler Design
Chapter 1 Introduction.
-by Nisarg Vasavada (Compiled*)
课程名 编译原理 Compiling Techniques
Compiler Lecture 1 CS510.
Bottom-Up Syntax Analysis
Basic Program Analysis: AST
CPSC 388 – Compiler Design and Construction
CSE401 Introduction to Compiler Construction
Exam Topics Hal Perkins Autumn 2009
Exam Topics Hal Perkins Winter 2008
Compiler design Review COMP 442/6421 – Compiler Design
Presentation transcript:

Compiler Summary Mooly Sagiv html://

Lecture Format Compilation stages and techniques – Review Break Last year’s exam

Compiler Structure Input program Lexical analysis Tokens Parser AST Context Analysis Annotated AST Code Generation Assembly Assembler Assembled Binary code Syntax errors “Semantic” errors Executable code Library code Linker input output

Lexical Analysis Input: Text (input-file) Output: Tokens (with values) Jlex regular expressions input program scanner tokens

Techniques Convert regular expressions to finite automata Accepting states are associated with actions –Actions which are defined first take priority Scanner uses backtracking to find longest match

Syntax Analysis (Parsing) Input: Stream of tokens Output: Abstract Syntax Tree Jcup Context free grammar tokens parser AST

Recursive Descent (Top Down Parsing) Procedure for every non-terminal The procedure of every non-terminal identifies leftmost derivations –Consider a single token –Decide which production to apply Works for a limited class of grammars [The parser tables can be constructed algorithmically]

Bottom-Up Parsing Construct the tree from the leaves Store “states” on the stack Identifies rightmost derivations in reverse order Works for a limited class of grammars The parser tables can be constructed algorithmically (SLR(0)

Context Analysis Input: Abstract Syntax Tree Output: Annotated Abstract Syntax Trees –Semantic errors Several tree traversals [Can be declaratively defined using attribute grammar] Examples: –Name resolution –type checking –Consistency of usages Private fields, … –“Allocate” stack slots (offsets) for variables

Code Generation Input: AST Output Assembly

Code generation of procedures Generate prologue assembly code for opening a stack frame –Local (automatic) variables –callee-save registers Generate code for procedure body Generate epilog assembly code for closing the stack frame –Restore callee-save register Returns to the caller

Code generation for procedure body Code for control flow statements –Normal –Runtime checks –Exceptions Code for side-effect free expressions –2-phase Weighted tree (optimal) Code for basic blocks –Avoids store/loads –Construct dependency graphs –Optimize dependency graphs –Generate code with symbolic registers –Allocate architectural registers to symbolic Code for procedure invocation –Store caller-save registers –Transfer actual parameters –Actual call

Heap allocated data “Long” lived Duration can exceed procedure body Relies on Garbage collection –Library with the help of the compiler Garbage collection techniques –Stop the world vs. incremental –Generational Garbage collecting algorithms –Mark and sweep –Copying –Reference counts

Runtime descriptors Additional information on the stack/heap –Type information –Dynamic class binding –Dispatch tables –Array size Generate code to fill information

Assembler Convert assembly to binary Resolve labels –Two phase –Backpatch Simple overloading Produce relocation information

Linker Relocate code Address changes

Loader Part of the operating system Initializes runtime state

Tiger vs. TC Records Procedure nesting Object oriented –Classes –Virtual functions