Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: src/ia32/assembler-ia32.cc

Issue 1069683002: [ia32] Introduce BMI instructions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Align with gdb disassembler Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ia32/assembler-ia32.h ('k') | src/ia32/disasm-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions 5 // modification, are permitted provided that the following conditions
6 // are met: 6 // are met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if (cpu.has_sse41() && FLAG_enable_sse4_1) supported_ |= 1u << SSE4_1; 115 if (cpu.has_sse41() && FLAG_enable_sse4_1) supported_ |= 1u << SSE4_1;
116 if (cpu.has_sse3() && FLAG_enable_sse3) supported_ |= 1u << SSE3; 116 if (cpu.has_sse3() && FLAG_enable_sse3) supported_ |= 1u << SSE3;
117 if (cpu.has_avx() && FLAG_enable_avx && cpu.has_osxsave() && 117 if (cpu.has_avx() && FLAG_enable_avx && cpu.has_osxsave() &&
118 OSHasAVXSupport()) { 118 OSHasAVXSupport()) {
119 supported_ |= 1u << AVX; 119 supported_ |= 1u << AVX;
120 } 120 }
121 if (cpu.has_fma3() && FLAG_enable_fma3 && cpu.has_osxsave() && 121 if (cpu.has_fma3() && FLAG_enable_fma3 && cpu.has_osxsave() &&
122 OSHasAVXSupport()) { 122 OSHasAVXSupport()) {
123 supported_ |= 1u << FMA3; 123 supported_ |= 1u << FMA3;
124 } 124 }
125 if (cpu.has_bmi1() && FLAG_enable_bmi1) supported_ |= 1u << BMI1;
126 if (cpu.has_bmi2() && FLAG_enable_bmi2) supported_ |= 1u << BMI2;
127 if (cpu.has_lzcnt() && FLAG_enable_lzcnt) supported_ |= 1u << LZCNT;
128 if (cpu.has_popcnt() && FLAG_enable_popcnt) supported_ |= 1u << POPCNT;
125 if (strcmp(FLAG_mcpu, "auto") == 0) { 129 if (strcmp(FLAG_mcpu, "auto") == 0) {
126 if (cpu.is_atom()) supported_ |= 1u << ATOM; 130 if (cpu.is_atom()) supported_ |= 1u << ATOM;
127 } else if (strcmp(FLAG_mcpu, "atom") == 0) { 131 } else if (strcmp(FLAG_mcpu, "atom") == 0) {
128 supported_ |= 1u << ATOM; 132 supported_ |= 1u << ATOM;
129 } 133 }
130 } 134 }
131 135
132 136
133 void CpuFeatures::PrintTarget() { } 137 void CpuFeatures::PrintTarget() { }
134 void CpuFeatures::PrintFeatures() { 138 void CpuFeatures::PrintFeatures() {
135 printf("SSE3=%d SSE4_1=%d AVX=%d FMA3=%d ATOM=%d\n", 139 printf(
136 CpuFeatures::IsSupported(SSE3), CpuFeatures::IsSupported(SSE4_1), 140 "SSE3=%d SSE4_1=%d AVX=%d FMA3=%d BMI1=%d BMI2=%d LZCNT=%d POPCNT=%d "
137 CpuFeatures::IsSupported(AVX), CpuFeatures::IsSupported(FMA3), 141 "ATOM=%d\n",
138 CpuFeatures::IsSupported(ATOM)); 142 CpuFeatures::IsSupported(SSE3), CpuFeatures::IsSupported(SSE4_1),
143 CpuFeatures::IsSupported(AVX), CpuFeatures::IsSupported(FMA3),
144 CpuFeatures::IsSupported(BMI1), CpuFeatures::IsSupported(BMI2),
145 CpuFeatures::IsSupported(LZCNT), CpuFeatures::IsSupported(POPCNT),
146 CpuFeatures::IsSupported(ATOM));
139 } 147 }
140 148
141 149
142 // ----------------------------------------------------------------------------- 150 // -----------------------------------------------------------------------------
143 // Implementation of Displacement 151 // Implementation of Displacement
144 152
145 void Displacement::init(Label* L, Type type) { 153 void Displacement::init(Label* L, Type type) {
146 DCHECK(!L->is_bound()); 154 DCHECK(!L->is_bound());
147 int next = 0; 155 int next = 0;
148 if (L->is_linked()) { 156 if (L->is_linked()) {
(...skipping 2501 matching lines...) Expand 10 before | Expand all | Expand 10 after
2650 void Assembler::vss(byte op, XMMRegister dst, XMMRegister src1, 2658 void Assembler::vss(byte op, XMMRegister dst, XMMRegister src1,
2651 const Operand& src2) { 2659 const Operand& src2) {
2652 DCHECK(IsEnabled(AVX)); 2660 DCHECK(IsEnabled(AVX));
2653 EnsureSpace ensure_space(this); 2661 EnsureSpace ensure_space(this);
2654 emit_vex_prefix(src1, kLIG, kF3, k0F, kWIG); 2662 emit_vex_prefix(src1, kLIG, kF3, k0F, kWIG);
2655 EMIT(op); 2663 EMIT(op);
2656 emit_sse_operand(dst, src2); 2664 emit_sse_operand(dst, src2);
2657 } 2665 }
2658 2666
2659 2667
2668 void Assembler::bmi1(byte op, Register reg, Register vreg, const Operand& rm) {
2669 DCHECK(IsEnabled(BMI1));
2670 EnsureSpace ensure_space(this);
2671 emit_vex_prefix(vreg, kLZ, kNone, k0F38, kW0);
2672 EMIT(op);
2673 emit_operand(reg, rm);
2674 }
2675
2676
2677 void Assembler::tzcnt(Register dst, const Operand& src) {
2678 DCHECK(IsEnabled(BMI1));
2679 EnsureSpace ensure_space(this);
2680 EMIT(0xF3);
2681 EMIT(0x0F);
2682 EMIT(0xBC);
2683 emit_operand(dst, src);
2684 }
2685
2686
2687 void Assembler::lzcnt(Register dst, const Operand& src) {
2688 DCHECK(IsEnabled(LZCNT));
2689 EnsureSpace ensure_space(this);
2690 EMIT(0xF3);
2691 EMIT(0x0F);
2692 EMIT(0xBD);
2693 emit_operand(dst, src);
2694 }
2695
2696
2697 void Assembler::popcnt(Register dst, const Operand& src) {
2698 DCHECK(IsEnabled(POPCNT));
2699 EnsureSpace ensure_space(this);
2700 EMIT(0xF3);
2701 EMIT(0x0F);
2702 EMIT(0xB8);
2703 emit_operand(dst, src);
2704 }
2705
2706
2707 void Assembler::bmi2(SIMDPrefix pp, byte op, Register reg, Register vreg,
2708 const Operand& rm) {
2709 DCHECK(IsEnabled(BMI2));
2710 EnsureSpace ensure_space(this);
2711 emit_vex_prefix(vreg, kLZ, pp, k0F38, kW0);
2712 EMIT(op);
2713 emit_operand(reg, rm);
2714 }
2715
2716
2717 void Assembler::rorx(Register dst, const Operand& src, byte imm8) {
2718 DCHECK(IsEnabled(BMI2));
2719 DCHECK(is_uint8(imm8));
2720 Register vreg = {0}; // VEX.vvvv unused
2721 EnsureSpace ensure_space(this);
2722 emit_vex_prefix(vreg, kLZ, kF2, k0F3A, kW0);
2723 EMIT(0xF0);
2724 emit_operand(dst, src);
2725 EMIT(imm8);
2726 }
2727
2728
2660 void Assembler::emit_sse_operand(XMMRegister reg, const Operand& adr) { 2729 void Assembler::emit_sse_operand(XMMRegister reg, const Operand& adr) {
2661 Register ireg = { reg.code() }; 2730 Register ireg = { reg.code() };
2662 emit_operand(ireg, adr); 2731 emit_operand(ireg, adr);
2663 } 2732 }
2664 2733
2665 2734
2666 void Assembler::emit_sse_operand(XMMRegister dst, XMMRegister src) { 2735 void Assembler::emit_sse_operand(XMMRegister dst, XMMRegister src) {
2667 EMIT(0xC0 | dst.code() << 3 | src.code()); 2736 EMIT(0xC0 | dst.code() << 3 | src.code());
2668 } 2737 }
2669 2738
2670 2739
2671 void Assembler::emit_sse_operand(Register dst, XMMRegister src) { 2740 void Assembler::emit_sse_operand(Register dst, XMMRegister src) {
2672 EMIT(0xC0 | dst.code() << 3 | src.code()); 2741 EMIT(0xC0 | dst.code() << 3 | src.code());
2673 } 2742 }
2674 2743
2675 2744
2676 void Assembler::emit_sse_operand(XMMRegister dst, Register src) { 2745 void Assembler::emit_sse_operand(XMMRegister dst, Register src) {
2677 EMIT(0xC0 | (dst.code() << 3) | src.code()); 2746 EMIT(0xC0 | (dst.code() << 3) | src.code());
2678 } 2747 }
2679 2748
2680 2749
2681 void Assembler::emit_vex_prefix(XMMRegister vreg, VectorLength l, SIMDPrefix pp, 2750 void Assembler::emit_vex_prefix(XMMRegister vreg, VectorLength l, SIMDPrefix pp,
2682 LeadingOpcode mm, VexW w) { 2751 LeadingOpcode mm, VexW w) {
2683 if (mm != k0F || w != kW0) { 2752 if (mm != k0F || w != kW0) {
2684 EMIT(0xc4); 2753 EMIT(0xc4);
2685 EMIT(0xc0 | mm); 2754 // Change RXB from "110" to "111" to align with gdb disassembler.
2755 EMIT(0xe0 | mm);
2686 EMIT(w | ((~vreg.code() & 0xf) << 3) | l | pp); 2756 EMIT(w | ((~vreg.code() & 0xf) << 3) | l | pp);
2687 } else { 2757 } else {
2688 EMIT(0xc5); 2758 EMIT(0xc5);
2689 EMIT(((~vreg.code()) << 3) | l | pp); 2759 EMIT(((~vreg.code()) << 3) | l | pp);
2690 } 2760 }
2691 } 2761 }
2692 2762
2693 2763
2764 void Assembler::emit_vex_prefix(Register vreg, VectorLength l, SIMDPrefix pp,
2765 LeadingOpcode mm, VexW w) {
2766 XMMRegister ivreg = {vreg.code()};
2767 emit_vex_prefix(ivreg, l, pp, mm, w);
2768 }
2769
2770
2694 void Assembler::GrowBuffer() { 2771 void Assembler::GrowBuffer() {
2695 DCHECK(buffer_overflow()); 2772 DCHECK(buffer_overflow());
2696 if (!own_buffer_) FATAL("external code buffer is too small"); 2773 if (!own_buffer_) FATAL("external code buffer is too small");
2697 2774
2698 // Compute new buffer size. 2775 // Compute new buffer size.
2699 CodeDesc desc; // the new buffer 2776 CodeDesc desc; // the new buffer
2700 desc.buffer_size = 2 * buffer_size_; 2777 desc.buffer_size = 2 * buffer_size_;
2701 2778
2702 // Some internal data structures overflow for very large buffers, 2779 // Some internal data structures overflow for very large buffers,
2703 // they must ensure that kMaximalBufferSize is not too large. 2780 // they must ensure that kMaximalBufferSize is not too large.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 fprintf(coverage_log, "%s\n", file_line); 2955 fprintf(coverage_log, "%s\n", file_line);
2879 fflush(coverage_log); 2956 fflush(coverage_log);
2880 } 2957 }
2881 } 2958 }
2882 2959
2883 #endif 2960 #endif
2884 2961
2885 } } // namespace v8::internal 2962 } } // namespace v8::internal
2886 2963
2887 #endif // V8_TARGET_ARCH_IA32 2964 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/assembler-ia32.h ('k') | src/ia32/disasm-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698