All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	Sameh Gobriel <sameh.gobriel@intel.com>,
	Vladimir Medvedkin <vladimir.medvedkin@intel.com>,
	Yipeng Wang <yipeng1.wang@intel.com>,
	Tyler Retzlaff <roretzla@linux.microsoft.com>
Subject: [PATCH v2] hash: provide crc32 functions based on intrinsics
Date: Tue, 21 May 2024 17:02:14 -0700	[thread overview]
Message-ID: <1716336134-27366-2-git-send-email-roretzla@linux.microsoft.com> (raw)
In-Reply-To: <1716336134-27366-1-git-send-email-roretzla@linux.microsoft.com>

MSVC does not support inline asm so replace crc32 inline function
implementations with intrinsics compatible with all toolchains.

Signed-off-by: Tyler Retzlaff <roretzla@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


  reply	other threads:[~2024-05-22  0:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20 21:28 [PATCH] provide crc32 functions based on intrinsics for MSVC Tyler Retzlaff
2024-03-20 21:28 ` [PATCH] hash: provide crc32 functions based on intrinsics Tyler Retzlaff
2024-05-16 17:04   ` Thomas Monjalon
2024-05-22  0:02   ` [PATCH v2] " Tyler Retzlaff
2024-05-22  0:02     ` Tyler Retzlaff [this message]
2024-05-22  2:21       ` Stephen Hemminger
2024-05-22  8:36         ` Morten Brørup
2024-05-26 15:07           ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1716336134-27366-2-git-send-email-roretzla@linux.microsoft.com \
    --to=roretzla@linux.microsoft.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=sameh.gobriel@intel.com \
    --cc=vladimir.medvedkin@intel.com \
    --cc=yipeng1.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.