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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 Mips64OperandGenerator g(this); | 415 Mips64OperandGenerator g(this); |
416 Emit(kMips64Nor, g.DefineAsRegister(node), g.UseRegister(m.left().node()), | 416 Emit(kMips64Nor, g.DefineAsRegister(node), g.UseRegister(m.left().node()), |
417 g.TempImmediate(0)); | 417 g.TempImmediate(0)); |
418 return; | 418 return; |
419 } | 419 } |
420 VisitBinop(this, node, kMips64Xor); | 420 VisitBinop(this, node, kMips64Xor); |
421 } | 421 } |
422 | 422 |
423 | 423 |
424 void InstructionSelector::VisitWord32Shl(Node* node) { | 424 void InstructionSelector::VisitWord32Shl(Node* node) { |
425 Int32BinopMatcher m(node); | |
titzer
2015/12/04 09:26:59
Here, too.
dusan.milosavljevic
2015/12/04 12:50:58
Done.
| |
426 if (m.left().IsWord32And() && CanCover(node, m.left().node()) && | |
427 m.right().IsInRange(1, 31)) { | |
428 Mips64OperandGenerator g(this); | |
429 Int32BinopMatcher mleft(m.left().node()); | |
430 if (mleft.right().HasValue()) { | |
431 uint32_t mask = mleft.right().Value(); | |
432 uint32_t mask_width = base::bits::CountPopulation32(mask); | |
433 uint32_t mask_msb = base::bits::CountLeadingZeros32(mask); | |
434 if ((mask_width != 0) && (mask_msb + mask_width == 32)) { | |
435 uint32_t shift = m.right().Value(); | |
436 DCHECK_EQ(0u, base::bits::CountTrailingZeros32(mask)); | |
437 DCHECK_NE(0u, shift); | |
438 if ((shift + mask_width) >= 32) { | |
439 // If the mask is contiguous and reaches or extends beyond the top | |
440 // bit, only the shift is needed. | |
441 Emit(kMips64Shl, g.DefineAsRegister(node), | |
442 g.UseRegister(mleft.left().node()), | |
443 g.UseImmediate(m.right().node())); | |
444 return; | |
445 } | |
446 } | |
447 } | |
448 } | |
425 VisitRRO(this, kMips64Shl, node); | 449 VisitRRO(this, kMips64Shl, node); |
426 } | 450 } |
427 | 451 |
428 | 452 |
429 void InstructionSelector::VisitWord32Shr(Node* node) { | 453 void InstructionSelector::VisitWord32Shr(Node* node) { |
430 Int32BinopMatcher m(node); | 454 Int32BinopMatcher m(node); |
431 if (m.left().IsWord32And() && m.right().HasValue()) { | 455 if (m.left().IsWord32And() && m.right().HasValue()) { |
432 uint32_t lsb = m.right().Value() & 0x1f; | 456 uint32_t lsb = m.right().Value() & 0x1f; |
433 Int32BinopMatcher mleft(m.left().node()); | 457 Int32BinopMatcher mleft(m.left().node()); |
434 if (mleft.right().HasValue()) { | 458 if (mleft.right().HasValue()) { |
(...skipping 26 matching lines...) Expand all Loading... | |
461 Int64BinopMatcher m(node); | 485 Int64BinopMatcher m(node); |
462 if ((m.left().IsChangeInt32ToInt64() || m.left().IsChangeUint32ToUint64()) && | 486 if ((m.left().IsChangeInt32ToInt64() || m.left().IsChangeUint32ToUint64()) && |
463 m.right().IsInRange(32, 63)) { | 487 m.right().IsInRange(32, 63)) { |
464 // There's no need to sign/zero-extend to 64-bit if we shift out the upper | 488 // There's no need to sign/zero-extend to 64-bit if we shift out the upper |
465 // 32 bits anyway. | 489 // 32 bits anyway. |
466 Emit(kMips64Dshl, g.DefineSameAsFirst(node), | 490 Emit(kMips64Dshl, g.DefineSameAsFirst(node), |
467 g.UseRegister(m.left().node()->InputAt(0)), | 491 g.UseRegister(m.left().node()->InputAt(0)), |
468 g.UseImmediate(m.right().node())); | 492 g.UseImmediate(m.right().node())); |
469 return; | 493 return; |
470 } | 494 } |
495 if (m.left().IsWord64And() && CanCover(node, m.left().node()) && | |
496 m.right().IsInRange(1, 63)) { | |
497 Int64BinopMatcher mleft(m.left().node()); | |
498 if (mleft.right().HasValue()) { | |
499 uint64_t mask = mleft.right().Value(); | |
500 uint32_t mask_width = base::bits::CountPopulation64(mask); | |
501 uint32_t mask_msb = base::bits::CountLeadingZeros64(mask); | |
502 if ((mask_width != 0) && (mask_msb + mask_width == 64)) { | |
503 uint64_t shift = m.right().Value(); | |
504 DCHECK_EQ(0u, base::bits::CountTrailingZeros64(mask)); | |
505 DCHECK_NE(0u, shift); | |
506 | |
507 if ((shift + mask_width) >= 64) { | |
508 // If the mask is contiguous and reaches or extends beyond the top | |
509 // bit, only the shift is needed. | |
510 Emit(kMips64Dshl, g.DefineAsRegister(node), | |
511 g.UseRegister(mleft.left().node()), | |
512 g.UseImmediate(m.right().node())); | |
513 return; | |
514 } | |
515 } | |
516 } | |
517 } | |
471 VisitRRO(this, kMips64Dshl, node); | 518 VisitRRO(this, kMips64Dshl, node); |
472 } | 519 } |
473 | 520 |
474 | 521 |
475 void InstructionSelector::VisitWord64Shr(Node* node) { | 522 void InstructionSelector::VisitWord64Shr(Node* node) { |
476 Int64BinopMatcher m(node); | 523 Int64BinopMatcher m(node); |
477 if (m.left().IsWord64And() && m.right().HasValue()) { | 524 if (m.left().IsWord64And() && m.right().HasValue()) { |
478 uint32_t lsb = m.right().Value() & 0x3f; | 525 uint32_t lsb = m.right().Value() & 0x3f; |
479 Int64BinopMatcher mleft(m.left().node()); | 526 Int64BinopMatcher mleft(m.left().node()); |
480 if (mleft.right().HasValue()) { | 527 if (mleft.right().HasValue()) { |
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1663 MachineOperatorBuilder::kFloat32RoundUp | | 1710 MachineOperatorBuilder::kFloat32RoundUp | |
1664 MachineOperatorBuilder::kFloat64RoundTruncate | | 1711 MachineOperatorBuilder::kFloat64RoundTruncate | |
1665 MachineOperatorBuilder::kFloat32RoundTruncate | | 1712 MachineOperatorBuilder::kFloat32RoundTruncate | |
1666 MachineOperatorBuilder::kFloat64RoundTiesEven | | 1713 MachineOperatorBuilder::kFloat64RoundTiesEven | |
1667 MachineOperatorBuilder::kFloat32RoundTiesEven; | 1714 MachineOperatorBuilder::kFloat32RoundTiesEven; |
1668 } | 1715 } |
1669 | 1716 |
1670 } // namespace compiler | 1717 } // namespace compiler |
1671 } // namespace internal | 1718 } // namespace internal |
1672 } // namespace v8 | 1719 } // namespace v8 |
OLD | NEW |