Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: src/mips64/macro-assembler-mips64.cc

Issue 1512023002: [turbofan] Change TruncateFloat32ToUint64 to TryTruncateFloat32ToUint64. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added better mips64 code. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/mips64/macro-assembler-mips64.h ('k') | test/cctest/compiler/test-representation-change.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits.h> // For LONG_MIN, LONG_MAX. 5 #include <limits.h> // For LONG_MIN, LONG_MAX.
6 6
7 #if V8_TARGET_ARCH_MIPS64 7 #if V8_TARGET_ARCH_MIPS64
8 8
9 #include "src/base/division-by-constant.h" 9 #include "src/base/division-by-constant.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 } 1631 }
1632 1632
1633 void MacroAssembler::Trunc_ul_d(FPURegister fd, FPURegister fs, 1633 void MacroAssembler::Trunc_ul_d(FPURegister fd, FPURegister fs,
1634 FPURegister scratch, Register result) { 1634 FPURegister scratch, Register result) {
1635 Trunc_ul_d(fs, t8, scratch, result); 1635 Trunc_ul_d(fs, t8, scratch, result);
1636 dmtc1(t8, fd); 1636 dmtc1(t8, fd);
1637 } 1637 }
1638 1638
1639 1639
1640 void MacroAssembler::Trunc_ul_s(FPURegister fd, FPURegister fs, 1640 void MacroAssembler::Trunc_ul_s(FPURegister fd, FPURegister fs,
1641 FPURegister scratch) { 1641 FPURegister scratch, Register result) {
1642 Trunc_ul_s(fs, t8, scratch); 1642 Trunc_ul_s(fs, t8, scratch, result);
1643 dmtc1(t8, fd); 1643 dmtc1(t8, fd);
1644 } 1644 }
1645 1645
1646 1646
1647 void MacroAssembler::Trunc_w_d(FPURegister fd, FPURegister fs) { 1647 void MacroAssembler::Trunc_w_d(FPURegister fd, FPURegister fs) {
1648 trunc_w_d(fd, fs); 1648 trunc_w_d(fd, fs);
1649 } 1649 }
1650 1650
1651 1651
1652 void MacroAssembler::Round_w_d(FPURegister fd, FPURegister fs) { 1652 void MacroAssembler::Round_w_d(FPURegister fd, FPURegister fs) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 1695
1696 bind(&done); 1696 bind(&done);
1697 } 1697 }
1698 1698
1699 1699
1700 void MacroAssembler::Trunc_ul_d(FPURegister fd, Register rs, 1700 void MacroAssembler::Trunc_ul_d(FPURegister fd, Register rs,
1701 FPURegister scratch, Register result) { 1701 FPURegister scratch, Register result) {
1702 DCHECK(!fd.is(scratch)); 1702 DCHECK(!fd.is(scratch));
1703 DCHECK(!AreAliased(rs, result, at)); 1703 DCHECK(!AreAliased(rs, result, at));
1704 1704
1705 Label simple_convert, done, fail;
1705 if (result.is_valid()) { 1706 if (result.is_valid()) {
1706 mov(result, zero_reg); 1707 mov(result, zero_reg);
1707 Move(kDoubleRegZero, 0.0); 1708 Move(kDoubleRegZero, 0.0);
1709 // If fd < 0 or unordered, then the conversion fails.
1710 BranchF(&fail, &fail, lt, fd, kDoubleRegZero);
1708 } 1711 }
1709 1712
1710 // Load 2^63 into scratch as its double representation. 1713 // Load 2^63 into scratch as its double representation.
1711 li(at, 0x43e0000000000000); 1714 li(at, 0x43e0000000000000);
1712 dmtc1(at, scratch); 1715 dmtc1(at, scratch);
1713 1716
1714 // Test if scratch > fd. 1717 // Test if scratch > fd.
1715 // If fd < 2^63 we can convert it normally. 1718 // If fd < 2^63 we can convert it normally.
1716 // If fd is unordered the conversion fails. 1719 BranchF(&simple_convert, nullptr, lt, fd, scratch);
1717 Label simple_convert, done, fail;
1718 BranchF(&simple_convert, &fail, lt, fd, scratch);
1719 1720
1720 // First we subtract 2^63 from fd, then trunc it to rs 1721 // First we subtract 2^63 from fd, then trunc it to rs
1721 // and add 2^63 to rs. 1722 // and add 2^63 to rs.
1722 sub_d(scratch, fd, scratch); 1723 sub_d(scratch, fd, scratch);
1723 trunc_l_d(scratch, scratch); 1724 trunc_l_d(scratch, scratch);
1724 dmfc1(rs, scratch); 1725 dmfc1(rs, scratch);
1725 Or(rs, rs, Operand(1UL << 63)); 1726 Or(rs, rs, Operand(1UL << 63));
1726 Branch(&done); 1727 Branch(&done);
1727 1728
1728 // Simple conversion. 1729 // Simple conversion.
1729 bind(&simple_convert); 1730 bind(&simple_convert);
1730 trunc_l_d(scratch, fd); 1731 trunc_l_d(scratch, fd);
1731 dmfc1(rs, scratch); 1732 dmfc1(rs, scratch);
1732 1733
1733 bind(&done); 1734 bind(&done);
1734 if (result.is_valid()) { 1735 if (result.is_valid()) {
1735 // Conversion is failed if the result is negative or unordered. 1736 // Conversion is failed if the result is negative.
1736 BranchF(&fail, &fail, lt, scratch, kDoubleRegZero); 1737 addiu(at, zero_reg, -1);
1737 li(result, Operand(1)); 1738 dsrl(at, at, 1); // Load 2^62.
1739 dmfc1(result, scratch);
1740 xor_(result, result, at);
1741 Slt(result, zero_reg, result);
1738 } 1742 }
1739 1743
1740 bind(&fail); 1744 bind(&fail);
1741 } 1745 }
1742 1746
1743 1747
1744 void MacroAssembler::Trunc_ul_s(FPURegister fd, Register rs, 1748 void MacroAssembler::Trunc_ul_s(FPURegister fd, Register rs,
1745 FPURegister scratch) { 1749 FPURegister scratch, Register result) {
1746 DCHECK(!fd.is(scratch)); 1750 DCHECK(!fd.is(scratch));
1747 DCHECK(!rs.is(at)); 1751 DCHECK(!AreAliased(rs, result, at));
1752
1753 Label simple_convert, done, fail;
1754 if (result.is_valid()) {
1755 mov(result, zero_reg);
1756 Move(kDoubleRegZero, 0.0);
1757 // If fd < 0 or unordered, then the conversion fails.
1758 BranchF32(&fail, &fail, lt, fd, kDoubleRegZero);
1759 }
1748 1760
1749 // Load 2^63 into scratch as its float representation. 1761 // Load 2^63 into scratch as its float representation.
1750 li(at, 0x5f000000); 1762 li(at, 0x5f000000);
1751 dmtc1(at, scratch); 1763 mtc1(at, scratch);
1752 1764
1753 // Test if scratch > fd. 1765 // Test if scratch > fd.
1754 // If fd < 2^63 we can convert it normally. 1766 // If fd < 2^63 we can convert it normally.
1755 Label simple_convert, done; 1767 BranchF32(&simple_convert, nullptr, lt, fd, scratch);
1756 BranchF32(&simple_convert, NULL, lt, fd, scratch);
1757 1768
1758 // First we subtract 2^63 from fd, then trunc it to rs 1769 // First we subtract 2^63 from fd, then trunc it to rs
1759 // and add 2^63 to rs. 1770 // and add 2^63 to rs.
1760 sub_s(scratch, fd, scratch); 1771 sub_s(scratch, fd, scratch);
1761 trunc_l_s(scratch, scratch); 1772 trunc_l_s(scratch, scratch);
1762 dmfc1(rs, scratch); 1773 dmfc1(rs, scratch);
1763 Or(rs, rs, Operand(1UL << 63)); 1774 Or(rs, rs, Operand(1UL << 63));
1764 Branch(&done); 1775 Branch(&done);
1765 1776
1766 // Simple conversion. 1777 // Simple conversion.
1767 bind(&simple_convert); 1778 bind(&simple_convert);
1768 trunc_l_s(scratch, fd); 1779 trunc_l_s(scratch, fd);
1769 dmfc1(rs, scratch); 1780 dmfc1(rs, scratch);
1770 1781
1771 bind(&done); 1782 bind(&done);
1783 if (result.is_valid()) {
1784 // Conversion is failed if the result is negative or unordered.
1785 addiu(at, zero_reg, -1);
1786 dsrl(at, at, 1); // Load 2^62.
1787 dmfc1(result, scratch);
1788 xor_(result, result, at);
1789 Slt(result, zero_reg, result);
1790 }
1791
1792 bind(&fail);
1772 } 1793 }
1773 1794
1774 1795
1775 void MacroAssembler::Madd_d(FPURegister fd, FPURegister fr, FPURegister fs, 1796 void MacroAssembler::Madd_d(FPURegister fd, FPURegister fr, FPURegister fs,
1776 FPURegister ft, FPURegister scratch) { 1797 FPURegister ft, FPURegister scratch) {
1777 if (0) { // TODO(plind): find reasonable arch-variant symbol names. 1798 if (0) { // TODO(plind): find reasonable arch-variant symbol names.
1778 madd_d(fd, fr, fs, ft); 1799 madd_d(fd, fr, fs, ft);
1779 } else { 1800 } else {
1780 // Can not change source regs's value. 1801 // Can not change source regs's value.
1781 DCHECK(!fr.is(scratch) && !fs.is(scratch) && !ft.is(scratch)); 1802 DCHECK(!fr.is(scratch) && !fs.is(scratch) && !ft.is(scratch));
(...skipping 4517 matching lines...) Expand 10 before | Expand all | Expand 10 after
6299 if (mag.shift > 0) sra(result, result, mag.shift); 6320 if (mag.shift > 0) sra(result, result, mag.shift);
6300 srl(at, dividend, 31); 6321 srl(at, dividend, 31);
6301 Addu(result, result, Operand(at)); 6322 Addu(result, result, Operand(at));
6302 } 6323 }
6303 6324
6304 6325
6305 } // namespace internal 6326 } // namespace internal
6306 } // namespace v8 6327 } // namespace v8
6307 6328
6308 #endif // V8_TARGET_ARCH_MIPS64 6329 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips64/macro-assembler-mips64.h ('k') | test/cctest/compiler/test-representation-change.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698