ZealOS/docs/Compiler/OptPass5.ZC.html
2021-12-11 06:10:58 -05:00

136 lines
14 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V1.07">
<style type="text/css">
body {background-color:#1f1f1f;}
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
.cF1{color:#4f84a6;background-color:#1f1f1f;}
.cF2{color:#73a255;background-color:#1f1f1f;}
.cF3{color:#297582;background-color:#1f1f1f;}
.cF4{color:#b34f4b;background-color:#1f1f1f;}
.cF5{color:#8a52c3;background-color:#1f1f1f;}
.cF6{color:#b7822f;background-color:#1f1f1f;}
.cF7{color:#444444;background-color:#1f1f1f;}
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
.cF9{color:#94bfde;background-color:#1f1f1f;}
.cFA{color:#a1ce97;background-color:#1f1f1f;}
.cFB{color:#6db4be;background-color:#1f1f1f;}
.cFC{color:#e88e88;background-color:#1f1f1f;}
.cFD{color:#ca94e8;background-color:#1f1f1f;}
.cFE{color:#d4b475;background-color:#1f1f1f;}
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>OptPass5</span><span class=cF0>(</span><span class=cF9>CCompCtrl</span><span class=cF0> *cc)
<a name="l2"></a>{
<a name="l3"></a> </span><span class=cF9>CIntermediateCode</span><span class=cF0> *tmpi, *tmpi1;
<a name="l4"></a> </span><span class=cF9>I64</span><span class=cF0> code, i;
<a name="l5"></a> </span><span class=cF9>CParseStack</span><span class=cF0> *ps = cc-&gt;ps;
<a name="l6"></a>
<a name="l7"></a> ps-&gt;ptr = </span><span class=cFE>0</span><span class=cF0>;
<a name="l8"></a> ps-&gt;ptr2 = </span><span class=cFE>0</span><span class=cF0>;
<a name="l9"></a>
<a name="l10"></a> tmpi = cc-&gt;coc.coc_head.next;
<a name="l11"></a> </span><span class=cF1>while</span><span class=cF0> (code = tmpi-&gt;ic_code)
<a name="l12"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l13"></a> </span><span class=cF1>if</span><span class=cF0> (code &gt;</span><span class=cF3>IC_NOP2</span><span class=cF0>)
<a name="l14"></a> {
<a name="l15"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi-&gt;ic_flags&amp;</span><span class=cF3>ICF_PASS_TRACE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l16"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;cc-&gt;saved_pass_trace, </span><span class=cFE>5</span><span class=cF7>)</span><span class=cF0>)
<a name="l17"></a> {
<a name="l18"></a> </span><span class=cF6>&quot;%2d:&quot;</span><span class=cF0>, ps-&gt;ptr;
<a name="l19"></a> </span><span class=cFD>ICPut</span><span class=cF0>(cc, tmpi);
<a name="l20"></a> }
<a name="l21"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l22"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>intermediate_code_table</span><span class=cF0>[code].arg_count == </span><span class=cF3>IS_V_ARG</span><span class=cF0>)
<a name="l23"></a> ps-&gt;ptr -= tmpi-&gt;ic_data &gt;&gt; </span><span class=cFE>3</span><span class=cF0>;
<a name="l24"></a> </span><span class=cF1>if</span><span class=cF0> (code == </span><span class=cF3>IC_PUSH_REGS</span><span class=cF0>)
<a name="l25"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l26"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cF3>REG_REGS_NUM</span><span class=cF0>; i++)
<a name="l27"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;tmpi-&gt;ic_data, i</span><span class=cF7>)</span><span class=cF0>)
<a name="l28"></a> ps-&gt;ptr++;
<a name="l29"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l30"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (code == </span><span class=cF3>IC_POP_REGS</span><span class=cF0>)
<a name="l31"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l32"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cF3>REG_REGS_NUM</span><span class=cF0>; i++)
<a name="l33"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;tmpi-&gt;ic_data, i</span><span class=cF7>)</span><span class=cF0>)
<a name="l34"></a> ps-&gt;ptr--;
<a name="l35"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l36"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi-&gt;arg2.type &amp; </span><span class=cF3>MDF_STACK</span><span class=cF0>)
<a name="l37"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l38"></a> tmpi1 = </span><span class=cFD>ParsePop</span><span class=cF0>(ps);
<a name="l39"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi1-&gt;ic_code == </span><span class=cF3>IC_MOV</span><span class=cF0> || tmpi1-&gt;ic_code == </span><span class=cF3>IC_REG</span><span class=cF0>)
<a name="l40"></a> {
<a name="l41"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi1-&gt;ic_flags &amp; </span><span class=cF3>ICF_RES_TO_INT</span><span class=cF0>)
<a name="l42"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l43"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi1-&gt;arg1.type &amp; </span><span class=cF3>MDF_IMM</span><span class=cF0>)
<a name="l44"></a> tmpi1-&gt;arg1.disp = tmpi1-&gt;arg1.disp(</span><span class=cF1>F64</span><span class=cF0>);
<a name="l45"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l46"></a> tmpi-&gt;ic_flags |= </span><span class=cF3>ICF_ARG2_TO_INT</span><span class=cF0>;
<a name="l47"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l48"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmpi1-&gt;ic_flags &amp; </span><span class=cF3>ICF_RES_TO_F64</span><span class=cF0>)
<a name="l49"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l50"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi1-&gt;arg1.type &amp; </span><span class=cF3>MDF_IMM</span><span class=cF0>)
<a name="l51"></a> tmpi1-&gt;arg1.disp(</span><span class=cF1>F64</span><span class=cF0>) = tmpi1-&gt;arg1.disp;
<a name="l52"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l53"></a> tmpi-&gt;ic_flags |= </span><span class=cF3>ICF_ARG2_TO_F64</span><span class=cF0>;
<a name="l54"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l55"></a> tmpi-&gt;arg2.type = tmpi1-&gt;arg1.type &amp; </span><span class=cF3>MDG_MASK</span><span class=cF0> +
<a name="l56"></a> </span><span class=cF5>MinI64</span><span class=cF0>(tmpi-&gt;arg2.type.raw_type, </span><span class=cF5>MinI64</span><span class=cF7>(</span><span class=cF0>tmpi1-&gt;res.type.raw_type, tmpi1-&gt;arg1.type.raw_type</span><span class=cF7>)</span><span class=cF0>);
<a name="l57"></a> tmpi-&gt;arg2.</span><span class=cF1>reg</span><span class=cF0> = tmpi1-&gt;arg1.</span><span class=cF1>reg</span><span class=cF0>;
<a name="l58"></a> tmpi-&gt;arg2.disp = tmpi1-&gt;arg1.disp;
<a name="l59"></a> tmpi-&gt;ic_flags |= tmpi1-&gt;ic_flags &amp; </span><span class=cF3>ICG_NO_CONVERT_MASK</span><span class=cF0>;
<a name="l60"></a> </span><span class=cFD>OptSetNOP2</span><span class=cF0>(tmpi1);
<a name="l61"></a> }
<a name="l62"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l63"></a>
<a name="l64"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi-&gt;arg1.type &amp; </span><span class=cF3>MDF_STACK</span><span class=cF0>)
<a name="l65"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l66"></a> tmpi1 = </span><span class=cFD>ParsePop</span><span class=cF0>(ps);
<a name="l67"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi1-&gt;ic_code == </span><span class=cF3>IC_MOV</span><span class=cF0> || tmpi1-&gt;ic_code == </span><span class=cF3>IC_REG</span><span class=cF0>)
<a name="l68"></a> {
<a name="l69"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi1-&gt;ic_flags &amp; </span><span class=cF3>ICF_RES_TO_INT</span><span class=cF0>)
<a name="l70"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l71"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi1-&gt;arg1.type &amp; </span><span class=cF3>MDF_IMM</span><span class=cF0>)
<a name="l72"></a> tmpi1-&gt;arg1.disp = tmpi1-&gt;arg1.disp(</span><span class=cF1>F64</span><span class=cF0>);
<a name="l73"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l74"></a> tmpi-&gt;ic_flags |= </span><span class=cF3>ICF_ARG1_TO_INT</span><span class=cF0>;
<a name="l75"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l76"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmpi1-&gt;ic_flags &amp; </span><span class=cF3>ICF_RES_TO_F64</span><span class=cF0>)
<a name="l77"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l78"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi1-&gt;arg1.type &amp; </span><span class=cF3>MDF_IMM</span><span class=cF0>)
<a name="l79"></a> {
<a name="l80"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi1-&gt;arg1.type &amp; </span><span class=cF3>RTF_UNSIGNED</span><span class=cF0>)
<a name="l81"></a> tmpi1-&gt;arg1.disp(</span><span class=cF1>F64</span><span class=cF0>) = tmpi1-&gt;arg1.disp(</span><span class=cF9>U64</span><span class=cF0>);
<a name="l82"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l83"></a> tmpi1-&gt;arg1.disp(</span><span class=cF1>F64</span><span class=cF0>) = tmpi1-&gt;arg1.disp(</span><span class=cF9>I64</span><span class=cF0>);
<a name="l84"></a> }
<a name="l85"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l86"></a> tmpi-&gt;ic_flags |= </span><span class=cF3>ICF_ARG1_TO_F64</span><span class=cF0>;
<a name="l87"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l88"></a> tmpi-&gt;arg1.type = tmpi1-&gt;arg1.type &amp; </span><span class=cF3>MDG_MASK</span><span class=cF0> +
<a name="l89"></a> </span><span class=cF5>MinI64</span><span class=cF0>(tmpi-&gt;arg1.type.raw_type, </span><span class=cF5>MinI64</span><span class=cF7>(</span><span class=cF0>tmpi1-&gt;res.type.raw_type, tmpi1-&gt;arg1.type.raw_type</span><span class=cF7>)</span><span class=cF0>);
<a name="l90"></a> </span><span class=cFD>CompMinTypePointed</span><span class=cF0>(tmpi, tmpi1-&gt;arg1_type_pointed_to);
<a name="l91"></a> tmpi-&gt;arg1.</span><span class=cF1>reg</span><span class=cF0> = tmpi1-&gt;arg1.</span><span class=cF1>reg</span><span class=cF0>;
<a name="l92"></a> tmpi-&gt;arg1.disp = tmpi1-&gt;arg1.disp;
<a name="l93"></a> tmpi-&gt;ic_flags |= tmpi1-&gt;ic_flags &amp; </span><span class=cF3>ICG_NO_CONVERT_MASK</span><span class=cF0>;
<a name="l94"></a> </span><span class=cFD>OptSetNOP2</span><span class=cF0>(tmpi1);
<a name="l95"></a> }
<a name="l96"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l97"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi-&gt;res.type &amp; </span><span class=cF3>MDF_STACK</span><span class=cF0> &amp;&amp; !</span><span class=cF7>(</span><span class=cF0>tmpi-&gt;ic_flags &amp; </span><span class=cF3>ICF_RES_NOT_USED</span><span class=cF7>)</span><span class=cF0>)
<a name="l98"></a> </span><span class=cFD>ParsePush</span><span class=cF0>(ps, tmpi);
<a name="l99"></a> }
<a name="l100"></a> tmpi = tmpi-&gt;next;
<a name="l101"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l102"></a> </span><span class=cF1>if</span><span class=cF0> (ps-&gt;ptr &gt; </span><span class=cFE>2</span><span class=cF0>)
<a name="l103"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l104"></a> </span><span class=cF6>&quot;Pass:%d Stack:%08X\n&quot;</span><span class=cF0>, cc-&gt;pass, ps-&gt;ptr;
<a name="l105"></a> </span><span class=cF5>LexExcept</span><span class=cF0>(cc, </span><span class=cF6>&quot;Compiler Optimization Error at &quot;</span><span class=cF0>);
<a name="l106"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l107"></a>}
</span></pre></body>
</html>