Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / src / Flatten.adoc
1 Flatten
2 =======
3
4 <:Flatten:> is an optimization pass for the <:SSA:>
5 <:IntermediateLanguage:>, invoked from <:SSASimplify:>.
6
7 == Description ==
8
9 This pass flattens arguments to <:SSA:> constructors, blocks, and
10 functions.
11
12 If a tuple is explicitly available at all uses of a function
13 (resp. block), then:
14
15 * The formals and call sites are changed so that the components of the
16 tuple are passed.
17
18 * The tuple is reconstructed at the beginning of the body of the
19 function (resp. block).
20
21 Similarly, if a tuple is explicitly available at all uses of a
22 constructor, then:
23
24 * The constructor argument datatype is changed to flatten the tuple
25 type.
26
27 * The tuple is passed flat at each `ConApp`.
28
29 * The tuple is reconstructed at each `Case` transfer target.
30
31 == Implementation ==
32
33 * <!ViewGitFile(mlton,master,mlton/ssa/flatten.fun)>
34
35 == Details and Notes ==
36
37 {empty}