Project 6
Due on April 14th 11:59 PM (Accepted with no penalty).
Accepted late by April 15th 11:59 PM for 1 penalty
Accepted late by April 16th 11:59 PM for 2 penalties
Not accepted on or after April 17th 12:00 AM
Each penalty incurs a 15% stacking reduction on the project grade or uses 1 "penalty token". Penalty tokens are applied by course personnel to your maximum benefit.
  • The starter code will be released shortly.
  • The oracle will be released shortly.
  • The kickstart video will be available soon.

For this assignment you will covert the Abstract-Syntax Tree of the Jeff program to a flat 3AC representation. Your main task will be to write conversion functions for the nodes of the AST.

Your compiler must accept an option

-a <3acFile>

that outputs the 3AC code for a given input program to the provided file.


Your grade will be based on your compiler's ability to build a 3AC respresentation of an input program. In order to demonstrate the correctness of your transformation, we will apply a number of test programs to your submitted compiler and compare the output to what we expect. We will invoke your compiler in a way similar to the below sequence of commands:

	tar -xf p6.tgz
	cd p6_files
	jeffc <case1jeff> -a <case1.out>
	jeffc <case2jeff> -a <case2.out>
	jeffc <caseNjeff> -a <caseN.out>

Where <case1jeff> ... <caseNjeff> are input files and <case1.out> ... <caseN.out> are the corresponding output files.

We will expect your compiler to output 3AC code that preserves the semantics of the original program in a straightforward way. However, since there are many methods to represent a program, we will not require an exact match to our reference implementation. To ensure that your output is easy to understand, you should adhere to the specifications listed in the Output Specifications section, below.

Output Specifications

The 3AC format that we will use for this project will track closely with that presented in class (Instructions/quads must adhere to the 3AC rules, operands must be atomic values, and instructions are organized into procedures).

Instruction Formats

The instruction format is provided to you as part of the 3ac_quads files (as constructed by the toString() function of the abstract Quad class, with assistance from the various Quad subclasses.

In general, you should follow the instruction format and overall 3AC listing that is already present in the 3ac_quads.cpp output functions (toString and repr). Once the oracle is released, it will also give you a reasonable example of an output format. However, if you stick to the output format already coded up, we will accept your code.

Your Assignment

To complete this assignment, you should fill out the to3AC and flatten functions that are provided in skeleton form in 3ac_output.cpp.

If you would like to change the format of a 3AC instruction or you would like to add a 3AC instruction to the set, you may do so with approval of course staff. Please post your request on Piazza.

You are free to modify any and all other files provided to you, provided you follow the basic rules of the course (your code must be your own, must compile and run on the cycle servers, and should not unduly affect the system).

Hints and Advice

Believe in yourself! Also, make sure to watch the Project 6 video to get an overview of the project.