Compiler construction (MRJP) lab project

Laboratory grade is based on a project involving the implementation of a compiler for a simple imperative language Latte.

Stages

The project consits of three stages:

  1. Front-end: syntactic and semantic analysis. Deadline Nov. 18.
  2. JVM back-end. Deadline Dec 16.
  3. LLVM or x86 back-end, extensions. Deadline Jan. 20.
Your lab supervisor can set slightly different deadline, in particular require project presentation in person.

Scoring

At most 30 points in total, counting towards final course mark. To pass the lab and qualify to sit an exam, it is required to submit satisfactory solutions for all stages and get a total of at least 15 points.

Points are awarded for:

  1. front-end (4);
  2. additionally up to 2 points if the parser is written without using a parser generator;
  3. JVM back-end JVM (5)
  4. back-end for LLVM (8) or (exclusive) x86 (10)
  5. LLVM code in SSA form - additional 1p
  6. register allocation for x86 - additional (up to) 3p
  7. optimisations - up to 3p
  8. Extension (x/y denotes points for LLVM/x86 respectively)
    1. arrays (2)
    2. structures (2)
    3. objects (attributes, methods, inheritance without method override) - (3/4) extra
    4. virtual methods (3/4) extra (in total 8/10 can be awarded for objects with virtual methods)
    5. garbage collection (2)
A more precise specification of extensions is contained in the language description.

Late submissions

Late submissions are subject to penalty of 2p for each week started; however no submissions will be accepted after February 22.

Rules

The project must be original work, developed independently by the student submitting it. In particular:

Technical requirements

  1. The project must be submitted as a packed TAR archive (.tar.gz, .tgz, tar.bz2 or .tbz)
  2. The project root must contain at least:
  3. The project must be buildable on lab computers by running make in the project root.
  4. All necessary libraries (except standard library of the programming language used) must be described in README.
  5. After the build, project root must contain an executable file latc (may be a shell script calling other programs)
  6. The compiler must accept all test programs from the directory good and reject (with appropriate error messages) all programs from the directory bad. For the extensions, the compiler must accept all programs from the respective subdirectories in extension. Execution of a correct test program must give output exactly the same as in the corresponding .output file (given input in the corresponding .input file, if any).
  7. For an accepted program, the compiler must output OK ("OK\n") and exit with code 0.
  8. For a rejected program, the first line of stderr must be ERROR ("ERROR\n"). Further linses should contain appropriate error messages. The compiler must then exit with a non-zero exit code.

Stage II - JVM backend

The project must fulfill all the conditions above, moreover:
  1. Executing latc foo/bar/baz.lat for a correct program baz.lat should create file baz.j (Jasmin code) and baz.class in the directory foo/bar (passing option -d to Jasmin may be helpful here).
  2. The file jasmin.jar should be placed in lib
  3. Helper methods (printInt etc.) should be placed in the class Runtime.class in the lib directory.

Stage III - LLVM backend

  1. After running make the project root should contain executable latc_llvm
  2. Running latc_llvm foo/bar/baz.lat for a correct program baz.lat should create files baz.ll (readable LLVM code) and executtable a.out in the directory foo/bar.
  3. Helper functions (printInt etc.) should be placed in the file runtime.bc in the lib directory (with sources in runtime.ll).

Stage III - x86 backend

  1. After running make the project root should contain executable latc_ARCH where ARCH is x86 or x86_64
  2. Running latc_ARCH foo/bar/baz.lat for a correct program baz.latshould create files baz.s (assembly) and executtable a.out in the directory foo/bar.
  3. Helper functions (printInt etc.) should be placed in the file runtime.o in the lib directory (with sources in runtime.s).

Test programs archive:

lattests121017.tgz, MD5:49ca5702ca9795fb8f33d52b0b3c6fc3