Due: 10:00 pm, Wednesday, October 27.
Project 4 is to read chapter six of the text and build a frame analyzer for Appel's Tiger language.
Your code should take an AST and:
You should implement a MipsFrame
structure satisfying
the FRAME
signature as discussed in chapter 6 of the course text.
Note that this is not the final version of the FRAME
interface;
we'll be extending the FRAME
signature in the future.
For a complete description of the signature, see program 12.1,
which is on page 260 of my edition of the textbook.
(This may explain why you may be hunting in vain through
chapter 6 and $TIGER/chap6
for the signature…)
You will need to augment your existing
Semant
and Env
structures
as well as implement at least three other structures:
FindEscape
(escape analysis), and
MipsFrame
& Translate
(managing stack frames and lexical nesting).
You are required to allocate "temps" (abstract registers) for non-escaping variables; they should not go in the stack frame. While this happens first in the processing of the AST, I advise you to write it last.
Undergraduates are not required to handle more than four procedure parameters. That is, you can assume all parameters are passed in the registers. You are encouraged, however, to handle more than four (and you'll receive extra credit for doing so).
You should submit the following files:
mipsframe.sml
— MipsFrame
structurefindescape.sml
— FindEscape
structuretranslate.sml
— Translate
structuresemant.sml
— Updated Semant
structuresources.cm
fileWord to the wise: The tricky part of this project is working with the "static link" pointers in the frames to access non-local variables that occur in outer scopes. This requires small amounts of code but large amounts of thought.
–Olin