a64_emiter: CountLeadingZeros intrinsic shortcuts

This commit is contained in:
SachinVin 2020-04-24 21:23:38 +05:30
parent 73ee4b9480
commit b25b721a6a

View File

@ -22,7 +22,16 @@ const int kWRegSizeInBits = 32;
const int kXRegSizeInBits = 64; const int kXRegSizeInBits = 64;
// The below few functions are taken from V8. // The below few functions are taken from V8.
int CountLeadingZeros(uint64_t value, int width) { int CountLeadingZeros(u64 value, int width) {
#ifdef _MSC_VER
if (width == 64) {
return _CountLeadingZeros64(value);
}
#else
if (width == 64) {
return __builtin_clzll(value);
}
#endif
// TODO(jbramley): Optimize this for ARM64 hosts. // TODO(jbramley): Optimize this for ARM64 hosts.
int count = 0; int count = 0;
uint64_t bit_test = 1ULL << (width - 1); uint64_t bit_test = 1ULL << (width - 1);