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