Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / localhost / ToMachine
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>ToMachine</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>ToMachine</h1>
27 </div>
28 <div id="content">
29 <div id="preamble">
30 <div class="sectionbody">
31 <div class="paragraph"><p><a href="ToMachine">ToMachine</a> is a translation pass from the <a href="RSSA">RSSA</a>
32 <a href="IntermediateLanguage">IntermediateLanguage</a> to the <a href="Machine">Machine</a> <a href="IntermediateLanguage">IntermediateLanguage</a>.</p></div>
33 </div>
34 </div>
35 <div class="sect1">
36 <h2 id="_description">Description</h2>
37 <div class="sectionbody">
38 <div class="paragraph"><p>This pass converts from a <a href="RSSA">RSSA</a> program into a <a href="Machine">Machine</a> program.</p></div>
39 <div class="paragraph"><p>It uses <a href="AllocateRegisters">AllocateRegisters</a>, <a href="Chunkify">Chunkify</a>, and <a href="ParallelMove">ParallelMove</a>.</p></div>
40 </div>
41 </div>
42 <div class="sect1">
43 <h2 id="_implementation">Implementation</h2>
44 <div class="sectionbody">
45 <div class="ulist"><ul>
46 <li>
47 <p>
48 <a href="https://github.com/MLton/mlton/blob/master/mlton/backend/backend.sig"><span class="monospaced">backend.sig</span></a>
49 </p>
50 </li>
51 <li>
52 <p>
53 <a href="https://github.com/MLton/mlton/blob/master/mlton/backend/backend.fun"><span class="monospaced">backend.fun</span></a>
54 </p>
55 </li>
56 </ul></div>
57 </div>
58 </div>
59 <div class="sect1">
60 <h2 id="_details_and_notes">Details and Notes</h2>
61 <div class="sectionbody">
62 <div class="paragraph"><p>Because the MLton runtime system is shared by all <a href="Codegen">codegens</a>, it is most
63 convenient to decide on stack layout <em>before</em> any <a href="Codegen">codegen</a> takes over.
64 In particular, we compute all the stack frame info for each <a href="RSSA">RSSA</a>
65 function, including stack size, <a href="GarbageCollection">garbage collector</a>
66 masks for each frame, etc. To do so, the <a href="Machine">Machine</a>
67 <a href="IntermediateLanguage">IntermediateLanguage</a> imagines an abstract machine with an infinite
68 number of (pseudo-)registers of every size. A liveness analysis
69 determines, for each variable, whether or not it is live across a
70 point where the runtime system might take over (for example, any
71 garbage collection point) or a non-tail call to another <a href="RSSA">RSSA</a>
72 function. Those that are live go on the stack, while those that
73 aren&#8217;t live go into psuedo-registers. From this information, we know
74 all we need to about each stack frame. On the downside, nothing
75 further on is allowed to change this stack info; it is set in stone.</p></div>
76 </div>
77 </div>
78 </div>
79 <div id="footnotes"><hr></div>
80 <div id="footer">
81 <div id="footer-text">
82 </div>
83 <div id="footer-badges">
84 </div>
85 </div>
86 </body>
87 </html>