simdjson 4.4.0
Ridiculously Fast JSON
Loading...
Searching...
No Matches
bitmanipulation.h
1#ifndef SIMDJSON_RVV_VLS_BITMANIPULATION_H
2#define SIMDJSON_RVV_VLS_BITMANIPULATION_H
3
4#ifndef SIMDJSON_CONDITIONAL_INCLUDE
5#include "simdjson/rvv-vls/base.h"
6#endif // SIMDJSON_CONDITIONAL_INCLUDE
7
8namespace simdjson {
9namespace rvv_vls {
10namespace {
11
12// We sometimes call trailing_zero on inputs that are zero,
13// but the algorithms do not end up using the returned value.
14// Sadly, sanitizers are not smart enough to figure it out.
15SIMDJSON_NO_SANITIZE_UNDEFINED
16// This function can be used safely even if not all bytes have been
17// initialized.
18// See issue https://github.com/simdjson/simdjson/issues/1965
19SIMDJSON_NO_SANITIZE_MEMORY
20simdjson_inline int trailing_zeroes(uint64_t input_num) {
21 return __builtin_ctzll(input_num);
22}
23
24/* result might be undefined when input_num is zero */
25simdjson_inline uint64_t clear_lowest_bit(uint64_t input_num) {
26 return input_num & (input_num-1);
27}
28
29/* result might be undefined when input_num is zero */
30simdjson_inline int leading_zeroes(uint64_t input_num) {
31 return __builtin_clzll(input_num);
32}
33
34simdjson_inline long long int count_ones(uint64_t input_num) {
35 return __builtin_popcountll(input_num);
36}
37
38simdjson_inline bool add_overflow(uint64_t value1, uint64_t value2,
39 uint64_t *result) {
40 return __builtin_uaddll_overflow(value1, value2,
41 reinterpret_cast<unsigned long long *>(result));
42}
43
44} // unnamed namespace
45} // namespace rvv_vls
46} // namespace simdjson
47
48#endif // SIMDJSON_RVV_VLS_BITMANIPULATION_H
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8