Information on SUIF project

A short assignment using the Stanford SUIF compiler infrastructure is required to be submitted by all students.  Students will write a SUIF pass doing a simple compiler transformation.  The purpose of the assignment is to familiarize students with the use of SUIF, rather than require a large, complex project.  Collaboration (up to 2 students per group) is allowed.

Due date:    May 9 (Wednesday), 2007.
 

Collaboration policy

Students can do the project in groups of up to two students.  Only one set of submissions needs to be handed in per group.  Each group member is expected to play an active role in all aspects of the project.

Topics for project

A list of three suggested assignments is below - choose any one.  Alternatively, students may pick their own assignment topic, provided it is approved by the instructor. 

(a) Loop unrolling:  Unroll all nicely-structured FOR loops by a factor provided by a command-line parameter. In particular, nicely-structured loops are represented as TREE_FOR SUIF nodes: these are the only ones that need to be handled.  A pre-header/epilogue must be generated as needed for correctness.  For nested loops, only innermost loops (i.e, loops not containing other loops within them) should be unrolled.

(b) Procedure inlining:  Inline procs named "inline_...". You can assume that the input never contains recursive (or cross-recursive) procedures that need to be inlined.

(c) Break expression trees: Expression trees are SUIF instructions whose operands are themselves instructions. Breaking expression trees will effectively result in three-operand form for instructions. Insert new temporaries as needed.

Location of software and SUIF documentation

The SUIF software is at the following directory on glue:

    /afs/glue/class/old/enee/759c/newsuif/

Before starting the project, please read the following two documents in the order given as documentation on learning SUIF:

    /afs/glue/class/old/enee/759c/newsuif/doc/learning_suif/main.pdf

    /afs/glue/class/old/enee/759c/newsuif/doc/writing_suif/main.pdf

Sample programs

You should demonstrate that your project works by running your code on the sample programs listed below:

Project 1
See /afs/glue/class/old/enee/759c/newsuif/pgm/apps/projects/1/.

There are two subdirectories in the above directory, sample1/ and sample2/, each containing a C program in file main.c. These are the two sample programs for
unrolling. Please recall that only the inner loops of nested loops should be unrolled.

Project 2
See /afs/glue/class/old/enee/759c/newsuif/pgm/apps/projects/2/.

There are two subdirectories in the above directory, sample1/ and sample2/, each containing a C program in file main.c. These are the two sample programs for
inlining. Please recall that all procedures with names beginning with "inline_..." should be inlined.


Project 3
See /afs/glue/class/old/enee/759c/newsuif/pgm/apps/projects/3/.

There is single sample program in the above directory, sample/main.c. This is the same program for converting all instructions to three operand form. Please note that
all expression trees should be dismantled, including those which are embedded in high-level control structures, such as loops and if statements. 

Answer checking on sample programs

Each of the sample programs above prints a single number as output. This makes it easy for you to check that your compiler transformation is legal. That is, the program should return the same answer before transformation as after.

To check the answer of any C program, compile and run it using gcc. For example:

% gcc -o main main.c

compiles the original program in main.c into an executable main.

% main

The above will run the executable. Make a note of the answer printed. To test the output of your compiler transformation, convert the SUIF file into a C file (with a .s2c extension),
rename it to have a .c extension, and the compile and run it in a manner similar to the above. If your pass is correct, the transformed program should return the same answer as the original program.

Submission of the project: time and method
Students should show me their projects sometime on May 9 (Wednesday) in a particular glue lab (venue to be announced).   I will pass around a sign-up sheet in an earlier class listing 15 minute appointment slots during that time for demonstrations. Each group should sign in for one time slot only according to their convenience.
If no time listed is convenient, talk to me, and we will make other arrangements.

The following materials are expected as submission for the project. Each group should only hand in one set of materials. They should be handed to me during the time of the demonstration.

(1) A printout of the SUIF code that you wrote, and the rules Makefile that you used.

(2) A printout of the outputs of the sample programs for your project. In addition, printouts of additional programs that you wrote are also welcome, if you think they demonstrate additional capabilities. (If you could not get your pass to work correctly on the sample program(s), then printouts of simpler programs that you wrote that do work correctly, before and after transformation, should be handed in.) 

(3) In addition to the above printouts, please email to me your C++ SUIF code as an email attachment (tar file containing directory with your code).

The printouts you hand in should contain the names of the project partners and the project selected!