Index: src/mips64/macro-assembler-mips64.cc |
diff --git a/src/mips64/macro-assembler-mips64.cc b/src/mips64/macro-assembler-mips64.cc |
index dff40e5e74eabbd031c6c82241c3eb963b35de41..92c5d5becf07008ed62e426cd190bc95c7d3d071 100644 |
--- a/src/mips64/macro-assembler-mips64.cc |
+++ b/src/mips64/macro-assembler-mips64.cc |
@@ -1628,6 +1628,13 @@ void MacroAssembler::Trunc_ul_d(FPURegister fd, FPURegister fs, |
} |
+void MacroAssembler::Trunc_ul_s(FPURegister fd, FPURegister fs, |
+ FPURegister scratch) { |
+ Trunc_ul_s(fs, t8, scratch); |
+ dmtc1(t8, fd); |
+} |
+ |
+ |
void MacroAssembler::Trunc_w_d(FPURegister fd, FPURegister fs) { |
trunc_w_d(fd, fs); |
} |
@@ -1686,7 +1693,7 @@ void MacroAssembler::Trunc_ul_d(FPURegister fd, Register rs, |
DCHECK(!fd.is(scratch)); |
DCHECK(!rs.is(at)); |
- // Load 2^63 into scratch as its float representation. |
+ // Load 2^63 into scratch as its double representation. |
li(at, 0x43e0000000000000); |
dmtc1(at, scratch); |
@@ -1712,6 +1719,37 @@ void MacroAssembler::Trunc_ul_d(FPURegister fd, Register rs, |
} |
+void MacroAssembler::Trunc_ul_s(FPURegister fd, Register rs, |
+ FPURegister scratch) { |
+ DCHECK(!fd.is(scratch)); |
+ DCHECK(!rs.is(at)); |
+ |
+ // Load 2^63 into scratch as its float representation. |
+ li(at, 0x5f000000); |
+ dmtc1(at, scratch); |
+ |
+ // Test if scratch > fd. |
+ // If fd < 2^63 we can convert it normally. |
+ Label simple_convert, done; |
+ BranchF32(&simple_convert, NULL, lt, fd, scratch); |
+ |
+ // First we subtract 2^63 from fd, then trunc it to rs |
+ // and add 2^63 to rs. |
+ sub_s(scratch, fd, scratch); |
+ trunc_l_s(scratch, scratch); |
+ dmfc1(rs, scratch); |
+ Or(rs, rs, Operand(1UL << 63)); |
+ Branch(&done); |
+ |
+ // Simple conversion. |
+ bind(&simple_convert); |
+ trunc_l_s(scratch, fd); |
+ dmfc1(rs, scratch); |
+ |
+ bind(&done); |
+} |
+ |
+ |
void MacroAssembler::Madd_d(FPURegister fd, FPURegister fr, FPURegister fs, |
FPURegister ft, FPURegister scratch) { |
if (0) { // TODO(plind): find reasonable arch-variant symbol names. |