Add progress_fn argument to MultiWorker.next
[hiphop-php.git] / hphp / util / hash-crc-x64.S
blob91dff50678d4497bc5d8c8ecde24e0295ebd4208
1 #include "hphp/util/etch-helpers.h"
3 #if defined(__x86_64__) && !defined(NO_HWCRC) && !defined(_MSC_VER)
5 .file   "hphp/util/hash-crc-x64.S"
7 /*
8  * If SSE4.2 is explicitly specified, we define the HPHP::hash_string* functions
9  * here, otherwise those functions are the same as the 'fallback' version, which
10  * check CPUID and possibly jumps here.   Thus the function name is different
11  * depending on whether __SSE4_2__ is defined.
12  */
13 #ifdef __SSE4_2__
14 #define IF_SSE42(x, y) ETCH_NAME(x)
15 #else
16 #define IF_SSE42(x, y) ETCH_NAME(y)
17 #endif
19 #define HASH_FUNC_NAME IF_SSE42(_ZN4HPHP20hash_string_i_unsafeEPKcj, hash_string_i_crc)
21 ETCH_SECTION(HASH_FUNC_NAME)
22 .globl    HASH_FUNC_NAME
23 ETCH_TYPE(HASH_FUNC_NAME, @function)
24 HASH_FUNC_NAME:
25         CFI(startproc)
26         or      $-1, %eax
27         neg     %esi
28         je      ETCH_LABEL(iend)
29         mov     %esi, %ecx
30         movabs  $0xdfdfdfdfdfdfdfdf, %r8
31         jmp     ETCH_LABEL(iheader)
33 ETCH_LABEL(iloop):
34         add     $8, %rdi
35         crc32q  %rdx, %rax
36 ETCH_LABEL(iheader):
37         mov     %r8, %rdx
38         and     (%rdi), %rdx
39         add     $8, %ecx
40         jnc     ETCH_LABEL(iloop)
42         shl     $3, %ecx
43         shl     %cl, %rdx
44         crc32q  %rdx, %rax
46 ETCH_LABEL(iend):
47         shr     %eax
48         ret
49         CFI(endproc)
51 ETCH_SIZE(HASH_FUNC_NAME)
52 #undef HASH_FUNC_NAME
55 #define HASH_FUNC_NAME IF_SSE42(_ZN4HPHP13hash_string_iEPKcj, hash_string_i_unaligned_crc)
57 ETCH_SECTION(HASH_FUNC_NAME)
58 .globl    HASH_FUNC_NAME
59 ETCH_TYPE(HASH_FUNC_NAME, @function)
60 HASH_FUNC_NAME:
61         CFI(startproc)
62         xor     %ecx, %ecx
63         or      $-1, %eax
64         sub     %esi, %ecx
65         je      ETCH_LABEL(icend)
67         movabs  $0xdfdfdfdfdfdfdfdf, %r8
68         test    $7, %dil
69         jnz     ETCH_LABEL(iuheader)
70         jmp     ETCH_LABEL(icheader)
71         nop
73 ETCH_LABEL(icloop):
74         add     $8, %rdi
75         crc32   %rdx, %rax
76 ETCH_LABEL(icheader):
77         mov     %r8, %rdx
78         and     (%rdi), %rdx
79         add     $8, %ecx
80         jnc     ETCH_LABEL(icloop)
82 ETCH_LABEL(ictail):
83         shl     $3, %ecx
84         shl     %cl, %rdx
85         crc32   %rdx, %rax
87 ETCH_LABEL(icend):
88         shr     %eax
89         ret
91 ETCH_ALIGN16
92 ETCH_LABEL(iuloop):
93         and     (%rdi), %rdx
94         add     $8, %rdi
95         crc32   %rdx, %rax
96 ETCH_LABEL(iuheader):
97         mov     %r8, %rdx
98         add     $8, %ecx
99         jnc     ETCH_LABEL(iuloop)
101         xor     %edx, %edx
102         sub     $8, %ecx
103         jz      ETCH_LABEL(iuend)
105 ETCH_ALIGN16
106 ETCH_LABEL(iutailloop):
107         mov     (%rdi), %dl
108         add     $1, %rdi
109         ror     $8, %rdx
110         add     $1, %ecx
111         jnz     ETCH_LABEL(iutailloop)
113         and     %r8, %rdx
114         crc32   %rdx, %rax
115 ETCH_LABEL(iuend):
116         shr     %eax
117         ret
119         CFI(endproc)
120 ETCH_SIZE(HASH_FUNC_NAME)
121 #undef HASH_FUNC_NAME
124 #define HASH_FUNC_NAME IF_SSE42(_ZN4HPHP21hash_string_cs_unsafeEPKcj, hash_string_cs_crc)
126 ETCH_SECTION(HASH_FUNC_NAME)
127 .globl    HASH_FUNC_NAME
128 ETCH_TYPE(HASH_FUNC_NAME, @function)
129 HASH_FUNC_NAME:
130         CFI(startproc)
131         or      $-1, %eax
132         neg     %esi
133         je      ETCH_LABEL(csend)
134         mov     %esi, %ecx
135         jmp     ETCH_LABEL(csheader)
137 ETCH_LABEL(csloop):
138         add     $8, %rdi
139         crc32q  %rdx, %rax
140 ETCH_LABEL(csheader):
141         mov     (%rdi), %rdx
142         add     $8, %ecx
143         jnc     ETCH_LABEL(csloop)
145         shl     $3, %ecx
146         shl     %cl, %rdx
147         crc32q  %rdx, %rax
149 ETCH_LABEL(csend):
150         shr     %eax
151         ret
152         CFI(endproc)
153 ETCH_SIZE(HASH_FUNC_NAME)
154 #undef HASH_FUNC_NAME
157 #define HASH_FUNC_NAME IF_SSE42(_ZN4HPHP14hash_string_csEPKcj, hash_string_cs_unaligned_crc)
159 ETCH_SECTION(HASH_FUNC_NAME)
160 .globl    HASH_FUNC_NAME
161 ETCH_TYPE(HASH_FUNC_NAME, @function)
162 HASH_FUNC_NAME:
163         CFI(startproc)
164         or      $-1, %eax
165         sub     $8, %esi
166         js      ETCH_LABEL(csutail)
168 ETCH_LABEL(csuloop):
169         mov     (%rdi), %rdx
170         add     $8, %rdi
171         crc32q  %rdx, %rax
172         sub     $8, %esi
173         jns     ETCH_LABEL(csuloop)
175 ETCH_LABEL(csutail):
176         add     $8, %esi
177         je      ETCH_LABEL(csuend)
178         mov     %esi, %ecx
179         xor     %edx, %edx
181 ETCH_LABEL(csutailloop):
182         mov     (%rdi), %dl
183         inc     %rdi
184         ror     $8, %rdx
185         loop    ETCH_LABEL(csutailloop)
186         crc32q  %rdx, %rax
188 ETCH_LABEL(csuend):
189         shr     %eax
190         ret
191         CFI(endproc)
193 ETCH_LABEL(FE803):
194 ETCH_SIZE(HASH_FUNC_NAME)
195 #undef HASH_FUNC_NAME
198 #endif