Import Debian changes 20180207-1
[hcoop/debian/mlton.git] / doc / guide / localhost / MLRISCLibrary
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta name="generator" content="AsciiDoc 8.6.9">
6 <title>MLRISCLibrary</title>
7 <link rel="stylesheet" href="./asciidoc.css" type="text/css">
8 <link rel="stylesheet" href="./pygments.css" type="text/css">
9
10
11 <script type="text/javascript" src="./asciidoc.js"></script>
12 <script type="text/javascript">
13 /*<![CDATA[*/
14 asciidoc.install();
15 /*]]>*/
16 </script>
17 <link rel="stylesheet" href="./mlton.css" type="text/css">
18 </head>
19 <body class="article">
20 <div id="banner">
21 <div id="banner-home">
22 <a href="./Home">MLton 20180207</a>
23 </div>
24 </div>
25 <div id="header">
26 <h1>MLRISCLibrary</h1>
27 </div>
28 <div id="content">
29 <div id="preamble">
30 <div class="sectionbody">
31 <div class="paragraph"><p>The <a href="http://www.cs.nyu.edu/leunga/www/MLRISC/Doc/html/index.html">MLRISC
32 Library</a> is a framework for retargetable and optimizing compiler back
33 ends. The MLRISC Library is distributed with SML/NJ. Due to
34 differences between SML/NJ and MLton, this library will not work
35 out-of-the box with MLton.</p></div>
36 <div class="paragraph"><p>As of 20180119, MLton includes a port of the MLRISC Library
37 synchronized with SML/NJ version 110.82.</p></div>
38 </div>
39 </div>
40 <div class="sect1">
41 <h2 id="_usage">Usage</h2>
42 <div class="sectionbody">
43 <div class="ulist"><ul>
44 <li>
45 <p>
46 You can import a sub-library of the MLRISC Library into an MLB file with:
47 </p>
48 <table class="tableblock frame-all grid-all"
49 style="
50 width:100%;
51 ">
52 <col style="width:50%;">
53 <col style="width:50%;">
54 <thead>
55 <tr>
56 <th class="tableblock halign-left valign-top" >MLB file</th>
57 <th class="tableblock halign-left valign-top" >Description</th>
58 </tr>
59 </thead>
60 <tbody>
61 <tr>
62 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/ALPHA.mlb</span></p></td>
63 <td class="tableblock halign-left valign-top" ><p class="tableblock">The ALPHA backend</p></td>
64 </tr>
65 <tr>
66 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/AMD64.mlb</span></p></td>
67 <td class="tableblock halign-left valign-top" ><p class="tableblock">The AMD64 backend</p></td>
68 </tr>
69 <tr>
70 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/AMD64-Peephole.mlb</span></p></td>
71 <td class="tableblock halign-left valign-top" ><p class="tableblock">The AMD64 peephole optimizer</p></td>
72 </tr>
73 <tr>
74 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/CCall.mlb</span></p></td>
75 <td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
76 </tr>
77 <tr>
78 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/CCall-sparc.mlb</span></p></td>
79 <td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
80 </tr>
81 <tr>
82 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/CCall-x86-64.mlb</span></p></td>
83 <td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
84 </tr>
85 <tr>
86 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/CCall-x86.mlb</span></p></td>
87 <td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
88 </tr>
89 <tr>
90 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/Control.mlb</span></p></td>
91 <td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
92 </tr>
93 <tr>
94 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/Graphs.mlb</span></p></td>
95 <td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
96 </tr>
97 <tr>
98 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/HPPA.mlb</span></p></td>
99 <td class="tableblock halign-left valign-top" ><p class="tableblock">The HPPA backend</p></td>
100 </tr>
101 <tr>
102 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/IA32.mlb</span></p></td>
103 <td class="tableblock halign-left valign-top" ><p class="tableblock">The IA32 backend</p></td>
104 </tr>
105 <tr>
106 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/IA32-Peephole.mlb</span></p></td>
107 <td class="tableblock halign-left valign-top" ><p class="tableblock">The IA32 peephole optimizer</p></td>
108 </tr>
109 <tr>
110 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/Lib.mlb</span></p></td>
111 <td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
112 </tr>
113 <tr>
114 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/MLRISC.mlb</span></p></td>
115 <td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
116 </tr>
117 <tr>
118 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/MLTREE.mlb</span></p></td>
119 <td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
120 </tr>
121 <tr>
122 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/Peephole.mlb</span></p></td>
123 <td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
124 </tr>
125 <tr>
126 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/PPC.mlb</span></p></td>
127 <td class="tableblock halign-left valign-top" ><p class="tableblock">The PPC backend</p></td>
128 </tr>
129 <tr>
130 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/RA.mlb</span></p></td>
131 <td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
132 </tr>
133 <tr>
134 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/SPARC.mlb</span></p></td>
135 <td class="tableblock halign-left valign-top" ><p class="tableblock">The Sparc backend</p></td>
136 </tr>
137 <tr>
138 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/StagedAlloc.mlb</span></p></td>
139 <td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
140 </tr>
141 <tr>
142 <td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/Visual.mlb</span></p></td>
143 <td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
144 </tr>
145 </tbody>
146 </table>
147 </li>
148 <li>
149 <p>
150 If you are porting a project from SML/NJ&#8217;s <a href="CompilationManager">CompilationManager</a> to
151 MLton&#8217;s <a href="MLBasis"> ML Basis system</a> using <span class="monospaced">cm2mlb</span>, note that the
152 following map is included by default:
153 </p>
154 <div class="listingblock">
155 <div class="content monospaced">
156 <pre># MLRISC Library
157 $SMLNJ-MLRISC $(SML_LIB)/mlrisc-lib/mlb</pre>
158 </div></div>
159 <div class="paragraph"><p>This will automatically convert a <span class="monospaced">$SMLNJ-MLRISC/MLRISC.cm</span> import in
160 an input <span class="monospaced">.cm</span> file into a <span class="monospaced">$(SML_LIB)/mlrisc-lib/mlb/MLRISC.mlb</span>
161 import in the output <span class="monospaced">.mlb</span> file.</p></div>
162 </li>
163 </ul></div>
164 </div>
165 </div>
166 <div class="sect1">
167 <h2 id="_details">Details</h2>
168 <div class="sectionbody">
169 <div class="paragraph"><p>The following changes were made to the MLRISC Library, in addition to
170 deriving the <span class="monospaced">.mlb</span> files from the <span class="monospaced">.cm</span> files:</p></div>
171 <div class="ulist"><ul>
172 <li>
173 <p>
174 eliminate sequential <span class="monospaced">withtype</span> expansions: Most could be rewritten as a sequence of type definitions and datatype definitions.
175 </p>
176 </li>
177 <li>
178 <p>
179 eliminate higher-order functors: Every higher-order functor definition and application could be uncurried in the obvious way.
180 </p>
181 </li>
182 <li>
183 <p>
184 eliminate <span class="monospaced">where &lt;str&gt; = &lt;str&gt;</span>: Quite painful to expand out all the flexible types in the respective structures. Furthermore, many of the implied type equalities aren&#8217;t needed, but it&#8217;s too hard to pick out the right ones.
185 </p>
186 </li>
187 <li>
188 <p>
189 <span class="monospaced">library/array-noneq.sml</span> (added, not exported): Implements <span class="monospaced">signature ARRAY_NONEQ</span>, similar to <span class="monospaced">signature ARRAY</span> from the <a href="BasisLibrary">Basis Library</a>, but replacing the latter&#8217;s <span class="monospaced">eqtype 'a array = 'a array</span> and <span class="monospaced">type 'a vector = 'a Vector.vector</span> with <span class="monospaced">type 'a array</span> and <span class="monospaced">type 'a vector</span>. Thus, array-like containers may match <span class="monospaced">ARRAY_NONEQ</span>, whereas only the pervasive <span class="monospaced">'a array</span> container may math <span class="monospaced">ARRAY</span>. (SML/NJ&#8217;s implementation of <span class="monospaced">signature ARRAY</span> omits the type realizations.)
190 </p>
191 </li>
192 <li>
193 <p>
194 <span class="monospaced">library/dynamic-array.sml</span> and <span class="monospaced">library/hash-array.sml</span> (modifed): Replace <span class="monospaced">include ARRAY</span> with <span class="monospaced">include ARRAY_NONEQ</span>; see above.
195 </p>
196 </li>
197 </ul></div>
198 </div>
199 </div>
200 <div class="sect1">
201 <h2 id="_patch">Patch</h2>
202 <div class="sectionbody">
203 <div class="ulist"><ul>
204 <li>
205 <p>
206 <a href="https://github.com/MLton/mlton/blob/master/lib/mlrisc-lib/MLRISC.patch"><span class="monospaced">MLRISC.patch</span></a>
207 </p>
208 </li>
209 </ul></div>
210 </div>
211 </div>
212 </div>
213 <div id="footnotes"><hr></div>
214 <div id="footer">
215 <div id="footer-text">
216 </div>
217 <div id="footer-badges">
218 </div>
219 </div>
220 </body>
221 </html>