summaryrefslogtreecommitdiff
path: root/mpi/aarch64/mpih-add1.S
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2013-12-03 13:57:02 +0200
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2013-12-03 13:57:02 +0200
commit80896bc8f5e6ed9a627374e34f040ad5f3617584 (patch)
tree4025da8b0b8be08e1c479c6f39696805e83353ba /mpi/aarch64/mpih-add1.S
parentd4ce0cfe0d35d7ec69c115456848b5b735c928ea (diff)
downloadlibgcrypt-80896bc8f5e6ed9a627374e34f040ad5f3617584.tar.gz
Add aarch64 (arm64) mpi assembly
* mpi/aarch64/mpi-asm-defs.h: New. * mpi/aarch64/mpih-add1.S: New. * mpi/aarch64/mpih-mul1.S: New. * mpi/aarch64/mpih-mul2.S: New. * mpi/aarch64/mpih-mul3.S: New. * mpi/aarch64/mpih-sub1.S: New. * mpi/config.links [host=aarch64-*-*]: Add configguration for aarch64 assembly. * mpi/longlong.h [__aarch64__] (add_ssaaaa, sub_ddmmss, umul_ppmm) (count_leading_zeros): New. -- Add preliminary aarch64 assembly implementations for mpi. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'mpi/aarch64/mpih-add1.S')
-rw-r--r--mpi/aarch64/mpih-add1.S71
1 files changed, 71 insertions, 0 deletions
diff --git a/mpi/aarch64/mpih-add1.S b/mpi/aarch64/mpih-add1.S
new file mode 100644
index 00000000..9f7e2e69
--- /dev/null
+++ b/mpi/aarch64/mpih-add1.S
@@ -0,0 +1,71 @@
+/* ARM64 add_n -- Add two limb vectors of the same length > 0 and store
+ * sum in a third limb vector.
+ *
+ * Copyright © 2013 Jussi Kivilinna <jussi.kivilinna@iki.fi>
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_add_n( mpi_ptr_t res_ptr, x0
+ * mpi_ptr_t s1_ptr, x1
+ * mpi_ptr_t s2_ptr, x2
+ * mpi_size_t size) x3
+ */
+
+.text
+
+.globl _gcry_mpih_add_n
+.type _gcry_mpih_add_n,%function
+_gcry_mpih_add_n:
+ and x5, x3, #3;
+ adds xzr, xzr, xzr; /* clear carry flag */
+
+ cbz x5, .Large_loop;
+
+.Loop:
+ ldr x4, [x1], #8;
+ sub x3, x3, #1;
+ ldr x11, [x2], #8;
+ and x5, x3, #3;
+ adcs x4, x4, x11;
+ str x4, [x0], #8;
+ cbz x3, .Lend;
+ cbnz x5, .Loop;
+
+.Large_loop:
+ ldp x4, x6, [x1], #16;
+ ldp x5, x7, [x2], #16;
+ ldp x8, x10, [x1], #16;
+ ldp x9, x11, [x2], #16;
+ sub x3, x3, #4;
+ adcs x4, x4, x5;
+ adcs x6, x6, x7;
+ adcs x8, x8, x9;
+ adcs x10, x10, x11;
+ stp x4, x6, [x0], #16;
+ stp x8, x10, [x0], #16;
+ cbnz x3, .Large_loop;
+
+.Lend:
+ adc x0, xzr, xzr;
+ ret;
+.size _gcry_mpih_add_n,.-_gcry_mpih_add_n;