Debian Codegraph @

mpi/amd64/mpih-rshift.S

raw
1 /* AMD64 (x86_64) rshift -- Right shift a limb vector and store
2 * result in a second limb vector.
3 *
4 * Copyright (C) 1992, 1994, 1995, 1998,
5 * 2001, 2002, 2006 Free Software Foundation, Inc.
6 *
7 * This file is part of Libgcrypt.
8 *
9 * Libgcrypt is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
13 *
14 * Libgcrypt is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this program; if not, see <https://www.gnu.org/licenses/>.
21 * SPDX-License-Identifier: LGPL-2.1-or-later
22 *
23 * Note: This code is heavily based on the GNU MP Library.
24 * Actually it's the same code with only minor changes in the
25 * way the data is stored; this is to support the abstraction
26 * of an optional secure memory allocation which may be used
27 * to avoid revealing of sensitive data due to paging etc.
28 */
29
30
31 #include "sysdep.h"
32 #include "asm-syntax.h"
33
34 /*******************
35 * mpi_limb_t
36 * _gcry_mpih_rshift( mpi_ptr_t wp, rdi
37 * mpi_ptr_t up, rsi
38 * mpi_size_t usize, rdx
39 * unsigned cnt) rcx
40 */
41
42 TEXT
43 ALIGN(4)
44 .globl C_SYMBOL_NAME(_gcry_mpih_rshift)
45 C_SYMBOL_NAME(_gcry_mpih_rshift:)
46 FUNC_ENTRY()
47 /* Note: %xmm6 and %xmm7 not used for WIN64 ABI compatibility. */
48 movq (%rsi), %xmm4
49 movd %ecx, %xmm1
50 movl $64, %eax
51 subl %ecx, %eax
52 movd %eax, %xmm0
53 movdqa %xmm4, %xmm3
54 psllq %xmm0, %xmm4
55 movq %xmm4, %rax
56 leaq (%rsi,%rdx,8), %rsi
57 leaq (%rdi,%rdx,8), %rdi
58 negq %rdx
59 addq $2, %rdx
60 jg .Lendo
61
62 ALIGN(4) /* minimal alignment for claimed speed */
63 .Loop: movq -8(%rsi,%rdx,8), %xmm5
64 movdqa %xmm5, %xmm2
65 psllq %xmm0, %xmm5
66 psrlq %xmm1, %xmm3
67 por %xmm5, %xmm3
68 movq %xmm3, -16(%rdi,%rdx,8)
69 je .Lende
70 movq (%rsi,%rdx,8), %xmm4
71 movdqa %xmm4, %xmm3
72 psllq %xmm0, %xmm4
73 psrlq %xmm1, %xmm2
74 por %xmm4, %xmm2
75 movq %xmm2, -8(%rdi,%rdx,8)
76 addq $2, %rdx
77 jle .Loop
78
79 .Lendo: movdqa %xmm3, %xmm2
80 .Lende: psrlq %xmm1, %xmm2
81 movq %xmm2, -8(%rdi)
82 FUNC_EXIT()