| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "src/base/adapters.h" | 7 #include "src/base/adapters.h" |
| 8 #include "src/compiler/instruction-selector-impl.h" | 8 #include "src/compiler/instruction-selector-impl.h" |
| 9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 // No leal pattern match, use addl | 644 // No leal pattern match, use addl |
| 645 VisitBinop(this, node, kX64Add32); | 645 VisitBinop(this, node, kX64Add32); |
| 646 } | 646 } |
| 647 | 647 |
| 648 | 648 |
| 649 void InstructionSelector::VisitInt64Add(Node* node) { | 649 void InstructionSelector::VisitInt64Add(Node* node) { |
| 650 VisitBinop(this, node, kX64Add); | 650 VisitBinop(this, node, kX64Add); |
| 651 } | 651 } |
| 652 | 652 |
| 653 | 653 |
| 654 void InstructionSelector::VisitInt64AddWithOverflow(Node* node) { |
| 655 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
| 656 FlagsContinuation cont(kOverflow, ovf); |
| 657 VisitBinop(this, node, kX64Add, &cont); |
| 658 } |
| 659 FlagsContinuation cont; |
| 660 VisitBinop(this, node, kX64Add, &cont); |
| 661 } |
| 662 |
| 663 |
| 654 void InstructionSelector::VisitInt32Sub(Node* node) { | 664 void InstructionSelector::VisitInt32Sub(Node* node) { |
| 655 X64OperandGenerator g(this); | 665 X64OperandGenerator g(this); |
| 656 Int32BinopMatcher m(node); | 666 Int32BinopMatcher m(node); |
| 657 if (m.left().Is(0)) { | 667 if (m.left().Is(0)) { |
| 658 Emit(kX64Neg32, g.DefineSameAsFirst(node), g.UseRegister(m.right().node())); | 668 Emit(kX64Neg32, g.DefineSameAsFirst(node), g.UseRegister(m.right().node())); |
| 659 } else { | 669 } else { |
| 660 if (m.right().HasValue() && g.CanBeImmediate(m.right().node())) { | 670 if (m.right().HasValue() && g.CanBeImmediate(m.right().node())) { |
| 661 // Turn subtractions of constant values into immediate "leal" instructions | 671 // Turn subtractions of constant values into immediate "leal" instructions |
| 662 // by negating the value. | 672 // by negating the value. |
| 663 Emit(kX64Lea32 | AddressingModeField::encode(kMode_MRI), | 673 Emit(kX64Lea32 | AddressingModeField::encode(kMode_MRI), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 674 X64OperandGenerator g(this); | 684 X64OperandGenerator g(this); |
| 675 Int64BinopMatcher m(node); | 685 Int64BinopMatcher m(node); |
| 676 if (m.left().Is(0)) { | 686 if (m.left().Is(0)) { |
| 677 Emit(kX64Neg, g.DefineSameAsFirst(node), g.UseRegister(m.right().node())); | 687 Emit(kX64Neg, g.DefineSameAsFirst(node), g.UseRegister(m.right().node())); |
| 678 } else { | 688 } else { |
| 679 VisitBinop(this, node, kX64Sub); | 689 VisitBinop(this, node, kX64Sub); |
| 680 } | 690 } |
| 681 } | 691 } |
| 682 | 692 |
| 683 | 693 |
| 694 void InstructionSelector::VisitInt64SubWithOverflow(Node* node) { |
| 695 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
| 696 FlagsContinuation cont(kOverflow, ovf); |
| 697 return VisitBinop(this, node, kX64Sub, &cont); |
| 698 } |
| 699 FlagsContinuation cont; |
| 700 VisitBinop(this, node, kX64Sub, &cont); |
| 701 } |
| 702 |
| 703 |
| 684 namespace { | 704 namespace { |
| 685 | 705 |
| 686 void VisitMul(InstructionSelector* selector, Node* node, ArchOpcode opcode) { | 706 void VisitMul(InstructionSelector* selector, Node* node, ArchOpcode opcode) { |
| 687 X64OperandGenerator g(selector); | 707 X64OperandGenerator g(selector); |
| 688 Int32BinopMatcher m(node); | 708 Int32BinopMatcher m(node); |
| 689 Node* left = m.left().node(); | 709 Node* left = m.left().node(); |
| 690 Node* right = m.right().node(); | 710 Node* right = m.right().node(); |
| 691 if (g.CanBeImmediate(right)) { | 711 if (g.CanBeImmediate(right)) { |
| 692 selector->Emit(opcode, g.DefineAsRegister(node), g.Use(left), | 712 selector->Emit(opcode, g.DefineAsRegister(node), g.Use(left), |
| 693 g.UseImmediate(right)); | 713 g.UseImmediate(right)); |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 Node* const node = value->InputAt(0); | 1506 Node* const node = value->InputAt(0); |
| 1487 Node* const result = NodeProperties::FindProjection(node, 0); | 1507 Node* const result = NodeProperties::FindProjection(node, 0); |
| 1488 if (result == NULL || IsDefined(result)) { | 1508 if (result == NULL || IsDefined(result)) { |
| 1489 switch (node->opcode()) { | 1509 switch (node->opcode()) { |
| 1490 case IrOpcode::kInt32AddWithOverflow: | 1510 case IrOpcode::kInt32AddWithOverflow: |
| 1491 cont.OverwriteAndNegateIfEqual(kOverflow); | 1511 cont.OverwriteAndNegateIfEqual(kOverflow); |
| 1492 return VisitBinop(this, node, kX64Add32, &cont); | 1512 return VisitBinop(this, node, kX64Add32, &cont); |
| 1493 case IrOpcode::kInt32SubWithOverflow: | 1513 case IrOpcode::kInt32SubWithOverflow: |
| 1494 cont.OverwriteAndNegateIfEqual(kOverflow); | 1514 cont.OverwriteAndNegateIfEqual(kOverflow); |
| 1495 return VisitBinop(this, node, kX64Sub32, &cont); | 1515 return VisitBinop(this, node, kX64Sub32, &cont); |
| 1516 case IrOpcode::kInt64AddWithOverflow: |
| 1517 cont.OverwriteAndNegateIfEqual(kOverflow); |
| 1518 return VisitBinop(this, node, kX64Add, &cont); |
| 1519 case IrOpcode::kInt64SubWithOverflow: |
| 1520 cont.OverwriteAndNegateIfEqual(kOverflow); |
| 1521 return VisitBinop(this, node, kX64Sub, &cont); |
| 1496 default: | 1522 default: |
| 1497 break; | 1523 break; |
| 1498 } | 1524 } |
| 1499 } | 1525 } |
| 1500 } | 1526 } |
| 1501 break; | 1527 break; |
| 1502 case IrOpcode::kInt32Sub: | 1528 case IrOpcode::kInt32Sub: |
| 1503 return VisitWordCompare(this, value, kX64Cmp32, &cont); | 1529 return VisitWordCompare(this, value, kX64Cmp32, &cont); |
| 1504 case IrOpcode::kInt64Sub: | 1530 case IrOpcode::kInt64Sub: |
| 1505 return VisitWord64Compare(this, value, &cont); | 1531 return VisitWord64Compare(this, value, &cont); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 MachineOperatorBuilder::kFloat64RoundTruncate | | 1796 MachineOperatorBuilder::kFloat64RoundTruncate | |
| 1771 MachineOperatorBuilder::kFloat32RoundTiesEven | | 1797 MachineOperatorBuilder::kFloat32RoundTiesEven | |
| 1772 MachineOperatorBuilder::kFloat64RoundTiesEven; | 1798 MachineOperatorBuilder::kFloat64RoundTiesEven; |
| 1773 } | 1799 } |
| 1774 return flags; | 1800 return flags; |
| 1775 } | 1801 } |
| 1776 | 1802 |
| 1777 } // namespace compiler | 1803 } // namespace compiler |
| 1778 } // namespace internal | 1804 } // namespace internal |
| 1779 } // namespace v8 | 1805 } // namespace v8 |
| OLD | NEW |