Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / src / IntroduceLoops.adoc
CommitLineData
7f918cf1
CE
1IntroduceLoops
2==============
3
4<:IntroduceLoops:> is an optimization pass for the <:SSA:>
5<:IntermediateLanguage:>, invoked from <:SSASimplify:>.
6
7== Description ==
8
9This pass rewrites any <:SSA:> function that calls itself in tail
10position into one with a local loop and no self tail calls.
11
12A <:SSA:> function like
13----
14fun F (arg_0, arg_1) = L_0 ()
15 ...
16 L_16 (x_0)
17 ...
18 F (z_0, z_1) Tail
19 ...
20----
21becomes
22----
23fun F (arg_0', arg_1') = loopS_0 ()
24 loopS_0 ()
25 loop_0 (arg_0', arg_1')
26 loop_0 (arg_0, arg_1)
27 L_0 ()
28 ...
29 L_16 (x_0)
30 ...
31 loop_0 (z_0, z_1)
32 ...
33----
34
35== Implementation ==
36
37* <!ViewGitFile(mlton,master,mlton/ssa/introduce-loops.fun)>
38
39== Details and Notes ==
40
41{empty}