1 /* insert_string_sse -- insert_string variant using SSE4.2's CRC instructions
2  *
3  * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
4  * For conditions of distribution and use, see copyright notice in zlib.h
5  *
6  */
7 
8 #include "../../zbuild.h"
9 #include <immintrin.h>
10 #ifdef _MSC_VER
11 #  include <nmmintrin.h>
12 #endif
13 #include "../../deflate.h"
14 
15 #ifdef X86_SSE42_CRC_INTRIN
16 #  ifdef _MSC_VER
17 #    define UPDATE_HASH(s, h, val)\
18         h = _mm_crc32_u32(h, val)
19 #  else
20 #    define UPDATE_HASH(s, h, val)\
21         h = __builtin_ia32_crc32si(h, val)
22 #  endif
23 #else
24 #  ifdef _MSC_VER
25 #    define UPDATE_HASH(s, h, val) {\
26         __asm mov edx, h\
27         __asm mov eax, val\
28         __asm crc32 eax, edx\
29         __asm mov val, eax\
30     }
31 #  else
32 #    define UPDATE_HASH(s, h, val) \
33         __asm__ __volatile__ (\
34             "crc32 %1,%0\n\t"\
35             : "+r" (h)\
36             : "r" (val)\
37         );
38 #  endif
39 #endif
40 
41 #define INSERT_STRING       insert_string_sse4
42 #define QUICK_INSERT_STRING quick_insert_string_sse4
43 
44 #ifdef X86_SSE42_CRC_HASH
45 #  include "../../insert_string_tpl.h"
46 #endif
47