From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8CF1743D0A; Wed, 20 Mar 2024 22:28:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0497B42E23; Wed, 20 Mar 2024 22:28:52 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 477ED42D80 for ; Wed, 20 Mar 2024 22:28:49 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 61C6920B74C3; Wed, 20 Mar 2024 14:28:48 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 61C6920B74C3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1710970128; bh=IotKc2c0SZ5PqKnz0OxybcorAZ3mz1PIKmekCfccin0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sw8X6RJGHcOr4nPfuUm7YRsCzYp6X+kgrsVDS/50/AXeBuG8AZNn9VhM0QAUx5SbE p4ILdHYRb2207lKJ9dqtdSIq6gbaAGPalO494eY/1DxfZzZrjO0W2ZletZo0nMq81U 5TWRrw2OuuYZNpqPirkIiDXMamjXMYnYv3fTed6Q= From: Tyler Retzlaff To: dev@dpdk.org Cc: Bruce Richardson , Sameh Gobriel , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH] hash: provide crc32 functions based on intrinsics Date: Wed, 20 Mar 2024 14:28:47 -0700 Message-Id: <1710970127-25938-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1710970127-25938-1-git-send-email-roretzla@linux.microsoft.com> References: <1710970127-25938-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Provide crc32 inline functions implemented using intrinsics for MSVC. Signed-off-by: Tyler Retzlaff --- lib/hash/rte_crc_x86.h | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/lib/hash/rte_crc_x86.h b/lib/hash/rte_crc_x86.h index 3b865e2..b2ac07f 100644 --- a/lib/hash/rte_crc_x86.h +++ b/lib/hash/rte_crc_x86.h @@ -5,6 +5,31 @@ #ifndef _RTE_CRC_X86_H_ #define _RTE_CRC_X86_H_ +#ifdef RTE_TOOLCHAIN_MSVC +static inline uint32_t +crc32c_sse42_u8(uint8_t data, uint32_t init_val) +{ + return _mm_crc32_u8(init_val, data); +} + +static inline uint32_t +crc32c_sse42_u16(uint16_t data, uint32_t init_val) +{ + return _mm_crc32_u16(init_val, data); +} + +static inline uint32_t +crc32c_sse42_u32(uint32_t data, uint32_t init_val) +{ + return _mm_crc32_u32(init_val, data); +} + +static inline uint32_t +crc32c_sse42_u64(uint64_t data, uint64_t init_val) +{ + return _mm_crc32_u64(init_val, data); +} +#else static inline uint32_t crc32c_sse42_u8(uint8_t data, uint32_t init_val) { @@ -36,6 +61,17 @@ } 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; +} +#endif + +static inline uint32_t crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val) { union { @@ -49,16 +85,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