CS 434
Compiler Design


The design and construction of a compiler involves both theoretical issues of algorithm design and practical issues of software engineering. In this course we will look at both of these aspects of compiler construction. The course will involve a large software project intended to expose you to the engineering aspects of managing a large project and to familiarize you with the basic problems that must be addressed in any compiler. In class, we will explore the techniques that have been developed for lexical analysis, parsing, code generation and optimization.

Instructor

Tom Murtagh
Office: TCL 306
Phone: 597-2369
Hours: Tue., Wed.: 2:00 - 4:00 & Thurs.: 2:30 - 4:00

Texts

A+U
Aho, Alfred V. and Ullman, Jeffrey D., Principles of Compiler Design, Addison Wesley Publishing Co., 1978.
AS+U
Aho, Alfred V., Sethi, Ravi and Ullman, Jeffrey D., Compilers: Principles, Techniques and Tools, Addison Wesley Publishing Co., 1986.
C+T
Cooper, Keith and Torczon, Linda, Engineering a Compiler, Morgan-Kaufmann Publishers, 2004.
K+R
Kernighan, B.W. and Ritchie, D.M., The C Programming Language, Prentice Hall, 1978.

There are no required texts for this course. I will place a copies of all the texts listed above on reserve, but...

I strongly suggest you get a copy of the Kernighan and Ritchie text on C if you are not already comfortable programming in C.

I also strongly recommend that you purchase a copy of the text by Cooper and Torczon. For many years, I have taught this course without a text, relying instead on distributing my own course notes. I will continue to distribute these notes, but after examining the Cooper and Torczon text, I decided (at the last minute) that it would be nice to try to integrate this relatively new text into the course. Given that I know that I have presented the material without a text many times, I didn't quite have the confidence to make it a required text, but I think you will all find it valuable.

Below, in the list of topics planned for our class meetings, I have indicated which sections of these texts might be appropriate readings to accompany the topics discussed in class. I have used the authors initials (i.e. C+T, A+U, ...) to refer the texts in the list of readings. I will provide additional guidance to possible readings in class when appropriate.

Lectures and Readings

The following is a tentative schedule of lectures with associated readings.

Date Topic Readings

1. 2/2

The Structure of a Compiler.
  • C+T Ch. 1.
  • A+U Ch. 1.
  • AS+U Chs. 1 + 2.

2. 2/7, 2/9

Symbol Table Organization.
  • C+T Ch. 5 ( §5.1-5.4, 5.7 )
  • A+U Ch. 9.
  • AS+U §7.6.

3. 2/14

Run-time Storage Organization.
  • C+T Ch. 6 ( §6.1-6.5 )
  • A+U Ch. 10 (except §10.3).
  • AS+U §7.1-7.4.

4. 2/16

Variable Reference and Type Checking.
  • C+T §4.1, 4.2, 4.4
  • AS+U §6.1-6.4, 8.2.

5. 2/21

Formal Specification of Syntax.
  • C+T §3.1, 3.2
  • A+U Ch. 4.
  • AS+U §4.1-4.3.

6. 2/23, 2/28

Code Generation for Expressions.
  • C+T §7.1 - 7.7
  • A+U §7.1-7.8, 8.1.
  • AS+U §8.1, 8.3, 9.1.

7. 3/2

Code Generation for Control Structures.
  • C+T §7.8
  • A+U §7.9.
  • AS+U §8.4.

8. 3/7, 3/9

An Introduction to Parsing.
  • C+T §3.3, 3.4.1, 3.4.2
  • A+U §5.1, 5.2, 5.4.
  • AS+U §4.4, 4.5.

9. 3/14, 3/16

Working with Lex and Yacc.

10. 4/4, 4/6

Intro. to LR Parsing.
  • A+U §6.1-6.2.
  • AS+U §4.7 (up to p. 227).

11. 4/11

Code Generation for Procedures and Procedure Calls.
  • C+T §7.9, 7.10
  • A+U §8.2.
  • AS+U §8.7.

12. 4/13

More Code Generation & the Correctness of LR(0) parsing
  • A+U §6.3.
  • AS+U §4.7 (pp. 227-230).

13. 4/18

Dynamic Memory Management
  • C+T §6.7
  • F+L §9.3
  • AS+U §7.7-7.8

14. 4/20, 4/25, 4/27

SLR, LR(1) and LALR Parsing.
  • C+T Ch. 9.
  • A+U §6.4, 6.5.
  • AS+U §4.7 (pp. 230 -> ).

15. 4/27, 5/2

Basic Code Improvement Techniques.
  • C+T §8.1 - 8.5
  • A+U Ch. 12.
  • AS+U §10.1-10.3.

16. 5/4, 5/9, 5/11

Analysis for Code Improvement.
  • Briggs, P., K. D. Cooper, , and L.T. Simpson, Value Numbering, Software-Practice and Experience, Vol 27(6), 701-724 (June 1997).

Assignments, Projects and Grading

Most of the programming assignments for the course will be components of the construction of a compiler for a specially designed programming language. In addition, there will be written assignments designed to expose you to aspect of compiler construction not touched on in the main project. Your work on all homeworks and programs must conform to the "Honor Code Guidelines for Computer Science Courses" handout which I will make available. In interpreting these guidelines all the programs in this course should be treated as "homework programs".

There will be a midterm (probably) and a final examination. Final grades will be based on an average obtained by treating homework scores as 15%, project grades as 35%, the midterm as 20% and the final as 30%.

Woolite Project Schedule


Phase Assigned Duration Description
1.1 2/9 12 days Basic Declaration Processing: Type and Variable Declarations
1.2 2/21 7 days Identifier Reference Processing and Type Checking
2.1 3/2 12 days Code Generation for Expressions
2.2 3/14 9 days Code Generation for Control Structures
2.3 3/16 12 days? Code Generation for Methods
??? 4/11 9 days Parser and Scanner Construction
3.1 4/20 12 days Constant Folding
3.2 5/2 10 days Garbage Collection