CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.

Slides:



Advertisements
Similar presentations
1 CIS 461 Compiler Design and Construction Fall 2014 Instructor: Hugh McGuire slides derived from Tevfik Bultan, Keith Cooper, and Linda Torczon Lecture-Module.
Advertisements

Software & Services Group, Developer Products Division Copyright© 2010, Intel Corporation. All rights reserved. *Other brands and names are the property.
SYSTEM PROGRAMMING & SYSTEM ADMINISTRATION
CPSC Compiler Tutorial 9 Review of Compiler.
From Cooper & Torczon1 Implications Must recognize legal (and illegal) programs Must generate correct code Must manage storage of all variables (and code)
Compiler Construction1 A Compulsory Module for Students in Computer Science Department Faculty of IT / Al – Al Bayt University First Semester 2009/2010.
Introduction & Overview CS4533 from Cooper & Torczon.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
CPSC 388 – Compiler Design and Construction Lecture: MWF 11:00am-12:20pm, Room 106 Colton.
Overview of the Course. Critical Facts Welcome to CISC 672 — Advanced Compiler Construction Instructor: Dr. John Cavazos Office.
Invitation to Computer Science 5th Edition
Course Revision Contents  Compilers  Compilers Vs Interpreters  Structure of Compiler  Compilation Phases  Compiler Construction Tools  A Simple.
Chapter 1. Introduction.
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.
Overview of the Course Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
Overview of the Course Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
Parser-Driven Games Tool programming © Allan C. Milne Abertay University v
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
CSC 338: Compiler design and implementation
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
CST320 - Lec 11 Why study compilers? n n Ties lots of things you know together: –Theory (finite automata, grammars) –Data structures –Modularization –Utilization.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
1 Chapter 1 Introduction. 2 Outlines 1.1 Overview and History 1.2 What Do Compilers Do? 1.3 The Structure of a Compiler 1.4 The Syntax and Semantics of.
1 EECS 6083 Compiler Theory Based on slides from text web site: Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Compiler design Lecture 1: Compiler Overview Sulaimany University 2 Oct
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
Overview of Previous Lesson(s) Over View  A program must be translated into a form in which it can be executed by a computer.  The software systems.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Chapter 1 Introduction Major Data Structures in Compiler
Compiler Construction (CS-636)
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.
Chapter 1 Introduction. Chapter 1 -- Introduction2  Def: Compiler --  a program that translates a program written in a language like Pascal, C, PL/I,
Chapter 1: Introduction 1 Compiler Designs and Constructions Chapter 1: Introduction Objectives: Course Objectives Introduction Dr. Mohsen Chitsaz.
What is a compiler? –A program that reads a program written in one language (source language) and translates it into an equivalent program in another language.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
Chapter – 8 Software Tools.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
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.
Prologue Sung-Dong Kim, Dept. of Computer Engineering, Hansung University.
Lecture 02: Compiler Overview Kwangman Man ( SangJi University.
Chapter 1 Introduction Samuel College of Computer Science & Technology Harbin Engineering University.
Chapter 1. Introduction.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
COMP Compilers Lecture 1: Introduction
Advanced Computer Systems
Compiler Design (40-414) Main Text Book:
PRINCIPLES OF COMPILER DESIGN
Chapter 1 Introduction.
컴파일러 첫째주 2005/09/01 권혁철.
Introduction to Compiler Construction
Compiler Construction (CS-636)
Chapter 1 Introduction.
-by Nisarg Vasavada (Compiled*)
课程名 编译原理 Compiling Techniques
Chapter 1: Introduction to Compiling (Cont.)
Compiler Lecture 1 CS510.
Overview of the Course Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
Course supervisor: Lubna Siddiqui
Compiler Construction
COMP Compilers Lecture 1: Introduction
Compilers B V Sai Aravind (11CS10008).
CISC 7120X Programming Languages and Compilers
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Chapter 1 Introduction.
Presentation transcript:

CS 460/660 Compiler Construction

Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers are interesting – –Compilers include many applications of theory to practice – –Writing a compiler exposes practical algorithmic & engineering issues Compilers are everywhere – –Many practical applications have embedded languages – –Commands, macros, formatting tags … Many applications have input formats that look like languages

Class 01 3 Intrinsic Merit Compiler Construction poses some challenging and interesting problems: – –Compilers must do a lot but also run quickly – –Compilers have primary responsibility for run-time performance Computer architects perpetually create new challenges for the compiler by building more complex machines – –Compilers must hide that complexity from the programmer A successful compiler requires mastery of the many complex interactions between its constituent parts

Class 01 4 A True Capstone Compiler construction involves ideas from many different parts of computer science – –Data Structures Greedy algorithms, Heuristic search techniques – –Algorithms Graph algorithms, union-find Dynamic programming – –Theory DFAs & PDAs, pattern matching, Fixed-point algorithms – –Systems Allocation & naming, Synchronization, locality – –Architecture Pipeline & hierarchy management, Instruction set use

Class 01 5 Why does it matter today? In the last 2 years, most processors have gone multicore – –The era of clock-speed improvements seems to be drawing to an end Faster clock speeds mean higher power (n 2 effect) Smaller wires mean higher resistance for on-chip wires – –For the near term, performance improvement will come from placing multiple copies of the processor (core) on a single die Classic programs, written in old languages, are not well suited to capitalize on this kind of multiprocessor parallelism – –Parallel programs require sophisticated compilers

Class 01 6 Textbook Compilers: Principles, Techniques, and Tools –The Dragon Book You should read it, It is a good book I will cover some, but not all. –Quizzes/Tests come from lectures and readings

Class 01 7 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview of the structure of a typical compiler Discuss trends in programming languages and machine architecture that are shaping compilers.

Class 01 8 What is a Compiler? Def: Compiler -- –a program that translates a program written in a language like Pascal, C, PL/I, FORTRAN, or COBOL into another language. An important role of the compiler is to report any errors that it detects.

Class 01 9 What is an Interpreter? Def: Interpreter -- –Instead of producing a target program at translation, it appears to directly execute the operations specified in the source program on the inputs specified by the user.

Class What are the Differences? Compiler is usually much faster. Interpreter usually gives better diagnostics.

Class Structure of a Compiler So far we have viewed the compiler as a single black box.

Class Structure of a Compiler Now we want to open that box.

Class 01 13

Class Structure of a Compiler 1. The Lexical Analyzer reads the stream of characters and groups them into meaningful sequences called lexemes. 2. The Syntax Analyzer depicts the grammatical structure of the lexemes in a syntax tree 3. The Semantic Analyzer checks the tree for semantic consistency (type checking)

Class Structure of a Compiler 4. Intermediate Code Generation – produces assembly like instructions (three address code) 5. Code Optimization – seeks to improve intermediate code so better target code can be generated 6. Code Generation – takes the intermediate code and maps to the target code.

Class Structure of a Compiler 7. Symbol Table Management - An essential function of the compiler is to record the variable names used in the source program and collect attributes of each name. (type, scope,…)

Class The Grouping of the Phases into Passes Pass – several phases may be grouped together into a pass that reads an input file and writes an output file. –Front End Lexical Analysis, Syntax Analysis, Semantic Analysis, and Intermediate Code Generation –Code Optimization Might be an optional pass. –Back End Code Generation for a specific target machine.

Class Compiler-Construction Tools The compiler writer, like any software developer, can profitably use modern software development environments containing tools –Editor, debugger, version managers, profilers, test harnesses, … There are also tools to help implement various phases of a compiler. –Scanner Generator, Parser generator, …

Class 01 19