Left-to-right evaluation is provided as a default for the children of every node in the abstract target program tree. Part of the code generator implementation is to override that default for nodes in which a choice on the basis of register requirements is allowed by the SPIM abstraction (e.g. in iRegrr and fRegrr constructs).
Another situation in which the default evaluation order must be overridden is when the semantics of the language define short circuit evaluation. The SPIM abstraction itself must be extended to express short-circuit evaluation, and then assembly language text appropriate to that abstraction must be generated.
The default evaluation order is established by a lower-context symbol computation of the Code attribute. This computation is usually overridden by a rule computation in the specific context of interest (e.g. in the iRegrr rule).
By using a separate attribute for the specific action required by a node, the specification separates concerns: evaluation order and instruction selection can be specified separately. In determining the final sequence, the Instr attribute represents the node's local action independent of what that action is; the Instr attribute can be defined independent of where the action it represents occurs relative to execution of the node's children.
If no errors are detected in the input text, your program must construct the corresponding SPIM assembly code program, and print a representation of that program. If errors are detected, your program may construct and print assembly code or it may terminate after reporting all of the errors. The assembly code constructed in this case need not reflect the source program, but it must be acceptable as input to the SPIM assembler.
Test your program by applying it to the C-- test suite. If you feel that the test suite is inadequate, provide any additional tests you deem necessary. Your program should not detect any errors in any conformance test, and it should detect at least one error in every deviance test. The SPIM simulator should be able to execute the assembly code translations of all of the programs in the conformance test suite. When appropriate data is supplied, each simulated execution should output the correct result for that input data.
Hand in the assembly code translation of the factorial program. A directory containing the complete source code (or specifications, if you used tools) for your program must be permitted for world read by 1700 on the due date for this assignment. You need not make it available to be read by others before that time. Hand in the location of this directory (machine and path name).
Complete your personal postmortem, and submit it via the web before class on the due date of this assignment.
|Instructor||Revision 1.4 (1998/11/21 16:05:10)|