1 #ifndef SIMDJSON_LSX_BITMANIPULATION_H
2 #define SIMDJSON_LSX_BITMANIPULATION_H
4 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
5 #include "simdjson/lsx/base.h"
6 #include "simdjson/lsx/intrinsics.h"
7 #include "simdjson/lsx/bitmask.h"
17 SIMDJSON_NO_SANITIZE_UNDEFINED
21 SIMDJSON_NO_SANITIZE_MEMORY
22 simdjson_inline
int trailing_zeroes(uint64_t input_num) {
23 return __builtin_ctzll(input_num);
27 simdjson_inline uint64_t clear_lowest_bit(uint64_t input_num) {
28 return input_num & (input_num-1);
32 simdjson_inline
int leading_zeroes(uint64_t input_num) {
33 return __builtin_clzll(input_num);
37 simdjson_inline
int count_ones(uint64_t input_num) {
38 return __lsx_vpickve2gr_w(__lsx_vpcnt_d(__m128i(v2u64{input_num, 0})), 0);
41 simdjson_inline
bool add_overflow(uint64_t value1, uint64_t value2, uint64_t *result) {
42 return __builtin_uaddll_overflow(value1, value2,
43 reinterpret_cast<unsigned long long *
>(result));
The top level simdjson namespace, containing everything the library provides.