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

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

Issue 1405453003: CTZ instruction implemented as optional operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed a bug when bmi1=false Created 5 years, 2 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/macro-assembler-ia32.h ('k') | src/x64/assembler-x64.h » ('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 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_IA32 5 #if V8_TARGET_ARCH_IA32
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 2412 matching lines...) Expand 10 before | Expand all | Expand 10 after
2423 } 2423 }
2424 Label not_zero_src; 2424 Label not_zero_src;
2425 bsr(dst, src); 2425 bsr(dst, src);
2426 j(not_zero, &not_zero_src, Label::kNear); 2426 j(not_zero, &not_zero_src, Label::kNear);
2427 Move(dst, Immediate(63)); // 63^31 == 32 2427 Move(dst, Immediate(63)); // 63^31 == 32
2428 bind(&not_zero_src); 2428 bind(&not_zero_src);
2429 xor_(dst, Immediate(31)); // for x in [0..31], 31^x == 31-x. 2429 xor_(dst, Immediate(31)); // for x in [0..31], 31^x == 31-x.
2430 } 2430 }
2431 2431
2432 2432
2433 void MacroAssembler::Tzcnt(Register dst, const Operand& src) {
2434 if (CpuFeatures::IsSupported(BMI1)) {
2435 CpuFeatureScope scope(this, BMI1);
2436 tzcnt(dst, src);
2437 return;
2438 }
2439 Label not_zero_src;
2440 bsf(dst, src);
2441 j(not_zero, &not_zero_src, Label::kNear);
2442 Move(dst, Immediate(32)); // The result of tzcnt is 32 if src = 0.
2443 bind(&not_zero_src);
2444 }
2445
2446
2433 void MacroAssembler::SetCounter(StatsCounter* counter, int value) { 2447 void MacroAssembler::SetCounter(StatsCounter* counter, int value) {
2434 if (FLAG_native_code_counters && counter->Enabled()) { 2448 if (FLAG_native_code_counters && counter->Enabled()) {
2435 mov(Operand::StaticVariable(ExternalReference(counter)), Immediate(value)); 2449 mov(Operand::StaticVariable(ExternalReference(counter)), Immediate(value));
2436 } 2450 }
2437 } 2451 }
2438 2452
2439 2453
2440 void MacroAssembler::IncrementCounter(StatsCounter* counter, int value) { 2454 void MacroAssembler::IncrementCounter(StatsCounter* counter, int value) {
2441 DCHECK(value > 0); 2455 DCHECK(value > 0);
2442 if (FLAG_native_code_counters && counter->Enabled()) { 2456 if (FLAG_native_code_counters && counter->Enabled()) {
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
3125 mov(eax, dividend); 3139 mov(eax, dividend);
3126 shr(eax, 31); 3140 shr(eax, 31);
3127 add(edx, eax); 3141 add(edx, eax);
3128 } 3142 }
3129 3143
3130 3144
3131 } // namespace internal 3145 } // namespace internal
3132 } // namespace v8 3146 } // namespace v8
3133 3147
3134 #endif // V8_TARGET_ARCH_IA32 3148 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698