Compiler Construction - Lecture Slides - Fall 2004 | EECS 583, Study Guides, Projects, Research of Electrical and Electronics Engineering

Material Type: Project; Professor: Mahlke; Class: Advanced Compilers; Subject: Electrical Engineering And Computer Science; University: University of Michigan - Ann Arbor; Term: Fall 2004;

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 09/02/2009

koofers-user-2tx-1
koofers-user-2tx-1 🇺🇸

10 documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EECS 483 – Compiler
Construction
Fall 2004, University of Michigan
Scott Mahlke (mall key)
Mike Chu (guest speaker today)
September 8, 2004
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download Compiler Construction - Lecture Slides - Fall 2004 | EECS 583 and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!

EECS 483 – CompilerConstruction

Fall 2004, University of Michigan Scott Mahlke (mall key) Mike Chu (guest speaker today) September 8, 2004

GSIs and Office Hours

Y

Contacting Scott

» [email protected] » Office - 2223 EECS » Office hours - TBD Y

GSI

» Yuan Lin – [email protected] » Office hrs – Will be announced next week » Office hrs will be held in the media union » Primary contact for project/coding questions

Background You Should Have

Y

1. Programming

» Good C++ programmer (essential) » Linux, gcc, gdb, emacs, cvs, stl » Compiler system not ported to Windows or Mac Y

2. Basics of computer organization

» EECS 370 » RISC architecture, pipelining, registers, assembly code Y

3. Basic theory of computation

» EECS 376 » Finite automata, regular expressions, context-free grammars

  • 4 -

Textbook and Other Classroom Material

Y Class textbook » Compilers: Principles, Techniques ,^ and Tools , Aho, Sethi, Ullman (aka red dragon book) Y 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 Y Course webpage + course newsgroup » Will be set up next week » Newsgroup – umich.eecs.class. y GSI will regularly check this and answer questions y Read regularly, read before asking new questions

What the Class Will be Like (2)

Y

Learning compilers

» Learn by doing – Writing code » Substantial amount of programming y Learning curve for MIRV » Reasonable amount of reading Y

Classroom

» Attendance – You should be here » Print out lecture notes beforehand – notes incomplete » Lots of examples to work out in class

Course Grading

Y

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 Y

Components

» Exams (2) – 40% (20% each) » Projects (4) – 55% (10%, 12.5%, 12.5%, 20%) » Homeworks – Practice problems only » Class participation and involvement – 5%

Homeworks

Y

A couple of these given out during the semester

» Not sure how many yet » Optional – not to be turned in Y

Goals

» Learn the important concepts » Practice questions for the exams

Projects

Y

Build most of the important parts of a simplecompiler divided into 4 parts 1.

Preprocessing, parsing, syntax check

Building syntax trees

Creating assembly code

Analysis and optimization of assembly code Y

Notes »

P1-3: Spec of what you need to do » P4: You have to define and decide what to do y Goal is to create the fastest code possible » P1 done individually » P2-4: groups of 2-3 people

Class Participation

Y

Interaction and discussion is important, but hardin a large class

» Be here and don’t just stare at the wall » Be prepared to discuss the material Y

Opportunities for participation

» Solving class problems » Posting insights on the newsgroup » Feedback to me about the class Y

Not a large part of your grade

» But it will have an affect, particularly in the borderline cases

  • 13 -

Course Schedule

Week Subject Reading Projects Exams 0: 9/ Introduction Ch 1 1: 9/13, 9/ Lexical analysis Ch 2- P1 out, 9/ 2: 9/20, 9/ Syntax analysis Ch 4- 3: 9/27, 9/ Syntax analysis Ch 4- P1 due, 9/ 4: 10/4, 10/ Syntax analysisMIRV / Semantic Ch 4-5Ch 6 P2 out, 10/ 5: 10/11, 10/ Semantic analysis Ch 6 6: 10/18, 10/ Semantic analysis Ch 6 P2 due, 10/ 7: 10/25, 10/ Exam reviewExam 1 E1, 10/ 8: 11/1, 11/ Intermediate code Ch 7- P3 out, 11/ 9: 11/8, 11/ Control flow Ch 9 – 10: 11/15,11/ Dataflow and Opti Ch 9- P3 due, 11/ 11: 11/22,11/ Dataflow and Opti Ch 9- P4 out, 11/ 12: 11/29, 12/ Code generation Ch 9- 13: 12/6, 12/ Code gen, reviewExam 2 Ch 9- E2, 12/ 14: 12/ Advanced topics 15: 12/17,12/ P4 demos P4 due

  • 15 -

Compiler Structure

Y Source language » Fortran, Pascal, C, C++ » Verilog, VHDL, Tex, Html Y Target language » Machine code, assembly » High-level languages, simply actions Y Compile time vs run time » Compile time or statically – Positioning of variables » Run time or dynamically – SP values, heap allocation Translator Loader, Linkerand Run-time System Output ObjectProgram SourceProgram

  • 16 -

General Structure of a Modern Compiler

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

Lex/Flex

Y

Automatic generation of scanners

» Hand-coded ones are faster » But tedious to write, and error prone! Y

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

Y

Check input stream for syntactic correctness

» Framework for subsequent semantic processing » Implemented as a push down automaton (PDA) Y

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 Y

Yacc (yet another compiler compiler)/bison

» Given a context free grammar » Generate a parser for that language (again a C program)