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

Side by Side Diff: src/compiler/s390/code-generator-s390.cc

Issue 2662963002: s390: TF Optimize 32-bit Mul/Div/Mod/Popcnt (Closed)
Patch Set: fix dcheck Created 3 years, 10 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 | « no previous file | src/compiler/s390/instruction-codes-s390.h » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 "src/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/compilation-info.h" 7 #include "src/compilation-info.h"
8 #include "src/compiler/code-generator-impl.h" 8 #include "src/compiler/code-generator-impl.h"
9 #include "src/compiler/gap-resolver.h" 9 #include "src/compiler/gap-resolver.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 __ Mul64(i.InputRegister(0), i.InputImmediate(1)); 1524 __ Mul64(i.InputRegister(0), i.InputImmediate(1));
1525 } else if (HasStackSlotInput(instr, 1)) { 1525 } else if (HasStackSlotInput(instr, 1)) {
1526 __ Mul64(i.InputRegister(0), i.InputStackSlot(1)); 1526 __ Mul64(i.InputRegister(0), i.InputStackSlot(1));
1527 } else { 1527 } else {
1528 UNIMPLEMENTED(); 1528 UNIMPLEMENTED();
1529 } 1529 }
1530 break; 1530 break;
1531 case kS390_MulHigh32: 1531 case kS390_MulHigh32:
1532 ASSEMBLE_BIN_OP(MulHigh32, MulHigh32, MulHigh32); 1532 ASSEMBLE_BIN_OP(MulHigh32, MulHigh32, MulHigh32);
1533 break; 1533 break;
1534 case kS390_Mul32WithHigh32:
1535 __ LoadRR(r1, i.InputRegister(0));
1536 __ mr_z(r0, i.InputRegister(1));
1537 __ LoadW(i.OutputRegister(0), r1); // low
1538 __ LoadW(i.OutputRegister(1), r0); // high
1539 break;
1540 case kS390_MulHighU32: 1534 case kS390_MulHighU32:
1541 __ LoadRR(r1, i.InputRegister(0)); 1535 ASSEMBLE_BIN_OP(MulHighU32, MulHighU32, MulHighU32);
1542 if (HasRegisterInput(instr, 1)) {
1543 __ mlr(r0, i.InputRegister(1));
1544 } else if (HasStackSlotInput(instr, 1)) {
1545 __ ml(r0, i.InputStackSlot32(1));
1546 } else {
1547 UNIMPLEMENTED();
1548 }
1549 __ LoadlW(i.OutputRegister(), r0);
1550 break; 1536 break;
1551 case kS390_MulFloat: 1537 case kS390_MulFloat:
1552 // Ensure we don't clobber right 1538 // Ensure we don't clobber right
1553 if (i.OutputDoubleRegister().is(i.InputDoubleRegister(1))) { 1539 if (i.OutputDoubleRegister().is(i.InputDoubleRegister(1))) {
1554 ASSEMBLE_FLOAT_UNOP(meebr); 1540 ASSEMBLE_FLOAT_UNOP(meebr);
1555 } else { 1541 } else {
1556 if (!i.OutputDoubleRegister().is(i.InputDoubleRegister(0))) 1542 if (!i.OutputDoubleRegister().is(i.InputDoubleRegister(0)))
1557 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); 1543 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0));
1558 __ meebr(i.OutputDoubleRegister(), i.InputDoubleRegister(1)); 1544 __ meebr(i.OutputDoubleRegister(), i.InputDoubleRegister(1));
1559 } 1545 }
1560 break; 1546 break;
1561 case kS390_MulDouble: 1547 case kS390_MulDouble:
1562 // Ensure we don't clobber right 1548 // Ensure we don't clobber right
1563 if (i.OutputDoubleRegister().is(i.InputDoubleRegister(1))) { 1549 if (i.OutputDoubleRegister().is(i.InputDoubleRegister(1))) {
1564 ASSEMBLE_FLOAT_UNOP(mdbr); 1550 ASSEMBLE_FLOAT_UNOP(mdbr);
1565 } else { 1551 } else {
1566 if (!i.OutputDoubleRegister().is(i.InputDoubleRegister(0))) 1552 if (!i.OutputDoubleRegister().is(i.InputDoubleRegister(0)))
1567 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); 1553 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0));
1568 __ mdbr(i.OutputDoubleRegister(), i.InputDoubleRegister(1)); 1554 __ mdbr(i.OutputDoubleRegister(), i.InputDoubleRegister(1));
1569 } 1555 }
1570 break; 1556 break;
1571 #if V8_TARGET_ARCH_S390X 1557 #if V8_TARGET_ARCH_S390X
1572 case kS390_Div64: 1558 case kS390_Div64:
1573 __ LoadRR(r1, i.InputRegister(0)); 1559 __ LoadRR(r1, i.InputRegister(0));
1574 __ dsgr(r0, i.InputRegister(1)); // R1: Dividend 1560 __ dsgr(r0, i.InputRegister(1)); // R1: Dividend
1575 __ ltgr(i.OutputRegister(), r1); // Copy R1: Quotient to output 1561 __ ltgr(i.OutputRegister(), r1); // Copy R1: Quotient to output
1576 break; 1562 break;
1577 #endif 1563 #endif
1578 case kS390_Div32: { 1564 case kS390_Div32: {
1579 AddressingMode mode = AddressingModeField::decode(instr->opcode()); 1565 ASSEMBLE_BIN_OP(Div32, Div32, Div32);
1580 __ lgfr(r1, i.InputRegister(0));
1581 if (mode != kMode_None) {
1582 size_t first_index = 1;
1583 MemOperand operand = i.MemoryOperand(&mode, &first_index);
1584 __ dsgf(r0, operand);
1585 } else if (HasRegisterInput(instr, 1)) {
1586 __ dsgfr(r0, i.InputRegister(1));
1587 } else if (HasStackSlotInput(instr, 1)) {
1588 __ dsgf(r0, i.InputStackSlot32(1));
1589 } else {
1590 UNREACHABLE();
1591 }
1592 __ LoadlW(i.OutputRegister(), r1);
1593 break; 1566 break;
1594 } 1567 }
1595 #if V8_TARGET_ARCH_S390X 1568 #if V8_TARGET_ARCH_S390X
1596 case kS390_DivU64: 1569 case kS390_DivU64:
1597 __ LoadRR(r1, i.InputRegister(0)); 1570 __ LoadRR(r1, i.InputRegister(0));
1598 __ LoadImmP(r0, Operand::Zero()); 1571 __ LoadImmP(r0, Operand::Zero());
1599 __ dlgr(r0, i.InputRegister(1)); // R0:R1: Dividend 1572 __ dlgr(r0, i.InputRegister(1)); // R0:R1: Dividend
1600 __ ltgr(i.OutputRegister(), r1); // Copy R1: Quotient to output 1573 __ ltgr(i.OutputRegister(), r1); // Copy R1: Quotient to output
1601 break; 1574 break;
1602 #endif 1575 #endif
1603 case kS390_DivU32: { 1576 case kS390_DivU32: {
1604 __ lr(r0, i.InputRegister(0)); 1577 ASSEMBLE_BIN_OP(DivU32, DivU32, DivU32);
1605 __ srdl(r0, Operand(32));
1606 AddressingMode mode = AddressingModeField::decode(instr->opcode());
1607 if (mode != kMode_None) {
1608 size_t first_index = 1;
1609 MemOperand operand = i.MemoryOperand(&mode, &first_index);
1610 __ dl(r0, operand);
1611 } else if (HasRegisterInput(instr, 1)) {
1612 __ dlr(r0, i.InputRegister(1));
1613 } else if (HasStackSlotInput(instr, 1)) {
1614 __ dl(r0, i.InputStackSlot32(1));
1615 } else {
1616 UNREACHABLE();
1617 }
1618 __ LoadlW(i.OutputRegister(), r1);
1619 break; 1578 break;
1620 } 1579 }
1621 case kS390_DivFloat: 1580 case kS390_DivFloat:
1622 // InputDoubleRegister(1)=InputDoubleRegister(0)/InputDoubleRegister(1) 1581 // InputDoubleRegister(1)=InputDoubleRegister(0)/InputDoubleRegister(1)
1623 if (i.OutputDoubleRegister().is(i.InputDoubleRegister(1))) { 1582 if (i.OutputDoubleRegister().is(i.InputDoubleRegister(1))) {
1624 __ ldr(kScratchDoubleReg, i.InputDoubleRegister(1)); 1583 __ ldr(kScratchDoubleReg, i.InputDoubleRegister(1));
1625 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); 1584 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0));
1626 __ debr(i.OutputDoubleRegister(), kScratchDoubleReg); 1585 __ debr(i.OutputDoubleRegister(), kScratchDoubleReg);
1627 } else { 1586 } else {
1628 if (!i.OutputDoubleRegister().is(i.InputDoubleRegister(0))) 1587 if (!i.OutputDoubleRegister().is(i.InputDoubleRegister(0)))
1629 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); 1588 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0));
1630 __ debr(i.OutputDoubleRegister(), i.InputDoubleRegister(1)); 1589 __ debr(i.OutputDoubleRegister(), i.InputDoubleRegister(1));
1631 } 1590 }
1632 break; 1591 break;
1633 case kS390_DivDouble: 1592 case kS390_DivDouble:
1634 // InputDoubleRegister(1)=InputDoubleRegister(0)/InputDoubleRegister(1) 1593 // InputDoubleRegister(1)=InputDoubleRegister(0)/InputDoubleRegister(1)
1635 if (i.OutputDoubleRegister().is(i.InputDoubleRegister(1))) { 1594 if (i.OutputDoubleRegister().is(i.InputDoubleRegister(1))) {
1636 __ ldr(kScratchDoubleReg, i.InputDoubleRegister(1)); 1595 __ ldr(kScratchDoubleReg, i.InputDoubleRegister(1));
1637 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); 1596 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0));
1638 __ ddbr(i.OutputDoubleRegister(), kScratchDoubleReg); 1597 __ ddbr(i.OutputDoubleRegister(), kScratchDoubleReg);
1639 } else { 1598 } else {
1640 if (!i.OutputDoubleRegister().is(i.InputDoubleRegister(0))) 1599 if (!i.OutputDoubleRegister().is(i.InputDoubleRegister(0)))
1641 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); 1600 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0));
1642 __ ddbr(i.OutputDoubleRegister(), i.InputDoubleRegister(1)); 1601 __ ddbr(i.OutputDoubleRegister(), i.InputDoubleRegister(1));
1643 } 1602 }
1644 break; 1603 break;
1645 case kS390_Mod32: 1604 case kS390_Mod32:
1646 ASSEMBLE_MODULO(dr, srda); 1605 ASSEMBLE_BIN_OP(Mod32, Mod32, Mod32);
1647 break; 1606 break;
1648 case kS390_ModU32: 1607 case kS390_ModU32:
1649 ASSEMBLE_MODULO(dlr, srdl); 1608 ASSEMBLE_BIN_OP(ModU32, ModU32, ModU32);
1650 break; 1609 break;
1651 #if V8_TARGET_ARCH_S390X 1610 #if V8_TARGET_ARCH_S390X
1652 case kS390_Mod64: 1611 case kS390_Mod64:
1653 __ LoadRR(r1, i.InputRegister(0)); 1612 __ LoadRR(r1, i.InputRegister(0));
1654 __ dsgr(r0, i.InputRegister(1)); // R1: Dividend 1613 __ dsgr(r0, i.InputRegister(1)); // R1: Dividend
1655 __ ltgr(i.OutputRegister(), r0); // Copy R0: Remainder to output 1614 __ ltgr(i.OutputRegister(), r0); // Copy R0: Remainder to output
1656 break; 1615 break;
1657 case kS390_ModU64: 1616 case kS390_ModU64:
1658 __ LoadRR(r1, i.InputRegister(0)); 1617 __ LoadRR(r1, i.InputRegister(0));
1659 __ LoadImmP(r0, Operand::Zero()); 1618 __ LoadImmP(r0, Operand::Zero());
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 break; 1751 break;
1793 case kS390_NegFloat: 1752 case kS390_NegFloat:
1794 ASSEMBLE_FLOAT_UNOP(lcebr); 1753 ASSEMBLE_FLOAT_UNOP(lcebr);
1795 break; 1754 break;
1796 case kS390_NegDouble: 1755 case kS390_NegDouble:
1797 ASSEMBLE_FLOAT_UNOP(lcdbr); 1756 ASSEMBLE_FLOAT_UNOP(lcdbr);
1798 break; 1757 break;
1799 case kS390_Cntlz32: { 1758 case kS390_Cntlz32: {
1800 __ llgfr(i.OutputRegister(), i.InputRegister(0)); 1759 __ llgfr(i.OutputRegister(), i.InputRegister(0));
1801 __ flogr(r0, i.OutputRegister()); 1760 __ flogr(r0, i.OutputRegister());
1802 __ LoadRR(i.OutputRegister(), r0); 1761 __ Add32(i.OutputRegister(), r0, Operand(-32));
1803 __ SubP(i.OutputRegister(), Operand(32)); 1762 // No need to zero-ext b/c llgfr is done already
1804 } break; 1763 break;
1764 }
1805 #if V8_TARGET_ARCH_S390X 1765 #if V8_TARGET_ARCH_S390X
1806 case kS390_Cntlz64: { 1766 case kS390_Cntlz64: {
1807 __ flogr(r0, i.InputRegister(0)); 1767 __ flogr(r0, i.InputRegister(0));
1808 __ LoadRR(i.OutputRegister(), r0); 1768 __ LoadRR(i.OutputRegister(), r0);
1809 } break; 1769 break;
1770 }
1810 #endif 1771 #endif
1811 case kS390_Popcnt32: 1772 case kS390_Popcnt32:
1812 __ Popcnt32(i.OutputRegister(), i.InputRegister(0)); 1773 __ Popcnt32(i.OutputRegister(), i.InputRegister(0));
1813 break; 1774 break;
1814 #if V8_TARGET_ARCH_S390X 1775 #if V8_TARGET_ARCH_S390X
1815 case kS390_Popcnt64: 1776 case kS390_Popcnt64:
1816 __ Popcnt64(i.OutputRegister(), i.InputRegister(0)); 1777 __ Popcnt64(i.OutputRegister(), i.InputRegister(0));
1817 break; 1778 break;
1818 #endif 1779 #endif
1819 case kS390_Cmp32: 1780 case kS390_Cmp32:
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
2725 padding_size -= 2; 2686 padding_size -= 2;
2726 } 2687 }
2727 } 2688 }
2728 } 2689 }
2729 2690
2730 #undef __ 2691 #undef __
2731 2692
2732 } // namespace compiler 2693 } // namespace compiler
2733 } // namespace internal 2694 } // namespace internal
2734 } // namespace v8 2695 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/s390/instruction-codes-s390.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698