| 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/bits.h" | 
| 5 #include "src/compiler/instruction-selector-impl.h" | 6 #include "src/compiler/instruction-selector-impl.h" | 
| 6 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" | 
| 7 #include "src/compiler-intrinsics.h" |  | 
| 8 | 8 | 
| 9 namespace v8 { | 9 namespace v8 { | 
| 10 namespace internal { | 10 namespace internal { | 
| 11 namespace compiler { | 11 namespace compiler { | 
| 12 | 12 | 
| 13 // Adds Arm-specific methods for generating InstructionOperands. | 13 // Adds Arm-specific methods for generating InstructionOperands. | 
| 14 class ArmOperandGenerator V8_FINAL : public OperandGenerator { | 14 class ArmOperandGenerator V8_FINAL : public OperandGenerator { | 
| 15  public: | 15  public: | 
| 16   explicit ArmOperandGenerator(InstructionSelector* selector) | 16   explicit ArmOperandGenerator(InstructionSelector* selector) | 
| 17       : OperandGenerator(selector) {} | 17       : OperandGenerator(selector) {} | 
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 416   } | 416   } | 
| 417   if (m.right().IsWord32Xor() && CanCover(node, m.right().node())) { | 417   if (m.right().IsWord32Xor() && CanCover(node, m.right().node())) { | 
| 418     Int32BinopMatcher mright(m.right().node()); | 418     Int32BinopMatcher mright(m.right().node()); | 
| 419     if (mright.right().Is(-1)) { | 419     if (mright.right().Is(-1)) { | 
| 420       EmitBic(this, node, m.left().node(), mright.left().node()); | 420       EmitBic(this, node, m.left().node(), mright.left().node()); | 
| 421       return; | 421       return; | 
| 422     } | 422     } | 
| 423   } | 423   } | 
| 424   if (IsSupported(ARMv7) && m.right().HasValue()) { | 424   if (IsSupported(ARMv7) && m.right().HasValue()) { | 
| 425     uint32_t value = m.right().Value(); | 425     uint32_t value = m.right().Value(); | 
| 426     uint32_t width = CompilerIntrinsics::CountSetBits(value); | 426     uint32_t width = base::bits::CountSetBits32(value); | 
| 427     uint32_t msb = CompilerIntrinsics::CountLeadingZeros(value); | 427     uint32_t msb = base::bits::CountLeadingZeros32(value); | 
| 428     if (width != 0 && msb + width == 32) { | 428     if (width != 0 && msb + width == 32) { | 
| 429       DCHECK_EQ(0, CompilerIntrinsics::CountTrailingZeros(value)); | 429       DCHECK_EQ(0, base::bits::CountTrailingZeros32(value)); | 
| 430       if (m.left().IsWord32Shr()) { | 430       if (m.left().IsWord32Shr()) { | 
| 431         Int32BinopMatcher mleft(m.left().node()); | 431         Int32BinopMatcher mleft(m.left().node()); | 
| 432         if (mleft.right().IsInRange(0, 31)) { | 432         if (mleft.right().IsInRange(0, 31)) { | 
| 433           Emit(kArmUbfx, g.DefineAsRegister(node), | 433           Emit(kArmUbfx, g.DefineAsRegister(node), | 
| 434                g.UseRegister(mleft.left().node()), | 434                g.UseRegister(mleft.left().node()), | 
| 435                g.UseImmediate(mleft.right().node()), g.TempImmediate(width)); | 435                g.UseImmediate(mleft.right().node()), g.TempImmediate(width)); | 
| 436           return; | 436           return; | 
| 437         } | 437         } | 
| 438       } | 438       } | 
| 439       Emit(kArmUbfx, g.DefineAsRegister(node), g.UseRegister(m.left().node()), | 439       Emit(kArmUbfx, g.DefineAsRegister(node), g.UseRegister(m.left().node()), | 
| 440            g.TempImmediate(0), g.TempImmediate(width)); | 440            g.TempImmediate(0), g.TempImmediate(width)); | 
| 441       return; | 441       return; | 
| 442     } | 442     } | 
| 443     // Try to interpret this AND as BFC. | 443     // Try to interpret this AND as BFC. | 
| 444     width = 32 - width; | 444     width = 32 - width; | 
| 445     msb = CompilerIntrinsics::CountLeadingZeros(~value); | 445     msb = base::bits::CountLeadingZeros32(~value); | 
| 446     uint32_t lsb = CompilerIntrinsics::CountTrailingZeros(~value); | 446     uint32_t lsb = base::bits::CountTrailingZeros32(~value); | 
| 447     if (msb + width + lsb == 32) { | 447     if (msb + width + lsb == 32) { | 
| 448       Emit(kArmBfc, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), | 448       Emit(kArmBfc, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), | 
| 449            g.TempImmediate(lsb), g.TempImmediate(width)); | 449            g.TempImmediate(lsb), g.TempImmediate(width)); | 
| 450       return; | 450       return; | 
| 451     } | 451     } | 
| 452   } | 452   } | 
| 453   VisitBinop(this, node, kArmAnd, kArmAnd); | 453   VisitBinop(this, node, kArmAnd, kArmAnd); | 
| 454 } | 454 } | 
| 455 | 455 | 
| 456 | 456 | 
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 529 | 529 | 
| 530 void InstructionSelector::VisitWord32Shr(Node* node) { | 530 void InstructionSelector::VisitWord32Shr(Node* node) { | 
| 531   ArmOperandGenerator g(this); | 531   ArmOperandGenerator g(this); | 
| 532   Int32BinopMatcher m(node); | 532   Int32BinopMatcher m(node); | 
| 533   if (IsSupported(ARMv7) && m.left().IsWord32And() && | 533   if (IsSupported(ARMv7) && m.left().IsWord32And() && | 
| 534       m.right().IsInRange(0, 31)) { | 534       m.right().IsInRange(0, 31)) { | 
| 535     int32_t lsb = m.right().Value(); | 535     int32_t lsb = m.right().Value(); | 
| 536     Int32BinopMatcher mleft(m.left().node()); | 536     Int32BinopMatcher mleft(m.left().node()); | 
| 537     if (mleft.right().HasValue()) { | 537     if (mleft.right().HasValue()) { | 
| 538       uint32_t value = (mleft.right().Value() >> lsb) << lsb; | 538       uint32_t value = (mleft.right().Value() >> lsb) << lsb; | 
| 539       uint32_t width = CompilerIntrinsics::CountSetBits(value); | 539       uint32_t width = base::bits::CountSetBits32(value); | 
| 540       uint32_t msb = CompilerIntrinsics::CountLeadingZeros(value); | 540       uint32_t msb = base::bits::CountLeadingZeros32(value); | 
| 541       if (msb + width + lsb == 32) { | 541       if (msb + width + lsb == 32) { | 
| 542         DCHECK_EQ(lsb, CompilerIntrinsics::CountTrailingZeros(value)); | 542         DCHECK_EQ(lsb, base::bits::CountTrailingZeros32(value)); | 
| 543         Emit(kArmUbfx, g.DefineAsRegister(node), | 543         Emit(kArmUbfx, g.DefineAsRegister(node), | 
| 544              g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), | 544              g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), | 
| 545              g.TempImmediate(width)); | 545              g.TempImmediate(width)); | 
| 546         return; | 546         return; | 
| 547       } | 547       } | 
| 548     } | 548     } | 
| 549   } | 549   } | 
| 550   VisitShift(this, node, TryMatchLSR); | 550   VisitShift(this, node, TryMatchLSR); | 
| 551 } | 551 } | 
| 552 | 552 | 
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 952     DCHECK(cont->IsSet()); | 952     DCHECK(cont->IsSet()); | 
| 953     Emit(cont->Encode(kArmVcmpF64), g.DefineAsRegister(cont->result()), | 953     Emit(cont->Encode(kArmVcmpF64), g.DefineAsRegister(cont->result()), | 
| 954          g.UseDoubleRegister(m.left().node()), | 954          g.UseDoubleRegister(m.left().node()), | 
| 955          g.UseDoubleRegister(m.right().node())); | 955          g.UseDoubleRegister(m.right().node())); | 
| 956   } | 956   } | 
| 957 } | 957 } | 
| 958 | 958 | 
| 959 }  // namespace compiler | 959 }  // namespace compiler | 
| 960 }  // namespace internal | 960 }  // namespace internal | 
| 961 }  // namespace v8 | 961 }  // namespace v8 | 
| OLD | NEW | 
|---|