simdjson  3.11.0
Ridiculously Fast JSON
bitmask.h
1 #ifndef SIMDJSON_HASWELL_BITMASK_H
2 #define SIMDJSON_HASWELL_BITMASK_H
3 
4 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
5 #include "simdjson/haswell/base.h"
6 #include "simdjson/haswell/intrinsics.h"
7 #endif // SIMDJSON_CONDITIONAL_INCLUDE
8 
9 namespace simdjson {
10 namespace haswell {
11 namespace {
12 
13 //
14 // Perform a "cumulative bitwise xor," flipping bits each time a 1 is encountered.
15 //
16 // For example, prefix_xor(00100100) == 00011100
17 //
18 simdjson_inline uint64_t prefix_xor(const uint64_t bitmask) {
19  // There should be no such thing with a processor supporting avx2
20  // but not clmul.
21  __m128i all_ones = _mm_set1_epi8('\xFF');
22  __m128i result = _mm_clmulepi64_si128(_mm_set_epi64x(0ULL, bitmask), all_ones, 0);
23  return _mm_cvtsi128_si64(result);
24 }
25 
26 } // unnamed namespace
27 } // namespace haswell
28 } // namespace simdjson
29 
30 #endif // SIMDJSON_HASWELL_BITMASK_H
The top level simdjson namespace, containing everything the library provides.
Definition: base.h:8