CS 453 Programming Assignment #7 — MeggyJava for game of life, or arrays and register allocation

Due Friday April 29th (by 11:59pm)

Introduction

This assignment is to be done with your CS 453 programming partner. In this assignment you will be writing a program that parses the full MeggyJava language including array declarations, array references, array assignments, and the length field for arrays. The full language also includes the last piece of Meggy functionality, Meggy.setAuxLEDs(). Here is a version of Meggy.java that contains the Java-only setAuxLEDs() implementation. You will

You will need to do type checking for arrays, and 20% of the assignment will be the ability of your compiler to perform register allocation.

The Assignment

You should create a jar file, MJPA7_groupname.jar, that can be executed as follows:
   java -jar MJPA7_groupname.jar InputFile.java
   
You should also provide a register allocation option.
   java -jar MJPA7_groupname.jar --regalloc InputFile.java
   

Your README needs a paragraph that describes how you did register allocation. We will be comparing the dynamic number of loads and stores in the code generated by your non-register allocating compiler to your register allocating code and there should be a definite reduction. MJSIM has been updated to print out the number of loads and stores that occurred during the simulation.

The input files can be any PA7 MeggyJava program. The PA7GameOfLife.java are possible test cases for MJPA7_groupname.jar. The output file named InputFile.java.s should be an AVR assembly program that uses the provided build process to run on the MeggyJr device. Additionally, the InputFile.java.s file must be such that we can run it through the AVR simulator MJSIM.jar (NOTE: this is a new version of MJSIM.jar updated for PA7).

We will be testing your register allocation by having the simulator count loads and stores when the generated code executes and checking that the number of loads and stores is noticeably less (at least 10%) than the code generated by the non-register allocation version of the your compiler without register allocation or the reference compiler.

EXTRA CREDIT: Any group who generates code that consistently executes fewer load and store instructions than the register-allocated code generated by the reference compiler will receive 5 points extra credit for PA7. The reference compiler for this piece will be posted here by April 22nd (The reference compiler MJ.jar is in ~cs453/public/).

Type Checking

Your compiler will need to perform some type checking. The following is a list of error messages that will be expected in addition to the error messages your compiler was expected to handle for previous programming assignments:
    [LINENUM,POSNUM] Array reference to non-array type

    [LINENUM,POSNUM] Index expression type for array reference must be INT
    
    [LINENUM,POSNUM] Operator length called on non-array type
    
    [LINENUM,POSNUM] Invalid operand type for new array operator
    
    [LINENUM,POSNUM] Invalid expression type assigned into array

where LINENUM is the line number for the symbol and POSNUM is the position number for the symbol.

To enable easier testing and grading do not change the phrasing of the error messages. Test against the reference type checkers in ~cs453/public/.

Code Generation

See the Meggy Sim instructions for usage notes. The set of instructions you will need include a file declaration at the top of the assembly file (.file "main.java"), instructions in the previously provided avrH.rtl.s and avrF.rtl.s files and the following:
    # Examples of each statement type are provided.
    # Register numbers, constant values, and labels can change.
    ldi    r24,lo8(1)
    ldi    r25,hi8(0)
    ldi    r24,73
    lds    r24, Button_A

    push   r24
    pop    r24

    call   functionName

    tst    r24    
    cp     r24, r25
    breq   MJ_L6
    brne   MJ_L7
    jmp    MJ_L6
    
    LabelWithAnyName:
    
    # top of a function declaration
    .text
    .global Cloudrain
    .type Cloudrain, @function
Cloudrain:

    # indirect stores and loads
    std    Y+1, r24
    ldd    r24, Y + 3

    call    malloc
    
    call   _Z10SetAuxLEDsh
    

For more details about the instructions see the 08-MeggyJrSimple-n-AVR.txt notes.

Notice that avrF.rtl.s already has an infinite loop at the end of main so that the program will always remain running on the Meggy Jr device even if there is no while loop in the MeggyJava program.

Getting Started

The following is a suggested progression for starting this assignment:
  1. Start with your working PA6 compiler.

  2. Get everything working for arrays.

  3. Implement some form of straight-forward register allocation.

  4. Work on besting the register allocation in the reference compiler for some extra credit.

Submitting the Assignment

Late Policy

Late assignments will be accepted up to 48 hours past the due date for a 10% deduction. The assignment will not be accepted past this period. Late means anything after 11:59pm on the day the assignment is due, including 12 midnight.


mstrout@cs.colostate.edu .... April 22, 2011