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

Side by Side Diff: src/compiler/ppc/instruction-selector-ppc.cc

Issue 1730383002: PPC: [turbofan] Introduce DeoptimizeIf And DeoptimizeUnless common operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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 | « src/compiler/ppc/code-generator-ppc.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/base/adapters.h" 5 #include "src/base/adapters.h"
6 #include "src/compiler/instruction-selector-impl.h" 6 #include "src/compiler/instruction-selector-impl.h"
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
9 #include "src/ppc/frames-ppc.h" 9 #include "src/ppc/frames-ppc.h"
10 10
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 outputs[output_count++] = g.DefineAsRegister(node); 137 outputs[output_count++] = g.DefineAsRegister(node);
138 if (cont->IsSet()) { 138 if (cont->IsSet()) {
139 outputs[output_count++] = g.DefineAsRegister(cont->result()); 139 outputs[output_count++] = g.DefineAsRegister(cont->result());
140 } 140 }
141 141
142 DCHECK_NE(0u, input_count); 142 DCHECK_NE(0u, input_count);
143 DCHECK_NE(0u, output_count); 143 DCHECK_NE(0u, output_count);
144 DCHECK_GE(arraysize(inputs), input_count); 144 DCHECK_GE(arraysize(inputs), input_count);
145 DCHECK_GE(arraysize(outputs), output_count); 145 DCHECK_GE(arraysize(outputs), output_count);
146 146
147 selector->Emit(cont->Encode(opcode), output_count, outputs, input_count, 147 opcode = cont->Encode(opcode);
148 inputs); 148 if (cont->IsDeoptimize()) {
149 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs,
150 cont->frame_state());
151 } else {
152 selector->Emit(opcode, output_count, outputs, input_count, inputs);
153 }
149 } 154 }
150 155
151 156
152 // Shared routine for multiple binary operations. 157 // Shared routine for multiple binary operations.
153 template <typename Matcher> 158 template <typename Matcher>
154 void VisitBinop(InstructionSelector* selector, Node* node, ArchOpcode opcode, 159 void VisitBinop(InstructionSelector* selector, Node* node, ArchOpcode opcode,
155 ImmediateMode operand_mode) { 160 ImmediateMode operand_mode) {
156 FlagsContinuation cont; 161 FlagsContinuation cont;
157 VisitBinop<Matcher>(selector, node, opcode, operand_mode, &cont); 162 VisitBinop<Matcher>(selector, node, opcode, operand_mode, &cont);
158 } 163 }
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 } 1262 }
1258 1263
1259 1264
1260 void InstructionSelector::VisitFloat64RoundTiesEven(Node* node) { 1265 void InstructionSelector::VisitFloat64RoundTiesEven(Node* node) {
1261 UNREACHABLE(); 1266 UNREACHABLE();
1262 } 1267 }
1263 1268
1264 1269
1265 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { 1270 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) {
1266 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { 1271 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
1267 FlagsContinuation cont(kOverflow, ovf); 1272 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf);
1268 return VisitBinop<Int32BinopMatcher>(this, node, kPPC_AddWithOverflow32, 1273 return VisitBinop<Int32BinopMatcher>(this, node, kPPC_AddWithOverflow32,
1269 kInt16Imm, &cont); 1274 kInt16Imm, &cont);
1270 } 1275 }
1271 FlagsContinuation cont; 1276 FlagsContinuation cont;
1272 VisitBinop<Int32BinopMatcher>(this, node, kPPC_AddWithOverflow32, kInt16Imm, 1277 VisitBinop<Int32BinopMatcher>(this, node, kPPC_AddWithOverflow32, kInt16Imm,
1273 &cont); 1278 &cont);
1274 } 1279 }
1275 1280
1276 1281
1277 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { 1282 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) {
1278 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { 1283 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
1279 FlagsContinuation cont(kOverflow, ovf); 1284 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf);
1280 return VisitBinop<Int32BinopMatcher>(this, node, kPPC_SubWithOverflow32, 1285 return VisitBinop<Int32BinopMatcher>(this, node, kPPC_SubWithOverflow32,
1281 kInt16Imm_Negate, &cont); 1286 kInt16Imm_Negate, &cont);
1282 } 1287 }
1283 FlagsContinuation cont; 1288 FlagsContinuation cont;
1284 VisitBinop<Int32BinopMatcher>(this, node, kPPC_SubWithOverflow32, 1289 VisitBinop<Int32BinopMatcher>(this, node, kPPC_SubWithOverflow32,
1285 kInt16Imm_Negate, &cont); 1290 kInt16Imm_Negate, &cont);
1286 } 1291 }
1287 1292
1288 1293
1289 #if V8_TARGET_ARCH_PPC64 1294 #if V8_TARGET_ARCH_PPC64
1290 void InstructionSelector::VisitInt64AddWithOverflow(Node* node) { 1295 void InstructionSelector::VisitInt64AddWithOverflow(Node* node) {
1291 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { 1296 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
1292 FlagsContinuation cont(kOverflow, ovf); 1297 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf);
1293 return VisitBinop<Int64BinopMatcher>(this, node, kPPC_Add, kInt16Imm, 1298 return VisitBinop<Int64BinopMatcher>(this, node, kPPC_Add, kInt16Imm,
1294 &cont); 1299 &cont);
1295 } 1300 }
1296 FlagsContinuation cont; 1301 FlagsContinuation cont;
1297 VisitBinop<Int64BinopMatcher>(this, node, kPPC_Add, kInt16Imm, &cont); 1302 VisitBinop<Int64BinopMatcher>(this, node, kPPC_Add, kInt16Imm, &cont);
1298 } 1303 }
1299 1304
1300 1305
1301 void InstructionSelector::VisitInt64SubWithOverflow(Node* node) { 1306 void InstructionSelector::VisitInt64SubWithOverflow(Node* node) {
1302 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { 1307 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
1303 FlagsContinuation cont(kOverflow, ovf); 1308 FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf);
1304 return VisitBinop<Int64BinopMatcher>(this, node, kPPC_Sub, kInt16Imm_Negate, 1309 return VisitBinop<Int64BinopMatcher>(this, node, kPPC_Sub, kInt16Imm_Negate,
1305 &cont); 1310 &cont);
1306 } 1311 }
1307 FlagsContinuation cont; 1312 FlagsContinuation cont;
1308 VisitBinop<Int64BinopMatcher>(this, node, kPPC_Sub, kInt16Imm_Negate, &cont); 1313 VisitBinop<Int64BinopMatcher>(this, node, kPPC_Sub, kInt16Imm_Negate, &cont);
1309 } 1314 }
1310 #endif 1315 #endif
1311 1316
1312 1317
1313 static bool CompareLogical(FlagsContinuation* cont) { 1318 static bool CompareLogical(FlagsContinuation* cont) {
(...skipping 15 matching lines...) Expand all
1329 1334
1330 // Shared routine for multiple compare operations. 1335 // Shared routine for multiple compare operations.
1331 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, 1336 void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
1332 InstructionOperand left, InstructionOperand right, 1337 InstructionOperand left, InstructionOperand right,
1333 FlagsContinuation* cont) { 1338 FlagsContinuation* cont) {
1334 PPCOperandGenerator g(selector); 1339 PPCOperandGenerator g(selector);
1335 opcode = cont->Encode(opcode); 1340 opcode = cont->Encode(opcode);
1336 if (cont->IsBranch()) { 1341 if (cont->IsBranch()) {
1337 selector->Emit(opcode, g.NoOutput(), left, right, 1342 selector->Emit(opcode, g.NoOutput(), left, right,
1338 g.Label(cont->true_block()), g.Label(cont->false_block())); 1343 g.Label(cont->true_block()), g.Label(cont->false_block()));
1344 } else if (cont->IsDeoptimize()) {
1345 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right,
1346 cont->frame_state());
1339 } else { 1347 } else {
1340 DCHECK(cont->IsSet()); 1348 DCHECK(cont->IsSet());
1341 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); 1349 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right);
1342 } 1350 }
1343 } 1351 }
1344 1352
1345 1353
1346 // Shared routine for multiple word compare operations. 1354 // Shared routine for multiple word compare operations.
1347 void VisitWordCompare(InstructionSelector* selector, Node* node, 1355 void VisitWordCompare(InstructionSelector* selector, Node* node,
1348 InstructionCode opcode, FlagsContinuation* cont, 1356 InstructionCode opcode, FlagsContinuation* cont,
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 1574
1567 } // namespace 1575 } // namespace
1568 1576
1569 1577
1570 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, 1578 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
1571 BasicBlock* fbranch) { 1579 BasicBlock* fbranch) {
1572 FlagsContinuation cont(kNotEqual, tbranch, fbranch); 1580 FlagsContinuation cont(kNotEqual, tbranch, fbranch);
1573 VisitWord32CompareZero(this, branch, branch->InputAt(0), &cont); 1581 VisitWord32CompareZero(this, branch, branch->InputAt(0), &cont);
1574 } 1582 }
1575 1583
1584 void InstructionSelector::VisitDeoptimizeIf(Node* node) {
1585 FlagsContinuation cont =
1586 FlagsContinuation::ForDeoptimize(kNotEqual, node->InputAt(1));
1587 VisitWord32CompareZero(this, node, node->InputAt(0), &cont);
1588 }
1589
1590 void InstructionSelector::VisitDeoptimizeUnless(Node* node) {
1591 FlagsContinuation cont =
1592 FlagsContinuation::ForDeoptimize(kEqual, node->InputAt(1));
1593 VisitWord32CompareZero(this, node, node->InputAt(0), &cont);
1594 }
1576 1595
1577 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { 1596 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) {
1578 PPCOperandGenerator g(this); 1597 PPCOperandGenerator g(this);
1579 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); 1598 InstructionOperand value_operand = g.UseRegister(node->InputAt(0));
1580 1599
1581 // Emit either ArchTableSwitch or ArchLookupSwitch. 1600 // Emit either ArchTableSwitch or ArchLookupSwitch.
1582 size_t table_space_cost = 4 + sw.value_range; 1601 size_t table_space_cost = 4 + sw.value_range;
1583 size_t table_time_cost = 3; 1602 size_t table_time_cost = 3;
1584 size_t lookup_space_cost = 3 + 2 * sw.case_count; 1603 size_t lookup_space_cost = 3 + 2 * sw.case_count;
1585 size_t lookup_time_cost = sw.case_count; 1604 size_t lookup_time_cost = sw.case_count;
(...skipping 10 matching lines...) Expand all
1596 // Generate a table lookup. 1615 // Generate a table lookup.
1597 return EmitTableSwitch(sw, index_operand); 1616 return EmitTableSwitch(sw, index_operand);
1598 } 1617 }
1599 1618
1600 // Generate a sequence of conditional jumps. 1619 // Generate a sequence of conditional jumps.
1601 return EmitLookupSwitch(sw, value_operand); 1620 return EmitLookupSwitch(sw, value_operand);
1602 } 1621 }
1603 1622
1604 1623
1605 void InstructionSelector::VisitWord32Equal(Node* const node) { 1624 void InstructionSelector::VisitWord32Equal(Node* const node) {
1606 FlagsContinuation cont(kEqual, node); 1625 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node);
1607 Int32BinopMatcher m(node); 1626 Int32BinopMatcher m(node);
1608 if (m.right().Is(0)) { 1627 if (m.right().Is(0)) {
1609 return VisitWord32CompareZero(this, m.node(), m.left().node(), &cont); 1628 return VisitWord32CompareZero(this, m.node(), m.left().node(), &cont);
1610 } 1629 }
1611 VisitWord32Compare(this, node, &cont); 1630 VisitWord32Compare(this, node, &cont);
1612 } 1631 }
1613 1632
1614 1633
1615 void InstructionSelector::VisitInt32LessThan(Node* node) { 1634 void InstructionSelector::VisitInt32LessThan(Node* node) {
1616 FlagsContinuation cont(kSignedLessThan, node); 1635 FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node);
1617 VisitWord32Compare(this, node, &cont); 1636 VisitWord32Compare(this, node, &cont);
1618 } 1637 }
1619 1638
1620 1639
1621 void InstructionSelector::VisitInt32LessThanOrEqual(Node* node) { 1640 void InstructionSelector::VisitInt32LessThanOrEqual(Node* node) {
1622 FlagsContinuation cont(kSignedLessThanOrEqual, node); 1641 FlagsContinuation cont =
1642 FlagsContinuation::ForSet(kSignedLessThanOrEqual, node);
1623 VisitWord32Compare(this, node, &cont); 1643 VisitWord32Compare(this, node, &cont);
1624 } 1644 }
1625 1645
1626 1646
1627 void InstructionSelector::VisitUint32LessThan(Node* node) { 1647 void InstructionSelector::VisitUint32LessThan(Node* node) {
1628 FlagsContinuation cont(kUnsignedLessThan, node); 1648 FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node);
1629 VisitWord32Compare(this, node, &cont); 1649 VisitWord32Compare(this, node, &cont);
1630 } 1650 }
1631 1651
1632 1652
1633 void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) { 1653 void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) {
1634 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); 1654 FlagsContinuation cont =
1655 FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node);
1635 VisitWord32Compare(this, node, &cont); 1656 VisitWord32Compare(this, node, &cont);
1636 } 1657 }
1637 1658
1638 1659
1639 #if V8_TARGET_ARCH_PPC64 1660 #if V8_TARGET_ARCH_PPC64
1640 void InstructionSelector::VisitWord64Equal(Node* const node) { 1661 void InstructionSelector::VisitWord64Equal(Node* const node) {
1641 FlagsContinuation cont(kEqual, node); 1662 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node);
1642 Int64BinopMatcher m(node); 1663 Int64BinopMatcher m(node);
1643 if (m.right().Is(0)) { 1664 if (m.right().Is(0)) {
1644 return VisitWord64CompareZero(this, m.node(), m.left().node(), &cont); 1665 return VisitWord64CompareZero(this, m.node(), m.left().node(), &cont);
1645 } 1666 }
1646 VisitWord64Compare(this, node, &cont); 1667 VisitWord64Compare(this, node, &cont);
1647 } 1668 }
1648 1669
1649 1670
1650 void InstructionSelector::VisitInt64LessThan(Node* node) { 1671 void InstructionSelector::VisitInt64LessThan(Node* node) {
1651 FlagsContinuation cont(kSignedLessThan, node); 1672 FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node);
1652 VisitWord64Compare(this, node, &cont); 1673 VisitWord64Compare(this, node, &cont);
1653 } 1674 }
1654 1675
1655 1676
1656 void InstructionSelector::VisitInt64LessThanOrEqual(Node* node) { 1677 void InstructionSelector::VisitInt64LessThanOrEqual(Node* node) {
1657 FlagsContinuation cont(kSignedLessThanOrEqual, node); 1678 FlagsContinuation cont =
1679 FlagsContinuation::ForSet(kSignedLessThanOrEqual, node);
1658 VisitWord64Compare(this, node, &cont); 1680 VisitWord64Compare(this, node, &cont);
1659 } 1681 }
1660 1682
1661 1683
1662 void InstructionSelector::VisitUint64LessThan(Node* node) { 1684 void InstructionSelector::VisitUint64LessThan(Node* node) {
1663 FlagsContinuation cont(kUnsignedLessThan, node); 1685 FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node);
1664 VisitWord64Compare(this, node, &cont); 1686 VisitWord64Compare(this, node, &cont);
1665 } 1687 }
1666 1688
1667 1689
1668 void InstructionSelector::VisitUint64LessThanOrEqual(Node* node) { 1690 void InstructionSelector::VisitUint64LessThanOrEqual(Node* node) {
1669 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); 1691 FlagsContinuation cont =
1692 FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node);
1670 VisitWord64Compare(this, node, &cont); 1693 VisitWord64Compare(this, node, &cont);
1671 } 1694 }
1672 #endif 1695 #endif
1673 1696
1674 1697
1675 void InstructionSelector::VisitFloat32Equal(Node* node) { 1698 void InstructionSelector::VisitFloat32Equal(Node* node) {
1676 FlagsContinuation cont(kEqual, node); 1699 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node);
1677 VisitFloat32Compare(this, node, &cont); 1700 VisitFloat32Compare(this, node, &cont);
1678 } 1701 }
1679 1702
1680 1703
1681 void InstructionSelector::VisitFloat32LessThan(Node* node) { 1704 void InstructionSelector::VisitFloat32LessThan(Node* node) {
1682 FlagsContinuation cont(kUnsignedLessThan, node); 1705 FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node);
1683 VisitFloat32Compare(this, node, &cont); 1706 VisitFloat32Compare(this, node, &cont);
1684 } 1707 }
1685 1708
1686 1709
1687 void InstructionSelector::VisitFloat32LessThanOrEqual(Node* node) { 1710 void InstructionSelector::VisitFloat32LessThanOrEqual(Node* node) {
1688 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); 1711 FlagsContinuation cont =
1712 FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node);
1689 VisitFloat32Compare(this, node, &cont); 1713 VisitFloat32Compare(this, node, &cont);
1690 } 1714 }
1691 1715
1692 1716
1693 void InstructionSelector::VisitFloat64Equal(Node* node) { 1717 void InstructionSelector::VisitFloat64Equal(Node* node) {
1694 FlagsContinuation cont(kEqual, node); 1718 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node);
1695 VisitFloat64Compare(this, node, &cont); 1719 VisitFloat64Compare(this, node, &cont);
1696 } 1720 }
1697 1721
1698 1722
1699 void InstructionSelector::VisitFloat64LessThan(Node* node) { 1723 void InstructionSelector::VisitFloat64LessThan(Node* node) {
1700 FlagsContinuation cont(kUnsignedLessThan, node); 1724 FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node);
1701 VisitFloat64Compare(this, node, &cont); 1725 VisitFloat64Compare(this, node, &cont);
1702 } 1726 }
1703 1727
1704 1728
1705 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { 1729 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) {
1706 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); 1730 FlagsContinuation cont =
1731 FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node);
1707 VisitFloat64Compare(this, node, &cont); 1732 VisitFloat64Compare(this, node, &cont);
1708 } 1733 }
1709 1734
1710 1735
1711 void InstructionSelector::EmitPrepareArguments( 1736 void InstructionSelector::EmitPrepareArguments(
1712 ZoneVector<PushParameter>* arguments, const CallDescriptor* descriptor, 1737 ZoneVector<PushParameter>* arguments, const CallDescriptor* descriptor,
1713 Node* node) { 1738 Node* node) {
1714 PPCOperandGenerator g(this); 1739 PPCOperandGenerator g(this);
1715 1740
1716 // Prepare for C function call. 1741 // Prepare for C function call.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 MachineOperatorBuilder::kFloat64RoundTruncate | 1833 MachineOperatorBuilder::kFloat64RoundTruncate |
1809 MachineOperatorBuilder::kFloat64RoundTiesAway | 1834 MachineOperatorBuilder::kFloat64RoundTiesAway |
1810 MachineOperatorBuilder::kWord32Popcnt | 1835 MachineOperatorBuilder::kWord32Popcnt |
1811 MachineOperatorBuilder::kWord64Popcnt; 1836 MachineOperatorBuilder::kWord64Popcnt;
1812 // We omit kWord32ShiftIsSafe as s[rl]w use 0x3f as a mask rather than 0x1f. 1837 // We omit kWord32ShiftIsSafe as s[rl]w use 0x3f as a mask rather than 0x1f.
1813 } 1838 }
1814 1839
1815 } // namespace compiler 1840 } // namespace compiler
1816 } // namespace internal 1841 } // namespace internal
1817 } // namespace v8 1842 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ppc/code-generator-ppc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698