Due: Sunday, 5 May 2013 at 11:59pm

Source:

Download: project7.zip

To Submit: Go Here

This is a group project. Teams of size 1 or 2 are acceptable. If you are working in a team of two, only one student needs to submit the project. Be sure to fill in the team.txt file.

As usual, start early!

What to turn in:

Turn in a file called project7.zip. It should contain at minimum:

Overview

You've spent the semester implementing a compiler for the OAT language, but you haven't had much opportunity to actually use the language itself. This project, meant to be fun, is to write some OAT code.

Building/Running the Project

This project uses the same build configuration as in Projects 5 and 6, however the version of OAT that we have provided does not do any interesting optimizations, so the -OAsm -Oil and -OAst flags do nothing. We recommend that you use the --llvm-backend flag, which will use LLVM's -O2 level optimizations by default. If you would prefer to use the optimizing compiler that you wrote for Project 6, contact us.

Note that you will need to use the -lib flag as described below to pass extra arguments so that gcc can link against C libraries.

What to Do

We have provided a complete, working implementation of the (non-optimizing) OAT compiler. For this project, you don't need to make any modifications to the OAT compiler (but see the description of Extra Credit below). Instead, you will write a smallish OAT program or library of your choosing, subject to these constraints:

We have provided lib/console.oat along with lib/console.c and lib/console.h as an example of how to wrap some C functions for use with OAT. You are welcome to use the console (it needs some version of the curses library) or wrap some other C library for use in OAT. Note that if you choose to use some other library, you will need to figure out a way to express the library's interface using OAT types -- this may not always be easy (or even directly possible). One approach is to have the C wrapper functions interface between the library types and the OAT types.

The compiler's -lib option can be used to pass arguments to the underlying call to gcc. The example below shows how to use -lib to provide the lib/console.c and -lcurses inputs to gcc when compiling the tests/encroach.oat example. The -I lib directive tells Oat to look in the lib directory (which in this case contains the source files console.oat, list.oat, and math.oat used by tests/encroach.oat).
~/cis341/projects/project7.ll> ./main.native --llvm-backend -I lib -lib lib/console.c -lib -lcurses tests/encroach.oat -o encroach
Configuring platform...
[Mac OS]
Processing: tests/encroach.oat
root name: encroach
* cpp -E  -Ilib tests/encroach.oat c_obj/encroach.i.oat
* gcc -mstackrealign -c -m32 -o c_obj/encroach.o c_obj/encroach.s
* gcc -Wl,-no_pie -mstackrealign -m32 -o encroach c_obj/encroach.o soln/runtime.c -lcurses lib/console.c   -Ilib 
  

Here are some ideas for the kinds of programs/libraries you could try to implement:

We will test your code on Eniac. If the libraries you need are not availble by default, let us know where to find them or include them in your submission. If, for some reason, you really would like to use a library only available on a different platform (e.g. Windows of Mac) please contact the course staff and we will try to accomodate you.

Also, if your library requires substantial C coding to implement suitable OAT binders, you don't have to write as large of a program in OAT itself -- again, if you have questions about the suitability of your project idea, please contact one of the course staff.

Extra Credit

If you'd like a significant challenge and a chance for extra credit, you can modify the OAT language to support some new feature that is useful for the program/library that you implement. Depending on the modification, you might need to change all of the OAT files -- from the lexer and parser through the back end of the compiler, and potentially even the X86 subset. Some example extensions that you might consider include: support for floating point computations, anonymous tuple types (as in ML), new controls structures like break and continue, or enumerations and switch.

If you choose to go this route, please contact one of the course staff to run your idea by us before you start.

Grading

Once again, this project does not have automated grading support. Also, this project is meant to be fun, so the grading will be largely ad-hoc. Your grade will be determined by:
Last modified: Thu Apr 18 21:43:19 EDT 2013