OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 BranchF(&fail, &fail, lt, fd, kDoubleRegZero); | |
1708 } | 1710 } |
1709 | 1711 |
1710 // Load 2^63 into scratch as its double representation. | 1712 // Load 2^63 into scratch as its double representation. |
1711 li(at, 0x43e0000000000000); | 1713 li(at, 0x43e0000000000000); |
1712 dmtc1(at, scratch); | 1714 dmtc1(at, scratch); |
1713 | 1715 |
1714 // Test if scratch > fd. | 1716 // Test if scratch > fd. |
1715 // If fd < 2^63 we can convert it normally. | 1717 // If fd < 2^63 we can convert it normally. |
1716 // If fd is unordered the conversion fails. | 1718 // If fd is unordered the conversion fails. |
1717 Label simple_convert, done, fail; | |
1718 BranchF(&simple_convert, &fail, lt, fd, scratch); | 1719 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 or unordered. |
1736 BranchF(&fail, &fail, lt, scratch, kDoubleRegZero); | 1737 BranchF(&fail, &fail, lt, scratch, kDoubleRegZero); |
1737 li(result, Operand(1)); | 1738 li(result, Operand(1)); |
1738 } | 1739 } |
1739 | 1740 |
1740 bind(&fail); | 1741 bind(&fail); |
1741 } | 1742 } |
1742 | 1743 |
1743 | 1744 |
1744 void MacroAssembler::Trunc_ul_s(FPURegister fd, Register rs, | 1745 void MacroAssembler::Trunc_ul_s(FPURegister fd, Register rs, |
1745 FPURegister scratch) { | 1746 FPURegister scratch, Register result) { |
1746 DCHECK(!fd.is(scratch)); | 1747 DCHECK(!fd.is(scratch)); |
1747 DCHECK(!rs.is(at)); | 1748 DCHECK(!AreAliased(rs, result, at)); |
1749 | |
1750 Label simple_convert, done, fail; | |
1751 if (result.is_valid()) { | |
1752 mov(result, zero_reg); | |
1753 Move(kDoubleRegZero, 0.0); | |
1754 // If fd < 0 or unordered, then the conversion fails. | |
1755 BranchF32(&fail, &fail, lt, fd, kDoubleRegZero); | |
1756 } | |
1748 | 1757 |
1749 // Load 2^63 into scratch as its float representation. | 1758 // Load 2^63 into scratch as its float representation. |
1750 li(at, 0x5f000000); | 1759 li(at, 0x5f000000); |
1751 dmtc1(at, scratch); | 1760 mtc1(at, scratch); |
1752 | 1761 |
1753 // Test if scratch > fd. | 1762 // Test if scratch > fd. |
1754 // If fd < 2^63 we can convert it normally. | 1763 // If fd < 2^63 we can convert it normally. |
1755 Label simple_convert, done; | 1764 // // If fd is unordered the conversion fails. |
1756 BranchF32(&simple_convert, NULL, lt, fd, scratch); | 1765 BranchF32(&simple_convert, nullptr, lt, fd, scratch); |
1757 | 1766 |
1758 // First we subtract 2^63 from fd, then trunc it to rs | 1767 // First we subtract 2^63 from fd, then trunc it to rs |
1759 // and add 2^63 to rs. | 1768 // and add 2^63 to rs. |
1760 sub_s(scratch, fd, scratch); | 1769 sub_s(scratch, fd, scratch); |
1761 trunc_l_s(scratch, scratch); | 1770 trunc_l_s(scratch, scratch); |
1762 dmfc1(rs, scratch); | 1771 dmfc1(rs, scratch); |
1763 Or(rs, rs, Operand(1UL << 63)); | 1772 Or(rs, rs, Operand(1UL << 63)); |
1764 Branch(&done); | 1773 Branch(&done); |
1765 | 1774 |
1766 // Simple conversion. | 1775 // Simple conversion. |
1767 bind(&simple_convert); | 1776 bind(&simple_convert); |
1768 trunc_l_s(scratch, fd); | 1777 trunc_l_s(scratch, fd); |
1769 dmfc1(rs, scratch); | 1778 dmfc1(rs, scratch); |
1770 | 1779 |
1771 bind(&done); | 1780 bind(&done); |
1781 if (result.is_valid()) { | |
1782 // Conversion is failed if the result is negative or unordered. | |
1783 BranchF(&fail, &fail, lt, scratch, kDoubleRegZero); | |
ahaas
2015/12/09 17:10:01
@v8-mips-ports: originally I wanted to use BranchF
paul.l...
2015/12/10 06:51:57
This is clearly broken, but I could not spot the b
| |
1784 li(result, Operand(1)); | |
1785 } | |
1786 | |
1787 bind(&fail); | |
1772 } | 1788 } |
1773 | 1789 |
1774 | 1790 |
1775 void MacroAssembler::Madd_d(FPURegister fd, FPURegister fr, FPURegister fs, | 1791 void MacroAssembler::Madd_d(FPURegister fd, FPURegister fr, FPURegister fs, |
1776 FPURegister ft, FPURegister scratch) { | 1792 FPURegister ft, FPURegister scratch) { |
1777 if (0) { // TODO(plind): find reasonable arch-variant symbol names. | 1793 if (0) { // TODO(plind): find reasonable arch-variant symbol names. |
1778 madd_d(fd, fr, fs, ft); | 1794 madd_d(fd, fr, fs, ft); |
1779 } else { | 1795 } else { |
1780 // Can not change source regs's value. | 1796 // Can not change source regs's value. |
1781 DCHECK(!fr.is(scratch) && !fs.is(scratch) && !ft.is(scratch)); | 1797 DCHECK(!fr.is(scratch) && !fs.is(scratch) && !ft.is(scratch)); |
(...skipping 4517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6299 if (mag.shift > 0) sra(result, result, mag.shift); | 6315 if (mag.shift > 0) sra(result, result, mag.shift); |
6300 srl(at, dividend, 31); | 6316 srl(at, dividend, 31); |
6301 Addu(result, result, Operand(at)); | 6317 Addu(result, result, Operand(at)); |
6302 } | 6318 } |
6303 | 6319 |
6304 | 6320 |
6305 } // namespace internal | 6321 } // namespace internal |
6306 } // namespace v8 | 6322 } // namespace v8 |
6307 | 6323 |
6308 #endif // V8_TARGET_ARCH_MIPS64 | 6324 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |