1 #ifndef SIMDJSON_HASWELL_BITMANIPULATION_H
2 #define SIMDJSON_HASWELL_BITMANIPULATION_H
4 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
5 #include "simdjson/haswell/base.h"
6 #include "simdjson/haswell/intrinsics.h"
7 #include "simdjson/haswell/bitmask.h"
17 SIMDJSON_NO_SANITIZE_UNDEFINED
21 SIMDJSON_NO_SANITIZE_MEMORY
22 simdjson_inline
int trailing_zeroes(uint64_t input_num) {
23 #if SIMDJSON_REGULAR_VISUAL_STUDIO
24 return (
int)_tzcnt_u64(input_num);
31 return __builtin_ctzll(input_num);
36 simdjson_inline uint64_t clear_lowest_bit(uint64_t input_num) {
37 return _blsr_u64(input_num);
41 simdjson_inline
int leading_zeroes(uint64_t input_num) {
42 return int(_lzcnt_u64(input_num));
45 #if SIMDJSON_REGULAR_VISUAL_STUDIO
46 simdjson_inline
unsigned __int64 count_ones(uint64_t input_num) {
48 return __popcnt64(input_num);
51 simdjson_inline
long long int count_ones(uint64_t input_num) {
52 return _popcnt64(input_num);
56 simdjson_inline
bool add_overflow(uint64_t value1, uint64_t value2,
58 #if SIMDJSON_REGULAR_VISUAL_STUDIO
59 return _addcarry_u64(0, value1, value2,
60 reinterpret_cast<unsigned __int64 *
>(result));
62 return __builtin_uaddll_overflow(value1, value2,
63 reinterpret_cast<unsigned long long *
>(result));
The top level simdjson namespace, containing everything the library provides.