xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/arm/mul_1.asm (revision d909946ca08dceb44d7d0f22ec9488679695d976)
1dnl  ARM mpn_mul_1 -- Multiply a limb vector with a limb and store the result
2dnl  in a second limb vector.
3dnl  Contributed by Robert Harley.
4
5dnl  Copyright 1998, 2000, 2001, 2003, 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	6-8
26C XScale	 ?
27C Cortex-A8	 ?
28C Cortex-A9	 4.75
29C Cortex-A15	 ?
30
31C We should rewrite this along the lines of addmul_1.asm.  That should save a
32C cycle on StrongARM, and several cycles on XScale.
33
34define(`rp',`r0')
35define(`up',`r1')
36define(`n',`r2')
37define(`vl',`r3')
38
39
40ASM_START()
41PROLOGUE(mpn_mul_1)
42	stmfd	sp!, { r8, r9, lr }
43	ands	r12, n, #1
44	beq	L(skip1)
45	ldr	lr, [up], #4
46	umull	r9, r12, lr, vl
47	str	r9, [rp], #4
48L(skip1):
49	tst	n, #2
50	beq	L(skip2)
51	mov	r8, r12
52	ldmia	up!, { r12, lr }
53	mov	r9, #0
54	umlal	r8, r9, r12, vl
55	mov	r12, #0
56	umlal	r9, r12, lr, vl
57	stmia	rp!, { r8, r9 }
58L(skip2):
59	bics	n, n, #3
60	beq	L(rtn)
61	stmfd	sp!, { r6, r7 }
62
63L(top):	mov	r6, r12
64	ldmia	up!, { r8, r9, r12, lr }
65	ldr	r7, [rp, #12]			C cache allocate
66	mov	r7, #0
67	umlal	r6, r7, r8, vl
68	mov	r8, #0
69	umlal	r7, r8, r9, vl
70	mov	r9, #0
71	umlal	r8, r9, r12, vl
72	mov	r12, #0
73	umlal	r9, r12, lr, vl
74	subs	n, n, #4
75	stmia	rp!, { r6, r7, r8, r9 }
76	bne	L(top)
77
78	ldmfd	sp!, { r6, r7 }
79
80L(rtn):	mov	r0, r12
81	ldmfd	sp!, { r8, r9, pc }
82EPILOGUE()
83