mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
4c98e51c53
* Add LoongArch SX support * Add LoongArch ASX support
32 lines
682 B
C++
32 lines
682 B
C++
#ifndef SIMDJSON_LASX_BITMASK_H
|
|
#define SIMDJSON_LASX_BITMASK_H
|
|
|
|
#ifndef SIMDJSON_CONDITIONAL_INCLUDE
|
|
#include "simdjson/lasx/base.h"
|
|
#endif // SIMDJSON_CONDITIONAL_INCLUDE
|
|
|
|
namespace simdjson {
|
|
namespace lasx {
|
|
namespace {
|
|
|
|
//
|
|
// Perform a "cumulative bitwise xor," flipping bits each time a 1 is encountered.
|
|
//
|
|
// For example, prefix_xor(00100100) == 00011100
|
|
//
|
|
simdjson_inline uint64_t prefix_xor(uint64_t bitmask) {
|
|
bitmask ^= bitmask << 1;
|
|
bitmask ^= bitmask << 2;
|
|
bitmask ^= bitmask << 4;
|
|
bitmask ^= bitmask << 8;
|
|
bitmask ^= bitmask << 16;
|
|
bitmask ^= bitmask << 32;
|
|
return bitmask;
|
|
}
|
|
|
|
} // unnamed namespace
|
|
} // namespace lasx
|
|
} // namespace simdjson
|
|
|
|
#endif
|