simdjson 4.2.1
Ridiculously Fast JSON
Loading...
Searching...
No Matches
bitmask.h
1#ifndef SIMDJSON_WESTMERE_BITMASK_H
2#define SIMDJSON_WESTMERE_BITMASK_H
3
4#ifndef SIMDJSON_CONDITIONAL_INCLUDE
5#include "simdjson/westmere/base.h"
6#include "simdjson/westmere/intrinsics.h"
7#endif // SIMDJSON_CONDITIONAL_INCLUDE
8
9namespace simdjson {
10namespace westmere {
11namespace {
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//
18simdjson_inline uint64_t prefix_xor(const uint64_t bitmask) {
19 // There should be no such thing with a processing 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 westmere
28} // namespace simdjson
29
30#endif // SIMDJSON_WESTMERE_BITMASK_H
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8