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

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

Issue 1421163005: Implemented the ctz Turbo Fan operator for x64. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/x64/macro-assembler-x64.h ('k') | test/cctest/compiler/test-run-machops.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 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 3171 matching lines...) Expand 10 before | Expand all | Expand 10 after
3182 } 3182 }
3183 Label not_zero_src; 3183 Label not_zero_src;
3184 bsrq(dst, src); 3184 bsrq(dst, src);
3185 j(not_zero, &not_zero_src, Label::kNear); 3185 j(not_zero, &not_zero_src, Label::kNear);
3186 Set(dst, 127); // 127^63 == 64 3186 Set(dst, 127); // 127^63 == 64
3187 bind(&not_zero_src); 3187 bind(&not_zero_src);
3188 xorl(dst, Immediate(63)); // for x in [0..63], 63^x == 63 - x 3188 xorl(dst, Immediate(63)); // for x in [0..63], 63^x == 63 - x
3189 } 3189 }
3190 3190
3191 3191
3192 void MacroAssembler::Tzcntq(Register dst, Register src) {
3193 if (CpuFeatures::IsSupported(BMI1)) {
3194 CpuFeatureScope scope(this, BMI1);
3195 tzcntq(dst, src);
3196 return;
3197 }
3198 Label not_zero_src;
3199 bsfq(dst, src);
3200 j(not_zero, &not_zero_src, Label::kNear);
3201 Set(dst, 64); // The result of tzcnt is 32 if src = 0.
titzer 2015/11/09 18:50:34 s/32/64/g
3202 bind(&not_zero_src);
3203 }
3204
3205
3206 void MacroAssembler::Tzcntq(Register dst, const Operand& src) {
3207 if (CpuFeatures::IsSupported(BMI1)) {
3208 CpuFeatureScope scope(this, BMI1);
3209 tzcntq(dst, src);
3210 return;
3211 }
3212 Label not_zero_src;
3213 bsfq(dst, src);
3214 j(not_zero, &not_zero_src, Label::kNear);
3215 Set(dst, 64); // The result of tzcnt is 32 if src = 0.
titzer 2015/11/09 18:50:34 s/32/64/g
3216 bind(&not_zero_src);
3217 }
3218
3219
3192 void MacroAssembler::Tzcntl(Register dst, Register src) { 3220 void MacroAssembler::Tzcntl(Register dst, Register src) {
3193 if (CpuFeatures::IsSupported(BMI1)) { 3221 if (CpuFeatures::IsSupported(BMI1)) {
3194 CpuFeatureScope scope(this, BMI1); 3222 CpuFeatureScope scope(this, BMI1);
3195 tzcntl(dst, src); 3223 tzcntl(dst, src);
3196 return; 3224 return;
3197 } 3225 }
3198 Label not_zero_src; 3226 Label not_zero_src;
3199 bsfl(dst, src); 3227 bsfl(dst, src);
3200 j(not_zero, &not_zero_src, Label::kNear); 3228 j(not_zero, &not_zero_src, Label::kNear);
3201 Set(dst, 32); // The result of tzcnt is 32 if src = 0. 3229 Set(dst, 32); // The result of tzcnt is 32 if src = 0.
(...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after
5402 movl(rax, dividend); 5430 movl(rax, dividend);
5403 shrl(rax, Immediate(31)); 5431 shrl(rax, Immediate(31));
5404 addl(rdx, rax); 5432 addl(rdx, rax);
5405 } 5433 }
5406 5434
5407 5435
5408 } // namespace internal 5436 } // namespace internal
5409 } // namespace v8 5437 } // namespace v8
5410 5438
5411 #endif // V8_TARGET_ARCH_X64 5439 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | test/cctest/compiler/test-run-machops.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698