diff options
Diffstat (limited to 'html/036labels.cc.html')
-rw-r--r-- | html/036labels.cc.html | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/html/036labels.cc.html b/html/036labels.cc.html index ccf0ae1a..96657216 100644 --- a/html/036labels.cc.html +++ b/html/036labels.cc.html @@ -84,7 +84,7 @@ if ('onhashchange' in window) { <span id="L25" class="LineNr"> 25 </span><span class="Comment">//: programs.</span> <span id="L26" class="LineNr"> 26 </span> <span id="L27" class="LineNr"> 27 </span><span class="Normal">void</span> <a href='036labels.cc.html#L27'>test_Entry_label</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> -<span id="L28" class="LineNr"> 28 </span> <a href='011run.cc.html#L83'>run</a><span class="Delimiter">(</span> +<span id="L28" class="LineNr"> 28 </span> <a href='011run.cc.html#L82'>run</a><span class="Delimiter">(</span> <span id="L29" class="LineNr"> 29 </span> <span class="Constant">"== code 0x1\n"</span> <span id="L30" class="LineNr"> 30 </span> <span class="Constant">"05 0x0d0c0b0a/imm32\n"</span> <span id="L31" class="LineNr"> 31 </span> <span class="Constant">"Entry:\n"</span> @@ -96,8 +96,8 @@ if ('onhashchange' in window) { <span id="L37" class="LineNr"> 37 </span> <a href='003trace.cc.html#L294'>CHECK_TRACE_DOESNT_CONTAIN</a><span class="Delimiter">(</span><span class="Constant">"run: 0x00000001 opcode: 05"</span><span class="Delimiter">);</span> <span id="L38" class="LineNr"> 38 </span><span class="Delimiter">}</span> <span id="L39" class="LineNr"> 39 </span> -<span id="L40" class="LineNr"> 40 </span><span class="Delimiter">:(before "End <a href='032---operands.cc.html#L489'>looks_like_hex_int</a>(s) Detectors")</span> -<span id="L41" class="LineNr"> 41 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">)</span> == <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span id="L40" class="LineNr"> 40 </span><span class="Delimiter">:(before "End <a href='032---operands.cc.html#L490'>looks_like_hex_int</a>(s) Detectors")</span> +<span id="L41" class="LineNr"> 41 </span><span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">)</span> == <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L42" class="LineNr"> 42 </span> <span id="L43" class="LineNr"> 43 </span><span class="Delimiter">:(code)</span> <span id="L44" class="LineNr"> 44 </span><span class="Normal">void</span> <a href='036labels.cc.html#L44'>test_pack_immediate_ignores_single_byte_nondigit_operand</a><span class="Delimiter">()</span> <span class="Delimiter">{</span> @@ -153,7 +153,7 @@ if ('onhashchange' in window) { <span id="L94" class="LineNr"> 94 </span> <span class="Delimiter">}</span> <span id="L95" class="LineNr"> 95 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>isdigit<span class="Delimiter">(</span>s<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span id="L96" class="LineNr"> 96 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << s << <span class="Constant">"' starts with a digit, and so can be confused with a number; use a different name.\n"</span> << end<span class="Delimiter">();</span> -<span id="L97" class="LineNr"> 97 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">)</span> == <span class="Constant">2</span><span class="Delimiter">)</span> +<span id="L97" class="LineNr"> 97 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>s<span class="Delimiter">)</span> == <span class="Constant">2</span><span class="Delimiter">)</span> <span id="L98" class="LineNr"> 98 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << s << <span class="Constant">"' is two characters long, which can look like raw hex bytes at a glance; use a different name\n"</span> << end<span class="Delimiter">();</span> <span id="L99" class="LineNr"> 99 </span><span class="Delimiter">}</span> <span id="L100" class="LineNr">100 </span> @@ -170,12 +170,12 @@ if ('onhashchange' in window) { <span id="L111" class="LineNr">111 </span> <span class="Delimiter">);</span> <span id="L112" class="LineNr">112 </span><span class="Delimiter">}</span> <span id="L113" class="LineNr">113 </span> -<span id="L114" class="LineNr">114 </span><span class="Delimiter">:(before "End Level-2 Transforms")</span> -<span id="L115" class="LineNr">115 </span><span class="Special"><a href='011run.cc.html#L252'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='036labels.cc.html#L117'>rewrite_labels</a><span class="Delimiter">);</span> +<span id="L114" class="LineNr">114 </span><span class="Delimiter">:(before "End Transforms")</span> +<span id="L115" class="LineNr">115 </span><span class="Special"><a href='031transforms.cc.html#L4'>Transform</a></span><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='036labels.cc.html#L117'>rewrite_labels</a><span class="Delimiter">);</span> <span id="L116" class="LineNr">116 </span><span class="Delimiter">:(code)</span> <span id="L117" class="LineNr">117 </span><span class="Normal">void</span> <a href='036labels.cc.html#L117'>rewrite_labels</a><span class="Delimiter">(</span>program& p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L118" class="LineNr">118 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"-- rewrite labels"</span> << end<span class="Delimiter">();</span> -<span id="L119" class="LineNr">119 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L107'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +<span id="L119" class="LineNr">119 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>segments</a><span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L120" class="LineNr">120 </span> segment& code = *find<span class="Delimiter">(</span>p<span class="Delimiter">,</span> <span class="Constant">"code"</span><span class="Delimiter">);</span> <span id="L121" class="LineNr">121 </span> map<string<span class="Delimiter">,</span> <span class="Normal">int32_t</span>> byte_index<span class="Delimiter">;</span> <span class="Comment">// values are unsigned, but we're going to do subtractions on them so they need to fit in 31 bits</span> <span id="L122" class="LineNr">122 </span> <a href='036labels.cc.html#L131'>compute_byte_indices_for_labels</a><span class="Delimiter">(</span>code<span class="Delimiter">,</span> byte_index<span class="Delimiter">);</span> @@ -183,18 +183,18 @@ if ('onhashchange' in window) { <span id="L124" class="LineNr">124 </span> <a href='036labels.cc.html#L205'>drop_labels</a><span class="Delimiter">(</span>code<span class="Delimiter">);</span> <span id="L125" class="LineNr">125 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L126" class="LineNr">126 </span> <a href='036labels.cc.html#L217'>replace_labels_with_displacements</a><span class="Delimiter">(</span>code<span class="Delimiter">,</span> byte_index<span class="Delimiter">);</span> -<span id="L127" class="LineNr">127 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L259'>contains_key</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> <span class="Constant">"Entry"</span><span class="Delimiter">))</span> -<span id="L128" class="LineNr">128 </span> p<span class="Delimiter">.</span><a href='011run.cc.html#L106'>entry</a> = code<span class="Delimiter">.</span>start + get<span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> <span class="Constant">"Entry"</span><span class="Delimiter">);</span> +<span id="L127" class="LineNr">127 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L233'>contains_key</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> <span class="Constant">"Entry"</span><span class="Delimiter">))</span> +<span id="L128" class="LineNr">128 </span> p<span class="Delimiter">.</span><a href='011run.cc.html#L105'>entry</a> = code<span class="Delimiter">.</span>start + get<span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> <span class="Constant">"Entry"</span><span class="Delimiter">);</span> <span id="L129" class="LineNr">129 </span><span class="Delimiter">}</span> <span id="L130" class="LineNr">130 </span> <span id="L131" class="LineNr">131 </span><span class="Normal">void</span> <a href='036labels.cc.html#L131'>compute_byte_indices_for_labels</a><span class="Delimiter">(</span><span class="Normal">const</span> segment& code<span class="Delimiter">,</span> map<string<span class="Delimiter">,</span> <span class="Normal">int32_t</span>>& byte_index<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L132" class="LineNr">132 </span> <span class="Normal">int</span> current_byte = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L133" class="LineNr">133 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L134" class="LineNr">134 </span> <span class="Normal">const</span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L135" class="LineNr">135 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span><span class="Delimiter">.</span>is_open<span class="Delimiter">()</span> && !inst<span class="Delimiter">.</span>original<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && <span class="Comment">/*</span><span class="Comment">not a label</span><span class="Comment">*/</span> *inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> != <span class="Constant">':'</span><span class="Delimiter">)</span> -<span id="L136" class="LineNr">136 </span> <span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Delimiter">(</span>code<span class="Delimiter">.</span>start + current_byte<span class="Delimiter">)</span> << <span class="Constant">' '</span> << inst<span class="Delimiter">.</span>original << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L137" class="LineNr">137 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L138" class="LineNr">138 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> +<span id="L133" class="LineNr">133 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L134" class="LineNr">134 </span> <span class="Normal">const</span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L135" class="LineNr">135 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span><span class="Delimiter">.</span>is_open<span class="Delimiter">()</span> && !inst<span class="Delimiter">.</span>original<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> && <span class="Comment">/*</span><span class="Comment">not a label</span><span class="Comment">*/</span> *inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>data<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> != <span class="Constant">':'</span><span class="Delimiter">)</span> +<span id="L136" class="LineNr">136 </span> <span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Delimiter">(</span>code<span class="Delimiter">.</span>start + current_byte<span class="Delimiter">)</span> << <span class="Constant">' '</span> << inst<span class="Delimiter">.</span>original << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L137" class="LineNr">137 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L138" class="LineNr">138 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> <span id="L139" class="LineNr">139 </span> <span class="Comment">// hack: if we have any operand metadata left after previous transforms,</span> <span id="L140" class="LineNr">140 </span> <span class="Comment">// deduce its size</span> <span id="L141" class="LineNr">141 </span> <span class="Comment">// Maybe we should just move this transform to before instruction</span> @@ -219,17 +219,17 @@ if ('onhashchange' in window) { <span id="L160" class="LineNr">160 </span> <span class="Comment">// ensure labels look sufficiently different from raw hex</span> <span id="L161" class="LineNr">161 </span> <a href='036labels.cc.html#L84'>check_valid_name</a><span class="Delimiter">(</span>label<span class="Delimiter">);</span> <span id="L162" class="LineNr">162 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='003trace.cc.html#L264'>trace_contains_errors</a><span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> -<span id="L163" class="LineNr">163 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L446'>contains_any_operand_metadata</a><span class="Delimiter">(</span>curr<span class="Delimiter">))</span> +<span id="L163" class="LineNr">163 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='032---operands.cc.html#L447'>contains_any_operand_metadata</a><span class="Delimiter">(</span>curr<span class="Delimiter">))</span> <span id="L164" class="LineNr">164 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"': label definition (':') not allowed in operand\n"</span> << end<span class="Delimiter">();</span> <span id="L165" class="LineNr">165 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>j > <span class="Constant">0</span><span class="Delimiter">)</span> -<span id="L166" class="LineNr">166 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"': labels can only be the first <a href='011run.cc.html#L128'>word</a> in a line.\n"</span> << end<span class="Delimiter">();</span> +<span id="L166" class="LineNr">166 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"'"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"': labels can only be the first <a href='011run.cc.html#L127'>word</a> in a line.\n"</span> << end<span class="Delimiter">();</span> <span id="L167" class="LineNr">167 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span><span class="Delimiter">.</span>is_open<span class="Delimiter">())</span> -<span id="L168" class="LineNr">168 </span> <span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L401'>HEXWORD</a> << <span class="Delimiter">(</span>code<span class="Delimiter">.</span>start + current_byte<span class="Delimiter">)</span> << <span class="Constant">' '</span> << label << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> -<span id="L169" class="LineNr">169 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L259'>contains_key</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> label<span class="Delimiter">)</span> && label != <span class="Constant">"Entry"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L168" class="LineNr">168 </span> <span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span> << <span class="Constant">"0x"</span> << <a href='010---vm.cc.html#L395'>HEXWORD</a> << <span class="Delimiter">(</span>code<span class="Delimiter">.</span>start + current_byte<span class="Delimiter">)</span> << <span class="Constant">' '</span> << label << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span id="L169" class="LineNr">169 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L233'>contains_key</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> label<span class="Delimiter">)</span> && label != <span class="Constant">"Entry"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L170" class="LineNr">170 </span> <a href='003trace.cc.html#L228'>raise</a> << <span class="Constant">"duplicate label '"</span> << label << <span class="Constant">"'\n"</span> << end<span class="Delimiter">();</span> <span id="L171" class="LineNr">171 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L172" class="LineNr">172 </span> <span class="Delimiter">}</span> -<span id="L173" class="LineNr">173 </span> <a href='001help.cc.html#L255'>put</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> label<span class="Delimiter">,</span> current_byte<span class="Delimiter">);</span> +<span id="L173" class="LineNr">173 </span> <a href='001help.cc.html#L229'>put</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> label<span class="Delimiter">,</span> current_byte<span class="Delimiter">);</span> <span id="L174" class="LineNr">174 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"label '"</span> << label << <span class="Constant">"' is at address "</span> << <span class="Delimiter">(</span>current_byte+code<span class="Delimiter">.</span>start<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span id="L175" class="LineNr">175 </span> <span class="Comment">// no modifying current_byte; label definitions won't be in the final binary</span> <span id="L176" class="LineNr">176 </span> <span class="Delimiter">}</span> @@ -238,23 +238,23 @@ if ('onhashchange' in window) { <span id="L179" class="LineNr">179 </span><span class="Delimiter">}</span> <span id="L180" class="LineNr">180 </span> <span id="L181" class="LineNr">181 </span><span class="Delimiter">:(before "End Globals")</span> -<span id="L182" class="LineNr">182 </span><span class="Normal">bool</span> <span class="Special"><a href='036labels.cc.html#L182'>Dump_debug_info</a></span> = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// currently used only by 'subx translate'</span> +<span id="L182" class="LineNr">182 </span><span class="Normal">bool</span> <span class="Special"><a href='036labels.cc.html#L182'>Dump_debug_info</a></span> = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// currently used only by 'bootstrap translate'</span> <span id="L183" class="LineNr">183 </span>ofstream <span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span><span class="Delimiter">;</span> <span id="L184" class="LineNr">184 </span>ofstream <span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span><span class="Delimiter">;</span> <span id="L185" class="LineNr">185 </span><span class="Delimiter">:(before "End Commandline Options")</span> -<span id="L186" class="LineNr">186 </span><span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L101'>is_equal</a><span class="Delimiter">(</span>*arg<span class="Delimiter">,</span> <span class="Constant">"--debug"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L186" class="LineNr">186 </span><span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L102'>is_equal</a><span class="Delimiter">(</span>*arg<span class="Delimiter">,</span> <span class="Constant">"--debug"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L187" class="LineNr">187 </span> <span class="Special"><a href='036labels.cc.html#L182'>Dump_debug_info</a></span> = <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L188" class="LineNr">188 </span> <span class="Comment">// End --debug Settings</span> <span id="L189" class="LineNr">189 </span><span class="Delimiter">}</span> <span id="L190" class="LineNr">190 </span><span class="Comment">//: wait to open "labels" for writing until we're sure we aren't trying to read it</span> -<span id="L191" class="LineNr">191 </span><span class="Delimiter">:(after "Begin subx translate")</span> +<span id="L191" class="LineNr">191 </span><span class="Delimiter">:(after "Begin bootstrap translate")</span> <span id="L192" class="LineNr">192 </span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='036labels.cc.html#L182'>Dump_debug_info</a></span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L193" class="LineNr">193 </span> cerr << <span class="Constant">"saving address->label information to 'labels'\n"</span><span class="Delimiter">;</span> <span id="L194" class="LineNr">194 </span> <span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span><span class="Delimiter">.</span>open<span class="Delimiter">(</span><span class="Constant">"labels"</span><span class="Delimiter">);</span> <span id="L195" class="LineNr">195 </span> cerr << <span class="Constant">"saving address->source information to 'source_lines'\n"</span><span class="Delimiter">;</span> <span id="L196" class="LineNr">196 </span> <span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span><span class="Delimiter">.</span>open<span class="Delimiter">(</span><span class="Constant">"source_lines"</span><span class="Delimiter">);</span> <span id="L197" class="LineNr">197 </span><span class="Delimiter">}</span> -<span id="L198" class="LineNr">198 </span><span class="Delimiter">:(before "End subx translate")</span> +<span id="L198" class="LineNr">198 </span><span class="Delimiter">:(before "End bootstrap translate")</span> <span id="L199" class="LineNr">199 </span><span class="Normal">if</span> <span class="Delimiter">(</span><span class="Special"><a href='036labels.cc.html#L182'>Dump_debug_info</a></span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L200" class="LineNr">200 </span> <span class="Special"><a href='036labels.cc.html#L183'>Labels_file</a></span><span class="Delimiter">.</span>close<span class="Delimiter">();</span> <span id="L201" class="LineNr">201 </span> <span class="Special"><a href='036labels.cc.html#L184'>Source_lines_file</a></span><span class="Delimiter">.</span>close<span class="Delimiter">();</span> @@ -262,10 +262,10 @@ if ('onhashchange' in window) { <span id="L203" class="LineNr">203 </span> <span id="L204" class="LineNr">204 </span><span class="Delimiter">:(code)</span> <span id="L205" class="LineNr">205 </span><span class="Normal">void</span> <a href='036labels.cc.html#L205'>drop_labels</a><span class="Delimiter">(</span>segment& code<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L206" class="LineNr">206 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L207" class="LineNr">207 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L208" class="LineNr">208 </span> vector<word>::iterator new_end = remove_if<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>end<span class="Delimiter">(),</span> <a href='036labels.cc.html#L213'>is_label</a><span class="Delimiter">);</span> -<span id="L209" class="LineNr">209 </span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>erase<span class="Delimiter">(</span>new_end<span class="Delimiter">,</span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>end<span class="Delimiter">());</span> +<span id="L206" class="LineNr">206 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L207" class="LineNr">207 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L208" class="LineNr">208 </span> vector<word>::iterator new_end = remove_if<span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>end<span class="Delimiter">(),</span> <a href='036labels.cc.html#L213'>is_label</a><span class="Delimiter">);</span> +<span id="L209" class="LineNr">209 </span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>erase<span class="Delimiter">(</span>new_end<span class="Delimiter">,</span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>end<span class="Delimiter">());</span> <span id="L210" class="LineNr">210 </span> <span class="Delimiter">}</span> <span id="L211" class="LineNr">211 </span><span class="Delimiter">}</span> <span id="L212" class="LineNr">212 </span> @@ -275,13 +275,13 @@ if ('onhashchange' in window) { <span id="L216" class="LineNr">216 </span> <span id="L217" class="LineNr">217 </span><span class="Normal">void</span> <a href='036labels.cc.html#L217'>replace_labels_with_displacements</a><span class="Delimiter">(</span>segment& code<span class="Delimiter">,</span> <span class="Normal">const</span> map<string<span class="Delimiter">,</span> <span class="Normal">int32_t</span>>& byte_index<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L218" class="LineNr">218 </span> <span class="Normal">int32_t</span> byte_index_next_instruction_starts_at = <span class="Constant">0</span><span class="Delimiter">;</span> -<span id="L219" class="LineNr">219 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L220" class="LineNr">220 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L114'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> +<span id="L219" class="LineNr">219 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L220" class="LineNr">220 </span> line& inst = code<span class="Delimiter">.</span><a href='011run.cc.html#L113'>lines</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span id="L221" class="LineNr">221 </span> byte_index_next_instruction_starts_at += <a href='035compute_segment_address.cc.html#L56'>num_bytes</a><span class="Delimiter">(</span>inst<span class="Delimiter">);</span> -<span id="L222" class="LineNr">222 </span> <a href='011run.cc.html#L122'>line</a> new_inst<span class="Delimiter">;</span> -<span id="L223" class="LineNr">223 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L224" class="LineNr">224 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> -<span id="L225" class="LineNr">225 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L259'>contains_key</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> curr<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L222" class="LineNr">222 </span> <a href='011run.cc.html#L121'>line</a> new_inst<span class="Delimiter">;</span> +<span id="L223" class="LineNr">223 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L224" class="LineNr">224 </span> <span class="Normal">const</span> word& curr = inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span> +<span id="L225" class="LineNr">225 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L233'>contains_key</a><span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> curr<span class="Delimiter">.</span>data<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L226" class="LineNr">226 </span> <span class="Normal">int32_t</span> displacement = <span class="Normal">static_cast</span><<span class="Normal">int32_t</span>><span class="Delimiter">(</span>get<span class="Delimiter">(</span>byte_index<span class="Delimiter">,</span> curr<span class="Delimiter">.</span>data<span class="Delimiter">))</span> - byte_index_next_instruction_starts_at<span class="Delimiter">;</span> <span id="L227" class="LineNr">227 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_operand_metadata<span class="Delimiter">(</span>curr<span class="Delimiter">,</span> <span class="Constant">"disp8"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L228" class="LineNr">228 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>displacement > <span class="Constant">0x7f</span> || displacement < -<span class="Constant">0x7f</span><span class="Delimiter">)</span> @@ -302,19 +302,19 @@ if ('onhashchange' in window) { <span id="L243" class="LineNr">243 </span> <span class="Delimiter">}</span> <span id="L244" class="LineNr">244 </span> <span class="Delimiter">}</span> <span id="L245" class="LineNr">245 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> -<span id="L246" class="LineNr">246 </span> new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> +<span id="L246" class="LineNr">246 </span> new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> <span id="L247" class="LineNr">247 </span> <span class="Delimiter">}</span> <span id="L248" class="LineNr">248 </span> <span class="Delimiter">}</span> -<span id="L249" class="LineNr">249 </span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>swap<span class="Delimiter">(</span>new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> +<span id="L249" class="LineNr">249 </span> inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>swap<span class="Delimiter">(</span>new_inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> <span id="L250" class="LineNr">250 </span> <a href='003trace.cc.html#L96'>trace</a><span class="Delimiter">(</span><span class="Constant">99</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"instruction after transform: '"</span> << data_to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << end<span class="Delimiter">();</span> <span id="L251" class="LineNr">251 </span> <span class="Delimiter">}</span> <span id="L252" class="LineNr">252 </span><span class="Delimiter">}</span> <span id="L253" class="LineNr">253 </span> <span id="L254" class="LineNr">254 </span>string <a href='036labels.cc.html#L254'>data_to_string</a><span class="Delimiter">(</span><span class="Normal">const</span> line& inst<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L255" class="LineNr">255 </span> ostringstream out<span class="Delimiter">;</span> -<span id="L256" class="LineNr">256 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L169'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L256" class="LineNr">256 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L170'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L257" class="LineNr">257 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">0</span><span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> -<span id="L258" class="LineNr">258 </span> out << inst<span class="Delimiter">.</span><a href='011run.cc.html#L123'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>data<span class="Delimiter">;</span> +<span id="L258" class="LineNr">258 </span> out << inst<span class="Delimiter">.</span><a href='011run.cc.html#L122'>words</a><span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>data<span class="Delimiter">;</span> <span id="L259" class="LineNr">259 </span> <span class="Delimiter">}</span> <span id="L260" class="LineNr">260 </span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span id="L261" class="LineNr">261 </span><span class="Delimiter">}</span> @@ -432,7 +432,7 @@ if ('onhashchange' in window) { <span id="L373" class="LineNr">373 </span><span class="Delimiter">}</span> <span id="L374" class="LineNr">374 </span> <span id="L375" class="LineNr">375 </span><span class="Comment">// This test could do with some refactoring.</span> -<span id="L376" class="LineNr">376 </span><span class="Comment">// We're duplicating the flow inside `subx translate`, but without</span> +<span id="L376" class="LineNr">376 </span><span class="Comment">// We're duplicating the flow inside `bootstrap translate`, but without</span> <span id="L377" class="LineNr">377 </span><span class="Comment">// reading/writing files.</span> <span id="L378" class="LineNr">378 </span><span class="Comment">// We can't just use run(string) because most of our tests allow programs</span> <span id="L379" class="LineNr">379 </span><span class="Comment">// without 'Entry' labels, as a convenience.</span> @@ -470,7 +470,7 @@ if ('onhashchange' in window) { <span id="L411" class="LineNr">411 </span> <span class="Delimiter">);</span> <span id="L412" class="LineNr">412 </span><span class="Delimiter">}</span> <span id="L413" class="LineNr">413 </span> -<span id="L414" class="LineNr">414 </span><span class="Delimiter">:(before "End size_of(<a href='011run.cc.html#L128'>word</a> w) Special-cases")</span> +<span id="L414" class="LineNr">414 </span><span class="Delimiter">:(before "End size_of(<a href='011run.cc.html#L127'>word</a> w) Special-cases")</span> <span id="L415" class="LineNr">415 </span><span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='036labels.cc.html#L213'>is_label</a><span class="Delimiter">(</span>w<span class="Delimiter">))</span> <span id="L416" class="LineNr">416 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> </pre> |