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

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

Issue 1819383002: MIPS: [wasm] Lowering of Int64Shl, Int64Shr, Int64Sar, Int64Add and Int64Sub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 8 months 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 | « src/mips/macro-assembler-mips.h ('k') | test/cctest/compiler/test-run-machops.cc » ('j') | 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_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 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 1347
1348 for (int16_t i = kNumRegisters - 1; i >= 0; i--) { 1348 for (int16_t i = kNumRegisters - 1; i >= 0; i--) {
1349 if ((regs & (1 << i)) != 0) { 1349 if ((regs & (1 << i)) != 0) {
1350 ldc1(FPURegister::from_code(i), MemOperand(sp, stack_offset)); 1350 ldc1(FPURegister::from_code(i), MemOperand(sp, stack_offset));
1351 stack_offset += kDoubleSize; 1351 stack_offset += kDoubleSize;
1352 } 1352 }
1353 } 1353 }
1354 addiu(sp, sp, stack_offset); 1354 addiu(sp, sp, stack_offset);
1355 } 1355 }
1356 1356
1357 void MacroAssembler::AddPair(Register dst_low, Register dst_high,
1358 Register left_low, Register left_high,
1359 Register right_low, Register right_high) {
1360 Label no_overflow;
1361 Register kScratchReg = s3;
1362 Register kScratchReg2 = s4;
1363 // Add lower word
1364 Addu(dst_low, left_low, right_low);
1365 Addu(dst_high, left_high, right_high);
1366 // Check for lower word unsigned overflow
1367 Sltu(kScratchReg, dst_low, left_low);
1368 Sltu(kScratchReg2, dst_low, right_low);
1369 Or(kScratchReg, kScratchReg2, kScratchReg);
1370 Branch(&no_overflow, eq, kScratchReg, Operand(zero_reg));
1371 // Increment higher word if there was overflow
1372 Addu(dst_high, dst_high, 0x1);
1373 bind(&no_overflow);
1374 }
1375
1376 void MacroAssembler::SubPair(Register dst_low, Register dst_high,
1377 Register left_low, Register left_high,
1378 Register right_low, Register right_high) {
1379 Label no_overflow;
1380 Register kScratchReg = s3;
1381 // Subtract lower word
1382 Subu(dst_low, left_low, right_low);
1383 Subu(dst_high, left_high, right_high);
1384 // Check for lower word unsigned underflow
1385 Sltu(kScratchReg, left_low, right_low);
1386 Branch(&no_overflow, eq, kScratchReg, Operand(zero_reg));
1387 // Decrement higher word if there was underflow
1388 Subu(dst_high, dst_high, 0x1);
1389 bind(&no_overflow);
1390 }
1391
1392 void MacroAssembler::ShlPair(Register dst_low, Register dst_high,
1393 Register src_low, Register src_high,
1394 Register shift) {
1395 Label less_than_32;
1396 Label zero_shift;
1397 Label word_shift;
1398 Label done;
1399 Register kScratchReg = s3;
1400 And(shift, shift, 0x3F);
1401 li(kScratchReg, 0x20);
1402 Branch(&less_than_32, lt, shift, Operand(kScratchReg));
1403
1404 Branch(&word_shift, eq, shift, Operand(kScratchReg));
1405 // Shift more than 32
1406 Subu(kScratchReg, shift, kScratchReg);
1407 mov(dst_low, zero_reg);
1408 sllv(dst_high, src_low, kScratchReg);
1409 Branch(&done);
1410 // Word shift
1411 bind(&word_shift);
1412 mov(dst_low, zero_reg);
1413 mov(dst_high, src_low);
1414 Branch(&done);
1415
1416 bind(&less_than_32);
1417 // Check if zero shift
1418 Branch(&zero_shift, eq, shift, Operand(zero_reg));
1419 // Shift less than 32
1420 Subu(kScratchReg, kScratchReg, shift);
1421 sllv(dst_high, src_high, shift);
1422 sllv(dst_low, src_low, shift);
1423 srlv(kScratchReg, src_low, kScratchReg);
1424 Or(dst_high, dst_high, kScratchReg);
1425 Branch(&done);
1426 // Zero shift
1427 bind(&zero_shift);
1428 mov(dst_low, src_low);
1429 mov(dst_high, src_high);
1430 bind(&done);
1431 }
1432
1433 void MacroAssembler::ShlPair(Register dst_low, Register dst_high,
1434 Register src_low, Register src_high,
1435 uint32_t shift) {
1436 Register kScratchReg = s3;
1437 shift = shift & 0x3F;
1438 if (shift < 32) {
1439 if (shift == 0) {
1440 mov(dst_low, src_low);
1441 mov(dst_high, src_high);
1442 } else {
1443 sll(dst_high, src_high, shift);
1444 sll(dst_low, src_low, shift);
1445 shift = 32 - shift;
1446 srl(kScratchReg, src_low, shift);
1447 Or(dst_high, dst_high, kScratchReg);
1448 }
1449 } else {
1450 if (shift == 32) {
1451 mov(dst_low, zero_reg);
1452 mov(dst_high, src_low);
1453 } else {
1454 shift = shift - 32;
1455 mov(dst_low, zero_reg);
1456 sll(dst_high, src_low, shift);
1457 }
1458 }
1459 }
1460
1461 void MacroAssembler::ShrPair(Register dst_low, Register dst_high,
1462 Register src_low, Register src_high,
1463 Register shift) {
1464 Label less_than_32;
1465 Label zero_shift;
1466 Label word_shift;
1467 Label done;
1468 Register kScratchReg = s3;
1469 And(shift, shift, 0x3F);
1470 li(kScratchReg, 0x20);
1471 Branch(&less_than_32, lt, shift, Operand(kScratchReg));
1472
1473 Branch(&word_shift, eq, shift, Operand(kScratchReg));
1474 // Shift more than 32
1475 Subu(kScratchReg, shift, kScratchReg);
1476 mov(dst_high, zero_reg);
1477 srlv(dst_low, src_high, kScratchReg);
1478 Branch(&done);
1479 // Word shift
1480 bind(&word_shift);
1481 mov(dst_high, zero_reg);
1482 mov(dst_low, src_high);
1483 Branch(&done);
1484
1485 bind(&less_than_32);
1486 // Check if zero shift
1487 Branch(&zero_shift, eq, shift, Operand(zero_reg));
1488 // Shift less than 32
1489 Subu(kScratchReg, kScratchReg, shift);
1490 srlv(dst_high, src_high, shift);
1491 srlv(dst_low, src_low, shift);
1492 sllv(kScratchReg, src_high, kScratchReg);
1493 Or(dst_low, dst_low, kScratchReg);
1494 Branch(&done);
1495 // Zero shift
1496 bind(&zero_shift);
1497 mov(dst_low, src_low);
1498 mov(dst_high, src_high);
1499 bind(&done);
1500 }
1501
1502 void MacroAssembler::ShrPair(Register dst_low, Register dst_high,
1503 Register src_low, Register src_high,
1504 uint32_t shift) {
1505 Register kScratchReg = s3;
1506 shift = shift & 0x3F;
1507 if (shift < 32) {
1508 if (shift == 0) {
1509 mov(dst_low, src_low);
1510 mov(dst_high, src_high);
1511 } else {
1512 srl(dst_high, src_high, shift);
1513 srl(dst_low, src_low, shift);
1514 shift = 32 - shift;
1515 sll(kScratchReg, src_high, shift);
1516 Or(dst_low, dst_low, kScratchReg);
1517 }
1518 } else {
1519 if (shift == 32) {
1520 mov(dst_high, zero_reg);
1521 mov(dst_low, src_high);
1522 } else {
1523 shift = shift - 32;
1524 mov(dst_high, zero_reg);
1525 srl(dst_low, src_high, shift);
1526 }
1527 }
1528 }
1529
1530 void MacroAssembler::SarPair(Register dst_low, Register dst_high,
1531 Register src_low, Register src_high,
1532 Register shift) {
1533 Label less_than_32;
1534 Label zero_shift;
1535 Label word_shift;
1536 Label done;
1537 Register kScratchReg = s3;
1538 Register kScratchReg2 = s4;
1539 And(shift, shift, 0x3F);
1540 li(kScratchReg, 0x20);
1541 Branch(&less_than_32, lt, shift, Operand(kScratchReg));
1542
1543 Branch(&word_shift, eq, shift, Operand(kScratchReg));
1544
1545 // Shift more than 32
1546 li(kScratchReg2, 0x1F);
1547 Subu(kScratchReg, shift, kScratchReg);
1548 srav(dst_high, src_high, kScratchReg2);
1549 srav(dst_low, src_high, kScratchReg);
1550 Branch(&done);
1551 // Word shift
1552 bind(&word_shift);
1553 li(kScratchReg2, 0x1F);
1554 srav(dst_high, src_high, kScratchReg2);
1555 mov(dst_low, src_high);
1556 Branch(&done);
1557
1558 bind(&less_than_32);
1559 // Check if zero shift
1560 Branch(&zero_shift, eq, shift, Operand(zero_reg));
1561
1562 // Shift less than 32
1563 Subu(kScratchReg, kScratchReg, shift);
1564 srav(dst_high, src_high, shift);
1565 srlv(dst_low, src_low, shift);
1566 sllv(kScratchReg, src_high, kScratchReg);
1567 Or(dst_low, dst_low, kScratchReg);
1568 Branch(&done);
1569 // Zero shift
1570 bind(&zero_shift);
1571 mov(dst_low, src_low);
1572 mov(dst_high, src_high);
1573 bind(&done);
1574 }
1575
1576 void MacroAssembler::SarPair(Register dst_low, Register dst_high,
1577 Register src_low, Register src_high,
1578 uint32_t shift) {
1579 Register kScratchReg = s3;
1580 shift = shift & 0x3F;
1581 if (shift < 32) {
1582 if (shift == 0) {
1583 mov(dst_low, src_low);
1584 mov(dst_high, src_high);
1585 } else {
1586 sra(dst_high, src_high, shift);
1587 srl(dst_low, src_low, shift);
1588 shift = 32 - shift;
1589 sll(kScratchReg, src_high, shift);
1590 Or(dst_low, dst_low, kScratchReg);
1591 }
1592 } else {
1593 if (shift == 32) {
1594 sra(dst_high, src_high, 31);
1595 mov(dst_low, src_high);
1596 } else {
1597 shift = shift - 32;
1598 sra(dst_high, src_high, 31);
1599 sra(dst_low, src_high, shift);
1600 }
1601 }
1602 }
1357 1603
1358 void MacroAssembler::Ext(Register rt, 1604 void MacroAssembler::Ext(Register rt,
1359 Register rs, 1605 Register rs,
1360 uint16_t pos, 1606 uint16_t pos,
1361 uint16_t size) { 1607 uint16_t size) {
1362 DCHECK(pos < 32); 1608 DCHECK(pos < 32);
1363 DCHECK(pos + size < 33); 1609 DCHECK(pos + size < 33);
1364 1610
1365 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) { 1611 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
1366 ext_(rt, rs, pos, size); 1612 ext_(rt, rs, pos, size);
(...skipping 4916 matching lines...) Expand 10 before | Expand all | Expand 10 after
6283 if (mag.shift > 0) sra(result, result, mag.shift); 6529 if (mag.shift > 0) sra(result, result, mag.shift);
6284 srl(at, dividend, 31); 6530 srl(at, dividend, 31);
6285 Addu(result, result, Operand(at)); 6531 Addu(result, result, Operand(at));
6286 } 6532 }
6287 6533
6288 6534
6289 } // namespace internal 6535 } // namespace internal
6290 } // namespace v8 6536 } // namespace v8
6291 6537
6292 #endif // V8_TARGET_ARCH_MIPS 6538 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/macro-assembler-mips.h ('k') | test/cctest/compiler/test-run-machops.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698