Changeset View
Changeset View
Standalone View
Standalone View
sys/libkern/x86/crc32_sse42.c
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | _mm_crc32_u8(uint32_t x, uint8_t y) | ||||
* local variable (on the stack or in a register), so only use | * local variable (on the stack or in a register), so only use | ||||
* the latter. This costs a register and an instruction but | * the latter. This costs a register and an instruction but | ||||
* not a uop. | * not a uop. | ||||
*/ | */ | ||||
__asm("crc32b %1,%0" : "+r" (x) : "r" (y)); | __asm("crc32b %1,%0" : "+r" (x) : "r" (y)); | ||||
return (x); | return (x); | ||||
} | } | ||||
static __inline uint32_t | #ifdef __amd64__ | ||||
_mm_crc32_u32(uint32_t x, uint32_t y) | |||||
{ | |||||
__asm("crc32l %1,%0" : "+r" (x) : "r" (y)); | |||||
return (x); | |||||
} | |||||
static __inline uint64_t | static __inline uint64_t | ||||
_mm_crc32_u64(uint64_t x, uint64_t y) | _mm_crc32_u64(uint64_t x, uint64_t y) | ||||
{ | { | ||||
__asm("crc32q %1,%0" : "+r" (x) : "r" (y)); | __asm("crc32q %1,%0" : "+r" (x) : "r" (y)); | ||||
return (x); | return (x); | ||||
} | } | ||||
#else | |||||
static __inline uint32_t | |||||
_mm_crc32_u32(uint32_t x, uint32_t y) | |||||
{ | |||||
__asm("crc32l %1,%0" : "+r" (x) : "r" (y)); | |||||
return (x); | |||||
} | |||||
#endif | |||||
/* CRC-32C (iSCSI) polynomial in reversed bit order. */ | /* CRC-32C (iSCSI) polynomial in reversed bit order. */ | ||||
#define POLY 0x82f63b78 | #define POLY 0x82f63b78 | ||||
/* | /* | ||||
* Block sizes for three-way parallel crc computation. LONG and SHORT must | * Block sizes for three-way parallel crc computation. LONG and SHORT must | ||||
* both be powers of two. | * both be powers of two. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 304 Lines • Show Last 20 Lines |