1 #ifndef SIMDJSON_PPC64_BITMANIPULATION_H
2 #define SIMDJSON_PPC64_BITMANIPULATION_H
4 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
5 #include "simdjson/ppc64/base.h"
15 SIMDJSON_NO_SANITIZE_UNDEFINED
19 SIMDJSON_NO_SANITIZE_MEMORY
20 simdjson_inline
int trailing_zeroes(uint64_t input_num) {
21 #if SIMDJSON_REGULAR_VISUAL_STUDIO
25 _BitScanForward64(&ret, input_num);
28 return __builtin_ctzll(input_num);
33 simdjson_inline uint64_t clear_lowest_bit(uint64_t input_num) {
34 return input_num & (input_num - 1);
38 simdjson_inline
int leading_zeroes(uint64_t input_num) {
39 #if SIMDJSON_REGULAR_VISUAL_STUDIO
40 unsigned long leading_zero = 0;
43 if (_BitScanReverse64(&leading_zero, input_num))
44 return (
int)(63 - leading_zero);
48 return __builtin_clzll(input_num);
52 #if SIMDJSON_REGULAR_VISUAL_STUDIO
53 simdjson_inline
int count_ones(uint64_t input_num) {
55 return __popcnt64(input_num);
58 simdjson_inline
int count_ones(uint64_t input_num) {
59 return __builtin_popcountll(input_num);
63 simdjson_inline
bool add_overflow(uint64_t value1, uint64_t value2,
65 #if SIMDJSON_REGULAR_VISUAL_STUDIO
66 *result = value1 + value2;
67 return *result < value1;
69 return __builtin_uaddll_overflow(value1, value2,
70 reinterpret_cast<unsigned long long *
>(result));
The top level simdjson namespace, containing everything the library provides.