Chromium Code Reviews| Index: src/mips/macro-assembler-mips.cc |
| diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc |
| index 272f8147b94185aac05ed5dd75d18940e2fb7e03..5a239a78253bcff353834a0f528040c0fc37864f 100644 |
| --- a/src/mips/macro-assembler-mips.cc |
| +++ b/src/mips/macro-assembler-mips.cc |
| @@ -1270,46 +1270,53 @@ void MacroAssembler::Ins(Register rt, |
| void MacroAssembler::Cvt_d_uw(FPURegister fd, |
| FPURegister fs, |
| FPURegister scratch) { |
| - // Move the data from fs to t8. |
| - mfc1(t8, fs); |
| - Cvt_d_uw(fd, t8, scratch); |
| + if (IsFp64Mode()) { |
| + // On FP64Mode we can simple do convertion from long. |
|
paul.l...
2015/11/19 01:23:38
Nits: fix spelling and word order in this sentence
Alan Li
2015/11/20 17:57:55
Done.
|
| + cvt_d_l(fd, fs); |
| + } else { |
| + mfc1(t8, fs); |
| + Cvt_d_uw(fd, t8, scratch, fs); |
| + } |
| } |
| -void MacroAssembler::Cvt_d_uw(FPURegister fd, |
| - Register rs, |
| - FPURegister scratch) { |
| +void MacroAssembler::Cvt_d_uw(FPURegister fd, Register rs, FPURegister scratch, |
| + FPURegister fs) { |
| // Convert rs to a FP value in fd (and fd + 1). |
|
paul.l...
2015/11/19 01:23:38
Remove the '(and fd + 1); from the comment. While
Alan Li
2015/11/20 17:57:55
Done.
|
| - // We do this by converting rs minus the MSB to avoid sign conversion, |
| - // then adding 2^31 to the result (if needed). |
| - |
| DCHECK(!fd.is(scratch)); |
| DCHECK(!rs.is(t9)); |
| DCHECK(!rs.is(at)); |
| - // Save rs's MSB to t9. |
| - Ext(t9, rs, 31, 1); |
| - // Remove rs's MSB. |
| - Ext(at, rs, 0, 31); |
| - // Move the result to fd. |
| - mtc1(at, fd); |
| - |
| - // Convert fd to a real FP value. |
| - cvt_d_w(fd, fd); |
| - |
| - Label conversion_done; |
| - |
| - // If rs's MSB was 0, it's done. |
| - // Otherwise we need to add that to the FP register. |
| - Branch(&conversion_done, eq, t9, Operand(zero_reg)); |
| + Label msb_clear, conversion_done; |
| + // For a value which is < 2^31, regard it as a signed positve word. |
| + Branch(&msb_clear, ge, rs, Operand(zero_reg), USE_DELAY_SLOT); |
| + lui(at, 0x41F0); // FP value: 2^32, in delay slot. |
| - // Load 2^31 into f20 as its float representation. |
| - li(at, 0x41E00000); |
| + // For unsigned word A which is greater than 2^31, consider this fact: |
| + // A = 2^32 + reinterpret_cast<int32>(A) |
| + // Thus we can first regard A as signed word and cast it into double, |
| + // then add 2^32 on the result to complete the casting. |
|
paul.l...
2015/11/19 01:23:38
Comment is too wordy, and strangely worded, we don
Alan Li
2015/11/20 17:57:55
Done.
|
| mtc1(zero_reg, scratch); |
| Mthc1(at, scratch); |
| - // Add it to fd. |
| + |
| + if (fs.is(no_freg)) { |
| + mtc1(rs, fd); |
| + cvt_d_w(fd, fd); |
| + } else { |
| + cvt_d_w(fd, fs); |
| + } |
| + |
| + Branch(USE_DELAY_SLOT, &conversion_done); |
| add_d(fd, fd, scratch); |
| + bind(&msb_clear); |
| + if (fs.is(no_freg)) { |
| + mtc1(rs, fd); |
| + cvt_d_w(fd, fd); |
| + } else { |
| + cvt_d_w(fd, fs); |
| + } |
| + |
| bind(&conversion_done); |
| } |