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 5D91444092; Wed, 22 May 2024 02:02:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D2AAA40273; Wed, 22 May 2024 02:02:17 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 8FF164026B for ; Wed, 22 May 2024 02:02:16 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id CA3F920B915B; Tue, 21 May 2024 17:02:15 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CA3F920B915B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1716336135; bh=vAml8JGOC5L2vl13JhPbU7XkUeDeP2LqYeNRnYsgSuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qz0gYdXCXLXk7yWFm5329FZeiNu28Ysb82zCCfpQyoJiMQpwmwb3eW6twgQqGc4xN oHm/J06S+fWE5I093DGhiMy8GloG5Rq35g/uFocYvyGtCd7hhR24Uwa64tumOVJkHv XFxq8NSLwJyqwf07Mx8rM6JWA4jHiRa9AlYpggzk= From: Tyler Retzlaff To: dev@dpdk.org Cc: Bruce Richardson , Sameh Gobriel , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v2] hash: provide crc32 functions based on intrinsics Date: Tue, 21 May 2024 17:02:14 -0700 Message-Id: <1716336134-27366-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1716336134-27366-1-git-send-email-roretzla@linux.microsoft.com> References: <1710970127-25938-2-git-send-email-roretzla@linux.microsoft.com> <1716336134-27366-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 MSVC does not support inline asm so replace crc32 inline function implementations with intrinsics compatible with all toolchains. Signed-off-by: Tyler Retzlaff --- 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 + 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