simdjson  3.11.0
Ridiculously Fast JSON
numberparsing_defs.h
1 #ifndef SIMDJSON_LSX_NUMBERPARSING_DEFS_H
2 #define SIMDJSON_LSX_NUMBERPARSING_DEFS_H
3 
4 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
5 #include "simdjson/lsx/base.h"
6 #include "simdjson/lsx/intrinsics.h"
7 #include "simdjson/internal/numberparsing_tables.h"
8 #endif // SIMDJSON_CONDITIONAL_INCLUDE
9 
10 #include <cstring>
11 
12 namespace simdjson {
13 namespace lsx {
14 namespace 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/
19 static 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 
27 simdjson_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 lsx
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_LSX_NUMBERPARSING_DEFS_H
The top level simdjson namespace, containing everything the library provides.
Definition: base.h:8