xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/arm/logops_n.asm (revision d90047b5d07facf36e6c01dcc0bded8997ce9cc2)
1dnl  ARM mpn_and_n, mpn_andn_n. mpn_nand_n, etc.
2
3dnl  Contributed to the GNU project by Torbjörn Granlund.
4
5dnl  Copyright 1997, 2000, 2001, 2012 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          and andn ior xor         nand iorn nior xnor
37C StrongARM	 ?			 ?
38C XScale	 ?			 ?
39C Cortex-A7	 ?			 ?
40C Cortex-A8	 ?			 ?
41C Cortex-A9	2.5-2.72		2.75-3
42C Cortex-A15	2.25			2.75
43
44C TODO
45C  * It seems that 2.25 c/l and 2.75 c/l is possible for A9.
46C  * Debug popping issue, see comment below.
47
48define(`rp', `r0')
49define(`up', `r1')
50define(`vp', `r2')
51define(`n',  `r3')
52
53define(`POSTOP')
54
55ifdef(`OPERATION_and_n',`
56  define(`func',    `mpn_and_n')
57  define(`LOGOP',   `and	$1, $2, $3')')
58ifdef(`OPERATION_andn_n',`
59  define(`func',    `mpn_andn_n')
60  define(`LOGOP',   `bic	$1, $2, $3')')
61ifdef(`OPERATION_nand_n',`
62  define(`func',    `mpn_nand_n')
63  define(`POSTOP',  `mvn	$1, $1')
64  define(`LOGOP',   `and	$1, $2, $3')')
65ifdef(`OPERATION_ior_n',`
66  define(`func',    `mpn_ior_n')
67  define(`LOGOP',   `orr	$1, $2, $3')')
68ifdef(`OPERATION_iorn_n',`
69  define(`func',    `mpn_iorn_n')
70  define(`POSTOP',  `mvn	$1, $1')
71  define(`LOGOP',   `bic	$1, $3, $2')')
72ifdef(`OPERATION_nior_n',`
73  define(`func',    `mpn_nior_n')
74  define(`POSTOP',  `mvn	$1, $1')
75  define(`LOGOP',   `orr	$1, $2, $3')')
76ifdef(`OPERATION_xor_n',`
77  define(`func',    `mpn_xor_n')
78  define(`LOGOP',   `eor	$1, $2, $3')')
79ifdef(`OPERATION_xnor_n',`
80  define(`func',    `mpn_xnor_n')
81  define(`POSTOP',  `mvn	$1, $1')
82  define(`LOGOP',   `eor	$1, $2, $3')')
83
84MULFUNC_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)
85
86ASM_START()
87PROLOGUE(func)
88	push	{ r8, r9, r10 }
89	tst	n, #1
90	beq	L(skip1)
91	ldr	r10, [vp], #4
92	ldr	r12, [up], #4
93	LOGOP(	r12, r12, r10)
94	POSTOP(	r12)
95	str	r12, [rp], #4
96L(skip1):
97	tst	n, #2
98	beq	L(skip2)
99	ldmia	vp!, { r10, r12 }
100	ldmia	up!, { r8, r9 }
101	LOGOP(	r8, r8, r10)
102	LOGOP(	r9, r9, r12)
103	POSTOP(	r8)
104	POSTOP(	r9)
105	stmia	rp!, { r8, r9 }
106L(skip2):
107	bics	n, n, #3
108	beq	L(rtn)
109	push	{ r4, r5, r6, r7 }
110
111	ldmia	vp!, { r8, r9, r10, r12 }
112	b	L(mid)
113
114L(top):	ldmia	vp!, { r8, r9, r10, r12 }
115	POSTOP(	r4)
116	POSTOP(	r5)
117	POSTOP(	r6)
118	POSTOP(	r7)
119	stmia	rp!, { r4, r5, r6, r7 }
120L(mid):	sub	n, n, #4
121	ldmia	up!, { r4, r5, r6, r7 }
122	teq	n, #0
123	LOGOP(	r4, r4, r8)
124	LOGOP(	r5, r5, r9)
125	LOGOP(	r6, r6, r10)
126	LOGOP(	r7, r7, r12)
127	bne	L(top)
128
129	POSTOP(	r4)
130	POSTOP(	r5)
131	POSTOP(	r6)
132	POSTOP(	r7)
133	stmia	rp!, { r4, r5, r6, r7 }
134
135	pop	{ r4, r5, r6, r7 }	C popping r8-r10 here strangely fails
136
137L(rtn):	pop	{ r8, r9, r10 }
138	ret	r14
139EPILOGUE()
140