Hackers guid to MLton IR

Stephen Weeks sweeks@wasabi.epr.com
Tue, 23 Nov 1999 21:57:40 -0800 (PST)


> Is there a "compiler hackers" guide to MLton's internals. 

Sadly there is not.  There is a document that I wrote way back in Nov
97, but it's probably too out of date to be worthwhile.  OTOH, I and
Henry and Suresh read the MLton mail address, so should be able to
answer your questions quickly.

> I'd like to hack
> into MLton to do some research, and what I'm looking for is a high-level
> description of the various ILs that MLton uses.

Here's a quick overview, from front end to back end.

Lang	File			Type System
------	-------------------	-------------------------
Ast	ast/ast.sig		none
CoreML	core-ml/core-ml.sig	none
Xml	xml/xml.sig		polymorphic, higher order
Sxml	xml/sxml.sig		monomorphic, higher order
Cps	cps/cps.sig		monomorphic, first order
Machine backend/machine.sig	lame

> In particular is there a phase of MLton where the IL is monorphic
> first-order and type safe. 

Depending on whether you care about higher order functions or not, you
can work on either Sxml or Cps.  Both languages are explicitly typed
and have typecheckers that can check a program for well-typedness.  I
usually find Cps much easier to work on and to construct analyses for.
Also, a word of warning: as far as the SML type system is concerned,
Sxml is the same as Xml -- the only difference is that Sxml doesn't
use the polymorphic aspects of Xml.

If you're going to use Cps and would like a higher level description
of the type system than cps/type-check.fun, I think Suresh may have a
tex'ed up version that is part of a paper we are working on.

Also, you probably figured this out, but you can get a good overview
of the sequence of compiler passes in src/compile.sml.