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 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1487 Register rs, | 1487 Register rs, |
1488 uint16_t pos, | 1488 uint16_t pos, |
1489 uint16_t size) { | 1489 uint16_t size) { |
1490 DCHECK(pos < 32); | 1490 DCHECK(pos < 32); |
1491 DCHECK(pos + size <= 32); | 1491 DCHECK(pos + size <= 32); |
1492 DCHECK(size != 0); | 1492 DCHECK(size != 0); |
1493 ins_(rt, rs, pos, size); | 1493 ins_(rt, rs, pos, size); |
1494 } | 1494 } |
1495 | 1495 |
1496 | 1496 |
1497 void MacroAssembler::Cvt_d_uw(FPURegister fd, | 1497 void MacroAssembler::Cvt_d_uw(FPURegister fd, FPURegister fs) { |
1498 FPURegister fs, | |
1499 FPURegister scratch) { | |
1500 // Move the data from fs to t8. | 1498 // Move the data from fs to t8. |
1501 mfc1(t8, fs); | 1499 mfc1(t8, fs); |
1502 Cvt_d_uw(fd, t8, scratch); | 1500 Cvt_d_uw(fd, t8); |
1503 } | 1501 } |
1504 | 1502 |
1505 | 1503 |
1506 void MacroAssembler::Cvt_d_uw(FPURegister fd, | 1504 void MacroAssembler::Cvt_d_uw(FPURegister fd, Register rs) { |
1507 Register rs, | 1505 // Convert rs to a FP value in fd. |
1508 FPURegister scratch) { | |
1509 // Convert rs to a FP value in fd (and fd + 1). | |
1510 // We do this by converting rs minus the MSB to avoid sign conversion, | |
1511 // then adding 2^31 to the result (if needed). | |
1512 | |
1513 DCHECK(!fd.is(scratch)); | 1506 DCHECK(!fd.is(scratch)); |
1514 DCHECK(!rs.is(t9)); | 1507 DCHECK(!rs.is(t9)); |
1515 DCHECK(!rs.is(at)); | 1508 DCHECK(!rs.is(at)); |
1516 | 1509 |
1517 // Save rs's MSB to t9. | 1510 // Zero extend int32 in rs. |
1518 Ext(t9, rs, 31, 1); | 1511 Dext(t9, rs, 0, 32); |
1519 // Remove rs's MSB. | 1512 dmtc1(t9, fd); |
1520 Ext(at, rs, 0, 31); | 1513 cvt_d_l(fd, fd); |
1521 // Move the result to fd. | |
1522 mtc1(at, fd); | |
1523 mthc1(zero_reg, fd); | |
1524 | |
1525 // Convert fd to a real FP value. | |
1526 cvt_d_w(fd, fd); | |
1527 | |
1528 Label conversion_done; | |
1529 | |
1530 // If rs's MSB was 0, it's done. | |
1531 // Otherwise we need to add that to the FP register. | |
1532 Branch(&conversion_done, eq, t9, Operand(zero_reg)); | |
1533 | |
1534 // Load 2^31 into f20 as its float representation. | |
1535 li(at, 0x41E00000); | |
1536 mtc1(zero_reg, scratch); | |
1537 mthc1(at, scratch); | |
1538 // Add it to fd. | |
1539 add_d(fd, fd, scratch); | |
1540 | |
1541 bind(&conversion_done); | |
1542 } | 1514 } |
1543 | 1515 |
1544 | 1516 |
1545 void MacroAssembler::Cvt_d_ul(FPURegister fd, FPURegister fs) { | 1517 void MacroAssembler::Cvt_d_ul(FPURegister fd, FPURegister fs) { |
1546 // Move the data from fs to t8. | 1518 // Move the data from fs to t8. |
1547 dmfc1(t8, fs); | 1519 dmfc1(t8, fs); |
1548 Cvt_d_ul(fd, t8); | 1520 Cvt_d_ul(fd, t8); |
1549 } | 1521 } |
1550 | 1522 |
1551 | 1523 |
1552 void MacroAssembler::Cvt_d_ul(FPURegister fd, Register rs) { | 1524 void MacroAssembler::Cvt_d_ul(FPURegister fd, Register rs) { |
1553 // Convert rs to a FP value in fd. | 1525 // Convert rs to a FP value in fd. |
1554 | 1526 |
1555 DCHECK(!rs.is(t9)); | 1527 DCHECK(!rs.is(t9)); |
1556 DCHECK(!rs.is(at)); | 1528 DCHECK(!rs.is(at)); |
1557 | 1529 |
1558 Label positive, conversion_done; | 1530 Label msb_set, conversion_done; |
1559 | 1531 |
1560 Branch(&positive, ge, rs, Operand(zero_reg)); | 1532 Branch(&msb_set, ge, rs, Operand(zero_reg)); |
1561 | 1533 |
1562 // Rs >= 2^31. | 1534 // Rs >= 2^63 |
1563 andi(t9, rs, 1); | 1535 andi(t9, rs, 1); |
1564 dsrl(rs, rs, 1); | 1536 dsrl(rs, rs, 1); |
1565 or_(t9, t9, rs); | 1537 or_(t9, t9, rs); |
1566 dmtc1(t9, fd); | 1538 dmtc1(t9, fd); |
1567 cvt_d_l(fd, fd); | 1539 cvt_d_l(fd, fd); |
1568 Branch(USE_DELAY_SLOT, &conversion_done); | 1540 Branch(USE_DELAY_SLOT, &conversion_done); |
1569 add_d(fd, fd, fd); // In delay slot. | 1541 add_d(fd, fd, fd); // In delay slot. |
1570 | 1542 |
1571 bind(&positive); | 1543 bind(&msb_set); |
paul.l...
2015/11/16 20:38:30
Oops, this label should be msb_clear.
dusan.milosavljevic
2015/11/16 22:08:51
Done.
| |
1572 // Rs < 2^31, we can do simple conversion. | 1544 // Rs < 2^63, we can do simple conversion. |
1573 dmtc1(rs, fd); | 1545 dmtc1(rs, fd); |
1574 cvt_d_l(fd, fd); | 1546 cvt_d_l(fd, fd); |
1575 | 1547 |
1576 bind(&conversion_done); | 1548 bind(&conversion_done); |
1577 } | 1549 } |
1578 | 1550 |
1579 | 1551 |
1580 void MacroAssembler::Round_l_d(FPURegister fd, FPURegister fs) { | 1552 void MacroAssembler::Round_l_d(FPURegister fd, FPURegister fs) { |
1581 round_l_d(fd, fs); | 1553 round_l_d(fd, fs); |
1582 } | 1554 } |
(...skipping 4648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6231 if (mag.shift > 0) sra(result, result, mag.shift); | 6203 if (mag.shift > 0) sra(result, result, mag.shift); |
6232 srl(at, dividend, 31); | 6204 srl(at, dividend, 31); |
6233 Addu(result, result, Operand(at)); | 6205 Addu(result, result, Operand(at)); |
6234 } | 6206 } |
6235 | 6207 |
6236 | 6208 |
6237 } // namespace internal | 6209 } // namespace internal |
6238 } // namespace v8 | 6210 } // namespace v8 |
6239 | 6211 |
6240 #endif // V8_TARGET_ARCH_MIPS64 | 6212 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |