OLD | NEW |
1 | 1 |
2 // Copyright 2012 the V8 project authors. All rights reserved. | 2 // Copyright 2012 the V8 project authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 #include <limits.h> // For LONG_MIN, LONG_MAX. | 6 #include <limits.h> // For LONG_MIN, LONG_MAX. |
7 | 7 |
8 #if V8_TARGET_ARCH_MIPS | 8 #if V8_TARGET_ARCH_MIPS |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 | 1320 |
1321 for (int16_t i = kNumRegisters - 1; i >= 0; i--) { | 1321 for (int16_t i = kNumRegisters - 1; i >= 0; i--) { |
1322 if ((regs & (1 << i)) != 0) { | 1322 if ((regs & (1 << i)) != 0) { |
1323 ldc1(FPURegister::from_code(i), MemOperand(sp, stack_offset)); | 1323 ldc1(FPURegister::from_code(i), MemOperand(sp, stack_offset)); |
1324 stack_offset += kDoubleSize; | 1324 stack_offset += kDoubleSize; |
1325 } | 1325 } |
1326 } | 1326 } |
1327 addiu(sp, sp, stack_offset); | 1327 addiu(sp, sp, stack_offset); |
1328 } | 1328 } |
1329 | 1329 |
| 1330 void MacroAssembler::ShlPair(Register dst_low, Register dst_high, |
| 1331 Register src_low, Register src_high, |
| 1332 Register shift) { |
| 1333 Label less_than_32; |
| 1334 Label zero_shift; |
| 1335 Label word_shift; |
| 1336 Label done; |
| 1337 Register kScratchReg = s3; |
| 1338 li(kScratchReg, 0x20); |
| 1339 Branch(&less_than_32, lt, shift, Operand(kScratchReg)); |
| 1340 |
| 1341 Branch(&word_shift, eq, shift, Operand(kScratchReg)); |
| 1342 // Shift more than 32 |
| 1343 Subu(kScratchReg, shift, kScratchReg); |
| 1344 mov(dst_low, zero_reg); |
| 1345 sllv(dst_high, src_low, kScratchReg); |
| 1346 Branch(&done); |
| 1347 // Word shift |
| 1348 bind(&word_shift); |
| 1349 mov(dst_low, zero_reg); |
| 1350 mov(dst_high, src_low); |
| 1351 Branch(&done); |
| 1352 |
| 1353 bind(&less_than_32); |
| 1354 // Check if zero shift |
| 1355 Branch(&zero_shift, eq, shift, Operand(zero_reg)); |
| 1356 // Shift less than 32 |
| 1357 Subu(kScratchReg, kScratchReg, shift); |
| 1358 sllv(dst_high, src_high, shift); |
| 1359 sllv(dst_low, src_low, shift); |
| 1360 srlv(kScratchReg, src_low, kScratchReg); |
| 1361 Or(dst_high, dst_high, kScratchReg); |
| 1362 Branch(&done); |
| 1363 // Zero shift |
| 1364 bind(&zero_shift); |
| 1365 mov(dst_low, src_low); |
| 1366 mov(dst_high, src_high); |
| 1367 bind(&done); |
| 1368 } |
| 1369 |
| 1370 void MacroAssembler::ShlPair(Register dst_low, Register dst_high, |
| 1371 Register src_low, Register src_high, |
| 1372 uint32_t shift) { |
| 1373 Register kScratchReg = s3; |
| 1374 if (shift < 32) { |
| 1375 if (shift == 0) { |
| 1376 mov(dst_low, src_low); |
| 1377 mov(dst_high, src_high); |
| 1378 } else { |
| 1379 sll(dst_high, src_high, shift); |
| 1380 sll(dst_low, src_low, shift); |
| 1381 shift = 32 - shift; |
| 1382 srl(kScratchReg, src_low, shift); |
| 1383 Or(dst_high, dst_high, kScratchReg); |
| 1384 } |
| 1385 } else { |
| 1386 if (shift == 32) { |
| 1387 mov(dst_low, zero_reg); |
| 1388 mov(dst_high, src_low); |
| 1389 } else { |
| 1390 shift = shift - 32; |
| 1391 mov(dst_low, zero_reg); |
| 1392 sll(dst_high, src_low, shift); |
| 1393 } |
| 1394 } |
| 1395 } |
| 1396 |
| 1397 void MacroAssembler::ShrPair(Register dst_low, Register dst_high, |
| 1398 Register src_low, Register src_high, |
| 1399 Register shift) { |
| 1400 Label less_than_32; |
| 1401 Label zero_shift; |
| 1402 Label word_shift; |
| 1403 Label done; |
| 1404 Register kScratchReg = s3; |
| 1405 li(kScratchReg, 0x20); |
| 1406 Branch(&less_than_32, lt, shift, Operand(kScratchReg)); |
| 1407 |
| 1408 Branch(&word_shift, eq, shift, Operand(kScratchReg)); |
| 1409 // Shift more than 32 |
| 1410 Subu(kScratchReg, shift, kScratchReg); |
| 1411 mov(dst_high, zero_reg); |
| 1412 srlv(dst_low, src_high, kScratchReg); |
| 1413 Branch(&done); |
| 1414 // Word shift |
| 1415 bind(&word_shift); |
| 1416 mov(dst_high, zero_reg); |
| 1417 mov(dst_low, src_high); |
| 1418 Branch(&done); |
| 1419 |
| 1420 bind(&less_than_32); |
| 1421 // Check if zero shift |
| 1422 Branch(&zero_shift, eq, shift, Operand(zero_reg)); |
| 1423 // Shift less than 32 |
| 1424 Subu(kScratchReg, kScratchReg, shift); |
| 1425 srlv(dst_high, src_high, shift); |
| 1426 srlv(dst_low, src_low, shift); |
| 1427 sllv(kScratchReg, src_high, kScratchReg); |
| 1428 Or(dst_low, dst_low, kScratchReg); |
| 1429 Branch(&done); |
| 1430 // Zero shift |
| 1431 bind(&zero_shift); |
| 1432 mov(dst_low, src_low); |
| 1433 mov(dst_high, src_high); |
| 1434 bind(&done); |
| 1435 } |
| 1436 |
| 1437 void MacroAssembler::ShrPair(Register dst_low, Register dst_high, |
| 1438 Register src_low, Register src_high, |
| 1439 uint32_t shift) { |
| 1440 Register kScratchReg = s3; |
| 1441 if (shift < 32) { |
| 1442 if (shift == 0) { |
| 1443 mov(dst_low, src_low); |
| 1444 mov(dst_high, src_high); |
| 1445 } else { |
| 1446 srl(dst_high, src_high, shift); |
| 1447 srl(dst_low, src_low, shift); |
| 1448 shift = 32 - shift; |
| 1449 sll(kScratchReg, src_high, shift); |
| 1450 Or(dst_low, dst_low, kScratchReg); |
| 1451 } |
| 1452 } else { |
| 1453 if (shift == 32) { |
| 1454 mov(dst_high, zero_reg); |
| 1455 mov(dst_low, src_high); |
| 1456 } else { |
| 1457 shift = shift - 32; |
| 1458 mov(dst_high, zero_reg); |
| 1459 srl(dst_low, src_high, shift); |
| 1460 } |
| 1461 } |
| 1462 } |
| 1463 |
| 1464 void MacroAssembler::SarPair(Register dst_low, Register dst_high, |
| 1465 Register src_low, Register src_high, |
| 1466 Register shift) { |
| 1467 Label less_than_32; |
| 1468 Label zero_shift; |
| 1469 Label word_shift; |
| 1470 Label done; |
| 1471 Register kScratchReg = s3; |
| 1472 Register kScratchReg2 = s4; |
| 1473 li(kScratchReg, 0x20); |
| 1474 Branch(&less_than_32, lt, shift, Operand(kScratchReg)); |
| 1475 |
| 1476 Branch(&word_shift, eq, shift, Operand(kScratchReg)); |
| 1477 |
| 1478 // Shift more than 32 |
| 1479 li(kScratchReg2, 0x1F); |
| 1480 Subu(kScratchReg, shift, kScratchReg); |
| 1481 srav(dst_high, src_high, kScratchReg2); |
| 1482 srav(dst_low, src_high, kScratchReg); |
| 1483 Branch(&done); |
| 1484 // Word shift |
| 1485 bind(&word_shift); |
| 1486 li(kScratchReg2, 0x1F); |
| 1487 srav(dst_high, src_high, kScratchReg2); |
| 1488 mov(dst_low, src_high); |
| 1489 Branch(&done); |
| 1490 |
| 1491 bind(&less_than_32); |
| 1492 // Check if zero shift |
| 1493 Branch(&zero_shift, eq, shift, Operand(zero_reg)); |
| 1494 |
| 1495 // Shift less than 32 |
| 1496 Subu(kScratchReg, kScratchReg, shift); |
| 1497 srav(dst_high, src_high, shift); |
| 1498 srlv(dst_low, src_low, shift); |
| 1499 sllv(kScratchReg, src_high, kScratchReg); |
| 1500 Or(dst_low, dst_low, kScratchReg); |
| 1501 Branch(&done); |
| 1502 // Zero shift |
| 1503 bind(&zero_shift); |
| 1504 mov(dst_low, src_low); |
| 1505 mov(dst_high, src_high); |
| 1506 bind(&done); |
| 1507 } |
| 1508 |
| 1509 void MacroAssembler::SarPair(Register dst_low, Register dst_high, |
| 1510 Register src_low, Register src_high, |
| 1511 uint32_t shift) { |
| 1512 Register kScratchReg = s3; |
| 1513 if (shift < 32) { |
| 1514 if (shift == 0) { |
| 1515 mov(dst_low, src_low); |
| 1516 mov(dst_high, src_high); |
| 1517 } else { |
| 1518 sra(dst_high, src_high, shift); |
| 1519 srl(dst_low, src_low, shift); |
| 1520 shift = 32 - shift; |
| 1521 sll(kScratchReg, src_high, shift); |
| 1522 Or(dst_low, dst_low, kScratchReg); |
| 1523 } |
| 1524 } else { |
| 1525 if (shift == 32) { |
| 1526 sra(dst_high, src_high, 31); |
| 1527 mov(dst_low, src_high); |
| 1528 } else { |
| 1529 shift = shift - 32; |
| 1530 sra(dst_high, src_high, 31); |
| 1531 sra(dst_low, src_high, shift); |
| 1532 } |
| 1533 } |
| 1534 } |
1330 | 1535 |
1331 void MacroAssembler::Ext(Register rt, | 1536 void MacroAssembler::Ext(Register rt, |
1332 Register rs, | 1537 Register rs, |
1333 uint16_t pos, | 1538 uint16_t pos, |
1334 uint16_t size) { | 1539 uint16_t size) { |
1335 DCHECK(pos < 32); | 1540 DCHECK(pos < 32); |
1336 DCHECK(pos + size < 33); | 1541 DCHECK(pos + size < 33); |
1337 | 1542 |
1338 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) { | 1543 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) { |
1339 ext_(rt, rs, pos, size); | 1544 ext_(rt, rs, pos, size); |
(...skipping 4889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6229 if (mag.shift > 0) sra(result, result, mag.shift); | 6434 if (mag.shift > 0) sra(result, result, mag.shift); |
6230 srl(at, dividend, 31); | 6435 srl(at, dividend, 31); |
6231 Addu(result, result, Operand(at)); | 6436 Addu(result, result, Operand(at)); |
6232 } | 6437 } |
6233 | 6438 |
6234 | 6439 |
6235 } // namespace internal | 6440 } // namespace internal |
6236 } // namespace v8 | 6441 } // namespace v8 |
6237 | 6442 |
6238 #endif // V8_TARGET_ARCH_MIPS | 6443 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |