This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CS 143 Compilers Handout 9 Programming Assignment IV Due Thursday, November 19th, 2009 at 11:59 PM 1 Introduction In this assignment, you will implement a code generator for Cool. When successfully completed, you will have a fully functional Cool compiler! The code generator makes use of the AST constructed in PA3 and static analysis performed in PA4. Your code generator should produce MIPS assembly code that faithfully implements any correct Cool program. There is no error recovery in code generation—all erroneous Cool programs have been detected by the front-end phases of the compiler. As with the static analysis assignment, this assignment has considerable room for design decisions. Your program is correct if the code it generates works correctly; how you achieve that goal is up to you. We will suggest certain conventions that we believe will make your life easier, but you do not have to take our advice. As always, explain and justify your design decisions in the README file. This assignment is about twice the amount of the code of the previous programming assignment, though they share much of the same infrastructure. Start early! Critical to getting a correct code generator is a thorough understanding of both the expected behavior of Cool constructs and the interface between the runtime system and the generated code. The expected behavior of Cool programs is defined by the operational semantics for Cool given in Section 13 of the Cool Reference Manual . Recall that this is only a specification of the meaning of the language constructs—not how to implement them. The interface between the runtime system and the generated code is given in The Cool Runtime System . See that document for a detailed discussion of the requirements of the runtime system on the generated code. There is a lot of information in this handout and the aforementioned documents, and you need to know most of it to write a correct code generator. Please read thoroughly. You may work in a group of one or two people. 2 Files and Directories To get started, create a directory where you want to do the assignment and execute one of the following commands in that directory. If you are using C++, run this command to get the initial skeleton: make -f /usr/class/cs143/assignments/PA5/Makefile For Java, type: make -f /usr/class/cs143/assignments/PA5J/Makefile (notice the “J” in the path name). As usual, there are other files used in the assignment that are symbolically linked to your directory or are included from /usr/class/cs143/include and /usr/class/cs143/src . You should not modify these files. Almost all of these files have been described in previous assignments. We now describe the most important files for each version of the project....
View Full Document
This note was uploaded on 01/12/2010 for the course CS 143 at Stanford.