Tiger Compiler from "Modern Compiler Implementation in ML" by Andrew W. Appel
Standard ML Assembly C Other
Latest commit d083a35 May 15, 2015 @sunchao Merge pull request #1 from humberto-ortiz/master
Small corrections to tiger compiler.
Permalink
Failed to load latest commit information.
.gitignore ignore testcases/*. Mar 21, 2013
Makefile Build for darwin or linux. May 5, 2015
README.md Add .spim extension to make instruction. May 5, 2015
absyn.sml - mipsframe.sml: fixed register names. added "view shift" instructions. Oct 23, 2013
assem.sml - mipsframe.sml: fixed register names. added "view shift" instructions. Oct 23, 2013
canon.sml removed extra whitespace Nov 18, 2013
codegen.sig Updated README.md Dec 16, 2014
color.sig - better graph representation. Nov 24, 2013
color.sml
driver.sml move all files into a single dir Jan 31, 2013
env.sig - removed extra whitespace. Nov 18, 2013
env.sml
errormsg.sml
findescape.sml - mipsframe.sml: fixed register names. added "view shift" instructions. Oct 23, 2013
flowgraph.sml - better graph representation. Nov 24, 2013
frame.sig - added SP. Nov 18, 2013
graph.sig
graph.sml
hash_table.sml
liveness.sml - better graph representation. Nov 24, 2013
main.sml - removed printing absyn. Nov 24, 2013
makegraph.sml - better graph representation. Nov 24, 2013
mipsframe.sml - removed register ZERO (temporarily?). Nov 24, 2013
mipsgen.sml - removed usage of ZERO register Nov 24, 2013
parse.sml - removed whitespace. Nov 18, 2013
parsetest.sml move all files into a single dir Jan 31, 2013
prabsyn.sml
printtree.sml move all files into a single dir Jan 31, 2013
regalloc.sig
regalloc.sml
runtime.c
runtime.s added Makefile, runtime.s, etc Dec 16, 2014
semant.sig move all files into a single dir Jan 31, 2013
semant.sml
simplecolor.sml
slp.sml moved slp.sml Jan 23, 2013
sources.cm - use color.sml now. Nov 24, 2013
symbol.sml - removed whitespaces. Nov 18, 2013
table.sig
table.sml
temp.sig
temp.sml move all files into a single dir Jan 31, 2013
testcoloring.sml Updated README.md Dec 16, 2014
testliveness.sml more work on coloring. added a simple test Aug 1, 2013
tiger.grm move all files into a single dir Jan 31, 2013
tiger.grm.sig move all files into a single dir Jan 31, 2013
tiger.grm.sml move all files into a single dir Jan 31, 2013
tiger.lex fixed an issule about svalue, and header. Mar 22, 2013
tigerc added Makefile, runtime.s, etc Dec 16, 2014
tokens.sig move all files into a single dir Jan 31, 2013
tokens.sml
translate.sig - changed "call" Mar 21, 2013
translate.sml - removed extra print statement. Nov 24, 2013
tree.sml - removed whitespaces. Nov 18, 2013
types.sml - removed whitespaces. Nov 18, 2013

README.md

Tiger Compiler

Tiger Compiler from "Modern Compiler Implementation in ML" by Andrew W. Appel

Introduction

This is a Tiger compiler with all modules completed until Chapter 12 in the book. Basically I followed all the instructions from the book without much alternation. I also tried to adhere to the functional style as much as possible, that means, minimize the usage of mutable data structures.

Requirement

So far the compiler works with either mac or linux. Besides that, you need to have Standard ML and spim installed. Both of them can be fetched via homebrew.

Standard ML is obviously need to compile the programs. Since the compiler generates spim code, you'll need the SPIM simulator to actually run the executables.

Build

To build the compiler, simply run

make main

This will build the image using sources.cm. Note that it currently doesn't support windows.

Compile

Given a tiger source program foo.tig, to compile it, you'll need to first copy the file to the project directory, and run

make foo.spim

This will compile the file, append runtime.s to it, and generate a output SPIM program called foo.spim. Then to execute the program, run

spim -file foo.spim

If foo.spim exists, make will not overwrite it. You must remove the file before running make again.

Future Work

The second half of the book covers a lot of interesting stuff, and I'm thinking about extending the compile with the following features:

  • Garbage Collection
  • OO Features
  • Functional Features
  • Polymorphism and Type Inference
  • Optimizations