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 "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 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 PPCOperandGenerator g(this); | 982 PPCOperandGenerator g(this); |
983 Int64BinopMatcher m(node); | 983 Int64BinopMatcher m(node); |
984 if (m.left().Is(0)) { | 984 if (m.left().Is(0)) { |
985 Emit(kPPC_Neg, g.DefineAsRegister(node), g.UseRegister(m.right().node())); | 985 Emit(kPPC_Neg, g.DefineAsRegister(node), g.UseRegister(m.right().node())); |
986 } else { | 986 } else { |
987 VisitBinop<Int64BinopMatcher>(this, node, kPPC_Sub, kInt16Imm_Negate); | 987 VisitBinop<Int64BinopMatcher>(this, node, kPPC_Sub, kInt16Imm_Negate); |
988 } | 988 } |
989 } | 989 } |
990 #endif | 990 #endif |
991 | 991 |
| 992 namespace { |
| 993 |
| 994 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
| 995 InstructionOperand left, InstructionOperand right, |
| 996 FlagsContinuation* cont); |
| 997 void EmitInt32MulWithOverflow(InstructionSelector* selector, Node* node, |
| 998 FlagsContinuation* cont) { |
| 999 PPCOperandGenerator g(selector); |
| 1000 Int32BinopMatcher m(node); |
| 1001 InstructionOperand result_operand = g.DefineAsRegister(node); |
| 1002 InstructionOperand high32_operand = g.TempRegister(); |
| 1003 InstructionOperand temp_operand = g.TempRegister(); |
| 1004 { |
| 1005 InstructionOperand outputs[] = {result_operand, high32_operand}; |
| 1006 InstructionOperand inputs[] = {g.UseRegister(m.left().node()), |
| 1007 g.UseRegister(m.right().node())}; |
| 1008 selector->Emit(kPPC_Mul32WithHigh32, 2, outputs, 2, inputs); |
| 1009 } |
| 1010 { |
| 1011 InstructionOperand shift_31 = g.UseImmediate(31); |
| 1012 InstructionOperand outputs[] = {temp_operand}; |
| 1013 InstructionOperand inputs[] = {result_operand, shift_31}; |
| 1014 selector->Emit(kPPC_ShiftRightAlg32, 1, outputs, 2, inputs); |
| 1015 } |
| 1016 |
| 1017 VisitCompare(selector, kPPC_Cmp32, high32_operand, temp_operand, cont); |
| 1018 } |
| 1019 |
| 1020 } // namespace |
| 1021 |
992 | 1022 |
993 void InstructionSelector::VisitInt32Mul(Node* node) { | 1023 void InstructionSelector::VisitInt32Mul(Node* node) { |
994 VisitRRR(this, kPPC_Mul32, node); | 1024 VisitRRR(this, kPPC_Mul32, node); |
995 } | 1025 } |
996 | 1026 |
997 | 1027 |
998 #if V8_TARGET_ARCH_PPC64 | 1028 #if V8_TARGET_ARCH_PPC64 |
999 void InstructionSelector::VisitInt64Mul(Node* node) { | 1029 void InstructionSelector::VisitInt64Mul(Node* node) { |
1000 VisitRRR(this, kPPC_Mul64, node); | 1030 VisitRRR(this, kPPC_Mul64, node); |
1001 } | 1031 } |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 switch (node->opcode()) { | 1649 switch (node->opcode()) { |
1620 case IrOpcode::kInt32AddWithOverflow: | 1650 case IrOpcode::kInt32AddWithOverflow: |
1621 cont->OverwriteAndNegateIfEqual(kOverflow); | 1651 cont->OverwriteAndNegateIfEqual(kOverflow); |
1622 return VisitBinop<Int32BinopMatcher>( | 1652 return VisitBinop<Int32BinopMatcher>( |
1623 selector, node, kPPC_AddWithOverflow32, kInt16Imm, cont); | 1653 selector, node, kPPC_AddWithOverflow32, kInt16Imm, cont); |
1624 case IrOpcode::kInt32SubWithOverflow: | 1654 case IrOpcode::kInt32SubWithOverflow: |
1625 cont->OverwriteAndNegateIfEqual(kOverflow); | 1655 cont->OverwriteAndNegateIfEqual(kOverflow); |
1626 return VisitBinop<Int32BinopMatcher>(selector, node, | 1656 return VisitBinop<Int32BinopMatcher>(selector, node, |
1627 kPPC_SubWithOverflow32, | 1657 kPPC_SubWithOverflow32, |
1628 kInt16Imm_Negate, cont); | 1658 kInt16Imm_Negate, cont); |
| 1659 case IrOpcode::kInt32MulWithOverflow: |
| 1660 cont->OverwriteAndNegateIfEqual(kNotEqual); |
| 1661 return EmitInt32MulWithOverflow(selector, node, cont); |
1629 #if V8_TARGET_ARCH_PPC64 | 1662 #if V8_TARGET_ARCH_PPC64 |
1630 case IrOpcode::kInt64AddWithOverflow: | 1663 case IrOpcode::kInt64AddWithOverflow: |
1631 cont->OverwriteAndNegateIfEqual(kOverflow); | 1664 cont->OverwriteAndNegateIfEqual(kOverflow); |
1632 return VisitBinop<Int64BinopMatcher>(selector, node, kPPC_Add, | 1665 return VisitBinop<Int64BinopMatcher>(selector, node, kPPC_Add, |
1633 kInt16Imm, cont); | 1666 kInt16Imm, cont); |
1634 case IrOpcode::kInt64SubWithOverflow: | 1667 case IrOpcode::kInt64SubWithOverflow: |
1635 cont->OverwriteAndNegateIfEqual(kOverflow); | 1668 cont->OverwriteAndNegateIfEqual(kOverflow); |
1636 return VisitBinop<Int64BinopMatcher>(selector, node, kPPC_Sub, | 1669 return VisitBinop<Int64BinopMatcher>(selector, node, kPPC_Sub, |
1637 kInt16Imm_Negate, cont); | 1670 kInt16Imm_Negate, cont); |
1638 #endif | 1671 #endif |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 } | 1846 } |
1814 | 1847 |
1815 | 1848 |
1816 void InstructionSelector::VisitUint64LessThanOrEqual(Node* node) { | 1849 void InstructionSelector::VisitUint64LessThanOrEqual(Node* node) { |
1817 FlagsContinuation cont = | 1850 FlagsContinuation cont = |
1818 FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); | 1851 FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); |
1819 VisitWord64Compare(this, node, &cont); | 1852 VisitWord64Compare(this, node, &cont); |
1820 } | 1853 } |
1821 #endif | 1854 #endif |
1822 | 1855 |
| 1856 void InstructionSelector::VisitInt32MulWithOverflow(Node* node) { |
| 1857 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
| 1858 FlagsContinuation cont = FlagsContinuation::ForSet(kNotEqual, ovf); |
| 1859 return EmitInt32MulWithOverflow(this, node, &cont); |
| 1860 } |
| 1861 FlagsContinuation cont; |
| 1862 EmitInt32MulWithOverflow(this, node, &cont); |
| 1863 } |
| 1864 |
1823 | 1865 |
1824 void InstructionSelector::VisitFloat32Equal(Node* node) { | 1866 void InstructionSelector::VisitFloat32Equal(Node* node) { |
1825 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); | 1867 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); |
1826 VisitFloat32Compare(this, node, &cont); | 1868 VisitFloat32Compare(this, node, &cont); |
1827 } | 1869 } |
1828 | 1870 |
1829 | 1871 |
1830 void InstructionSelector::VisitFloat32LessThan(Node* node) { | 1872 void InstructionSelector::VisitFloat32LessThan(Node* node) { |
1831 FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); | 1873 FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); |
1832 VisitFloat32Compare(this, node, &cont); | 1874 VisitFloat32Compare(this, node, &cont); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 // static | 2063 // static |
2022 MachineOperatorBuilder::AlignmentRequirements | 2064 MachineOperatorBuilder::AlignmentRequirements |
2023 InstructionSelector::AlignmentRequirements() { | 2065 InstructionSelector::AlignmentRequirements() { |
2024 return MachineOperatorBuilder::AlignmentRequirements:: | 2066 return MachineOperatorBuilder::AlignmentRequirements:: |
2025 FullUnalignedAccessSupport(); | 2067 FullUnalignedAccessSupport(); |
2026 } | 2068 } |
2027 | 2069 |
2028 } // namespace compiler | 2070 } // namespace compiler |
2029 } // namespace internal | 2071 } // namespace internal |
2030 } // namespace v8 | 2072 } // namespace v8 |
OLD | NEW |