addmul_1.asm revision 1.1.1.2
1dnl  ARM mpn_addmul_1.
2
3dnl  Copyright 2012 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 StrongARM:	 -
35C XScale	 -
36C ARM11		 6.4
37C Cortex-A7	 5.25
38C Cortex-A8	 7
39C Cortex-A9	 3.25
40C Cortex-A15	 4
41
42C TODO
43C  * Micro-optimise feed-in code.
44C  * Optimise for n=1,2 by delaying register saving.
45C  * Try using ldm/stm.
46
47define(`rp',`r0')
48define(`up',`r1')
49define(`n', `r2')
50define(`v0',`r3')
51
52ASM_START()
53PROLOGUE(mpn_addmul_1)
54	stmfd	sp!, { r4, r5, r6, r7 }
55
56	ands	r6, n, #3
57	mov	r12, #0
58	beq	L(fi0)
59	cmp	r6, #2
60	bcc	L(fi1)
61	beq	L(fi2)
62
63L(fi3):	ldr	r4, [up], #4
64	ldr	r6, [rp, #0]
65	ldr	r5, [up], #4
66	b	L(lo3)
67
68L(fi0):	ldr	r5, [up], #4
69	ldr	r7, [rp], #4
70	ldr	r4, [up], #4
71	b	L(lo0)
72
73L(fi1):	ldr	r4, [up], #4
74	ldr	r6, [rp], #8
75	subs	n, n, #1
76	beq	L(1)
77	ldr	r5, [up], #4
78	b	L(lo1)
79
80L(fi2):	ldr	r5, [up], #4
81	ldr	r7, [rp], #12
82	ldr	r4, [up], #4
83	b	L(lo2)
84
85	ALIGN(16)
86L(top):	ldr	r6, [rp, #-8]
87	ldr	r5, [up], #4
88	str	r7, [rp, #-12]
89L(lo1):	umaal	r6, r12, r4, v0
90	ldr	r7, [rp, #-4]
91	ldr	r4, [up], #4
92	str	r6, [rp, #-8]
93L(lo0):	umaal	r7, r12, r5, v0
94	ldr	r6, [rp, #0]
95	ldr	r5, [up], #4
96	str	r7, [rp, #-4]
97L(lo3):	umaal	r6, r12, r4, v0
98	ldr	r7, [rp, #4]
99	ldr	r4, [up], #4
100	str	r6, [rp], #16
101L(lo2):	umaal	r7, r12, r5, v0
102	subs	n, n, #4
103	bhi	L(top)
104
105	ldr	r6, [rp, #-8]
106	str	r7, [rp, #-12]
107L(1):	umaal	r6, r12, r4, v0
108	str	r6, [rp, #-8]
109	mov	r0, r12
110	ldmfd	sp!, { r4, r5, r6, r7 }
111	bx	lr
112EPILOGUE()
113