MSVC does not support inline asm so replace crc32 inline function implementations with intrinsics compatible with all toolchains.
Signed-off-by: Tyler Retzlaff <roret...@linux.microsoft.com> --- lib/hash/rte_crc_x86.h | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/lib/hash/rte_crc_x86.h b/lib/hash/rte_crc_x86.h index 3b865e2..eadfe42 100644 --- a/lib/hash/rte_crc_x86.h +++ b/lib/hash/rte_crc_x86.h @@ -5,35 +5,33 @@ #ifndef _RTE_CRC_X86_H_ #define _RTE_CRC_X86_H_ +#include <rte_vect.h> + static inline uint32_t crc32c_sse42_u8(uint8_t data, uint32_t init_val) { - __asm__ volatile( - "crc32b %[data], %[init_val];" - : [init_val] "+r" (init_val) - : [data] "rm" (data)); - return init_val; + return _mm_crc32_u8(init_val, data); } static inline uint32_t crc32c_sse42_u16(uint16_t data, uint32_t init_val) { - __asm__ volatile( - "crc32w %[data], %[init_val];" - : [init_val] "+r" (init_val) - : [data] "rm" (data)); - return init_val; + return _mm_crc32_u16(init_val, data); } static inline uint32_t crc32c_sse42_u32(uint32_t data, uint32_t init_val) { - __asm__ volatile( - "crc32l %[data], %[init_val];" - : [init_val] "+r" (init_val) - : [data] "rm" (data)); - return init_val; + return _mm_crc32_u32(init_val, data); +} + +#ifdef RTE_ARCH_X86_64 +static inline uint32_t +crc32c_sse42_u64(uint64_t data, uint64_t init_val) +{ + return _mm_crc32_u64(init_val, data); } +#endif static inline uint32_t crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val) @@ -49,16 +47,6 @@ return (uint32_t)init_val; } -static inline uint32_t -crc32c_sse42_u64(uint64_t data, uint64_t init_val) -{ - __asm__ volatile( - "crc32q %[data], %[init_val];" - : [init_val] "+r" (init_val) - : [data] "rm" (data)); - return (uint32_t)init_val; -} - /* * Use single crc32 instruction to perform a hash on a byte value. * Fall back to software crc32 implementation in case SSE4.2 is -- 1.8.3.1