<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[150644] trunk/Source/JavaScriptCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/150644">150644</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2013-05-24 09:46:10 -0700 (Fri, 24 May 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>[sh4] Optimize LLINT generated code and fix few bugs in baseline JIT.
https://bugs.webkit.org/show_bug.cgi?id=116716

Patch by Julien Brianceau &lt;jbrianceau@nds.com&gt; on 2013-05-24
Reviewed by Geoffrey Garen.

* assembler/MacroAssemblerSH4.h:
(JSC::MacroAssemblerSH4::mul32): Cosmetic changes.
(JSC::MacroAssemblerSH4::convertInt32ToDouble): Absolute address was not dereferenced.
(JSC::MacroAssemblerSH4::branch32): Absolute address was not dereferenced.
(JSC::MacroAssemblerSH4::revertJumpReplacementToBranchPtrWithPatch): Use all 32 bits of pointer for revertJump call.
* assembler/SH4Assembler.h:
(JSC::SH4Assembler::revertJump): Use changePCrelativeAddress to patch the whole pointer.
(JSC::SH4Assembler::linkJump): Cosmetic change.
* offlineasm/sh4.rb: Optimize LLINT generated code.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreassemblerMacroAssemblerSH4h">trunk/Source/JavaScriptCore/assembler/MacroAssemblerSH4.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreassemblerSH4Assemblerh">trunk/Source/JavaScriptCore/assembler/SH4Assembler.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreofflineasmsh4rb">trunk/Source/JavaScriptCore/offlineasm/sh4.rb</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (150643 => 150644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2013-05-24 16:34:46 UTC (rev 150643)
+++ trunk/Source/JavaScriptCore/ChangeLog        2013-05-24 16:46:10 UTC (rev 150644)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2013-05-24  Julien Brianceau  &lt;jbrianceau@nds.com&gt;
+
+        [sh4] Optimize LLINT generated code and fix few bugs in baseline JIT.
+        https://bugs.webkit.org/show_bug.cgi?id=116716
+
+        Reviewed by Geoffrey Garen.
+
+        * assembler/MacroAssemblerSH4.h:
+        (JSC::MacroAssemblerSH4::mul32): Cosmetic changes.
+        (JSC::MacroAssemblerSH4::convertInt32ToDouble): Absolute address was not dereferenced.
+        (JSC::MacroAssemblerSH4::branch32): Absolute address was not dereferenced.
+        (JSC::MacroAssemblerSH4::revertJumpReplacementToBranchPtrWithPatch): Use all 32 bits of pointer for revertJump call.
+        * assembler/SH4Assembler.h:
+        (JSC::SH4Assembler::revertJump): Use changePCrelativeAddress to patch the whole pointer.
+        (JSC::SH4Assembler::linkJump): Cosmetic change.
+        * offlineasm/sh4.rb: Optimize LLINT generated code.
+
</ins><span class="cx"> 2013-05-23  Peter Wang  &lt;peter.wang@torchmobile.com.cn&gt;
</span><span class="cx"> 
</span><span class="cx">         CLoop llint backend should not use the d8 register as scratch register
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreassemblerMacroAssemblerSH4h"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/assembler/MacroAssemblerSH4.h (150643 => 150644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/assembler/MacroAssemblerSH4.h        2013-05-24 16:34:46 UTC (rev 150643)
+++ trunk/Source/JavaScriptCore/assembler/MacroAssemblerSH4.h        2013-05-24 16:46:10 UTC (rev 150644)
</span><span class="lines">@@ -232,9 +232,9 @@
</span><span class="cx">     {
</span><span class="cx">         RegisterID scr = claimScratch();
</span><span class="cx">         move(imm, scr);
</span><del>-        if  (src != dest)
</del><ins>+        if (src != dest)
</ins><span class="cx">             move(src, dest);
</span><del>-        mul32(scr,  dest);
</del><ins>+        mul32(scr, dest);
</ins><span class="cx">         releaseScratch(scr);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1137,7 +1137,7 @@
</span><span class="cx">     void convertInt32ToDouble(AbsoluteAddress src, FPRegisterID dest)
</span><span class="cx">     {
</span><span class="cx">         RegisterID scr = claimScratch();
</span><del>-        m_assembler.loadConstant(reinterpret_cast&lt;uint32_t&gt;(src.m_ptr), scr);
</del><ins>+        load32(src.m_ptr, scr);
</ins><span class="cx">         convertInt32ToDouble(scr, dest);
</span><span class="cx">         releaseScratch(scr);
</span><span class="cx">     }
</span><span class="lines">@@ -1661,7 +1661,7 @@
</span><span class="cx">     {
</span><span class="cx">         RegisterID scr = claimScratch();
</span><span class="cx"> 
</span><del>-        move(TrustedImm32(reinterpret_cast&lt;uint32_t&gt;(left.m_ptr)), scr);
</del><ins>+        load32(left.m_ptr, scr);
</ins><span class="cx">         m_assembler.cmplRegReg(right, scr, SH4Condition(cond));
</span><span class="cx">         releaseScratch(scr);
</span><span class="cx"> 
</span><span class="lines">@@ -2192,7 +2192,7 @@
</span><span class="cx"> 
</span><span class="cx">     static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID, void* initialValue)
</span><span class="cx">     {
</span><del>-        SH4Assembler::revertJump(instructionStart.dataLocation(), reinterpret_cast&lt;uintptr_t&gt;(initialValue) &amp; 0xffff);
</del><ins>+        SH4Assembler::revertJump(instructionStart.dataLocation(), initialValue);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreassemblerSH4Assemblerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/assembler/SH4Assembler.h (150643 => 150644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/assembler/SH4Assembler.h        2013-05-24 16:34:46 UTC (rev 150643)
+++ trunk/Source/JavaScriptCore/assembler/SH4Assembler.h        2013-05-24 16:46:10 UTC (rev 150644)
</span><span class="lines">@@ -1528,18 +1528,11 @@
</span><span class="cx">         cacheFlush(instruction, sizeof(SH4Word) * nbinst);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static void revertJump(void* instructionStart, SH4Word imm)
</del><ins>+    static void revertJump(void* instructionStart, void *immptr)
</ins><span class="cx">     {
</span><span class="cx">         SH4Word *insn = reinterpret_cast&lt;SH4Word*&gt;(instructionStart);
</span><del>-        SH4Word disp;
-
</del><span class="cx">         ASSERT((insn[0] &amp; 0xf000) == MOVL_READ_OFFPC_OPCODE);
</span><del>-
-        disp = insn[0] &amp; 0x00ff;
-        insn += 2 + (disp &lt;&lt; 1); // PC += 4 + (disp*4)
-        insn = (SH4Word *) ((unsigned) insn &amp; (~3));
-        insn[0] = imm;
-        cacheFlush(insn, sizeof(SH4Word));
</del><ins>+        changePCrelativeAddress(insn[0] &amp; 0x00ff, insn, reinterpret_cast&lt;uint32_t&gt;(immptr));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     void linkJump(AssemblerLabel from, AssemblerLabel to, JumpType type = JumpFar)
</span><span class="lines">@@ -1593,7 +1586,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         instruction = *instructionPtr;
</span><del>-        if ((instruction  &amp; 0xf000) == 0xe000) {
</del><ins>+        if ((instruction &amp; 0xf000) == 0xe000) {
</ins><span class="cx">             uint32_t* addr = getLdrImmAddressOnPool(instructionPtr, m_buffer.poolAddress());
</span><span class="cx">             *addr = offsetBits - 2;
</span><span class="cx">             printInstr(*instructionPtr, from.m_offset + 2);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreofflineasmsh4rb"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/offlineasm/sh4.rb (150643 => 150644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/offlineasm/sh4.rb        2013-05-24 16:34:46 UTC (rev 150643)
+++ trunk/Source/JavaScriptCore/offlineasm/sh4.rb        2013-05-24 16:46:10 UTC (rev 150644)
</span><span class="lines">@@ -318,13 +318,25 @@
</span><span class="cx">         | node |
</span><span class="cx">         if node.is_a? Instruction
</span><span class="cx">             case node.opcode
</span><del>-            when &quot;bdnequn&quot;, &quot;bdgtequn&quot;, &quot;bdltun&quot;, &quot;bdltequn&quot;, &quot;bdgtun&quot;
-                # Handle floating point unordered opcodes.
</del><ins>+            when &quot;bdltun&quot;, &quot;bdgtun&quot;
+                # Handle specific floating point unordered opcodes.
</ins><span class="cx">                 tmp1 = Tmp.new(codeOrigin, :gpr)
</span><span class="cx">                 tmp2 = Tmp.new(codeOrigin, :gpr)
</span><span class="cx">                 newList &lt;&lt; Instruction.new(codeOrigin, &quot;bdnan&quot;, [node.operands[0], node.operands[2], tmp1, tmp2])
</span><span class="cx">                 newList &lt;&lt; Instruction.new(codeOrigin, &quot;bdnan&quot;, [node.operands[1], node.operands[2], tmp1, tmp2])
</span><span class="cx">                 newList &lt;&lt; Instruction.new(codeOrigin, node.opcode[0..-3], node.operands)
</span><ins>+            when &quot;bdnequn&quot;, &quot;bdgtequn&quot;, &quot;bdltequn&quot;
+                newList &lt;&lt; Instruction.new(codeOrigin, node.opcode[0..-3], node.operands)
+            when &quot;bdneq&quot;, &quot;bdgteq&quot;, &quot;bdlteq&quot;
+                # Handle specific floating point ordered opcodes.
+                tmp1 = Tmp.new(codeOrigin, :gpr)
+                tmp2 = Tmp.new(codeOrigin, :gpr)
+                outlabel = LocalLabel.unique(&quot;out_#{node.opcode}&quot;)
+                outref = LocalLabelReference.new(codeOrigin, outlabel)
+                newList &lt;&lt; Instruction.new(codeOrigin, &quot;bdnan&quot;, [node.operands[0], outref, tmp1, tmp2])
+                newList &lt;&lt; Instruction.new(codeOrigin, &quot;bdnan&quot;, [node.operands[1], outref, tmp1, tmp2])
+                newList &lt;&lt; Instruction.new(codeOrigin, node.opcode, node.operands)
+                newList &lt;&lt; outlabel
</ins><span class="cx">             else
</span><span class="cx">                 newList &lt;&lt; node
</span><span class="cx">             end
</span><span class="lines">@@ -429,22 +441,46 @@
</span><span class="cx">     operands.map{|v| v.sh4Operand}.join(&quot;, &quot;)
</span><span class="cx"> end
</span><span class="cx"> 
</span><del>-def emitSH4LoadConstant(constant, operand)
-    if constant == 0x40000000
</del><ins>+def emitSH4Load32(constant, dest)
+    outlabel = LocalLabel.unique(&quot;load32out&quot;)
+    constlabel = LocalLabel.unique(&quot;load32const&quot;)
+    $asm.puts &quot;mov.l #{LocalLabelReference.new(codeOrigin, constlabel).asmLabel}, #{dest.sh4Operand}&quot;
+    $asm.puts &quot;bra #{LocalLabelReference.new(codeOrigin, outlabel).asmLabel}&quot;
+    $asm.puts &quot;nop&quot;
+    $asm.puts &quot;.balign 4&quot;
+    constlabel.lower(&quot;SH4&quot;)
+    $asm.puts &quot;.long #{constant}&quot;
+    outlabel.lower(&quot;SH4&quot;)
+end
+
+def emitSH4Load32AndJump(constant, scratch)
+    constlabel = LocalLabel.unique(&quot;load32const&quot;)
+    $asm.puts &quot;mov.l #{LocalLabelReference.new(codeOrigin, constlabel).asmLabel}, #{scratch.sh4Operand}&quot;
+    $asm.puts &quot;jmp @#{scratch.sh4Operand}&quot;
+    $asm.puts &quot;nop&quot;
+    $asm.puts &quot;.balign 4&quot;
+    constlabel.lower(&quot;SH4&quot;)
+    $asm.puts &quot;.long #{constant}&quot;
+end
+
+def emitSH4LoadImm(operands)
+    if operands[0].value == 0x40000000
</ins><span class="cx">         # FirstConstantRegisterIndex const is often used (0x40000000).
</span><span class="cx">         # It's more efficient to &quot;build&quot; the value with 3 opcodes without branch.
</span><del>-        $asm.puts &quot;mov #64, #{operand.sh4Operand}&quot;
-        $asm.puts &quot;shll16 #{operand.sh4Operand}&quot;
-        $asm.puts &quot;shll8 #{operand.sh4Operand}&quot;
-    else
</del><ins>+        $asm.puts &quot;mov #64, #{operands[1].sh4Operand}&quot;
+        $asm.puts &quot;shll16 #{operands[1].sh4Operand}&quot;
+        $asm.puts &quot;shll8 #{operands[1].sh4Operand}&quot;
+    elsif (-128..127).include? operands[0].value
+        $asm.puts &quot;mov #{sh4Operands(operands)}&quot;
+    elsif (-32768..32767).include? operands[0].value
</ins><span class="cx">         constlabel = LocalLabel.unique(&quot;loadconstant&quot;)
</span><del>-        $asm.puts &quot;.balign 4&quot;
-        $asm.puts &quot;mov.l @(8, PC), #{operand.sh4Operand}&quot;
</del><ins>+        $asm.puts &quot;mov.w @(6, PC), #{operands[1].sh4Operand}&quot;
</ins><span class="cx">         $asm.puts &quot;bra #{LocalLabelReference.new(codeOrigin, constlabel).asmLabel}&quot;
</span><span class="cx">         $asm.puts &quot;nop&quot;
</span><del>-        $asm.puts &quot;nop&quot;
-        $asm.puts &quot;.long #{constant}&quot;
</del><ins>+        $asm.puts &quot;.word #{operands[0].value}&quot;
</ins><span class="cx">         constlabel.lower(&quot;SH4&quot;)
</span><ins>+    else
+        emitSH4Load32(operands[0].value, operands[1])
</ins><span class="cx">     end
</span><span class="cx"> end
</span><span class="cx"> 
</span><span class="lines">@@ -480,12 +516,7 @@
</span><span class="cx">         $asm.puts &quot;bra #{label.asmLabel}&quot;
</span><span class="cx">         $asm.puts &quot;nop&quot;
</span><span class="cx">     else
</span><del>-        $asm.puts &quot;.balign 4&quot;
-        $asm.puts &quot;mov.l @(8, PC), #{SH4_TMP_GPRS[0].sh4Operand}&quot;
-        $asm.puts &quot;jmp @#{SH4_TMP_GPRS[0].sh4Operand}&quot;
-        $asm.puts &quot;nop&quot;
-        $asm.puts &quot;nop&quot;
-        $asm.puts &quot;.long #{label.asmLabel}&quot;
</del><ins>+        emitSH4Load32AndJump(label.asmLabel, SH4_TMP_GPRS[0])
</ins><span class="cx">     end
</span><span class="cx">     outlabel.lower(&quot;SH4&quot;)
</span><span class="cx"> end
</span><span class="lines">@@ -519,43 +550,43 @@
</span><span class="cx">     scrmask = operands[2]
</span><span class="cx">     scrint = operands[3]
</span><span class="cx"> 
</span><ins>+    notNaNlabel = LocalLabel.unique(&quot;notnan&quot;)
+    notNaNref = LocalLabelReference.new(codeOrigin, notNaNlabel)
+    constlabel1 = LocalLabel.unique(&quot;notnanConst1&quot;)
+    constlabel2 = LocalLabel.unique(&quot;notnanConst2&quot;)
+
</ins><span class="cx">     # If we don't have &quot;E = Emax + 1&quot;, it's not a NaN.
</span><del>-    notNaNlabel = LocalLabel.unique(&quot;notnan&quot;)
</del><span class="cx">     $asm.puts &quot;fcnvds #{dblop.sh4Operand}, fpul&quot;
</span><span class="cx">     $asm.puts &quot;sts fpul, #{scrint.sh4Operand}&quot;
</span><del>-    emitSH4LoadConstant(0x7f800000, scrmask)
</del><ins>+    $asm.puts &quot;mov.l #{LocalLabelReference.new(codeOrigin, constlabel1).asmLabel}, #{scrmask.sh4Operand}&quot;
</ins><span class="cx">     $asm.puts &quot;and #{sh4Operands([scrmask, scrint])}&quot;
</span><span class="cx">     $asm.puts &quot;cmp/eq #{sh4Operands([scrmask, scrint])}&quot;
</span><del>-    $asm.puts &quot;bf #{LocalLabelReference.new(codeOrigin, notNaNlabel).asmLabel}&quot;
</del><ins>+    $asm.puts &quot;bf #{notNaNref.asmLabel}&quot;
</ins><span class="cx"> 
</span><span class="cx">     # If we have &quot;E = Emax + 1&quot; and &quot;f != 0&quot;, then it's a NaN.
</span><span class="cx">     $asm.puts &quot;sts fpul, #{scrint.sh4Operand}&quot;
</span><del>-    emitSH4LoadConstant(0x003fffff, scrmask)
</del><ins>+    $asm.puts &quot;mov.l #{LocalLabelReference.new(codeOrigin, constlabel2).asmLabel}, #{scrmask.sh4Operand}&quot;
</ins><span class="cx">     $asm.puts &quot;tst #{sh4Operands([scrmask, scrint])}&quot;
</span><del>-    $asm.puts &quot;bf #{labelop.asmLabel}&quot;
</del><ins>+    $asm.puts &quot;bt #{notNaNref.asmLabel}&quot;
+    $asm.puts &quot;bra #{labelop.asmLabel}&quot;
+    $asm.puts &quot;nop&quot;
</ins><span class="cx"> 
</span><ins>+    $asm.puts &quot;.balign 4&quot;
+    constlabel1.lower(&quot;SH4&quot;)
+    $asm.puts &quot;.long 0x7f800000&quot;
+    constlabel2.lower(&quot;SH4&quot;)
+    $asm.puts &quot;.long 0x003fffff&quot;
+
</ins><span class="cx">     notNaNlabel.lower(&quot;SH4&quot;)
</span><span class="cx"> end
</span><span class="cx"> 
</span><span class="cx"> def emitSH4DoubleCondBranch(cmpOpcode, neg, operands)
</span><span class="cx">     if cmpOpcode == &quot;lt&quot;
</span><del>-        if !neg
-            outlabel = LocalLabel.unique(&quot;dcbout&quot;)
-            $asm.puts &quot;fcmp/gt #{sh4Operands([operands[1], operands[0]])}&quot;
-            $asm.puts &quot;bt #{LocalLabelReference.new(codeOrigin, outlabel).asmLabel}&quot;
-            $asm.puts &quot;fcmp/eq #{sh4Operands([operands[1], operands[0]])}&quot;
-            $asm.puts &quot;bf #{operands[2].asmLabel}&quot;
-            outlabel.lower(&quot;SH4&quot;)
-        else
-            $asm.puts &quot;fcmp/gt #{sh4Operands([operands[1], operands[0]])}&quot;
-            $asm.puts &quot;bt #{operands[2].asmLabel}&quot;
-            $asm.puts &quot;fcmp/eq #{sh4Operands([operands[1], operands[0]])}&quot;
-            $asm.puts &quot;bt #{operands[2].asmLabel}&quot;
-        end
</del><ins>+        $asm.puts &quot;fcmp/gt #{sh4Operands([operands[0], operands[1]])}&quot;
</ins><span class="cx">     else
</span><span class="cx">         $asm.puts &quot;fcmp/#{cmpOpcode} #{sh4Operands([operands[1], operands[0]])}&quot;
</span><del>-        emitSH4BranchIfT(operands[2], neg)
</del><span class="cx">     end
</span><ins>+    emitSH4BranchIfT(operands[2], neg)
</ins><span class="cx"> end
</span><span class="cx"> 
</span><span class="cx"> class Instruction
</span><span class="lines">@@ -728,12 +759,7 @@
</span><span class="cx">                 raise &quot;Unhandled parameters for opcode #{opcode} at #{codeOriginString}&quot;
</span><span class="cx">             end
</span><span class="cx">         when &quot;jmpf&quot;
</span><del>-            $asm.puts &quot;.balign 4&quot;
-            $asm.puts &quot;mov.l @(8, PC), #{operands[0].sh4Operand}&quot;
-            $asm.puts &quot;jmp @#{operands[0].sh4Operand}&quot;
-            $asm.puts &quot;nop&quot;
-            $asm.puts &quot;nop&quot;
-            $asm.puts &quot;.long #{operands[1].asmLabel}&quot;
</del><ins>+            emitSH4Load32AndJump(operands[1].asmLabel, operands[0])
</ins><span class="cx">         when &quot;ret&quot;
</span><span class="cx">             $asm.puts &quot;rts&quot;
</span><span class="cx">             $asm.puts &quot;nop&quot;
</span><span class="lines">@@ -746,10 +772,10 @@
</span><span class="cx">         when &quot;loadi&quot;, &quot;loadis&quot;, &quot;loadp&quot;, &quot;storei&quot;, &quot;storep&quot;
</span><span class="cx">             $asm.puts &quot;mov.l #{sh4Operands(operands)}&quot;
</span><span class="cx">         when &quot;move&quot;
</span><del>-            if operands[0].is_a? Immediate and (operands[0].value &lt; -128 or operands[0].value &gt; 127)
-                emitSH4LoadConstant(operands[0].value, operands[1])
-            elsif operands[0].is_a? LabelReference
-                emitSH4LoadConstant(operands[0].asmLabel, operands[1])
</del><ins>+            if operands[0].is_a? LabelReference
+                emitSH4Load32(operands[0].asmLabel, operands[1])
+            elsif operands[0].is_a? Immediate
+                emitSH4LoadImm(operands)
</ins><span class="cx">             else
</span><span class="cx">                 $asm.puts &quot;mov #{sh4Operands(operands)}&quot;
</span><span class="cx">             end
</span></span></pre>
</div>
</div>

</body>
</html>