hash: add assembly implementation of CRC32 intrinsics
authorYerden Zhumabekov <e_zhumabekov@sts.kz>
Thu, 29 Jan 2015 08:48:59 +0000 (14:48 +0600)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 23 Feb 2015 17:14:41 +0000 (18:14 +0100)
Added:
- crc32c_sse42_u32() emits 'crc32l' asm instruction;
- crc32c_sse42_u64() emits 'crc32q' asm instruction;
- crc32c_sse42_u64_mimic(), wrapper in case of run on 32-bit platform.

Signed-off-by: Yerden Zhumabekov <e_zhumabekov@sts.kz>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
lib/librte_hash/rte_hash_crc.h

index 4da7ca4..fe35996 100644 (file)
@@ -363,6 +363,40 @@ crc32c_2words(uint64_t data, uint32_t init_val)
        return crc;
 }
 
+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;
+}
+
+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 init_val;
+}
+
+static inline uint32_t
+crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
+{
+       union {
+               uint32_t u32[2];
+               uint64_t u64;
+       } d;
+
+       d.u64 = data;
+       init_val = crc32c_sse42_u32(d.u32[0], init_val);
+       init_val = crc32c_sse42_u32(d.u32[1], init_val);
+       return init_val;
+}
+
 /**
  * Use single crc32 instruction to perform a hash on a 4 byte value.
  *