(* NAME: Your name OUID: Ohio University ID I worked with ... on this assignment. *)Each student should individually turn in llvm.ml on Blackboard, regardless whether you worked with someone else. Triple programming does not mean each student does a third of the assignment. Instead, it means the three of you construct llvm.ml collaboratively, while all sitting at the same computer screen.
$ 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).