1#ifndef SIMDJSON_LSX_STRINGPARSING_DEFS_H
2#define SIMDJSON_LSX_STRINGPARSING_DEFS_H
4#ifndef SIMDJSON_CONDITIONAL_INCLUDE
5#include "simdjson/lsx/base.h"
6#include "simdjson/lsx/simd.h"
7#include "simdjson/lsx/bitmanipulation.h"
17struct backslash_and_quote {
19 static constexpr uint32_t BYTES_PROCESSED = 32;
20 simdjson_inline backslash_and_quote copy_and_find(
const uint8_t *src, uint8_t *dst);
22 simdjson_inline
bool has_quote_first() {
return ((bs_bits - 1) & quote_bits) != 0; }
23 simdjson_inline
bool has_backslash() {
return bs_bits != 0; }
24 simdjson_inline
int quote_index() {
return trailing_zeroes(quote_bits); }
25 simdjson_inline
int backslash_index() {
return trailing_zeroes(bs_bits); }
31simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(
const uint8_t *src, uint8_t *dst) {
34 static_assert(
SIMDJSON_PADDING >= (BYTES_PROCESSED - 1),
"backslash and quote finder must process fewer than SIMDJSON_PADDING bytes");
35 simd8<uint8_t> v0(src);
36 simd8<uint8_t> v1(src +
sizeof(v0));
38 v1.store(dst +
sizeof(v0));
42 uint64_t bs_and_quote = simd8x64<bool>(v0 ==
'\\', v1 ==
'\\', v0 ==
'"', v1 ==
'"').to_bitmask();
44 uint32_t(bs_and_quote),
45 uint32_t(bs_and_quote >> 32)
51 static constexpr uint32_t BYTES_PROCESSED = 16;
52 simdjson_inline
static escaping copy_and_find(
const uint8_t *src, uint8_t *dst);
54 simdjson_inline
bool has_escape() {
return escape_bits != 0; }
55 simdjson_inline
int escape_index() {
return trailing_zeroes(escape_bits); }
62simdjson_inline escaping escaping::copy_and_find(
const uint8_t *src, uint8_t *dst) {
63 static_assert(
SIMDJSON_PADDING >= (BYTES_PROCESSED - 1),
"escaping finder must process fewer than SIMDJSON_PADDING bytes");
64 simd8<uint8_t> v(src);
66 simd8<bool> is_quote = (v ==
'"');
67 simd8<bool> is_backslash = (v ==
'\\');
68 simd8<bool> is_control = (v < 32);
70 static_cast<uint64_t
>((is_backslash | is_quote | is_control).to_bitmask())
The top level simdjson namespace, containing everything the library provides.
constexpr size_t SIMDJSON_PADDING
The amount of padding needed in a buffer to parse JSON.