(1) to have your grade on A6 replace your grade on any other assignment, in which case we'll update your grade on that assignment to max(previous assignment grade, A6); or
(2) If you've done well on all the other assignments, you can still do A6 for a small amount of EC.
Please indicate whether you choose option (1) or (2) in a comment at the top of your llvm.ml submission.
Download the entire set of A6 files here. You won't rely very heavily on the Grumpy language specification for this assignment but we link to it just in case.
$ tar xzvf a6.tgzIn the resulting directory src you'll find the following file structure:
src/ -- compiler source files Makefile -- the project Makefile _tags -- the tags file for ocamlbuild AST.mli -- language-independent abstract syntax stuff AST.ml -- associated helper functions exp.mli -- the definition of Grumpy's abstract syntax exp.ml -- associated functions lexer.mll -- ocamllex source file (stub) parser.mly -- Menhir source file (stub) tycheck.mli -- The type-checker interface tycheck.ml -- The type-checker (stub) ssa.mli -- Defines the RTL intermediate language ssa.ml -- ssa translation (stub) config.ml -- the LLVM target triple (described below) llvm.mli -- commented interface to the LLVM language llvm.ml -- (Part II) grumpy.ml -- the toplevel compiler program tests/ -- test casesTo build the project, type
$ makeYou'll see a bunch of warnings at this point because many of the files above are stubs. Stick your own working versions in their place.
Run the tests by doing
$ make testor by typing ./run.sh from within the tests directory.
For this assignment, the *.expected files in the tests directory contain the values we expect each Grumpy program to return. Building the test target does the following:
warning: overriding the module target triple with x86_64-pc-linux-gnuTo disable this warning, edit src/config.ml to set target_triple to equal the triple suggested for your machine. For example, on my machine, I change config.ml from:
let target_triple = ref "i386-pc-linux-gnu"to:
let target_triple = ref "x86_64-pc-linux-gnu"because I have a 64-bit platform.
Your job in this part is to implement the compilation functions sketched out as stubs in src/llvm.ml. The top-level compilation function
val llvm_of_prog : (ty, instr list) prog -> (lty, linstr list) progmaps SSA programs to LLVM programs.
To complete this part, first open llvm.ml and read the general instructions (number 0). Then, complete the four numbered functions 1-4, leading up to llvm_of_prog (number 4).