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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 } | 679 } |
680 VisitRRO(this, kMips64Shl, node); | 680 VisitRRO(this, kMips64Shl, node); |
681 } | 681 } |
682 | 682 |
683 | 683 |
684 void InstructionSelector::VisitWord32Shr(Node* node) { | 684 void InstructionSelector::VisitWord32Shr(Node* node) { |
685 Int32BinopMatcher m(node); | 685 Int32BinopMatcher m(node); |
686 if (m.left().IsWord32And() && m.right().HasValue()) { | 686 if (m.left().IsWord32And() && m.right().HasValue()) { |
687 uint32_t lsb = m.right().Value() & 0x1f; | 687 uint32_t lsb = m.right().Value() & 0x1f; |
688 Int32BinopMatcher mleft(m.left().node()); | 688 Int32BinopMatcher mleft(m.left().node()); |
689 if (mleft.right().HasValue()) { | 689 if (mleft.right().HasValue() && mleft.right().Value() != 0) { |
690 // Select Ext for Shr(And(x, mask), imm) where the result of the mask is | 690 // Select Ext for Shr(And(x, mask), imm) where the result of the mask is |
691 // shifted into the least-significant bits. | 691 // shifted into the least-significant bits. |
692 uint32_t mask = (mleft.right().Value() >> lsb) << lsb; | 692 uint32_t mask = (mleft.right().Value() >> lsb) << lsb; |
693 unsigned mask_width = base::bits::CountPopulation32(mask); | 693 unsigned mask_width = base::bits::CountPopulation32(mask); |
694 unsigned mask_msb = base::bits::CountLeadingZeros32(mask); | 694 unsigned mask_msb = base::bits::CountLeadingZeros32(mask); |
695 if ((mask_msb + mask_width + lsb) == 32) { | 695 if ((mask_msb + mask_width + lsb) == 32) { |
696 Mips64OperandGenerator g(this); | 696 Mips64OperandGenerator g(this); |
697 DCHECK_EQ(lsb, base::bits::CountTrailingZeros32(mask)); | 697 DCHECK_EQ(lsb, base::bits::CountTrailingZeros32(mask)); |
698 Emit(kMips64Ext, g.DefineAsRegister(node), | 698 Emit(kMips64Ext, g.DefineAsRegister(node), |
699 g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), | 699 g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 } | 772 } |
773 VisitRRO(this, kMips64Dshl, node); | 773 VisitRRO(this, kMips64Dshl, node); |
774 } | 774 } |
775 | 775 |
776 | 776 |
777 void InstructionSelector::VisitWord64Shr(Node* node) { | 777 void InstructionSelector::VisitWord64Shr(Node* node) { |
778 Int64BinopMatcher m(node); | 778 Int64BinopMatcher m(node); |
779 if (m.left().IsWord64And() && m.right().HasValue()) { | 779 if (m.left().IsWord64And() && m.right().HasValue()) { |
780 uint32_t lsb = m.right().Value() & 0x3f; | 780 uint32_t lsb = m.right().Value() & 0x3f; |
781 Int64BinopMatcher mleft(m.left().node()); | 781 Int64BinopMatcher mleft(m.left().node()); |
782 if (mleft.right().HasValue()) { | 782 if (mleft.right().HasValue() && mleft.right().Value() != 0) { |
783 // Select Dext for Shr(And(x, mask), imm) where the result of the mask is | 783 // Select Dext for Shr(And(x, mask), imm) where the result of the mask is |
784 // shifted into the least-significant bits. | 784 // shifted into the least-significant bits. |
785 uint64_t mask = (mleft.right().Value() >> lsb) << lsb; | 785 uint64_t mask = (mleft.right().Value() >> lsb) << lsb; |
786 unsigned mask_width = base::bits::CountPopulation64(mask); | 786 unsigned mask_width = base::bits::CountPopulation64(mask); |
787 unsigned mask_msb = base::bits::CountLeadingZeros64(mask); | 787 unsigned mask_msb = base::bits::CountLeadingZeros64(mask); |
788 if ((mask_msb + mask_width + lsb) == 64) { | 788 if ((mask_msb + mask_width + lsb) == 64) { |
789 Mips64OperandGenerator g(this); | 789 Mips64OperandGenerator g(this); |
790 DCHECK_EQ(lsb, base::bits::CountTrailingZeros64(mask)); | 790 DCHECK_EQ(lsb, base::bits::CountTrailingZeros64(mask)); |
791 Emit(kMips64Dext, g.DefineAsRegister(node), | 791 Emit(kMips64Dext, g.DefineAsRegister(node), |
792 g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), | 792 g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), |
(...skipping 1873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2666 } else { | 2666 } else { |
2667 DCHECK(kArchVariant == kMips64r2); | 2667 DCHECK(kArchVariant == kMips64r2); |
2668 return MachineOperatorBuilder::AlignmentRequirements:: | 2668 return MachineOperatorBuilder::AlignmentRequirements:: |
2669 NoUnalignedAccessSupport(); | 2669 NoUnalignedAccessSupport(); |
2670 } | 2670 } |
2671 } | 2671 } |
2672 | 2672 |
2673 } // namespace compiler | 2673 } // namespace compiler |
2674 } // namespace internal | 2674 } // namespace internal |
2675 } // namespace v8 | 2675 } // namespace v8 |
OLD | NEW |