1dnl  ARM64 mpn_and_n, mpn_andn_n. mpn_nand_n, etc.
2
3dnl  Contributed to the GNU project by Torbj��rn Granlund.
4
5dnl  Copyright 2013 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     cycles/limb
36C	      nand,nior	      all other
37C Cortex-A53	3.25-3.5	2.75-3
38C Cortex-A57	 2.0		 1.5
39C X-Gene	 2.14		 2.0
40
41changecom(blah)
42
43define(`rp', `x0')
44define(`up', `x1')
45define(`vp', `x2')
46define(`n',  `x3')
47
48define(`POSTOP', `dnl')
49
50ifdef(`OPERATION_and_n',`
51  define(`func',    `mpn_and_n')
52  define(`LOGOP',   `and	$1, $2, $3')')
53ifdef(`OPERATION_andn_n',`
54  define(`func',    `mpn_andn_n')
55  define(`LOGOP',   `bic	$1, $2, $3')')
56ifdef(`OPERATION_nand_n',`
57  define(`func',    `mpn_nand_n')
58  define(`POSTOP',  `mvn	$1, $1')
59  define(`LOGOP',   `and	$1, $2, $3')')
60ifdef(`OPERATION_ior_n',`
61  define(`func',    `mpn_ior_n')
62  define(`LOGOP',   `orr	$1, $2, $3')')
63ifdef(`OPERATION_iorn_n',`
64  define(`func',    `mpn_iorn_n')
65  define(`LOGOP',   `orn	$1, $2, $3')')
66ifdef(`OPERATION_nior_n',`
67  define(`func',    `mpn_nior_n')
68  define(`POSTOP',  `mvn	$1, $1')
69  define(`LOGOP',   `orr	$1, $2, $3')')
70ifdef(`OPERATION_xor_n',`
71  define(`func',    `mpn_xor_n')
72  define(`LOGOP',   `eor	$1, $2, $3')')
73ifdef(`OPERATION_xnor_n',`
74  define(`func',    `mpn_xnor_n')
75  define(`LOGOP',   `eon	$1, $2, $3')')
76
77MULFUNC_PROLOGUE(mpn_and_n mpn_andn_n mpn_nand_n mpn_ior_n mpn_iorn_n mpn_nior_n mpn_xor_n mpn_xnor_n)
78
79ASM_START()
80PROLOGUE(func)
81	lsr	x18, n, #2
82	tbz	n, #0, L(bx0)
83
84L(bx1):	ldr	x7, [up]
85	ldr	x11, [vp]
86	LOGOP(	x15, x7, x11)
87	POSTOP(	x15)
88	str	x15, [rp],#8
89	tbnz	n, #1, L(b11)
90
91L(b01):	cbz	x18, L(ret)
92	ldp	x4, x5, [up,#8]
93	ldp	x8, x9, [vp,#8]
94	sub	up, up, #8
95	sub	vp, vp, #8
96	b	L(mid)
97
98L(b11):	ldp	x6, x7, [up,#8]
99	ldp	x10, x11, [vp,#8]
100	add	up, up, #8
101	add	vp, vp, #8
102	cbz	x18, L(end)
103	b	L(top)
104
105L(bx0):	tbnz	n, #1, L(b10)
106
107L(b00):	ldp	x4, x5, [up],#-16
108	ldp	x8, x9, [vp],#-16
109	b	L(mid)
110
111L(b10):	ldp	x6, x7, [up]
112	ldp	x10, x11, [vp]
113	cbz	x18, L(end)
114
115	ALIGN(16)
116L(top):	ldp	x4, x5, [up,#16]
117	ldp	x8, x9, [vp,#16]
118	LOGOP(	x12, x6, x10)
119	LOGOP(	x13, x7, x11)
120	POSTOP(	x12)
121	POSTOP(	x13)
122	stp	x12, x13, [rp],#16
123L(mid):	ldp	x6, x7, [up,#32]!
124	ldp	x10, x11, [vp,#32]!
125	LOGOP(	x12, x4, x8)
126	LOGOP(	x13, x5, x9)
127	POSTOP(	x12)
128	POSTOP(	x13)
129	stp	x12, x13, [rp],#16
130	sub	x18, x18, #1
131	cbnz	x18, L(top)
132
133L(end):	LOGOP(	x12, x6, x10)
134	LOGOP(	x13, x7, x11)
135	POSTOP(	x12)
136	POSTOP(	x13)
137	stp	x12, x13, [rp]
138L(ret):	ret
139EPILOGUE()
140