| 1 |
/* ARM64 mul_1 -- Multiply a limb vector with a limb and store the result in |
| 2 |
* a second 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_mul_1( mpi_ptr_t res_ptr, x0 |
| 30 |
* mpi_ptr_t s1_ptr, x1 |
| 31 |
* mpi_size_t s1_size, w2 |
| 32 |
* mpi_limb_t s2_limb) x3 |
| 33 |
*/ |
| 34 |
|
| 35 |
.text |
| 36 |
|
| 37 |
.globl C_SYMBOL_NAME(_gcry_mpih_mul_1) |
| 38 |
ELF(.type C_SYMBOL_NAME(_gcry_mpih_mul_1),%function) |
| 39 |
.align 4 |
| 40 |
C_SYMBOL_NAME(_gcry_mpih_mul_1): |
| 41 |
CFI_STARTPROC() |
| 42 |
and w5, w2, #3; |
| 43 |
mov x4, xzr; |
| 44 |
|
| 45 |
cbz w5, .Large_loop; |
| 46 |
|
| 47 |
.Loop: |
| 48 |
ldr x5, [x1], #8; |
| 49 |
sub w2, w2, #1; |
| 50 |
mul x9, x5, x3; |
| 51 |
umulh x10, x5, x3; |
| 52 |
and w5, w2, #3; |
| 53 |
adds x4, x4, x9; |
| 54 |
str x4, [x0], #8; |
| 55 |
adc x4, x10, xzr; |
| 56 |
|
| 57 |
cbz w2, .Lend; |
| 58 |
cbnz w5, .Loop; |
| 59 |
|
| 60 |
.Large_loop: |
| 61 |
ldp x5, x6, [x1]; |
| 62 |
sub w2, w2, #4; |
| 63 |
|
| 64 |
mul x9, x5, x3; |
| 65 |
ldp x7, x8, [x1, #16]; |
| 66 |
umulh x10, x5, x3; |
| 67 |
add x1, x1, #32; |
| 68 |
|
| 69 |
adds x4, x4, x9; |
| 70 |
str x4, [x0], #8; |
| 71 |
mul x11, x6, x3; |
| 72 |
adc x4, x10, xzr; |
| 73 |
|
| 74 |
umulh x12, x6, x3; |
| 75 |
|
| 76 |
adds x4, x4, x11; |
| 77 |
str x4, [x0], #8; |
| 78 |
mul x13, x7, x3; |
| 79 |
adc x4, x12, xzr; |
| 80 |
|
| 81 |
umulh x14, x7, x3; |
| 82 |
|
| 83 |
adds x4, x4, x13; |
| 84 |
str x4, [x0], #8; |
| 85 |
mul x15, x8, x3; |
| 86 |
adc x4, x14, xzr; |
| 87 |
|
| 88 |
umulh x16, x8, x3; |
| 89 |
|
| 90 |
adds x4, x4, x15; |
| 91 |
str x4, [x0], #8; |
| 92 |
adc x4, x16, xzr; |
| 93 |
|
| 94 |
cbnz w2, .Large_loop; |
| 95 |
|
| 96 |
.Lend: |
| 97 |
mov x0, x4; |
| 98 |
ret_spec_stop; |
| 99 |
CFI_ENDPROC() |
| 100 |
ELF(.size C_SYMBOL_NAME(_gcry_mpih_mul_1),.-C_SYMBOL_NAME(_gcry_mpih_mul_1);) |