Instructor:
Steve Zdancewic    e-mail: cis341 (AT) seas.upenn.edu
    office hours: Tues. 4:00-5:00 pm (and by appointment) Levine 511
Teaching Assistants:
Dmitri Garbuzov      e-mail: cis341 (AT) seas.upenn.edu
      office hours: TBA
Richard Zhang
      e-mail: cis341 (AT) seas.upenn.edu
      office hours: Tues. 12:30-1:30 (Levine
6th floor bump space)
Jae Joon Lee
      e-mail: cis341 (AT) seas.upenn.edu
      office hours: Mon. 7:00-9:00pm JMHH F80
Vivek Raj
      e-mail: cis341 (AT) seas.upenn.edu
      office hours: Fri. 9:00-10:00am and 2:00-3:00pm (Levine
6th floor bump space)
Course information:
  time: TR 9:00am - 10:30am  room: Meyerson Hall B3
  piazza: cis341
Prerequisites: CIS 121 and CIS 240
Topics:
- Lexing/Parsing
- Code generation
- Semantic analysis
- Optimization
- Run-time support
Reading and References
The following books contain useful course material, and much of the lecture content is derived from them (and other sources).
- Compilers (2nd edition) by Aho, Lam, Sethi, and Ullman
- Advanced Compiler Design and Implementation by Muchnick
- Modern Compiler Implementation in ML by Appel
- Real World OCaml
- OCaml Programming Style Guide
- The Caml Web Site, particularly the documentation and users' manual and the standard libraries
- OCaml.org
- Developing Applications with Objective Caml by Emmanuel Chailloux, Pascal Manoury and Bruno Pagano
- Introduction to Objective Caml by Jason Hickey
Projects: The Quaker OAT Compiler
There are a total of 8 homework projects. Homework 1 is an individual assignment. The rest of the projects are pair-programming projects -- students are strongly encouraged to work in pairs, but may ask permission to work alone on them.
Here are instructions for getting access to the tools you need to complete course assignments.
- Homework 1: Hellocaml
Due: Jan. 19 at 11:59:59pm - Homework 2: X86lite
Due: Feb. 2 at 11:59:59pm - Homework 3: Compiling LLVMlite
Due: Feb. 23 at 11:59:59pm - Homework 4: Compiling Oat v.1
Due: March 28st at 11:59:59pm - Homework 5: Full Oat
Due: April 13th at 11:59:59pm - Homework 6: Dataflow Analysis and Register Allocation
Due: April 26th at 11:59:59pm
Grading Criteria
- 12% Midterm - Date: March 2nd, in class.
- Midterm (2015) and Solutions (2015)
- Midterm (2011) and (partial) Solutions (2011)
- Midterm (2013) and (partial) Solutions (2013)
- 18% Final exam - Date: Thursday, May 4th noon - 2:00p.m.
Solutions (2017)
- Final Exam (2013) and (partial) solution
- Final Exam (2011) and (partial) solution
- 70% Course projects (pair projects)
Lecture Slides and Notes
Note: The following schedule is tentative!Date | Topic | Slides | Handouts |
---|---|---|---|
1/10 |
|
||
1/12 |
Introductions: Compilers, Interpreters, and OCaml | lec01.pdf |
lec01.zip |
1/17 * |
OCaml Crash Course: Translating Simple to OCaml | lec02.pdf |
lec02.zip |
1/19 * |
X86lite & metaprogramming | lec03.pdf |
|
1/24 |
X86lite programming / C calling conventions | lec04.pdf |
lec04.zip |
1/26 |
Intermediate Representations I | lec05.pdf |
compiler1.zip |
1/31 |
Intermediate Representations II | lec06.pdf |
lec06.zip | -->
2/2 |
IRs III / LLVM | lec07.pdf |
lec07.zip factorial.ll |
2/7 |
Structured Data in the LLVM IR | lec08.pdf |
struct.c struct64.ll |
2/9 |
NO CLASS! (Snow Day) | ||
2/14 |
Structured Data II / LLVMlite | lec09.pdf |
See HW3 |
2/16 |
Lexing: DFAs and ocamllex | lec10.pdf |
lec10.zip |
2/21 |
Parsing I: Context Free Grammars | lec11.pdf |
lec11.zip |
2/23 |
Parsing II: LL(k) parsing, LR(0) parsing | lec12.pdf |
parser.ml |
2/28 |
Parsing III: LR(1) Parsing and Menhir | lec13.pdf |
lec13.zip |
3/2 |
Midterm Exam | |
|
3/7 |
no class | |
Spring Break |
3/9 |
no class | |
Spring Break |
3/14 |
NO CLASS! (Snow Day) | (none) |
|
3/16 |
Typechecking: Inference Rules | lec14.pdf |
|
3/21 |
First-class Functions I | lec15.pdf |
|
3/23 |
First-class Functions II: Interpreters | lec16.pdf |
fun.ml |
3/28 |
Closure Conversion and Types I | lec17.pdf |
lec17.zip" |
3/30 |
Types II : Subtyping and Semantics | lec18.pdf |
|
4/4 |
Subtyping and Inheritance | lec19.pdf |
|
4/6 |
OO: Dynamic Dispatch | lec20.pdf |
|
4/11 |
OO: Multiple Inheritance / Optimizations I | lec21.pdf |
|
4/13 |
Optimizations II / Data Flow Analysis | lec22.pdf |
|
4/18 |
Register Allocation | lec23.pdf |
|
4/20 |
Data Flow Analysis II | lec24.pdf |
|
4/25 |
Control Flow Analysis / SSA Revisited | lec25.pdf |
|
5/4 |
Final Exam: noon - 2:00pm, DRLB A4 | |
Many of the slides in these lectures have been adapted (with permission) from course materials by Andrew Myers at Cornell University and Greg Morrisett at Harvard University.

Course Policies
General Project Guidelines
- Groups:
Teams for group projects will consist of one or two students. - Difficulty:
The course projects are challenging and time consuming. They may require significant effort to understand the implementation details and concepts:Start Early! - Late Projects:
All projects are due at 11:59pm on the due date.- Projects submitted late, but within 24 hours of the deadline are subject to a 15 point penalty.
- Projects submitted late, but between 24 and 48 hours of the deadline are subject to a 30 point penalty.
- If, for some reason, you have an extension of less than 48 hours on the homework, the extension only overrides the associated late penalty -- it does not extend the late period!
- Regrade Policy:
Regrade requests should be sent to the TA. Only reasonable requests will be considered. The entire project or exam will be regraded. Note that this means that the score on a regraded project might decrease.
Submission Policy
- Projects that do not compile will get no credit.
- Projects that compile will receive partial credit according to the grading guidelines provided in the project description.
Academic Integrity
This course will abide by the University's Code of Academic Integrity. In particular, for individual projects and group projects, the following guidelines should be followed:- For individual projects, you must type in and edit
your own code, documentation, and any other materials submitted
for grading.
- Copying someone else's file is not allowed.
- Allowing someone else to copy a file of yours, either explicitly or implicitly by leaving your code unprotected, is not allowed.
- Editing each other's files is not allowed
- Regarding the ethics of what you may or may not discuss with
others:
- "High level" discussions are fine.
For example, discussions about the problem statement. - "Low level" discussions are fine.
For example, discussions about OCaml syntax or using omake, understanding compiler error messages, understanding the mechanics of the tools and libraries used for the projects. - "Mid level" discussions require
discretion. In this CIS course, discussions at this
level must be limited. Unless explicitly stated
otherwise, you may not collaborate significantly with
classmates (except group project members) at this level.
If you have minor discussions with others at this level or get
help from outside resources (tutors, web sites, etc), you must
cite in the readme of the submitted projects the names of the
people or websites who helped you and how they did. For
example:
Name: Chris Brown Email: ***@seas.upenn.edu I received tips from Jo Johnson on the i/o and example.com/mem.htm on memory ...
- "High level" discussions are fine.
- If there is any doubt about the use of external sources or collaboration, please ask for clarification by the course staff.