Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / src / SSA.adoc
1 SSA
2 ===
3
4 <:SSA:> is an <:IntermediateLanguage:>, translated from <:SXML:> by
5 <:ClosureConvert:>, optimized by <:SSASimplify:>, and translated by
6 <:ToSSA2:> to <:SSA2:>.
7
8 == Description ==
9
10 <:SSA:> is a <:FirstOrder:>, <:SimplyTyped:> <:IntermediateLanguage:>.
11 It is the main <:IntermediateLanguage:> used for optimizations.
12
13 An <:SSA:> program consists of a collection of datatype declarations,
14 a sequence of global statements, and a collection of functions, along
15 with a distinguished "main" function. Each function consists of a
16 collection of basic blocks, where each basic block is a sequence of
17 statements ending with some control transfer.
18
19 == Implementation ==
20
21 * <!ViewGitFile(mlton,master,mlton/ssa/ssa.sig)>
22 * <!ViewGitFile(mlton,master,mlton/ssa/ssa.fun)>
23 * <!ViewGitFile(mlton,master,mlton/ssa/ssa-tree.sig)>
24 * <!ViewGitFile(mlton,master,mlton/ssa/ssa-tree.fun)>
25
26 == Type Checking ==
27
28 Type checking (<!ViewGitFile(mlton,master,mlton/ssa/type-check.sig)>,
29 <!ViewGitFile(mlton,master,mlton/ssa/type-check.fun)>) of a <:SSA:> program
30 verifies the following:
31
32 * no duplicate definitions (tycons, cons, vars, labels, funcs)
33 * no out of scope references (tycons, cons, vars, labels, funcs)
34 * variable definitions dominate variable uses
35 * case transfers are exhaustive and irredundant
36 * `Enter`/`Leave` profile statements match
37 * "traditional" well-typedness
38
39 == Details and Notes ==
40
41 SSA is an abbreviation for Static Single Assignment.
42
43 For some initial design discussion, see the thread at:
44
45 * http://mlton.org/pipermail/mlton/2001-August/019689.html
46
47 For some retrospectives, see the threads at:
48
49 * http://mlton.org/pipermail/mlton/2003-January/023054.html
50 * http://mlton.org/pipermail/mlton/2007-February/029597.html