CMP 2
From LRDE
This page contains the log of the topics of the Compiler Construction Course 1 and Compiler Construction Course 2 for class EPITA 2009 (i.e., from February 2007 to July 2007). The topic was started with the Formal Languages Lecture; see the ThlLog2009.
Week 1: 2007-02-27: Introduction to the Project, Development Tools (Roland, Akim)
- The Tiger Project
- Ressources (http://www.lrde.epita.fr/~akim/compil/)
- Assignments (http://www.lrde.epita.fr/~akim/compil/assignments.html)
- Appel's books
- Tiger Compiler Reference Manual (http://www.lrde.epita.fr/~akim/compil/tiger.html)
- epita.cours.compile
- Goals (C++, OO, DP, Management, Several Iterations, Testing, Documenting, Maintaining, Fixing, Understanding Computers, English)
- Non goals (Compiler Construction)
- Rules of the Game
- No copy between groups
- Tests are part of the project (test cases and frameworks should not be exchanged)
- Fixing mistakes earlier is better
- Work between groups is encouraged as long as they don't cheat
- Tests
- Tests matter
- Rules
- A bug => a test
- A suspicious behavior => one or several tests to isolate it
- Don't throw away tests!
- Don't exchange tests! (bis repetita)
- C Compilation model (cpp, cc1, as, ld)
- The Tiger Compiler pipe (annoted with tools and steps)
- Front-end: TC-0 - TC-6 (mandatory part)
- Back-end: TC-7 - TC-9 (optional part)
- Width of a compiler pipe (line, function, compilation unit)
- Misc: students should overcome Make, Makefiles and seperate compilation, etc.
- Ressources (http://www.lrde.epita.fr/~akim/compil/)
- Development Tools (See the lecture notes:
dev-tools.pdf and dev-tools-handout-4.pdf)
Week 2: 2007-03-06: History of Programming Languages, Early Computers (Akim)
Week 3: 2007-03-13: Abstract Syntax (Roland)
- See the lecture notes, ast.pdf and ast-handout-4.pdf
(Week 4: 2007-03-20: Canceled)
Week 5: 2007-03-27: Leopard, OOP (intro), Misc. on LC-2, Scanner (late course), Names and Bindings (Roland)
- Introducing Leopard
- Renaming of the language and the project
- New features: object-oriented programming
- New elements of (concrete) syntax
- New nodes of the abstract syntax
- A bit of object semantics
- Examples
- LC-2: Miscellaneous
- Why, DefaultVisitor
- std::ios_base::xalloc, lib/misc/indent.{hh,cc}, misc::xalloc
- Scanner (late course). See the lecture notes, scanner.pdf and
- Symbols, Identifiers and Bindings. See the lecture notes, names.pdf and
Week 6: 2007-04-03: Names (cont.), Q&A on LC-2, AST transformations in concrete syntax, Object-Oriented Programming (Roland)
- Symbols, Identifiers and Bindings (cont.). See the lecture notes, names.pdf and
- (Questions and) Anwers on LC-2
- C++ traits
- lib/misc/select-const.hh, and its use in ast::GenVisitor and ast::GenDefaultVisitor
- DefaultVisitor::decs_visit
- misc/indent.{hh,cc}
- Removing the syntactic sugar in concrete syntax
- Why it matters
- An example: desugaring boolean operators (&= and =||)
- in abstract syntax
- in concrete syntax
- How it works: TWEASTS (Text With Embedded Abstract Syntax Trees, ast::Tweast), metavariables (ast::MetavarMap), and their use from the parser.
- More desugaring
- astclone::Cloner
- related features in the Leopard Compiler (modules desugar and inline)
- a (quick) example: turning for loops into while loops
- Object-Oriented Programming. See the lecture notes, object.pdf
Week 7: 2007-04-10: Type-checking (Roland)
- Types. See the lecture notes, type-checking.pdf
and type-checking-handout-4.pdf
- Sequent Calculus
- In English: "If alpha is of type Int in the context Gamma and beta is of type Int in the context Gamma,
then alpha + beta is of type Int in the context Gamma."
- Using symbols (where ||- ("tee" or "turnstile") is the symbol meaning "yields" or "proves"):
%TABLE{tableborder="0" tablerules="rows" cellpadding="3" cellspacing="3" databg="none"}%
Γ |- α : Int Γ |- α : Int |
Γ |- α + β : Int |
- Type inference
- (a_ ? _b : _c_) > 0
- (a_ ? _b : f_ (_b)) > 0
- (a_ ? _b : f_ (_c)) > 0
- Type inference
- Questions and Anwers on LC-4
- solving forward references and mutual recurrences: the dual-visit scheme (visitDecHeader, visitDecBody)
- Hierarchy of types (src/types/)
Warning: Display title "CMP 2" overrides earlier display title "CMP 1".
Week 1: 2007-05-03: Intermediate languages, part 1 (Roland)
- Intermediate languages. See the lecture notes, intermediate.pdf and intermediate-handout-4.pdf (pages 1 to 48)
Week 2: 2007-05-10: Intermediate languages, part 2 (Roland)
- Intermediate languages. See the lecture notes, intermediate.pdf and intermediate-handout-4.pdf (pages 49 to 82)
Week 3: 2007-05-15: LC-5, Canonization (LC-6) (Roland)
- Intermediate languages. See the lecture notes, intermediate.pdf and intermediate-handout-4.pdf (from page 82 up to the end)
Week 4: 2007-05-24: RISC and MIPS (Roland)
- Subprograms. See the lecture notes, subprograms.pdf and subprograms-handout-4.pdf
- The RISC architecture and the MIPS R2000 assembly language. See the lecture notes, instr-selection.pdf and instr-selection-handout-4.pdf (first half)
Week 5: 2007-06-07: Instruction selection (LC-7) and liveness analysis (LC-8) (Roland)
- Instruction selection. See the lecture notes, instr-selection.pdf and instr-selection-handout-4.pdf (second half)
- Samples of MonoBURG inputs from the Leopard Compiler.
- Liveness analysis. See the lecture notes, liveness.pdf and liveness-handout-4.pdf
Week 6: 2007-06-14: Register allocation (Roland)
- Register allocation. See the lecture notes, regalloc.pdf and regalloc-handout-4.pdf