Homework 5: Translation to IR

Due Tuesday, 11 March 2008, 6 PM

Finally we start actually compiling!

Homework 5 is to read Chapter 7 of the text and build a module to translate Tiger ASTs to an IR tree.

In the last two projects, the Translate module has gone from an empty stub to a small collection of frame-manipulation utilities. Now we finally flesh it out to do real translation.

You will need to augment existing structures as described in Chapter 7. You may define the Frame.procEntryExit1 function as a stub (we'll come back to it at a later date). Make sure you use it, however, in your translation code.

The definition of the TRANSLATE interface is part of this project; define it with your teammates. You may discuss it outside your team in general terms, but no code on the mailing list, please.

Your Semant module should export a transProg function which is the ultimate AST-to-IR interface for the whole post-parser ensemble of modules we have constructed up to this point.

You are required to handle evaluation-for-control (Cx expressions) in a reasonably sophisticated manner. For example,

    if a < 0 || x > y
      then ...
      else ... 

should translate into a reasonable tree of conditional tests and branches. This may require some thought.

You should submit

I predict you will find this part of the compiler the most fun yet.


Last updated 12 March 2008.

Valid XHTML 1.1 Valid CSS!