Classes have been dropped for this project, you don't need to worry about MemberField access or class declarations.
For this assignment you will covert the Abstract-Syntax Tree of the Drewno Mars 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
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 representation 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 make dmc <case1.dm> -a <case1.out> dmc <case2.dm> -a <case2.out> ... dmc <caseN.dm> -a <caseN.out>
are input files and
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.
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).
The instruction format is provided to you as part of the 3ac_quads files (as constructed by
toString() function of the abstract Quad class, with assistance from the various Quad
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).
If you feel that the oracle's output is correct but unreasonable,
please consult course staff for approval to output code in
a different way. If you feel that the oracle's output is
incorrect, please report the issue on Piazza. If course staff
confirms your report as the first to identify a particular
error in the oracle, you will be given extra credit (if you
report the bug completely anonymously, we will not be able
to award extra credit - but you can report is anonymously to
To complete this assignment, you should fill out the
flatten functions that are provided in
skeleton form in
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).
Believe in yourself! Also, make sure to watch the Project 6 video to get an overview of the project.