1 #ifndef SIMDJSON_WESTMERE_NUMBERPARSING_DEFS_H
2 #define SIMDJSON_WESTMERE_NUMBERPARSING_DEFS_H
4 #include "simdjson/westmere/base.h"
5 #include "simdjson/westmere/intrinsics.h"
7 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
8 #include "simdjson/internal/numberparsing_tables.h"
13 namespace numberparsing {
16 static simdjson_inline uint32_t parse_eight_digits_unrolled(
const uint8_t *chars) {
18 const __m128i ascii0 = _mm_set1_epi8(
'0');
19 const __m128i mul_1_10 =
20 _mm_setr_epi8(10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1);
21 const __m128i mul_1_100 = _mm_setr_epi16(100, 1, 100, 1, 100, 1, 100, 1);
22 const __m128i mul_1_10000 =
23 _mm_setr_epi16(10000, 1, 10000, 1, 10000, 1, 10000, 1);
24 const __m128i input = _mm_sub_epi8(
25 _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(chars)), ascii0);
26 const __m128i t1 = _mm_maddubs_epi16(input, mul_1_10);
27 const __m128i t2 = _mm_madd_epi16(t1, mul_1_100);
28 const __m128i t3 = _mm_packus_epi32(t2, t2);
29 const __m128i t4 = _mm_madd_epi16(t3, mul_1_10000);
30 return _mm_cvtsi128_si32(
35 simdjson_inline internal::value128 full_multiplication(uint64_t value1, uint64_t value2) {
36 internal::value128 answer;
37 #if SIMDJSON_REGULAR_VISUAL_STUDIO || SIMDJSON_IS_32BITS
40 answer.high = __umulh(value1, value2);
41 answer.low = value1 * value2;
43 answer.low = _umul128(value1, value2, &answer.high);
46 __uint128_t r = (
static_cast<__uint128_t
>(value1)) * value2;
47 answer.low = uint64_t(r);
48 answer.high = uint64_t(r >> 64);
57 #define SIMDJSON_SWAR_NUMBER_PARSING 1
The top level simdjson namespace, containing everything the library provides.