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

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

Issue 1510493012: MIPS64: Fix BranchF() usage. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix comments. 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 | « no previous file | no next file » | 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 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 Label simple_convert, done, fail;
1706 if (result.is_valid()) { 1706 if (result.is_valid()) {
1707 mov(result, zero_reg); 1707 mov(result, zero_reg);
1708 Move(kDoubleRegZero, 0.0); 1708 Move(kDoubleRegZero, 0.0);
1709 // If fd < 0 or unordered, then the conversion fails.
1709 BranchF(&fail, &fail, lt, fd, kDoubleRegZero); 1710 BranchF(&fail, &fail, lt, fd, kDoubleRegZero);
1710 } 1711 }
1711 1712
1712 // Load 2^63 into scratch as its double representation. 1713 // Load 2^63 into scratch as its double representation.
1713 li(at, 0x43e0000000000000); 1714 li(at, 0x43e0000000000000);
1714 dmtc1(at, scratch); 1715 dmtc1(at, scratch);
1715 1716
1716 // Test if scratch > fd. 1717 // Test if scratch > fd.
1717 // If fd < 2^63 we can convert it normally. 1718 // If fd < 2^63 we can convert it normally.
1718 // If fd is unordered the conversion fails. 1719 BranchF(&simple_convert, nullptr, lt, fd, scratch);
1719 BranchF(&simple_convert, &fail, lt, fd, scratch);
1720 1720
1721 // 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
1722 // and add 2^63 to rs. 1722 // and add 2^63 to rs.
1723 sub_d(scratch, fd, scratch); 1723 sub_d(scratch, fd, scratch);
1724 trunc_l_d(scratch, scratch); 1724 trunc_l_d(scratch, scratch);
1725 dmfc1(rs, scratch); 1725 dmfc1(rs, scratch);
1726 Or(rs, rs, Operand(1UL << 63)); 1726 Or(rs, rs, Operand(1UL << 63));
1727 Branch(&done); 1727 Branch(&done);
1728 1728
1729 // Simple conversion. 1729 // Simple conversion.
1730 bind(&simple_convert); 1730 bind(&simple_convert);
1731 trunc_l_d(scratch, fd); 1731 trunc_l_d(scratch, fd);
1732 dmfc1(rs, scratch); 1732 dmfc1(rs, scratch);
1733 1733
1734 bind(&done); 1734 bind(&done);
1735 if (result.is_valid()) { 1735 if (result.is_valid()) {
1736 // Conversion is failed if the result is negative or unordered. 1736 // Conversion is failed if the result is negative.
1737 BranchF(&fail, &fail, lt, scratch, kDoubleRegZero); 1737 addiu(at, zero_reg, -1);
1738 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);
1739 } 1742 }
1740 1743
1741 bind(&fail); 1744 bind(&fail);
1742 } 1745 }
1743 1746
1744 1747
1745 void MacroAssembler::Trunc_ul_s(FPURegister fd, Register rs, 1748 void MacroAssembler::Trunc_ul_s(FPURegister fd, Register rs,
1746 FPURegister scratch, Register result) { 1749 FPURegister scratch, Register result) {
1747 DCHECK(!fd.is(scratch)); 1750 DCHECK(!fd.is(scratch));
1748 DCHECK(!AreAliased(rs, result, at)); 1751 DCHECK(!AreAliased(rs, result, at));
1749 1752
1750 Label simple_convert, done, fail; 1753 Label simple_convert, done, fail;
1751 if (result.is_valid()) { 1754 if (result.is_valid()) {
1752 mov(result, zero_reg); 1755 mov(result, zero_reg);
1753 Move(kDoubleRegZero, 0.0); 1756 Move(kDoubleRegZero, 0.0);
1754 // If fd < 0 or unordered, then the conversion fails. 1757 // If fd < 0 or unordered, then the conversion fails.
1755 BranchF32(&fail, &fail, lt, fd, kDoubleRegZero); 1758 BranchF32(&fail, &fail, lt, fd, kDoubleRegZero);
1756 } 1759 }
1757 1760
1758 // Load 2^63 into scratch as its float representation. 1761 // Load 2^63 into scratch as its float representation.
1759 li(at, 0x5f000000); 1762 li(at, 0x5f000000);
1760 mtc1(at, scratch); 1763 mtc1(at, scratch);
1761 1764
1762 // Test if scratch > fd. 1765 // Test if scratch > fd.
1763 // If fd < 2^63 we can convert it normally. 1766 // If fd < 2^63 we can convert it normally.
1764 // // If fd is unordered the conversion fails.
1765 BranchF32(&simple_convert, nullptr, lt, fd, scratch); 1767 BranchF32(&simple_convert, nullptr, lt, fd, scratch);
1766 1768
1767 // 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
1768 // and add 2^63 to rs. 1770 // and add 2^63 to rs.
1769 sub_s(scratch, fd, scratch); 1771 sub_s(scratch, fd, scratch);
1770 trunc_l_s(scratch, scratch); 1772 trunc_l_s(scratch, scratch);
1771 dmfc1(rs, scratch); 1773 dmfc1(rs, scratch);
1772 Or(rs, rs, Operand(1UL << 63)); 1774 Or(rs, rs, Operand(1UL << 63));
1773 Branch(&done); 1775 Branch(&done);
1774 1776
1775 // Simple conversion. 1777 // Simple conversion.
1776 bind(&simple_convert); 1778 bind(&simple_convert);
1777 trunc_l_s(scratch, fd); 1779 trunc_l_s(scratch, fd);
1778 dmfc1(rs, scratch); 1780 dmfc1(rs, scratch);
1779 1781
1780 bind(&done); 1782 bind(&done);
1781 if (result.is_valid()) { 1783 if (result.is_valid()) {
1782 // Conversion is failed if the result is negative or unordered. 1784 // Conversion is failed if the result is negative or unordered.
1783 BranchF(&fail, &fail, lt, scratch, kDoubleRegZero); 1785 addiu(at, zero_reg, -1);
1784 li(result, Operand(1)); 1786 dsrl(at, at, 1); // Load 2^62.
1787 dmfc1(result, scratch);
1788 xor_(result, result, at);
1789 Slt(result, zero_reg, result);
1785 } 1790 }
1786 1791
1787 bind(&fail); 1792 bind(&fail);
1788 } 1793 }
1789 1794
1790 1795
1791 void MacroAssembler::Madd_d(FPURegister fd, FPURegister fr, FPURegister fs, 1796 void MacroAssembler::Madd_d(FPURegister fd, FPURegister fr, FPURegister fs,
1792 FPURegister ft, FPURegister scratch) { 1797 FPURegister ft, FPURegister scratch) {
1793 if (0) { // TODO(plind): find reasonable arch-variant symbol names. 1798 if (0) { // TODO(plind): find reasonable arch-variant symbol names.
1794 madd_d(fd, fr, fs, ft); 1799 madd_d(fd, fr, fs, ft);
(...skipping 4520 matching lines...) Expand 10 before | Expand all | Expand 10 after
6315 if (mag.shift > 0) sra(result, result, mag.shift); 6320 if (mag.shift > 0) sra(result, result, mag.shift);
6316 srl(at, dividend, 31); 6321 srl(at, dividend, 31);
6317 Addu(result, result, Operand(at)); 6322 Addu(result, result, Operand(at));
6318 } 6323 }
6319 6324
6320 6325
6321 } // namespace internal 6326 } // namespace internal
6322 } // namespace v8 6327 } // namespace v8
6323 6328
6324 #endif // V8_TARGET_ARCH_MIPS64 6329 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698