OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 2472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2483 } | 2483 } |
2484 | 2484 |
2485 | 2485 |
2486 void MacroAssembler::Move(XMMRegister dst, uint32_t src) { | 2486 void MacroAssembler::Move(XMMRegister dst, uint32_t src) { |
2487 if (src == 0) { | 2487 if (src == 0) { |
2488 Xorpd(dst, dst); | 2488 Xorpd(dst, dst); |
2489 } else { | 2489 } else { |
2490 unsigned pop = base::bits::CountPopulation32(src); | 2490 unsigned pop = base::bits::CountPopulation32(src); |
2491 DCHECK_NE(0u, pop); | 2491 DCHECK_NE(0u, pop); |
2492 if (pop == 32) { | 2492 if (pop == 32) { |
2493 pcmpeqd(dst, dst); | 2493 Pcmpeqd(dst, dst); |
2494 } else { | 2494 } else { |
2495 movl(kScratchRegister, Immediate(src)); | 2495 movl(kScratchRegister, Immediate(src)); |
2496 Movq(dst, kScratchRegister); | 2496 Movq(dst, kScratchRegister); |
2497 } | 2497 } |
2498 } | 2498 } |
2499 } | 2499 } |
2500 | 2500 |
2501 | 2501 |
2502 void MacroAssembler::Move(XMMRegister dst, uint64_t src) { | 2502 void MacroAssembler::Move(XMMRegister dst, uint64_t src) { |
2503 if (src == 0) { | 2503 if (src == 0) { |
2504 Xorpd(dst, dst); | 2504 Xorpd(dst, dst); |
2505 } else { | 2505 } else { |
2506 unsigned nlz = base::bits::CountLeadingZeros64(src); | 2506 unsigned nlz = base::bits::CountLeadingZeros64(src); |
2507 unsigned ntz = base::bits::CountTrailingZeros64(src); | 2507 unsigned ntz = base::bits::CountTrailingZeros64(src); |
2508 unsigned pop = base::bits::CountPopulation64(src); | 2508 unsigned pop = base::bits::CountPopulation64(src); |
2509 DCHECK_NE(0u, pop); | 2509 DCHECK_NE(0u, pop); |
2510 if (pop == 64) { | 2510 if (pop == 64) { |
2511 pcmpeqd(dst, dst); | 2511 Pcmpeqd(dst, dst); |
2512 } else if (pop + ntz == 64) { | 2512 } else if (pop + ntz == 64) { |
2513 pcmpeqd(dst, dst); | 2513 Pcmpeqd(dst, dst); |
2514 psllq(dst, ntz); | 2514 Psllq(dst, ntz); |
2515 } else if (pop + nlz == 64) { | 2515 } else if (pop + nlz == 64) { |
2516 pcmpeqd(dst, dst); | 2516 Pcmpeqd(dst, dst); |
2517 psrlq(dst, nlz); | 2517 Psrlq(dst, nlz); |
2518 } else { | 2518 } else { |
2519 uint32_t lower = static_cast<uint32_t>(src); | 2519 uint32_t lower = static_cast<uint32_t>(src); |
2520 uint32_t upper = static_cast<uint32_t>(src >> 32); | 2520 uint32_t upper = static_cast<uint32_t>(src >> 32); |
2521 if (upper == 0) { | 2521 if (upper == 0) { |
2522 Move(dst, lower); | 2522 Move(dst, lower); |
2523 } else { | 2523 } else { |
2524 movq(kScratchRegister, src); | 2524 movq(kScratchRegister, src); |
2525 Movq(dst, kScratchRegister); | 2525 Movq(dst, kScratchRegister); |
2526 } | 2526 } |
2527 } | 2527 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2712 void MacroAssembler::Xorpd(XMMRegister dst, XMMRegister src) { | 2712 void MacroAssembler::Xorpd(XMMRegister dst, XMMRegister src) { |
2713 if (CpuFeatures::IsSupported(AVX)) { | 2713 if (CpuFeatures::IsSupported(AVX)) { |
2714 CpuFeatureScope scope(this, AVX); | 2714 CpuFeatureScope scope(this, AVX); |
2715 vxorpd(dst, dst, src); | 2715 vxorpd(dst, dst, src); |
2716 } else { | 2716 } else { |
2717 xorpd(dst, src); | 2717 xorpd(dst, src); |
2718 } | 2718 } |
2719 } | 2719 } |
2720 | 2720 |
2721 | 2721 |
| 2722 void MacroAssembler::Pcmpeqd(XMMRegister dst, XMMRegister src) { |
| 2723 if (CpuFeatures::IsSupported(AVX)) { |
| 2724 CpuFeatureScope scope(this, AVX); |
| 2725 vpcmpeqd(dst, dst, src); |
| 2726 } else { |
| 2727 pcmpeqd(dst, src); |
| 2728 } |
| 2729 } |
| 2730 |
| 2731 |
| 2732 void MacroAssembler::Psllq(XMMRegister dst, byte imm8) { |
| 2733 if (CpuFeatures::IsSupported(AVX)) { |
| 2734 CpuFeatureScope scope(this, AVX); |
| 2735 vpsllq(dst, dst, imm8); |
| 2736 } else { |
| 2737 psllq(dst, imm8); |
| 2738 } |
| 2739 } |
| 2740 |
| 2741 |
| 2742 void MacroAssembler::Psrlq(XMMRegister dst, byte imm8) { |
| 2743 if (CpuFeatures::IsSupported(AVX)) { |
| 2744 CpuFeatureScope scope(this, AVX); |
| 2745 vpsrlq(dst, dst, imm8); |
| 2746 } else { |
| 2747 psrlq(dst, imm8); |
| 2748 } |
| 2749 } |
| 2750 |
| 2751 |
2722 void MacroAssembler::Cmp(Register dst, Handle<Object> source) { | 2752 void MacroAssembler::Cmp(Register dst, Handle<Object> source) { |
2723 AllowDeferredHandleDereference smi_check; | 2753 AllowDeferredHandleDereference smi_check; |
2724 if (source->IsSmi()) { | 2754 if (source->IsSmi()) { |
2725 Cmp(dst, Smi::cast(*source)); | 2755 Cmp(dst, Smi::cast(*source)); |
2726 } else { | 2756 } else { |
2727 MoveHeapObject(kScratchRegister, source); | 2757 MoveHeapObject(kScratchRegister, source); |
2728 cmpp(dst, kScratchRegister); | 2758 cmpp(dst, kScratchRegister); |
2729 } | 2759 } |
2730 } | 2760 } |
2731 | 2761 |
(...skipping 2595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5327 movl(rax, dividend); | 5357 movl(rax, dividend); |
5328 shrl(rax, Immediate(31)); | 5358 shrl(rax, Immediate(31)); |
5329 addl(rdx, rax); | 5359 addl(rdx, rax); |
5330 } | 5360 } |
5331 | 5361 |
5332 | 5362 |
5333 } // namespace internal | 5363 } // namespace internal |
5334 } // namespace v8 | 5364 } // namespace v8 |
5335 | 5365 |
5336 #endif // V8_TARGET_ARCH_X64 | 5366 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |