1#ifndef SIMDJSON_WESTMERE_STRINGPARSING_H
2#define SIMDJSON_WESTMERE_STRINGPARSING_H
3
4#include "simdjson/portability.h"
5
6#ifdef IS_X86_64
7
8#include "westmere/simd.h"
9#include "simdjson/common_defs.h"
10#include "simdjson/parsedjson.h"
11#include "jsoncharutils.h"
12#include "westmere/intrinsics.h"
13#include "westmere/bitmanipulation.h"
14
15TARGET_WESTMERE
16namespace simdjson::westmere {
17
18using namespace simd;
19
20// Holds backslashes and quotes locations.
21struct parse_string_helper {
22 uint32_t bs_bits;
23 uint32_t quote_bits;
24 static const uint32_t BYTES_PROCESSED = 32;
25};
26
27really_inline parse_string_helper find_bs_bits_and_quote_bits(const uint8_t *src, uint8_t *dst) {
28 // this can read up to 31 bytes beyond the buffer size, but we require
29 // SIMDJSON_PADDING of padding
30 static_assert(SIMDJSON_PADDING >= (parse_string_helper::BYTES_PROCESSED - 1));
31 simd8<uint8_t> v0(src);
32 simd8<uint8_t> v1(src + 16);
33 v0.store(dst);
34 v1.store(dst + 16);
35 uint64_t bs_and_quote = simd8x64<bool>(v0 == '\\', v1 == '\\', v0 == '"', v1 == '"').to_bitmask();
36 return {
37 static_cast<uint32_t>(bs_and_quote), // bs_bits
38 static_cast<uint32_t>(bs_and_quote >> 32) // quote_bits
39 };
40}
41
42#include "generic/stringparsing.h"
43
44} // namespace simdjson::westmere
45UNTARGET_REGION
46
47#endif // IS_X86_64
48
49#endif
50