Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / localhost / IntroduceLoops
CommitLineData
7f918cf1
CE
1<!DOCTYPE html>\r
2<html lang="en">\r
3<head>\r
4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
5<meta name="generator" content="AsciiDoc 8.6.9">\r
6<title>IntroduceLoops</title>\r
7<link rel="stylesheet" href="./asciidoc.css" type="text/css">\r
8<link rel="stylesheet" href="./pygments.css" type="text/css">\r
9\r
10\r
11<script type="text/javascript" src="./asciidoc.js"></script>\r
12<script type="text/javascript">\r
13/*<![CDATA[*/\r
14asciidoc.install();\r
15/*]]>*/\r
16</script>\r
17<link rel="stylesheet" href="./mlton.css" type="text/css">\r
18</head>\r
19<body class="article">\r
20<div id="banner">\r
21<div id="banner-home">\r
22<a href="./Home">MLton 20180207</a>\r
23</div>\r
24</div>\r
25<div id="header">\r
26<h1>IntroduceLoops</h1>\r
27</div>\r
28<div id="content">\r
29<div id="preamble">\r
30<div class="sectionbody">\r
31<div class="paragraph"><p><a href="IntroduceLoops">IntroduceLoops</a> is an optimization pass for the <a href="SSA">SSA</a>\r
32<a href="IntermediateLanguage">IntermediateLanguage</a>, invoked from <a href="SSASimplify">SSASimplify</a>.</p></div>\r
33</div>\r
34</div>\r
35<div class="sect1">\r
36<h2 id="_description">Description</h2>\r
37<div class="sectionbody">\r
38<div class="paragraph"><p>This pass rewrites any <a href="SSA">SSA</a> function that calls itself in tail\r
39position into one with a local loop and no self tail calls.</p></div>\r
40<div class="paragraph"><p>A <a href="SSA">SSA</a> function like</p></div>\r
41<div class="listingblock">\r
42<div class="content monospaced">\r
43<pre>fun F (arg_0, arg_1) = L_0 ()\r
44 ...\r
45 L_16 (x_0)\r
46 ...\r
47 F (z_0, z_1) Tail\r
48 ...</pre>\r
49</div></div>\r
50<div class="paragraph"><p>becomes</p></div>\r
51<div class="listingblock">\r
52<div class="content monospaced">\r
53<pre>fun F (arg_0', arg_1') = loopS_0 ()\r
54 loopS_0 ()\r
55 loop_0 (arg_0', arg_1')\r
56 loop_0 (arg_0, arg_1)\r
57 L_0 ()\r
58 ...\r
59 L_16 (x_0)\r
60 ...\r
61 loop_0 (z_0, z_1)\r
62 ...</pre>\r
63</div></div>\r
64</div>\r
65</div>\r
66<div class="sect1">\r
67<h2 id="_implementation">Implementation</h2>\r
68<div class="sectionbody">\r
69<div class="ulist"><ul>\r
70<li>\r
71<p>\r
72<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/introduce-loops.fun"><span class="monospaced">introduce-loops.fun</span></a>\r
73</p>\r
74</li>\r
75</ul></div>\r
76</div>\r
77</div>\r
78<div class="sect1">\r
79<h2 id="_details_and_notes">Details and Notes</h2>\r
80<div class="sectionbody">\r
81<div class="paragraph"><p></p></div>\r
82</div>\r
83</div>\r
84</div>\r
85<div id="footnotes"><hr></div>\r
86<div id="footer">\r
87<div id="footer-text">\r
88</div>\r
89<div id="footer-badges">\r
90</div>\r
91</div>\r
92</body>\r
93</html>\r