1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Only works if SSE is supported. We don't know if it is
// on 32-bit x86, but, its always supported in x86-86
#if defined(__x86_64__)
#include <emmintrin.h>
void rust_crypto_ghash_times_x(__m128i* x) {
/*
asm!("
movdqa $0, %xmm1
psrlq $$1, $0
psllq $$63, %xmm1
pshufd $$0x0c, %xmm1, %xmm1
por %xmm1, $0
" : "+x" (self.d) : : "xmm1" );
*/
asm(
" \
movdqu (%0), %%xmm1 \
mov %%xmm1, %%xmm2 \
psrlq $1, %%xmm2 \
psllq $63, %%xmm1 \
pshufd $0x0c, %%xmm1, %%xmm1 \
por %%xmm1, %%xmm2 \
movdqu %%xmm2, (%0) \
"
: "+m" (x) // outputs
: // inputs
: "xmm1", "xmm2" // clobbers
);
}
void rust_crypto_ghash_cond_xor() {
/*
asm!("
movdqa $1, %xmm1
pand $3, %xmm1
pcmpeqd $3, %xmm1
pshufd $$0x00, %xmm1, %xmm1
pand $2, %xmm1
pxor %xmm1, $0
" : "+x" (y.d) : "x" (self.d), "x" (x.d), "x" (lsb) : "xmm1"
);
*/
asm(
" \
"
: // outputs
: // inputs
: "xmm1", "memory" // clobbers
);
}
#endif