simdjson 4.4.0
Ridiculously Fast JSON
Loading...
Searching...
No Matches
numberparsing_defs.h
1#ifndef SIMDJSON_RVV_VLS_NUMBERPARSING_DEFS_H
2#define SIMDJSON_RVV_VLS_NUMBERPARSING_DEFS_H
3
4#ifndef SIMDJSON_CONDITIONAL_INCLUDE
5#include "simdjson/rvv-vls/base.h"
6#include "simdjson/internal/numberparsing_tables.h"
7#endif // SIMDJSON_CONDITIONAL_INCLUDE
8
9#include <cstring>
10
11#ifdef JSON_TEST_NUMBERS // for unit testing
12void found_invalid_number(const uint8_t *buf);
13void found_integer(int64_t result, const uint8_t *buf);
14void found_unsigned_integer(uint64_t result, const uint8_t *buf);
15void found_float(double result, const uint8_t *buf);
16#endif
17
18namespace simdjson {
19namespace rvv_vls {
20namespace numberparsing {
21
22// credit: https://johnnylee-sde.github.io/Fast-numeric-string-to-int/
24static simdjson_inline uint32_t parse_eight_digits_unrolled(const char *chars) {
25 uint64_t val;
26#if __riscv_misaligned_fast
27 memcpy(&val, chars, sizeof(uint64_t));
28#else
29 val = __riscv_vmv_x(__riscv_vreinterpret_u64m1(__riscv_vlmul_ext_u8m1(__riscv_vle8_v_u8mf2((uint8_t*)chars, 8))));
30#endif
31 val = (val & 0x0F0F0F0F0F0F0F0F) * 2561 >> 8;
32 val = (val & 0x00FF00FF00FF00FF) * 6553601 >> 16;
33 return uint32_t((val & 0x0000FFFF0000FFFF) * 42949672960001 >> 32);
34}
35
37static simdjson_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars) {
38 return parse_eight_digits_unrolled(reinterpret_cast<const char *>(chars));
39}
40
42simdjson_inline internal::value128 full_multiplication(uint64_t value1, uint64_t value2) {
43 internal::value128 answer;
44 __uint128_t r = (static_cast<__uint128_t>(value1)) * value2;
45 answer.low = uint64_t(r);
46 answer.high = uint64_t(r >> 64);
47 return answer;
48}
49
50} // namespace numberparsing
51} // namespace rvv_vls
52} // namespace simdjson
53
54#define SIMDJSON_SWAR_NUMBER_PARSING 1
55
56#endif // SIMDJSON_RVV_VLS_NUMBERPARSING_DEFS_H
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8