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/base/bits.h" | 6 #include "src/base/bits.h" |
7 #include "src/compiler/instruction-selector-impl.h" | 7 #include "src/compiler/instruction-selector-impl.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 | 10 |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 MipsOperandGenerator g(this); | 323 MipsOperandGenerator g(this); |
324 Emit(kMipsNor, g.DefineAsRegister(node), g.UseRegister(m.left().node()), | 324 Emit(kMipsNor, g.DefineAsRegister(node), g.UseRegister(m.left().node()), |
325 g.TempImmediate(0)); | 325 g.TempImmediate(0)); |
326 return; | 326 return; |
327 } | 327 } |
328 VisitBinop(this, node, kMipsXor); | 328 VisitBinop(this, node, kMipsXor); |
329 } | 329 } |
330 | 330 |
331 | 331 |
332 void InstructionSelector::VisitWord32Shl(Node* node) { | 332 void InstructionSelector::VisitWord32Shl(Node* node) { |
| 333 Int32BinopMatcher m(node); |
| 334 if (m.left().IsWord32And() && CanCover(node, m.left().node()) && |
| 335 m.right().IsInRange(1, 31)) { |
| 336 MipsOperandGenerator g(this); |
| 337 Int32BinopMatcher mleft(m.left().node()); |
| 338 // Match Word32Shl(Word32And(x, mask), imm) to Shl where the mask is |
| 339 // contiguous, and the shift immediate non-zero. |
| 340 if (mleft.right().HasValue()) { |
| 341 uint32_t mask = mleft.right().Value(); |
| 342 uint32_t mask_width = base::bits::CountPopulation32(mask); |
| 343 uint32_t mask_msb = base::bits::CountLeadingZeros32(mask); |
| 344 if ((mask_width != 0) && (mask_msb + mask_width == 32)) { |
| 345 uint32_t shift = m.right().Value(); |
| 346 DCHECK_EQ(0u, base::bits::CountTrailingZeros32(mask)); |
| 347 DCHECK_NE(0u, shift); |
| 348 if ((shift + mask_width) >= 32) { |
| 349 // If the mask is contiguous and reaches or extends beyond the top |
| 350 // bit, only the shift is needed. |
| 351 Emit(kMipsShl, g.DefineAsRegister(node), |
| 352 g.UseRegister(mleft.left().node()), |
| 353 g.UseImmediate(m.right().node())); |
| 354 return; |
| 355 } |
| 356 } |
| 357 } |
| 358 } |
333 VisitRRO(this, kMipsShl, node); | 359 VisitRRO(this, kMipsShl, node); |
334 } | 360 } |
335 | 361 |
336 | 362 |
337 void InstructionSelector::VisitWord32Shr(Node* node) { | 363 void InstructionSelector::VisitWord32Shr(Node* node) { |
338 Int32BinopMatcher m(node); | 364 Int32BinopMatcher m(node); |
339 if (m.left().IsWord32And() && m.right().HasValue()) { | 365 if (m.left().IsWord32And() && m.right().HasValue()) { |
340 uint32_t lsb = m.right().Value() & 0x1f; | 366 uint32_t lsb = m.right().Value() & 0x1f; |
341 Int32BinopMatcher mleft(m.left().node()); | 367 Int32BinopMatcher mleft(m.left().node()); |
342 if (mleft.right().HasValue()) { | 368 if (mleft.right().HasValue()) { |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 MachineOperatorBuilder::kFloat32Max | | 1252 MachineOperatorBuilder::kFloat32Max | |
1227 MachineOperatorBuilder::kFloat32RoundDown | | 1253 MachineOperatorBuilder::kFloat32RoundDown | |
1228 MachineOperatorBuilder::kFloat32RoundUp | | 1254 MachineOperatorBuilder::kFloat32RoundUp | |
1229 MachineOperatorBuilder::kFloat32RoundTruncate | | 1255 MachineOperatorBuilder::kFloat32RoundTruncate | |
1230 MachineOperatorBuilder::kFloat32RoundTiesEven; | 1256 MachineOperatorBuilder::kFloat32RoundTiesEven; |
1231 } | 1257 } |
1232 | 1258 |
1233 } // namespace compiler | 1259 } // namespace compiler |
1234 } // namespace internal | 1260 } // namespace internal |
1235 } // namespace v8 | 1261 } // namespace v8 |
OLD | NEW |