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