| 1 |
/* ARM mul_3 -- Multiply a limb vector with a limb and subtract the result |
| 2 |
* from 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_submul_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_submul_1) |
| 38 |
ELF(.type C_SYMBOL_NAME(_gcry_mpih_submul_1),%function) |
| 39 |
.align 4 |
| 40 |
C_SYMBOL_NAME(_gcry_mpih_submul_1): |
| 41 |
CFI_STARTPROC() |
| 42 |
and w5, w2, #3; |
| 43 |
mov x7, xzr; |
| 44 |
cbz w5, .Large_loop; |
| 45 |
|
| 46 |
subs xzr, xzr, xzr; |
| 47 |
|
| 48 |
.Loop: |
| 49 |
ldr x4, [x1], #8; |
| 50 |
cinc x7, x7, cc; |
| 51 |
ldr x5, [x0]; |
| 52 |
sub w2, w2, #1; |
| 53 |
|
| 54 |
mul x6, x4, x3; |
| 55 |
subs x5, x5, x7; |
| 56 |
umulh x4, x4, x3; |
| 57 |
and w10, w2, #3; |
| 58 |
|
| 59 |
cset x7, cc; |
| 60 |
subs x5, x5, x6; |
| 61 |
add x7, x7, x4; |
| 62 |
str x5, [x0], #8; |
| 63 |
|
| 64 |
cbz w2, .Loop_end; |
| 65 |
cbnz w10, .Loop; |
| 66 |
|
| 67 |
cinc x7, x7, cc; |
| 68 |
|
| 69 |
.Large_loop: |
| 70 |
ldp x4, x8, [x1], #16; |
| 71 |
sub w2, w2, #4; |
| 72 |
ldp x5, x9, [x0]; |
| 73 |
|
| 74 |
mul x6, x4, x3; |
| 75 |
subs x5, x5, x7; |
| 76 |
umulh x4, x4, x3; |
| 77 |
|
| 78 |
cset x7, cc; |
| 79 |
subs x5, x5, x6; |
| 80 |
mul x6, x8, x3; |
| 81 |
add x7, x7, x4; |
| 82 |
str x5, [x0], #8; |
| 83 |
cinc x7, x7, cc; |
| 84 |
|
| 85 |
umulh x8, x8, x3; |
| 86 |
|
| 87 |
subs x9, x9, x7; |
| 88 |
cset x7, cc; |
| 89 |
subs x9, x9, x6; |
| 90 |
ldp x4, x10, [x1], #16; |
| 91 |
str x9, [x0], #8; |
| 92 |
add x7, x7, x8; |
| 93 |
ldp x5, x9, [x0]; |
| 94 |
cinc x7, x7, cc; |
| 95 |
|
| 96 |
mul x6, x4, x3; |
| 97 |
subs x5, x5, x7; |
| 98 |
umulh x4, x4, x3; |
| 99 |
|
| 100 |
cset x7, cc; |
| 101 |
subs x5, x5, x6; |
| 102 |
mul x6, x10, x3; |
| 103 |
add x7, x7, x4; |
| 104 |
str x5, [x0], #8; |
| 105 |
cinc x7, x7, cc; |
| 106 |
|
| 107 |
umulh x10, x10, x3; |
| 108 |
|
| 109 |
subs x9, x9, x7; |
| 110 |
cset x7, cc; |
| 111 |
subs x9, x9, x6; |
| 112 |
add x7, x7, x10; |
| 113 |
str x9, [x0], #8; |
| 114 |
cinc x7, x7, cc; |
| 115 |
|
| 116 |
cbnz w2, .Large_loop; |
| 117 |
|
| 118 |
mov x0, x7; |
| 119 |
ret_spec_stop; |
| 120 |
|
| 121 |
.Loop_end: |
| 122 |
cinc x0, x7, cc; |
| 123 |
ret_spec_stop; |
| 124 |
CFI_ENDPROC() |
| 125 |
ELF(.size C_SYMBOL_NAME(_gcry_mpih_submul_1),.-C_SYMBOL_NAME(_gcry_mpih_submul_1);) |