Upload Tizen:Base source
[external/gmp.git] / mpn / arm / addmul_1.asm
1 dnl  ARM mpn_addmul_1 -- Multiply a limb vector with a limb and add the result
2 dnl  to a second limb vector.
3
4 dnl  Copyright 1998, 2000, 2001, 2003 Free Software Foundation, Inc.
5
6 dnl  This file is part of the GNU MP Library.
7
8 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9 dnl  it under the terms of the GNU Lesser General Public License as published
10 dnl  by the Free Software Foundation; either version 3 of the License, or (at
11 dnl  your option) any later version.
12
13 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
14 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 dnl  License for more details.
17
18 dnl  You should have received a copy of the GNU Lesser General Public License
19 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
20
21 include(`../config.m4')
22
23 C            cycles/limb
24 C StrongARM:  7.75-9.75  (dependent on vl value)
25 C XScale:        8-9     (dependent on vl value, estimated)
26
27 define(`rp',`r0')
28 define(`up',`r1')
29 define(`n',`r2')
30 define(`vl',`r3')
31 define(`rl',`r12')
32 define(`ul',`r6')
33 define(`r',`lr')
34
35
36 ASM_START()
37 PROLOGUE(mpn_addmul_1)
38         stmfd   sp!, { r4-r6, lr }
39         mov     r4, #0                  C clear r4
40         adds    r0, r0, #0              C clear cy
41         tst     n, #1
42         beq     L(skip1)
43         ldr     ul, [up], #4
44         ldr     rl, [rp, #0]
45         umull   r5, r4, ul, vl
46         adds    r, rl, r5
47         str     r, [rp], #4
48 L(skip1):
49         tst     n, #2
50         beq     L(skip2)
51         ldr     ul, [up], #4
52         ldr     rl, [rp, #0]
53         mov     r5, #0
54         umlal   r4, r5, ul, vl
55         ldr     ul, [up], #4
56         adcs    r, rl, r4
57         ldr     rl, [rp, #4]
58         mov     r4, #0
59         umlal   r5, r4, ul, vl
60         str     r, [rp], #4
61         adcs    r, rl, r5
62         str     r, [rp], #4
63 L(skip2):
64         bics    r, n, #3
65         beq     L(return)
66
67         ldr     ul, [up], #4
68         ldr     rl, [rp, #0]
69         mov     r5, #0
70         umlal   r4, r5, ul, vl
71         b       L(in)
72
73 L(loop):
74         ldr     ul, [up], #4
75         adcs    r, rl, r5
76         ldr     rl, [rp, #4]
77         mov     r5, #0
78         umlal   r4, r5, ul, vl
79         str     r, [rp], #4
80 L(in):  ldr     ul, [up], #4
81         adcs    r, rl, r4
82         ldr     rl, [rp, #4]
83         mov     r4, #0
84         umlal   r5, r4, ul, vl
85         str     r, [rp], #4
86         ldr     ul, [up], #4
87         adcs    r, rl, r5
88         ldr     rl, [rp, #4]
89         mov     r5, #0
90         umlal   r4, r5, ul, vl
91         str     r, [rp], #4
92         ldr     ul, [up], #4
93         adcs    r, rl, r4
94         ldr     rl, [rp, #4]
95         mov     r4, #0
96         umlal   r5, r4, ul, vl
97         str     r, [rp], #4
98         sub     n, n, #4
99         bics    r, n, #3
100         bne     L(loop)
101
102         adcs    r, rl, r5
103         str     r, [rp], #4
104 L(return):
105         adc     r0, r4, #0
106         ldmfd   sp!, { r4-r6, pc }
107 EPILOGUE(mpn_addmul_1)