EECS 483 – Compiler Construction Fall 2006, University of Michigan Scott Mahlke (mall-key) September 6, 2006.

Slides:



Advertisements
Similar presentations
Compilers Course 379K, TTH 9:30-11:00 Instructor: Dr. Doron A. Peled Office Hours: Mon 11:00-12:00.
Advertisements

Introduction to Compiler Construction
Compiler Construction by Muhammad Bilal Zafar (AP)
Program Representations. Representing programs Goals.
Goran Šuković, University of Montenegro 1/21 Compiler Construction Course at University of Montenegro 7 th Workshop on “Software Engineering Education.
Lecture 01 - Introduction Eran Yahav 1. 2 Who? Eran Yahav Taub 734 Tel: Monday 13:30-14:30
Representing programs Goals. Representing programs Primary goals –analysis is easy and effective just a few cases to handle directly link related things.
Cpeg421-08S/final-review1 Course Review Tom St. John.
Reference Book: Modern Compiler Design by Grune, Bal, Jacobs and Langendoen Wiley 2000.
Compiler Summary Mooly Sagiv html://
From Cooper & Torczon1 Implications Must recognize legal (and illegal) programs Must generate correct code Must manage storage of all variables (and code)
Compiler Construction
Overview of Compiler Design CIS 631, CSE 691, CIS400, CSE 400 Compiler Design Dr. Nancy McCracken January 15, 2008.
BİL744 Derleyici Gerçekleştirimi (Compiler Design)1.
CS 153: Concepts of Compiler Design August 25 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
410/510 1 of 20 Week 1 – Lecture 1 Introduction The Textbook Assessment Programming & Tools A v. small compiler Compiler Construction.
CS 153: Concepts of Compiler Design August 24 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
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.
Introduction to Compiler Construction Robert van Engelen COP5621 Compiler Construction Copyright Robert.
Compiler Construction1 COMP Compiler Construction Lecturer: Dr. Arthur Cater Teaching Assistant:
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.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
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.
Joey Paquet, Lecture 12 Review. Joey Paquet, Course Review Compiler architecture –Lexical analysis, syntactic analysis, semantic.
Joey Paquet, 2000, 2002, 2007, Concordia University Department of Computer Science COMP 442/6421 Compiler Design.
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. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Introduction to Compiling
Introduction CPSC 388 Ellen Walker Hiram College.
Compiler Design Introduction 1. 2 Course Outline Introduction to Compiling Lexical Analysis Syntax Analysis –Context Free Grammars –Top-Down Parsing –Bottom-Up.
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.
Compilers: Prelim/0 1 Compiler Structures Objective – –to give some background on the course , Semester 1, Who I am: Andrew Davison.
Course Overview for Compilers J. H. Wang Sep. 20, 2011.
C H A P T E R T W O Linking Syntax And Semantics Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
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.
1 Compiler Construction Vana Doufexi office CS dept.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
CS416 Compiler Design1. 2 Course Information Instructor : Dr. Ilyas Cicekli –Office: EA504, –Phone: , – Course Web.
CS510 Compiler Lecture 1. Sources Lecture Notes Book 1 : “Compiler construction principles and practice”, Kenneth C. Louden. Book 2 : “Compilers Principles,
Welcome! Simone Campanoni
CHAPTER 1 INTRODUCTION TO COMPILER SUNG-DONG KIM, DEPT. OF COMPUTER ENGINEERING, HANSUNG UNIVERSITY.
Advanced Computer Systems
Component 1.6.
Compiler Design (40-414) Main Text Book:
COP 5621 Compiler Construction
Chapter 1 Introduction.
Introduction to Compiler Construction
CS 326 Programming Languages, Concepts and Implementation
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
Compiler Lecture 1 CS510.
CMPE 152: Compiler Design December 5 Class Meeting
CS416 Compiler Design lec00-outline September 19, 2018
Introduction to Compiler Construction
Course supervisor: Lubna Siddiqui
Introduction CI612 Compiler Design CI612 Compiler Design.
CSE401 Introduction to Compiler Construction
Compiler Structures 0. Preliminaries
CS416 Compiler Design lec00-outline February 23, 2019
Introduction to Compiler Construction
CISC 7120X Programming Languages and Compilers
Compiler Construction
Lec00-outline May 18, 2019 Compiler Design CS416 Compiler Design.
Introduction to Compiler Construction
Exam Topics Hal Perkins Winter 2008
Presentation transcript:

EECS 483 – Compiler Construction Fall 2006, University of Michigan Scott Mahlke (mall-key) September 6, 2006

- 1 - GSIs and Office Hours v Contacting Scott »Office – 4633 CSE »Office hours – Right after class 12:30 – 1:00pm  Drop by – I will talk to you if I am free  Or make appointment v GSI – Simon Chen »Office hrs – Tue/Thu 1:30 – 3:30pm »Office hrs will be held in the GSI room - 4 th floor CSE »Primary contact for project/coding questions

- 2 - Class Overview v The goal is for you to understand the major parts of a modern compiler (but simplified, no gcc!) »Focus on the concepts in class »Put concepts to work in projects (learn by doing) v Emphasis - 1/2 frontend, 1/2 backend v Caveats »Underlying infrastructure for projects is being redone this semester »The class will be a bit disorganized, so hang in there

- 3 - Background You Should Have v 1. Programming (essential) »Good C/C++ programmer (essential) »Linux, gcc, gdb, emacs, stl »Compiler system not ported to Windows or Mac v 2. Basics of computer organization (helpful) »EECS 370 »RISC architecture, pipelining, registers, assembly code v 3. Basic theory of computation (helpful) »EECS 376 »Finite automata, regular expressions, context-free grammars

- 4 - Textbook and Other Classroom Material v Class textbook »Compilers: Principles, Techniques, and Tools, Aho, Sethi, Ullman (aka red dragon book) v Other useful books »Lex & Yacc, Levine, Mason and Brown »Advanced Compiler Design & Implementation, Steven Muchnick »Building an Optimizing Compiler, Robert Morgan »Modern Compiler Implementation in Java, Andrew Appel v Course webpage + course newsgroup »Will be set up next week »Newsgroup on phorum –  You will need an eecs account  GSI will regularly check this and answer questions  Read regularly, read before asking new questions

- 5 - What the Class Will be Like? v Class meeting time – 10:40 – 12:30, MW »LONG – Bring caffeine!! »We’ll take a short break around 11:30 v Graduate class model »No preset grading curve »No memorizing facts, algorithms, formulas, etc. »But, you will have to be independent in this class and figure some things out yourself  RTFM  Ask when you get stuck on something  But, staring at some code for 2 hours should not seem unreasonable

- 6 - What the Class Will be Like (2) v Learning compilers »Learn by doing – Writing code »Substantial amount of programming »Substantial amount of debugging »Reasonable amount of reading v Classroom »Attendance – You should be here »Print out lecture notes beforehand – notes incomplete »Lots of examples to work out in class

- 7 - Course Grading v Yes, everyone will get a grade... »No preset distribution of grades, scale, etc. »Most (hopefully all) will get A’s and B’s »Projects are essential part of class v Components »Exams (2) – 40% (20% each) »Projects (4) – 55% (10%, 12.5%, 12.5%, 20%) »Homeworks – Practice problems only »Class participation and involvement – 5%

- 8 - Exams v 2 exams, tentatively scheduled for: »Wednes, Oct 25, in class »Monday, Dec 11, in class v Format »Open book/notes – but that doesn’t mean studying is unnecessary »2 hrs »Lecture material, projects v No final exam

- 9 - Homeworks v A couple of these given out during the semester »Not sure how many yet »Optional – not to be turned in v Goals »Learn the important concepts »Practice questions for the exams

Projects v Build most of the important parts of a simple compiler divided into 4 parts 1.Preprocessing, parsing, syntax check 2.Building syntax trees/symbol table 3.Creating assembly code 4.Analysis and optimization of assembly code v Notes »P1-3: Spec of what you need to do »P4: You have to define and decide what to do  Goal is to create the fastest code possible »P1 done individually »P2-4: groups of 2 people

Project Grading v Different from what you may be used to »Each group will set up an appointment »They will give a 5-10 min demo of their code and explain their implementation »Show program running on given inputs, run on unseen inputs »Each group member will be expected to understand the implementation and be able to answer questions about it »Slackers beware!

Class Participation v Interaction and discussion is important, but hard even with a medium size class »Be here and don’t just stare at the wall »Be prepared to discuss the material v Opportunities for participation »Solving class problems »Posting insights on the newsgroup »Feedback to me about the class v Not a large part of your grade »But it will have an affect, particularly in the borderline cases

Course Schedule (subject to change) WeekSubjectReadingProjectsExams 0: 9/6IntroductionCh 1 1: 9/11, 9/13Lexical analysisCh 2-3P1 out, 9/13 2: 9/18, 9/20 Syntax analysisCh 4-5 3: 9/25, 9/27Syntax analysisCh 4-5P1 due, 9/27 4: 10/2, 10/4Syntax, Semantic analysis Ch 4-5 Ch 6 P2 out, 10/2 5: 10/9, 10/11Semantic analysisCh 6 6: 10/16, 10/18Semantic analysisCh 6P2 due, 10/18 7: 10/23, 10/25Exam review, Exam 1E1, 10/25 8: 10/30, 11/1Intermediate codeCh 7-8P3 out, 10/30 9: 11/6, 11/8Control flowCh 9 –10 10: 11/13, 11/15Dataflow and OptiCh 9-10P3 due, 11/15 11: 11/20, 11/22Dataflow and OptiCh 9-10P4 out, 11/20 12: 11/27, 11/29Code generationCh : 12/4, 12/6Code gen, Exam reviewCh : 12/11, 12/13Exam2, Advanced topicsE2, 12/11 15: 12/18P4 demosP4 due, 12/18

Why Compilers? v Compiler »A program that translates from 1 language to another »It must preserve semantics of the source »It should create an efficient version of the target language v In the beginning, there was machine language »Ugly – writing code, debugging »Then came textual assembly – still used on DSPs »High-level languages – Fortran, Pascal, C, C++ »Machine structures became too complex and software management too difficult to continue with low-level languages

Compiler Structure v Source language »Fortran, Pascal, C, C++ »Verilog, VHDL, Tex, Html v Target language »Machine code, assembly »High-level languages, simply actions v Compile time vs run time »Compile time or statically – Positioning of variables »Run time or dynamically – SP values, heap allocation Translator Loader, Linker and Run-time System Output Object Program Source Program

General Structure of a Modern Compiler Lexical Analysis Syntax Analysis Semantic Analysis Controlflow/Dataflow Optimization Code Generation Source Program Assembly Code Scanner Parser High-level IR to low-level IR conversion Build high-level IR Context Symbol Table CFG Machine independent asm to machine dependent Front end Back end

Lexical Analysis (Scanner) v Extracts and identifies lowest level lexical elements from a source stream »Reserved words: for, if, switch »Identifiers: “i”, “j”, “table” »Constants: , 17, “%d\n” »Punctuation symbols: “(“, “)”, “,”, “+” v Removes non-grammatical elements from the stream – ie spaces, comments v Implemented with a Finite State Automata (FSA) »Set of states – partial inputs »Transition functions to move between states

Lex/Flex v Automatic generation of scanners »Hand-coded ones are faster »But tedious to write, and error prone! v Lex/Flex »Given a specification of regular expressions »Generate a table driven FSA »Output is a C program that you compile to produce your scanner

Parser v Check input stream for syntactic correctness »Framework for subsequent semantic processing »Implemented as a push down automaton (PDA) v Lots of variations »Hand coded, recursive descent? »Table driven (top-down or bottom-up) »For any non-trivial language, writing a correct parser is a challenge v Yacc (yet another compiler compiler)/bison »Given a context free grammar »Generate a parser for that language (again a C program)

Static Semantic Analysis v Several distinct actions to perform »Check definition of identifiers, ascertain that the usage is correct »Disambiguate overloaded operators »Translate from source to IR (intermediate representation) v Standard formalism used to define the application of semantic rules is the Attribute Grammar (AG) »Graph that provides for the migration of information around the parse tree »Functions to apply to each node in the tree

Backend v Frontend – »Statements, loops, etc »These broken down into multiple assembly statements v Machine independent assembly code »3-address code, RTL »Infinite virtual registers, infinite resources »“Standard” opcode repetoire  load/store architecture v Goals »Optimize code quality »Map application to real hardware

Dataflow and Control Flow Analysis v Provide the necessary information about variable usage and execution behavior to determine when a transformation is legal/illegal v Dataflow analysis »Identify when variables contain “interesting” values »Which instructions created values or consume values »DEF, USE, GEN, KILL v Control flow analysis »Execution behavior caused by control statements »If’s, for/while loops, goto’s »Control flow graph

Optimization v How to make the code go faster v Classical optimizations »Dead code elimination – remove useless code »Common subexpression elimination – recomputing the same thing multiple times v Machine independent (classical) »Focus of this class »Useful for almost all architectures v Machine dependent »Depends on processor architecture »Memory system, branches, dependences

Code Generation v Mapping machine independent assembly code to the target architecture v Virtual to physical binding »Instruction selection – best machine opcodes to implement generic opcodes »Register allocation – infinite virtual registers to N physical registers »Scheduling – binding to resources (ie adder1) »Assembly emission v Machine assembly is our output, assembler, linker take over to create binary

Why are Compilers Important? v Computer architecture »Build processors that software can be automatically mapped to efficiently »Exploiting hardware features v CAD tools »Behavioral synthesis / C-to-gates tools are hardware compilers »Use program analysis/optimization to generate cheaper hardware v Software developers »How do I create a compiler? »How does it map my code to the hardware