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 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 } | 1104 } |
1105 | 1105 |
1106 } // namespace | 1106 } // namespace |
1107 | 1107 |
1108 | 1108 |
1109 void InstructionSelector::VisitWord32Shr(Node* node) { | 1109 void InstructionSelector::VisitWord32Shr(Node* node) { |
1110 Int32BinopMatcher m(node); | 1110 Int32BinopMatcher m(node); |
1111 if (m.left().IsWord32And() && m.right().HasValue()) { | 1111 if (m.left().IsWord32And() && m.right().HasValue()) { |
1112 uint32_t lsb = m.right().Value() & 0x1f; | 1112 uint32_t lsb = m.right().Value() & 0x1f; |
1113 Int32BinopMatcher mleft(m.left().node()); | 1113 Int32BinopMatcher mleft(m.left().node()); |
1114 if (mleft.right().HasValue()) { | 1114 if (mleft.right().HasValue() && mleft.right().Value() != 0) { |
1115 // Select Ubfx for Shr(And(x, mask), imm) where the result of the mask is | 1115 // Select Ubfx for Shr(And(x, mask), imm) where the result of the mask is |
1116 // shifted into the least-significant bits. | 1116 // shifted into the least-significant bits. |
1117 uint32_t mask = (mleft.right().Value() >> lsb) << lsb; | 1117 uint32_t mask = (mleft.right().Value() >> lsb) << lsb; |
1118 unsigned mask_width = base::bits::CountPopulation32(mask); | 1118 unsigned mask_width = base::bits::CountPopulation32(mask); |
1119 unsigned mask_msb = base::bits::CountLeadingZeros32(mask); | 1119 unsigned mask_msb = base::bits::CountLeadingZeros32(mask); |
1120 if ((mask_msb + mask_width + lsb) == 32) { | 1120 if ((mask_msb + mask_width + lsb) == 32) { |
1121 Arm64OperandGenerator g(this); | 1121 Arm64OperandGenerator g(this); |
1122 DCHECK_EQ(lsb, base::bits::CountTrailingZeros32(mask)); | 1122 DCHECK_EQ(lsb, base::bits::CountTrailingZeros32(mask)); |
1123 Emit(kArm64Ubfx32, g.DefineAsRegister(node), | 1123 Emit(kArm64Ubfx32, g.DefineAsRegister(node), |
1124 g.UseRegister(mleft.left().node()), | 1124 g.UseRegister(mleft.left().node()), |
(...skipping 23 matching lines...) Expand all Loading... |
1148 | 1148 |
1149 VisitRRO(this, kArm64Lsr32, node, kShift32Imm); | 1149 VisitRRO(this, kArm64Lsr32, node, kShift32Imm); |
1150 } | 1150 } |
1151 | 1151 |
1152 | 1152 |
1153 void InstructionSelector::VisitWord64Shr(Node* node) { | 1153 void InstructionSelector::VisitWord64Shr(Node* node) { |
1154 Int64BinopMatcher m(node); | 1154 Int64BinopMatcher m(node); |
1155 if (m.left().IsWord64And() && m.right().HasValue()) { | 1155 if (m.left().IsWord64And() && m.right().HasValue()) { |
1156 uint32_t lsb = m.right().Value() & 0x3f; | 1156 uint32_t lsb = m.right().Value() & 0x3f; |
1157 Int64BinopMatcher mleft(m.left().node()); | 1157 Int64BinopMatcher mleft(m.left().node()); |
1158 if (mleft.right().HasValue()) { | 1158 if (mleft.right().HasValue() && mleft.right().Value() != 0) { |
1159 // Select Ubfx for Shr(And(x, mask), imm) where the result of the mask is | 1159 // Select Ubfx for Shr(And(x, mask), imm) where the result of the mask is |
1160 // shifted into the least-significant bits. | 1160 // shifted into the least-significant bits. |
1161 uint64_t mask = (mleft.right().Value() >> lsb) << lsb; | 1161 uint64_t mask = (mleft.right().Value() >> lsb) << lsb; |
1162 unsigned mask_width = base::bits::CountPopulation64(mask); | 1162 unsigned mask_width = base::bits::CountPopulation64(mask); |
1163 unsigned mask_msb = base::bits::CountLeadingZeros64(mask); | 1163 unsigned mask_msb = base::bits::CountLeadingZeros64(mask); |
1164 if ((mask_msb + mask_width + lsb) == 64) { | 1164 if ((mask_msb + mask_width + lsb) == 64) { |
1165 Arm64OperandGenerator g(this); | 1165 Arm64OperandGenerator g(this); |
1166 DCHECK_EQ(lsb, base::bits::CountTrailingZeros64(mask)); | 1166 DCHECK_EQ(lsb, base::bits::CountTrailingZeros64(mask)); |
1167 Emit(kArm64Ubfx, g.DefineAsRegister(node), | 1167 Emit(kArm64Ubfx, g.DefineAsRegister(node), |
1168 g.UseRegister(mleft.left().node()), | 1168 g.UseRegister(mleft.left().node()), |
(...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2723 // static | 2723 // static |
2724 MachineOperatorBuilder::AlignmentRequirements | 2724 MachineOperatorBuilder::AlignmentRequirements |
2725 InstructionSelector::AlignmentRequirements() { | 2725 InstructionSelector::AlignmentRequirements() { |
2726 return MachineOperatorBuilder::AlignmentRequirements:: | 2726 return MachineOperatorBuilder::AlignmentRequirements:: |
2727 FullUnalignedAccessSupport(); | 2727 FullUnalignedAccessSupport(); |
2728 } | 2728 } |
2729 | 2729 |
2730 } // namespace compiler | 2730 } // namespace compiler |
2731 } // namespace internal | 2731 } // namespace internal |
2732 } // namespace v8 | 2732 } // namespace v8 |
OLD | NEW |