| 1 |
/* ARM64 sub_n -- Subtract two limb vectors of the same length > 0 and store |
| 2 |
* sum in a third limb vector. |
| 3 |
* |
| 4 |
* Copyright (C) 2013 Jussi Kivilinna <[email protected]> |
| 5 |
* |
| 6 |
* This file is part of Libgcrypt. |
| 7 |
* |
| 8 |
* Libgcrypt is free software; you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU Lesser General Public License as |
| 10 |
* published by the Free Software Foundation; either version 2.1 of |
| 11 |
* the License, or (at your option) any later version. |
| 12 |
* |
| 13 |
* Libgcrypt is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Lesser General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Lesser General Public |
| 19 |
* License along with this program; if not, see <http://www.gnu.org/licenses/>. |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
#include "sysdep.h" |
| 24 |
#include "asm-syntax.h" |
| 25 |
#include "asm-common-aarch64.h" |
| 26 |
|
| 27 |
/******************* |
| 28 |
* mpi_limb_t |
| 29 |
* _gcry_mpih_sub_n( mpi_ptr_t res_ptr, x0 |
| 30 |
* mpi_ptr_t s1_ptr, x1 |
| 31 |
* mpi_ptr_t s2_ptr, x2 |
| 32 |
* mpi_size_t size) w3 |
| 33 |
*/ |
| 34 |
|
| 35 |
.text |
| 36 |
|
| 37 |
.globl C_SYMBOL_NAME(_gcry_mpih_sub_n) |
| 38 |
ELF(.type C_SYMBOL_NAME(_gcry_mpih_sub_n),%function) |
| 39 |
.align 4 |
| 40 |
C_SYMBOL_NAME(_gcry_mpih_sub_n): |
| 41 |
CFI_STARTPROC() |
| 42 |
and w5, w3, #3; |
| 43 |
subs xzr, xzr, xzr; /* prepare carry flag for sub */ |
| 44 |
|
| 45 |
cbz w5, .Large_loop; |
| 46 |
|
| 47 |
.Loop: |
| 48 |
ldr x4, [x1], #8; |
| 49 |
sub w3, w3, #1; |
| 50 |
ldr x11, [x2], #8; |
| 51 |
and w5, w3, #3; |
| 52 |
sbcs x4, x4, x11; |
| 53 |
str x4, [x0], #8; |
| 54 |
cbz w3, .Lend; |
| 55 |
cbnz w5, .Loop; |
| 56 |
|
| 57 |
.Large_loop: |
| 58 |
ldp x4, x6, [x1], #16; |
| 59 |
ldp x5, x7, [x2], #16; |
| 60 |
ldp x8, x10, [x1], #16; |
| 61 |
ldp x9, x11, [x2], #16; |
| 62 |
sub w3, w3, #4; |
| 63 |
sbcs x4, x4, x5; |
| 64 |
sbcs x6, x6, x7; |
| 65 |
sbcs x8, x8, x9; |
| 66 |
sbcs x10, x10, x11; |
| 67 |
stp x4, x6, [x0], #16; |
| 68 |
stp x8, x10, [x0], #16; |
| 69 |
cbnz w3, .Large_loop; |
| 70 |
|
| 71 |
.Lend: |
| 72 |
cset x0, cc; |
| 73 |
ret_spec_stop; |
| 74 |
CFI_ENDPROC() |
| 75 |
ELF(.size C_SYMBOL_NAME(_gcry_mpih_sub_n),.-C_SYMBOL_NAME(_gcry_mpih_sub_n);) |