1 dnl ARM mpn_addlsh1_n
and mpn_sublsh1_n
3 dnl Contributed to the GNU project by Torbjörn Granlund.
5 dnl Copyright
2012 Free Software Foundation
, Inc.
7 dnl
This file is part of the GNU MP Library.
9 dnl The GNU MP Library is free software
; you can redistribute it and/or modify
10 dnl it under the terms of
either:
12 dnl
* the GNU Lesser General
Public License as published by the Free
13 dnl Software Foundation
; either version 3 of the License, or (at your
14 dnl option
) any later version.
18 dnl
* the GNU General
Public License as published by the Free Software
19 dnl Foundation
; either version 2 of the License, or (at your option) any
22 dnl
or both
in parallel
, as here.
24 dnl The GNU MP Library is distributed
in the hope that it will be useful
, but
25 dnl WITHOUT ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY
26 dnl
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License
29 dnl You should have received copies of the GNU General
Public License
and the
30 dnl GNU Lesser General
Public License along with the GNU MP Library. If
not,
31 dnl see
https://www.gnu.
org/licenses
/.
33 include(`..
/config.m4
')
36 C cycles/limb cycles/limb
45 C * The addlsh1_n code runs well, but is only barely faster than mpn_addmul_1.
46 C The sublsh1_n code could surely be tweaked, its REVCY slows down things
47 C very much. If two insns are really needed, it might help to separate them
48 C for better micro-parallelism.
55 ifdef(`OPERATION_addlsh1_n', `
56 define
(`ADDSUB
', adds)
57 define(`ADDSUBC', adcs
)
58 define
(`SETCY
', `cmp $1, #1')
59 define
(`RETVAL
', `adc r0, $1, #2')
60 define
(`SAVECY
', `sbc $1, $2, #0')
61 define
(`RESTCY
', `cmn $1, #1')
63 define
(`INICYR
', `mov $1, #0')
64 define
(`r10r11
', `r11')
65 define
(`func
', mpn_addlsh1_n)
66 define(`func_nc', mpn_addlsh1_nc
)')
67 ifdef(`OPERATION_sublsh1_n', `
68 define
(`ADDSUB
', subs)
69 define(`ADDSUBC', sbcs
)
70 define
(`SETCY
', `rsbs $1, $1, #0')
71 define
(`RETVAL
', `adc r0, $1, #1')
72 define
(`SAVECY
', `sbc $1, $1, $1')
73 define
(`RESTCY
', `cmn $1, #1')
74 define
(`REVCY
', `sbc $1, $1, $1
76 define
(`INICYR
', `mvn $1, #0')
77 define
(`r10r11
', `r10')
78 define
(`func
', mpn_sublsh1_n)
79 define(`func_nc', mpn_sublsh1_nc
)')
81 MULFUNC_PROLOGUE(mpn_addlsh1_n mpn_sublsh1_n)
87 ifdef(`OPERATION_addlsh1_n', `
92 blt L(le2) C carry clear on branch path
94 cmn r0, #0 C clear carry
95 ldmia vp!, {r8, r9, r10}
102 ldmia vp!, {r8, r9, r10}
103 stmia rp!, {r4, r5, r6}
108 ldmia up!, {r4, r5, r6}
116 ldmia vp!, {r8, r9, r10}
117 stmia rp!, {r4, r5, r6}
119 L(mid): adcs r8, r8, r8
122 ldmia up!, {r4, r5, r6}
127 mov r7, r12 C swap alternating...
128 mov r12, r14 C ...carry-save...
129 mov r14, r7 C ...registers
135 stmia rp!, {r4, r5, r6}
138 L(le2): tst n, #1 C n = {-1,-2,-3} map to [2], [1], [0]