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_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 bnvc(rs, rt, L); | 1129 bnvc(rs, rt, L); |
1130 } | 1130 } |
1131 } | 1131 } |
1132 | 1132 |
1133 // ------------Pseudo-instructions------------- | 1133 // ------------Pseudo-instructions------------- |
1134 | 1134 |
1135 // Word Swap Byte | 1135 // Word Swap Byte |
1136 void MacroAssembler::ByteSwapSigned(Register dest, Register src, | 1136 void MacroAssembler::ByteSwapSigned(Register dest, Register src, |
1137 int operand_size) { | 1137 int operand_size) { |
1138 DCHECK(operand_size == 1 || operand_size == 2 || operand_size == 4); | 1138 DCHECK(operand_size == 1 || operand_size == 2 || operand_size == 4); |
| 1139 |
| 1140 if (operand_size == 2) { |
| 1141 Seh(src, src); |
| 1142 } else if (operand_size == 1) { |
| 1143 Seb(src, src); |
| 1144 } |
| 1145 // No need to do any preparation if operand_size is 4 |
| 1146 |
1139 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) { | 1147 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) { |
1140 if (operand_size == 2) { | |
1141 seh(src, src); | |
1142 } else if (operand_size == 1) { | |
1143 seb(src, src); | |
1144 } | |
1145 // No need to do any preparation if operand_size is 4 | |
1146 | |
1147 wsbh(dest, src); | 1148 wsbh(dest, src); |
1148 rotr(dest, dest, 16); | 1149 rotr(dest, dest, 16); |
1149 } else if (IsMipsArchVariant(kMips32r1) || IsMipsArchVariant(kLoongson)) { | 1150 } else if (IsMipsArchVariant(kMips32r1) || IsMipsArchVariant(kLoongson)) { |
1150 if (operand_size == 1) { | |
1151 sll(src, src, 24); | |
1152 sra(src, src, 24); | |
1153 } else if (operand_size == 2) { | |
1154 sll(src, src, 16); | |
1155 sra(src, src, 16); | |
1156 } | |
1157 // No need to do any preparation if operand_size is 4 | |
1158 | |
1159 Register tmp = t0; | 1151 Register tmp = t0; |
1160 Register tmp2 = t1; | 1152 Register tmp2 = t1; |
1161 | 1153 |
1162 andi(tmp2, src, 0xFF); | 1154 andi(tmp2, src, 0xFF); |
1163 sll(tmp2, tmp2, 24); | 1155 sll(tmp2, tmp2, 24); |
1164 or_(tmp, zero_reg, tmp2); | 1156 or_(tmp, zero_reg, tmp2); |
1165 | 1157 |
1166 andi(tmp2, src, 0xFF00); | 1158 andi(tmp2, src, 0xFF00); |
1167 sll(tmp2, tmp2, 8); | 1159 sll(tmp2, tmp2, 8); |
1168 or_(tmp, tmp, tmp2); | 1160 or_(tmp, tmp, tmp2); |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 srl(at, at, 32 - size); | 1821 srl(at, at, 32 - size); |
1830 and_(t8, rs, at); | 1822 and_(t8, rs, at); |
1831 sll(t8, t8, pos); | 1823 sll(t8, t8, pos); |
1832 sll(at, at, pos); | 1824 sll(at, at, pos); |
1833 nor(at, at, zero_reg); | 1825 nor(at, at, zero_reg); |
1834 and_(at, rt, at); | 1826 and_(at, rt, at); |
1835 or_(rt, t8, at); | 1827 or_(rt, t8, at); |
1836 } | 1828 } |
1837 } | 1829 } |
1838 | 1830 |
| 1831 void MacroAssembler::Seb(Register rd, Register rt) { |
| 1832 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) { |
| 1833 seb(rd, rt); |
| 1834 } else { |
| 1835 DCHECK(IsMipsArchVariant(kMips32r1) || IsMipsArchVariant(kLoongson)); |
| 1836 sll(rd, rt, 24); |
| 1837 sra(rd, rd, 24); |
| 1838 } |
| 1839 } |
| 1840 |
| 1841 void MacroAssembler::Seh(Register rd, Register rt) { |
| 1842 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) { |
| 1843 seh(rd, rt); |
| 1844 } else { |
| 1845 DCHECK(IsMipsArchVariant(kMips32r1) || IsMipsArchVariant(kLoongson)); |
| 1846 sll(rd, rt, 16); |
| 1847 sra(rd, rd, 16); |
| 1848 } |
| 1849 } |
| 1850 |
1839 void MacroAssembler::Neg_s(FPURegister fd, FPURegister fs) { | 1851 void MacroAssembler::Neg_s(FPURegister fd, FPURegister fs) { |
1840 if (IsMipsArchVariant(kMips32r6)) { | 1852 if (IsMipsArchVariant(kMips32r6)) { |
1841 // r6 neg_s changes the sign for NaN-like operands as well. | 1853 // r6 neg_s changes the sign for NaN-like operands as well. |
1842 neg_s(fd, fs); | 1854 neg_s(fd, fs); |
1843 } else { | 1855 } else { |
1844 DCHECK(IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r1) || | 1856 DCHECK(IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r1) || |
1845 IsMipsArchVariant(kLoongson)); | 1857 IsMipsArchVariant(kLoongson)); |
1846 Label is_nan, done; | 1858 Label is_nan, done; |
1847 Register scratch1 = t8; | 1859 Register scratch1 = t8; |
1848 Register scratch2 = t9; | 1860 Register scratch2 = t9; |
(...skipping 5029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6878 if (mag.shift > 0) sra(result, result, mag.shift); | 6890 if (mag.shift > 0) sra(result, result, mag.shift); |
6879 srl(at, dividend, 31); | 6891 srl(at, dividend, 31); |
6880 Addu(result, result, Operand(at)); | 6892 Addu(result, result, Operand(at)); |
6881 } | 6893 } |
6882 | 6894 |
6883 | 6895 |
6884 } // namespace internal | 6896 } // namespace internal |
6885 } // namespace v8 | 6897 } // namespace v8 |
6886 | 6898 |
6887 #endif // V8_TARGET_ARCH_MIPS | 6899 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |