From 19cdc09928fa321c3d6430890d1b5269832fa8f1 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 4 Jul 2019 17:36:26 -0400 Subject: [PATCH] Improving support for VS --- include/simdjson/stage1_find_marks.h | 37 ++++++++++++++-------------- include/simdjson/stringparsing.h | 2 +- src/jsonparser.cpp | 2 +- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/include/simdjson/stage1_find_marks.h b/include/simdjson/stage1_find_marks.h index 4b0df107..65525557 100644 --- a/include/simdjson/stage1_find_marks.h +++ b/include/simdjson/stage1_find_marks.h @@ -6,17 +6,16 @@ #include "simdjson/parsedjson.h" #include "simdjson/portability.h" -#if defined (__AVX2__) || (__SSE4_2__) +#if defined (__AVX2__) || defined (__SSE4_2__) || (defined(_MSC_VER) && defined(_M_AMD64)) #ifndef SIMDJSON_SKIPUTF8VALIDATION #define SIMDJSON_UTF8VALIDATE - #endif #else // currently we don't UTF8 validate for ARM // also we assume that if you're not __AVX2__ // you're ARM, which is a bit dumb. TODO: Fix... -#ifdef __ARM_NEON +#if defined(__ARM_NEON) || (defined(_MSC_VER) && defined(_M_ARM64)) #include #else #warning It appears that neither ARM NEON nor AVX2 are detected. @@ -45,7 +44,7 @@ struct simd_input }; #endif -#ifdef __SSE4_2__ +#if defined(__SSE4_2__) || (defined(_MSC_VER) && defined(_M_AMD64)) template<> struct simd_input { @@ -56,7 +55,7 @@ struct simd_input }; #endif -#ifdef __ARM_NEON +#if defined(__ARM_NEON) || (defined(_MSC_VER) && defined(_M_ARM64)) template<> struct simd_input { #ifndef TRANSPOSE @@ -70,7 +69,7 @@ template<> struct simd_input }; #endif -#ifdef __ARM_NEON +#if defined(__ARM_NEON) || (defined(_MSC_VER) && defined(_M_ARM64)) really_inline uint16_t neonmovemask(uint8x16_t input) { const uint8x16_t bitmask = { 0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, @@ -165,7 +164,7 @@ uint64_t compute_quote_mask(uint64_t quote_bits) { } #endif -#ifdef __SSE4_2__ +#if defined(__SSE4_2__) || (defined(_MSC_VER) && defined(_M_AMD64)) template<> really_inline uint64_t compute_quote_mask(uint64_t quote_bits) { // CLMUL is supported on some SSE42 hardware such as Sandy Bridge, @@ -179,7 +178,7 @@ uint64_t compute_quote_mask(uint64_t quote_bits) { } #endif -#ifdef __ARM_NEON +#if defined(__ARM_NEON) || (defined(_MSC_VER) && defined(_M_ARM64)) template<> really_inline uint64_t compute_quote_mask(uint64_t quote_bits) { #ifdef __ARM_FEATURE_CRYPTO // some ARM processors lack this extension @@ -209,7 +208,7 @@ struct check_utf8_helper }; #endif -#ifdef __SSE4_2__ +#if defined(__SSE4_2__) || (defined(_MSC_VER) && defined(_M_AMD64)) template<> struct check_utf8_helper { @@ -246,7 +245,7 @@ void check_utf8(simd_input in, } #endif //__AVX2__ -#ifdef __SSE4_2__ +#if defined(__SSE4_2__) || (defined(_MSC_VER) && defined(_M_AMD64)) template<> really_inline void check_utf8(simd_input in, check_utf8_helper& helper) { @@ -290,7 +289,7 @@ errorValues check_utf8_errors(check_utf8_helper really_inline errorValues check_utf8_errors(check_utf8_helper& helper) { return _mm_testz_si128(helper.has_error, helper.has_error) == 0 ? simdjson::UTF8_ERROR : simdjson::SUCCESS; @@ -311,7 +310,7 @@ simd_input fill_input(const uint8_ } #endif -#ifdef __SSE4_2__ +#if defined(__SSE4_2__) || (defined(_MSC_VER) && defined(_M_AMD64)) template<> really_inline simd_input fill_input(const uint8_t * ptr) { struct simd_input in; @@ -323,7 +322,7 @@ simd_input fill_input(const ui } #endif -#ifdef __ARM_NEON +#if defined(__ARM_NEON) || (defined(_MSC_VER) && defined(_M_ARM64)) template<> really_inline simd_input fill_input(const uint8_t * ptr) { struct simd_input in; @@ -356,7 +355,7 @@ uint64_t cmp_mask_against_input(simd_input really_inline uint64_t cmp_mask_against_input(simd_input in, uint8_t m) { const __m128i mask = _mm_set1_epi8(m); @@ -373,7 +372,7 @@ uint64_t cmp_mask_against_input(simd_input really_inline uint64_t cmp_mask_against_input(simd_input in, uint8_t m) { const uint8x16_t mask = vmovq_n_u8(m); @@ -401,7 +400,7 @@ uint64_t unsigned_lteq_against_input(simd_input really_inline uint64_t unsigned_lteq_against_input(simd_input in, uint8_t m) { const __m128i maxval = _mm_set1_epi8(m); @@ -417,7 +416,7 @@ uint64_t unsigned_lteq_against_input(simd_input really_inline uint64_t unsigned_lteq_against_input(simd_input in, uint8_t m) { const uint8x16_t mask = vmovq_n_u8(m); @@ -609,7 +608,7 @@ void find_whitespace_and_structurals(simd_input really_inline void find_whitespace_and_structurals(simd_input in, uint64_t &whitespace, @@ -680,7 +679,7 @@ void find_whitespace_and_structurals(simd_input really_inline void find_whitespace_and_structurals( simd_input in, diff --git a/include/simdjson/stringparsing.h b/include/simdjson/stringparsing.h index 87687846..c9be1788 100644 --- a/include/simdjson/stringparsing.h +++ b/include/simdjson/stringparsing.h @@ -109,7 +109,7 @@ parse_string_helper find_bs_bits_and_quote_bits (const ui } #endif -#ifdef __SSE4_2__ +#if defined(__SSE4_2__) || (defined(_MSC_VER) && defined(_M_AMD64)) template<> really_inline parse_string_helper find_bs_bits_and_quote_bits (const uint8_t *src, uint8_t *dst) { // this can read up to 31 bytes beyond the buffer size, but we require diff --git a/src/jsonparser.cpp b/src/jsonparser.cpp index ed4e3912..7f82471a 100644 --- a/src/jsonparser.cpp +++ b/src/jsonparser.cpp @@ -40,7 +40,7 @@ int json_parse_dispatch(const uint8_t *buf, size_t len, ParsedJson &pj, bool rea json_parse_ptr = avx_implementation; break; #endif -#ifdef __SSE4_2__ +#if defined(__SSE4_2__) || (defined(_MSC_VER) && defined(_M_AMD64)) case instruction_set::sse4_2 : json_parse_ptr = sse4_2_implementation; break;