COS 320, Spring 2000. Programming Assignment

Programming Assignment 7: Basic Blocks and Traces

Note: For this project, you must run sml and gcc on the sparc machines such as arizona.  This isn't as bad as it sounds. Map your OIT account space as a drive on your home computer (see You can now edit OIT files on your home computer as if they were local.


1) Copy /u/cos320/proj7/* into a new directory proj7.

2) Untar CM.tar into the directory proj7.

3) Copy your working tiger.lex and tiger.grm from assignment 4. If you don't have working versions, then don't copy them! CM will automatically use versions that are provided.


This assignment is based on chapter 8 of your textbook. Please read it before starting.  The objective of this assignment is to fill in the "..." holes in canon.sml.

There are three main steps.

1) Creating canonical trees (the linearize function)

2) Finding basic blocks (the basicBlocks function)

3) Creating a trace (the traceSchedule function)


To view the canonical trees, run:

    Main.linearize "filename";

To view the basic blocks, run:

    Main.basicBlocks "filename";

To view the created trace, run:

    Main.traceSchedule "filename";

To test the completed project:

1) Run Main.compile "filename.tig";  This will generate a "filename.tig.s" assembly file.

2) Run "gcc runtime.c filename.tig.s" on arizona;  This will generate an "a.out" binary file.

3) Run the a.out binary file.


You must submit the file "canon.sml."

Please test your code with at least queens.tig, merge.tig, and merge-sort.tig.