1dnl  ARM64 mpn_com.
2
3dnl  Copyright 2013, 2014 Free Software Foundation, Inc.
4
5dnl  This file is part of the GNU MP Library.
6dnl
7dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8dnl  it under the terms of either:
9dnl
10dnl    * the GNU Lesser General Public License as published by the Free
11dnl      Software Foundation; either version 3 of the License, or (at your
12dnl      option) any later version.
13dnl
14dnl  or
15dnl
16dnl    * the GNU General Public License as published by the Free Software
17dnl      Foundation; either version 2 of the License, or (at your option) any
18dnl      later version.
19dnl
20dnl  or both in parallel, as here.
21dnl
22dnl  The GNU MP Library is distributed in the hope that it will be useful, but
23dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25dnl  for more details.
26dnl
27dnl  You should have received copies of the GNU General Public License and the
28dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
29dnl  see https://www.gnu.org/licenses/.
30
31include(`../config.m4')
32
33C	     cycles/limb
34C Cortex-A53	 2.25
35C Cortex-A57	 1.25
36C X-Gene	 1.75
37
38changecom(blah)
39
40define(`rp', `x0')
41define(`up', `x1')
42define(`n',  `x2')
43
44ASM_START()
45PROLOGUE(mpn_com)
46	cmp	n, #3
47	b.le	L(bc)
48
49C Copy until rp is 128-bit aligned
50	tbz	rp, #3, L(al2)
51	ld1	{v22.1d}, [up], #8
52	sub	n, n, #1
53	mvn	v22.8b, v22.8b
54	st1	{v22.1d}, [rp], #8
55
56L(al2):	ld1	{v26.2d}, [up], #16
57	subs	n, n, #6
58	b.lt	L(end)
59
60	ALIGN(16)
61L(top):	ld1	{v22.2d}, [up], #16
62	mvn	v26.16b, v26.16b
63	st1	{v26.2d}, [rp], #16
64	ld1	{v26.2d}, [up], #16
65	mvn	v22.16b, v22.16b
66	st1	{v22.2d}, [rp], #16
67	subs	n, n, #4
68	b.ge	L(top)
69
70L(end):	mvn	v26.16b, v26.16b
71	st1	{v26.2d}, [rp], #16
72
73C Copy last 0-3 limbs.  Note that rp is aligned after loop, but not when we
74C arrive here via L(bc)
75L(bc):	tbz	n, #1, L(tl1)
76	ld1	{v22.2d}, [up], #16
77	mvn	v22.16b, v22.16b
78	st1	{v22.2d}, [rp], #16
79L(tl1):	tbz	n, #0, L(tl2)
80	ld1	{v22.1d}, [up]
81	mvn	v22.8b, v22.8b
82	st1	{v22.1d}, [rp]
83L(tl2):	ret
84EPILOGUE()
85