xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/arm64/aors_n.asm (revision 122b5006ee1bd67145794b4cde92f4fe4781a5ec)
1dnl  ARM64 mpn_add_n and mpn_sub_n
2
3dnl  Contributed to the GNU project by Torbjörn Granlund.
4
5dnl  Copyright 2013, 2017 Free Software Foundation, Inc.
6
7dnl  This file is part of the GNU MP Library.
8dnl
9dnl  The GNU MP Library is free software; you can redistribute it and/or modify
10dnl  it under the terms of either:
11dnl
12dnl    * the GNU Lesser General Public License as published by the Free
13dnl      Software Foundation; either version 3 of the License, or (at your
14dnl      option) any later version.
15dnl
16dnl  or
17dnl
18dnl    * the GNU General Public License as published by the Free Software
19dnl      Foundation; either version 2 of the License, or (at your option) any
20dnl      later version.
21dnl
22dnl  or both in parallel, as here.
23dnl
24dnl  The GNU MP Library is distributed in the hope that it will be useful, but
25dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
27dnl  for more details.
28dnl
29dnl  You should have received copies of the GNU General Public License and the
30dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
31dnl  see https://www.gnu.org/licenses/.
32
33include(`../config.m4')
34
35C	     cycles/limb
36C Cortex-A53	2.75-3.25
37C Cortex-A57	 1.5
38C X-Gene	 2.0
39
40changecom(blah)
41
42define(`rp', `x0')
43define(`up', `x1')
44define(`vp', `x2')
45define(`n',  `x3')
46
47ifdef(`OPERATION_add_n', `
48  define(`ADDSUBC',	adcs)
49  define(`CLRCY',	`cmn	xzr, xzr')
50  define(`SETCY',	`cmp	$1, #1')
51  define(`RETVAL',	`cset	x0, cs')
52  define(`func_n',	mpn_add_n)
53  define(`func_nc',	mpn_add_nc)')
54ifdef(`OPERATION_sub_n', `
55  define(`ADDSUBC',	sbcs)
56  define(`CLRCY',	`cmp	xzr, xzr')
57  define(`SETCY',	`cmp	xzr, $1')
58  define(`RETVAL',	`cset	x0, cc')
59  define(`func_n',	mpn_sub_n)
60  define(`func_nc',	mpn_sub_nc)')
61
62MULFUNC_PROLOGUE(mpn_add_n mpn_add_nc mpn_sub_n mpn_sub_nc)
63
64ASM_START()
65PROLOGUE(func_nc)
66	SETCY(	x4)
67	b	L(ent)
68EPILOGUE()
69PROLOGUE(func_n)
70	CLRCY
71L(ent):	lsr	x18, n, #2
72	tbz	n, #0, L(bx0)
73
74L(bx1):	ldr	x7, [up]
75	ldr	x11, [vp]
76	ADDSUBC	x13, x7, x11
77	str	x13, [rp],#8
78	tbnz	n, #1, L(b11)
79
80L(b01):	cbz	x18, L(ret)
81	ldp	x4, x5, [up,#8]
82	ldp	x8, x9, [vp,#8]
83	sub	up, up, #8
84	sub	vp, vp, #8
85	b	L(mid)
86
87L(b11):	ldp	x6, x7, [up,#8]
88	ldp	x10, x11, [vp,#8]
89	add	up, up, #8
90	add	vp, vp, #8
91	cbz	x18, L(end)
92	b	L(top)
93
94L(bx0):	tbnz	n, #1, L(b10)
95
96L(b00):	ldp	x4, x5, [up]
97	ldp	x8, x9, [vp]
98	sub	up, up, #16
99	sub	vp, vp, #16
100	b	L(mid)
101
102L(b10):	ldp	x6, x7, [up]
103	ldp	x10, x11, [vp]
104	cbz	x18, L(end)
105
106	ALIGN(16)
107L(top):	ldp	x4, x5, [up,#16]
108	ldp	x8, x9, [vp,#16]
109	ADDSUBC	x12, x6, x10
110	ADDSUBC	x13, x7, x11
111	stp	x12, x13, [rp],#16
112L(mid):	ldp	x6, x7, [up,#32]!
113	ldp	x10, x11, [vp,#32]!
114	ADDSUBC	x12, x4, x8
115	ADDSUBC	x13, x5, x9
116	stp	x12, x13, [rp],#16
117	sub	x18, x18, #1
118	cbnz	x18, L(top)
119
120L(end):	ADDSUBC	x12, x6, x10
121	ADDSUBC	x13, x7, x11
122	stp	x12, x13, [rp]
123L(ret):	RETVAL
124	ret
125EPILOGUE()
126