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/compiler/instruction-selector-impl.h" | 5 #include "src/compiler/instruction-selector-impl.h" |
6 #include "src/compiler/node-matchers.h" | 6 #include "src/compiler/node-matchers.h" |
7 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 Node* left = m.left().node(); | 834 Node* left = m.left().node(); |
835 int shift = m.right().Value() & 0x1f; | 835 int shift = m.right().Value() & 0x1f; |
836 InstructionOperand const smull_operand = g.TempRegister(); | 836 InstructionOperand const smull_operand = g.TempRegister(); |
837 Emit(kArm64Smull, smull_operand, g.UseRegister(left->InputAt(0)), | 837 Emit(kArm64Smull, smull_operand, g.UseRegister(left->InputAt(0)), |
838 g.UseRegister(left->InputAt(1))); | 838 g.UseRegister(left->InputAt(1))); |
839 Emit(kArm64Asr, g.DefineAsRegister(node), smull_operand, | 839 Emit(kArm64Asr, g.DefineAsRegister(node), smull_operand, |
840 g.TempImmediate(32 + shift)); | 840 g.TempImmediate(32 + shift)); |
841 return; | 841 return; |
842 } | 842 } |
843 | 843 |
| 844 if (m.left().IsInt32Add() && m.right().HasValue() && |
| 845 CanCover(node, node->InputAt(0))) { |
| 846 Node* add_node = m.left().node(); |
| 847 Int32BinopMatcher madd_node(add_node); |
| 848 if (madd_node.left().IsInt32MulHigh() && |
| 849 CanCover(add_node, madd_node.left().node())) { |
| 850 // Combine the shift that would be generated by Int32MulHigh with the add |
| 851 // on the left of this Sar operation. We do it here, as the result of the |
| 852 // add potentially has 33 bits, so we have to ensure the result is |
| 853 // truncated by being the input to this 32-bit Sar operation. |
| 854 Arm64OperandGenerator g(this); |
| 855 Node* mul_node = madd_node.left().node(); |
| 856 |
| 857 InstructionOperand const smull_operand = g.TempRegister(); |
| 858 Emit(kArm64Smull, smull_operand, g.UseRegister(mul_node->InputAt(0)), |
| 859 g.UseRegister(mul_node->InputAt(1))); |
| 860 |
| 861 InstructionOperand const add_operand = g.TempRegister(); |
| 862 Emit(kArm64Add | AddressingModeField::encode(kMode_Operand2_R_ASR_I), |
| 863 add_operand, g.UseRegister(add_node->InputAt(1)), smull_operand, |
| 864 g.TempImmediate(32)); |
| 865 |
| 866 Emit(kArm64Asr32, g.DefineAsRegister(node), add_operand, |
| 867 g.UseImmediate(node->InputAt(1))); |
| 868 return; |
| 869 } |
| 870 } |
| 871 |
844 VisitRRO(this, kArm64Asr32, node, kShift32Imm); | 872 VisitRRO(this, kArm64Asr32, node, kShift32Imm); |
845 } | 873 } |
846 | 874 |
847 | 875 |
848 void InstructionSelector::VisitWord64Sar(Node* node) { | 876 void InstructionSelector::VisitWord64Sar(Node* node) { |
849 VisitRRO(this, kArm64Asr, node, kShift64Imm); | 877 VisitRRO(this, kArm64Asr, node, kShift64Imm); |
850 } | 878 } |
851 | 879 |
852 | 880 |
853 void InstructionSelector::VisitWord32Ror(Node* node) { | 881 void InstructionSelector::VisitWord32Ror(Node* node) { |
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2008 MachineOperatorBuilder::kFloat64RoundTruncate | | 2036 MachineOperatorBuilder::kFloat64RoundTruncate | |
2009 MachineOperatorBuilder::kFloat64RoundTiesAway | | 2037 MachineOperatorBuilder::kFloat64RoundTiesAway | |
2010 MachineOperatorBuilder::kWord32ShiftIsSafe | | 2038 MachineOperatorBuilder::kWord32ShiftIsSafe | |
2011 MachineOperatorBuilder::kInt32DivIsSafe | | 2039 MachineOperatorBuilder::kInt32DivIsSafe | |
2012 MachineOperatorBuilder::kUint32DivIsSafe; | 2040 MachineOperatorBuilder::kUint32DivIsSafe; |
2013 } | 2041 } |
2014 | 2042 |
2015 } // namespace compiler | 2043 } // namespace compiler |
2016 } // namespace internal | 2044 } // namespace internal |
2017 } // namespace v8 | 2045 } // namespace v8 |
OLD | NEW |