Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / localhost / Useless
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>Useless</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>Useless</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="Useless">Useless</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:</p></div>\r
39<div class="ulist"><ul>\r
40<li>\r
41<p>\r
42removes components of tuples that are constants (use unification)\r
43</p>\r
44</li>\r
45<li>\r
46<p>\r
47removes function arguments that are constants\r
48</p>\r
49</li>\r
50<li>\r
51<p>\r
52builds some kind of dependence graph where\r
53</p>\r
54<div class="ulist"><ul>\r
55<li>\r
56<p>\r
57a value of ground type is useful if it is an arg to a primitive\r
58</p>\r
59</li>\r
60<li>\r
61<p>\r
62a tuple is useful if it contains a useful component\r
63</p>\r
64</li>\r
65<li>\r
66<p>\r
67a constructor is useful if it contains a useful component or is used in a <span class="monospaced">Case</span> transfer\r
68</p>\r
69</li>\r
70</ul></div>\r
71</li>\r
72</ul></div>\r
73<div class="paragraph"><p>If a useful tuple is coerced to another useful tuple, then all of\r
74their components must agree (exactly). It is trivial to convert a\r
75useful value to a useless one.</p></div>\r
76</div>\r
77</div>\r
78<div class="sect1">\r
79<h2 id="_implementation">Implementation</h2>\r
80<div class="sectionbody">\r
81<div class="ulist"><ul>\r
82<li>\r
83<p>\r
84<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/useless.fun"><span class="monospaced">useless.fun</span></a>\r
85</p>\r
86</li>\r
87</ul></div>\r
88</div>\r
89</div>\r
90<div class="sect1">\r
91<h2 id="_details_and_notes">Details and Notes</h2>\r
92<div class="sectionbody">\r
93<div class="paragraph"><p>It is also trivial to convert a useful tuple to one of its useful\r
94components&#8201;&#8212;&#8201;but this seems hard.</p></div>\r
95<div class="paragraph"><p>Suppose that you have a <span class="monospaced">ref</span>/<span class="monospaced">array</span>/<span class="monospaced">vector</span> that is useful, but the\r
96components aren&#8217;t&#8201;&#8212;&#8201;then the components are converted to type <span class="monospaced">unit</span>,\r
97and any primitive args must be as well.</p></div>\r
98<div class="paragraph"><p>Unify all handler arguments so that <span class="monospaced">raise</span>/<span class="monospaced">handle</span> has a consistent\r
99calling convention.</p></div>\r
100</div>\r
101</div>\r
102</div>\r
103<div id="footnotes"><hr></div>\r
104<div id="footer">\r
105<div id="footer-text">\r
106</div>\r
107<div id="footer-badges">\r
108</div>\r
109</div>\r
110</body>\r
111</html>\r