| 1 | #ifndef SIMDJSON_HASWELL_STRINGPARSING_H |
|---|---|
| 2 | #define SIMDJSON_HASWELL_STRINGPARSING_H |
| 3 | |
| 4 | #include "simdjson/portability.h" |
| 5 | |
| 6 | #ifdef IS_X86_64 |
| 7 | |
| 8 | #include "haswell/simd.h" |
| 9 | #include "simdjson/common_defs.h" |
| 10 | #include "simdjson/parsedjson.h" |
| 11 | #include "jsoncharutils.h" |
| 12 | #include "haswell/intrinsics.h" |
| 13 | #include "haswell/bitmanipulation.h" |
| 14 | |
| 15 | TARGET_HASWELL |
| 16 | namespace simdjson::haswell { |
| 17 | |
| 18 | using namespace simd; |
| 19 | |
| 20 | // Holds backslashes and quotes locations. |
| 21 | struct parse_string_helper { |
| 22 | uint32_t bs_bits; |
| 23 | uint32_t quote_bits; |
| 24 | static const uint32_t BYTES_PROCESSED = 32; |
| 25 | }; |
| 26 | |
| 27 | really_inline parse_string_helper find_bs_bits_and_quote_bits(const uint8_t *src, uint8_t *dst) { |
| 28 | // this can read up to 15 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> v(src); |
| 32 | // store to dest unconditionally - we can overwrite the bits we don't like later |
| 33 | v.store(dst); |
| 34 | return { |
| 35 | (uint32_t)(v == '\\').to_bitmask(), // bs_bits |
| 36 | (uint32_t)(v == '"').to_bitmask(), // quote_bits |
| 37 | }; |
| 38 | } |
| 39 | |
| 40 | #include "generic/stringparsing.h" |
| 41 | |
| 42 | } // namespace simdjson::haswell |
| 43 | UNTARGET_REGION |
| 44 | |
| 45 | #endif // IS_X86_64 |
| 46 | |
| 47 | #endif |
| 48 |