templeos-info/public/Wb/Compiler/OptPass5.HC.HTML

122 lines
12 KiB
Plaintext
Raw Normal View History

2024-03-24 21:24:44 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<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>CCmpCtrl</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>CPrsStk</span><span class=cF0> *ps=cc-&gt;ps;
<a name="l6"></a> ps-&gt;ptr=0;
<a name="l7"></a> ps-&gt;ptr2=0;
<a name="l8"></a>
<a name="l9"></a> tmpi=cc-&gt;coc.coc_head.next;
<a name="l10"></a> </span><span class=cF1>while</span><span class=cF0> (code=tmpi-&gt;ic_code) </span><span class=cF7>{</span><span class=cF0>
<a name="l11"></a> </span><span class=cF1>if</span><span class=cF0> (code&gt;</span><span class=cF3>IC_NOP2</span><span class=cF0>) {
<a name="l12"></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="l13"></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,5</span><span class=cF7>)</span><span class=cF0>) {
<a name="l14"></a> </span><span class=cF6>&quot;%2d:&quot;</span><span class=cF0>,ps-&gt;ptr;
<a name="l15"></a> </span><span class=cFD>ICPut</span><span class=cF0>(cc,tmpi);
<a name="l16"></a> }
<a name="l17"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l18"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>intermediate_code_table</span><span class=cF0>[code].arg_cnt==</span><span class=cF3>IS_V_ARG</span><span class=cF0>)
<a name="l19"></a> ps-&gt;ptr-=tmpi-&gt;ic_data&gt;&gt;3;
<a name="l20"></a> </span><span class=cF1>if</span><span class=cF0> (code==</span><span class=cF3>IC_PUSH_REGS</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l21"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>REG_REGS_NUM</span><span class=cF0>;i++)
<a name="l22"></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="l23"></a> ps-&gt;ptr++;
<a name="l24"></a> </span><span class=cF7>}</span><span class=cF0> </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>) </span><span class=cF7>{</span><span class=cF0>
<a name="l25"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>REG_REGS_NUM</span><span class=cF0>;i++)
<a name="l26"></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="l27"></a> ps-&gt;ptr--;
<a name="l28"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l29"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi-&gt;arg2.type&amp;</span><span class=cF3>MDF_STK</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l30"></a> tmpi1=</span><span class=cFD>PrsPop</span><span class=cF0>(ps);
<a name="l31"></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="l32"></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>) </span><span class=cF7>{</span><span class=cF0>
<a name="l33"></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="l34"></a> tmpi1-&gt;arg1.disp=tmpi1-&gt;arg1.disp(</span><span class=cF1>F64</span><span class=cF0>);
<a name="l35"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l36"></a> tmpi-&gt;ic_flags|=</span><span class=cF3>ICF_ARG2_TO_INT</span><span class=cF0>;
<a name="l37"></a> </span><span class=cF7>}</span><span class=cF0> </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>) </span><span class=cF7>{</span><span class=cF0>
<a name="l38"></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="l39"></a> tmpi1-&gt;arg1.disp(</span><span class=cF1>F64</span><span class=cF0>)=tmpi1-&gt;arg1.disp;
<a name="l40"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l41"></a> tmpi-&gt;ic_flags|=</span><span class=cF3>ICF_ARG2_TO_F64</span><span class=cF0>;
<a name="l42"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l43"></a> tmpi-&gt;arg2.type=tmpi1-&gt;arg1.type&amp;</span><span class=cF3>MDG_MASK</span><span class=cF0>+
<a name="l44"></a> </span><span class=cF5>MinI64</span><span class=cF0>(tmpi-&gt;arg2.type.raw_type,
<a name="l45"></a> </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="l46"></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="l47"></a> tmpi-&gt;arg2.disp=tmpi1-&gt;arg1.disp;
<a name="l48"></a> tmpi-&gt;ic_flags|=tmpi1-&gt;ic_flags&amp;</span><span class=cF3>ICG_NO_CVT_MASK</span><span class=cF0>;
<a name="l49"></a> </span><span class=cFD>OptSetNOP2</span><span class=cF0>(tmpi1);
<a name="l50"></a> }
<a name="l51"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l52"></a>
<a name="l53"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi-&gt;arg1.type&amp;</span><span class=cF3>MDF_STK</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l54"></a> tmpi1=</span><span class=cFD>PrsPop</span><span class=cF0>(ps);
<a name="l55"></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="l56"></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>) </span><span class=cF7>{</span><span class=cF0>
<a name="l57"></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="l58"></a> tmpi1-&gt;arg1.disp=tmpi1-&gt;arg1.disp(</span><span class=cF1>F64</span><span class=cF0>);
<a name="l59"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l60"></a> tmpi-&gt;ic_flags|=</span><span class=cF3>ICF_ARG1_TO_INT</span><span class=cF0>;
<a name="l61"></a> </span><span class=cF7>}</span><span class=cF0> </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>) </span><span class=cF7>{</span><span class=cF0>
<a name="l62"></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="l63"></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="l64"></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="l65"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l66"></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="l67"></a> } </span><span class=cF1>else</span><span class=cF0>
<a name="l68"></a> tmpi-&gt;ic_flags|=</span><span class=cF3>ICF_ARG1_TO_F64</span><span class=cF0>;
<a name="l69"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l70"></a> tmpi-&gt;arg1.type=tmpi1-&gt;arg1.type&amp;</span><span class=cF3>MDG_MASK</span><span class=cF0>+
<a name="l71"></a> </span><span class=cF5>MinI64</span><span class=cF0>(tmpi-&gt;arg1.type.raw_type,
<a name="l72"></a> </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="l73"></a> </span><span class=cFD>CmpMinTypePointed</span><span class=cF0>(tmpi,tmpi1-&gt;arg1_type_pointed_to);
<a name="l74"></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="l75"></a> tmpi-&gt;arg1.disp=tmpi1-&gt;arg1.disp;
<a name="l76"></a> tmpi-&gt;ic_flags|=tmpi1-&gt;ic_flags&amp;</span><span class=cF3>ICG_NO_CVT_MASK</span><span class=cF0>;
<a name="l77"></a> </span><span class=cFD>OptSetNOP2</span><span class=cF0>(tmpi1);
<a name="l78"></a> }
<a name="l79"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l80"></a> </span><span class=cF1>if</span><span class=cF0> (tmpi-&gt;res.type&amp;</span><span class=cF3>MDF_STK</span><span class=cF0> &amp;&amp;
<a name="l81"></a> !</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="l82"></a> </span><span class=cFD>PrsPush</span><span class=cF0>(ps,tmpi);
<a name="l83"></a> }
<a name="l84"></a> tmpi=tmpi-&gt;next;
<a name="l85"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l86"></a> </span><span class=cF1>if</span><span class=cF0> (ps-&gt;ptr&gt;2) </span><span class=cF7>{</span><span class=cF0>
<a name="l87"></a> </span><span class=cF6>&quot;Pass:%d Stk:%08X\n&quot;</span><span class=cF0>,cc-&gt;pass,ps-&gt;ptr;
<a name="l88"></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="l89"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l90"></a>}
</span></pre></body>
</html>