simdjson 4.0.7
Ridiculously Fast JSON
Loading...
Searching...
No Matches
numberparsing_defs.h
1#ifndef SIMDJSON_LASX_NUMBERPARSING_DEFS_H
2#define SIMDJSON_LASX_NUMBERPARSING_DEFS_H
3
4#ifndef SIMDJSON_CONDITIONAL_INCLUDE
5#include "simdjson/lasx/base.h"
6#include "simdjson/lasx/intrinsics.h"
7#include "simdjson/internal/numberparsing_tables.h"
8#endif // SIMDJSON_CONDITIONAL_INCLUDE
9
10#include <cstring>
11
12namespace simdjson {
13namespace lasx {
14namespace numberparsing {
15
16// we don't have appropriate instructions, so let us use a scalar function
17// credit: https://johnnylee-sde.github.io/Fast-numeric-string-to-int/
19static simdjson_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars) {
20 uint64_t val;
21 std::memcpy(&val, chars, sizeof(uint64_t));
22 val = (val & 0x0F0F0F0F0F0F0F0F) * 2561 >> 8;
23 val = (val & 0x00FF00FF00FF00FF) * 6553601 >> 16;
24 return uint32_t((val & 0x0000FFFF0000FFFF) * 42949672960001 >> 32);
25}
26
27simdjson_inline internal::value128 full_multiplication(uint64_t value1, uint64_t value2) {
28 internal::value128 answer;
29 __uint128_t r = (static_cast<__uint128_t>(value1)) * value2;
30 answer.low = uint64_t(r);
31 answer.high = uint64_t(r >> 64);
32 return answer;
33}
34
35} // namespace numberparsing
36} // namespace lasx
37} // namespace simdjson
38
39#ifndef SIMDJSON_SWAR_NUMBER_PARSING
40#if SIMDJSON_IS_BIG_ENDIAN
41#define SIMDJSON_SWAR_NUMBER_PARSING 0
42#else
43#define SIMDJSON_SWAR_NUMBER_PARSING 1
44#endif
45#endif
46
47#endif // SIMDJSON_LASX_NUMBERPARSING_DEFS_H
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8