Upload Tizen:Base source
[external/gmp.git] / mpn / arm / mul_1.asm
1 dnl  ARM mpn_mul_1 -- Multiply a limb vector with a limb and store the result
2 dnl  in a second limb vector.
3 dnl  Contributed by Robert Harley.
4
5 dnl  Copyright 1998, 2000, 2001, 2003 Free Software Foundation, Inc.
6
7 dnl  This file is part of the GNU MP Library.
8
9 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
10 dnl  it under the terms of the GNU Lesser General Public License as published
11 dnl  by the Free Software Foundation; either version 3 of the License, or (at
12 dnl  your option) any later version.
13
14 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
15 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
17 dnl  License for more details.
18
19 dnl  You should have received a copy of the GNU Lesser General Public License
20 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
21
22 include(`../config.m4')
23
24 C            cycles/limb
25 C StrongARM:     6-8  (dependent on vl value)
26 C XScale:        ?-?
27
28 C We should rewrite this along the lines of addmul_1.asm.  That should save a
29 C cycle on StrongARM, and several cycles on XScale.
30
31 define(`rp',`r0')
32 define(`up',`r1')
33 define(`n',`r2')
34 define(`vl',`r3')
35
36
37 ASM_START()
38 PROLOGUE(mpn_mul_1)
39         stmfd   sp!, { r8, r9, lr }
40         ands    r12, n, #1
41         beq     L(skip1)
42         ldr     lr, [up], #4
43         umull   r9, r12, lr, vl
44         str     r9, [rp], #4
45 L(skip1):
46         tst     n, #2
47         beq     L(skip2)
48         mov     r8, r12
49         ldmia   up!, { r12, lr }
50         mov     r9, #0
51         umlal   r8, r9, r12, vl
52         mov     r12, #0
53         umlal   r9, r12, lr, vl
54         stmia   rp!, { r8, r9 }
55 L(skip2):
56         bics    n, n, #3
57         beq     L(return)
58         stmfd   sp!, { r6, r7 }
59 L(loop):
60         mov     r6, r12
61         ldmia   up!, { r8, r9, r12, lr }
62         ldr     r7, [rp, #12]                   C cache allocate
63         mov     r7, #0
64         umlal   r6, r7, r8, vl
65         mov     r8, #0
66         umlal   r7, r8, r9, vl
67         mov     r9, #0
68         umlal   r8, r9, r12, vl
69         mov     r12, #0
70         umlal   r9, r12, lr, vl
71         subs    n, n, #4
72         stmia   rp!, { r6, r7, r8, r9 }
73         bne     L(loop)
74         ldmfd   sp!, { r6, r7 }
75 L(return):
76         mov     r0, r12
77         ldmfd   sp!, { r8, r9, pc }
78 EPILOGUE(mpn_mul_1)