xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/arm/lshift.asm (revision f89f6560d453f5e37386cc7938c072d2f528b9fa)
1dnl  ARM mpn_lshift.
2
3dnl  Contributed to the GNU project by Torbjorn Granlund.
4
5dnl  Copyright 2012 Free Software Foundation, Inc.
6
7dnl  This file is part of the GNU MP Library.
8
9dnl  The GNU MP Library is free software; you can redistribute it and/or modify
10dnl  it under the terms of the GNU Lesser General Public License as published
11dnl  by the Free Software Foundation; either version 3 of the License, or (at
12dnl  your option) any later version.
13
14dnl  The GNU MP Library is distributed in the hope that it will be useful, but
15dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
17dnl  License for more details.
18
19dnl  You should have received a copy of the GNU Lesser General Public License
20dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
21
22include(`../config.m4')
23
24C	     cycles/limb
25C StrongARM	 ?
26C XScale	 ?
27C Cortex-A8	 ?
28C Cortex-A9	 3.5
29C Cortex-A15	 ?
30
31define(`rp',  `r0')
32define(`up',  `r1')
33define(`n',   `r2')
34define(`cnt', `r3')
35define(`tnc', `r12')
36
37ASM_START()
38PROLOGUE(mpn_lshift)
39	add	up, up, n, lsl #2
40	push	{r4, r6, r7, r8}
41	ldr	r4, [up, #-4]!
42	add	rp, rp, n, lsl #2
43	rsb	tnc, cnt, #32
44
45	lsl	r7, r4, cnt
46	tst	n, #1
47	beq	L(evn)			C n even
48
49L(odd):	subs	n, n, #2
50	bcc	L(1)			C n = 1
51	ldr	r8, [up, #-4]!
52	b	L(mid)
53
54L(evn):	ldr	r6, [up, #-4]!
55	subs	n, n, #2
56	beq	L(end)
57
58L(top):	ldr	r8, [up, #-4]!
59	orr	r7, r7, r6, lsr tnc
60	str	r7, [rp, #-4]!
61	lsl	r7, r6, cnt
62L(mid):	ldr	r6, [up, #-4]!
63	orr	r7, r7, r8, lsr tnc
64	str	r7, [rp, #-4]!
65	lsl	r7, r8, cnt
66	subs	n, n, #2
67	bgt	L(top)
68
69L(end):	orr	r7, r7, r6, lsr tnc
70	str	r7, [rp, #-4]!
71	lsl	r7, r6, cnt
72L(1):	str	r7, [rp, #-4]
73	lsr	r0, r4, tnc
74	pop	{r4, r6, r7, r8}
75ifdef(`ARM_THUMB_MODE',
76`	bx	r14
77',`	mov	pc, r14
78')
79EPILOGUE()
80