[MLton-user] Re: [MLton] Intermediate forms

Matthew Fluet fluet at tti-c.org
Fri Mar 7 14:35:24 PST 2008


On Fri, 7 Mar 2008, Eric McCorkle wrote:
>> Is there a way to have MLton print out my program as it is optimizing?
>> 
>> I've tried "-keep g", but the ASM is too detached from the SML, so I
>> can't tell "how much" is getting optimized.
>> 
>> In particular, I'd like to look at the SXML and SSA (or SSA2) versions.
>> 
>> Thanks so much
>
> You can do -keep ssa, -keep ssa2, -keep rssa.  The SSA languages are a bit 
> different from conventional, in that there are no phi-operators.  Instead, 
> blocks take arguments, and each block ends with one of several types of 
> transfers (goto, case, etc), which give the arguments for the next block.

The full collection of "-keep" arguments is:
   dot g machine o sml rssa ssa ssa2

As Eric stated, "-keep ssa", "-keep ssa2", and "-keep rssa" will emit the 
final SSA/SSA2/RSSA IL programs (i.e., after all simplifications on that 
IL).

The "-keep dot" will emit Graphviz .dot files for each SSA/SSA2 IL program 
emitted (including a .dot file for the whole-program call graph, a .dot 
file for the control-flow graph of each IL function, and a .dot file for 
the dominator tree of each IL function).

The "-keep machine" will emit the Machine IL, a fairly low-level register 
machine intermediate langauge, just before codegen.

A related useful option is "-show-types true", which will display the 
types of bound variables in each IL program emitted.

You can use "-keep-pass <name>" to keep the post IL programs of the major 
passes and the pre and post IL programs of the minor optimization passes. 
The "<name>" argument is actually a regular expression, so the truly 
adventurous can use "-keep-pass '.*'" to emit the pre/post IL programs of 
every pass.

As a reference, here are the major pass names and the IL program they will 
emit when passed to -keep-pass:
  parseAndElaborate : initial CoreML
  deadCode : final CoreML
  defunctorize : initial XML
  xmlSimplify : final XML
  monomorphise : initial SXML
  sxmlSimplify : final SXML
  closureConvert : initial SSA
  ssaSimplify : final SSA (also via "-keep ssa")
  toSsa2 : initial SSA2
  ssa2Simplify : final SSA2 (also via "-keep ssa2")
  toRssa : initial RSSA
  rssaSimplify : final RSSA (also via "-keep rssa")
  toMachine : initial&final Machine IL (also via "-keep machine")



More information about the MLton-user mailing list