Debian Codegraph @

gmp4/mpn/arm/v7a/cora15/addmul_1.asm

raw
1 dnl ARM mpn_addmul_1 optimised for A15.
2
3 dnl Copyright 2012, 2013 Free Software Foundation, Inc.
4
5 dnl This file is part of the GNU MP Library.
6 dnl
7 dnl The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl it under the terms of either:
9 dnl
10 dnl * the GNU Lesser General Public License as published by the Free
11 dnl Software Foundation; either version 3 of the License, or (at your
12 dnl option) any later version.
13 dnl
14 dnl or
15 dnl
16 dnl * the GNU General Public License as published by the Free Software
17 dnl Foundation; either version 2 of the License, or (at your option) any
18 dnl later version.
19 dnl
20 dnl or both in parallel, as here.
21 dnl
22 dnl The GNU MP Library is distributed in the hope that it will be useful, but
23 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 dnl for more details.
26 dnl
27 dnl You should have received copies of the GNU General Public License and the
28 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
29 dnl see https://www.gnu.org/licenses/.
30
31 include(`../config.m4')
32
33 C cycles/limb best
34 C StrongARM: -
35 C XScale ?
36 C Cortex-A7 ?
37 C Cortex-A8 ?
38 C Cortex-A9 6 3.25
39 C Cortex-A15 2 this
40
41 C This code uses umlal for adding in the rp[] data, keeping the recurrency path
42 C separate from any multiply instructions. It performs well on A15, at umlal's
43 C bandwidth.
44 C
45 C An A9 variant should perhaps stick to 3-way unrolling, and use ldm and stm
46 C for all loads and stores. Alternatively, it could do 2-way or 4-way, but
47 C then alignment aware code will be necessary (adding O(1) bookkeeping
48 C overhead).
49 C
50 C We don't use r12 due to ldrd and strd limitations.
51
52 C Architecture requirements:
53 C v5 -
54 C v5t -
55 C v5te ldrd strd
56 C v6 -
57 C v6t2 -
58 C v7a -
59
60 define(`rp', `r0')
61 define(`up', `r1')
62 define(`n', `r2')
63 define(`v0', `r3')
64
65 define(`w0', `r10') define(`w1', `r11')
66 define(`u0', `r8') define(`u1', `r9')
67
68 ASM_START()
69 PROLOGUE(mpn_addmul_1)
70 push { r4-r11 }
71
72 ands r6, n, #3
73 sub n, n, #3
74 beq L(b00)
75 cmp r6, #2
76 bcc L(b01)
77 beq L(b10)
78
79 L(b11): mov r6, #0
80 cmn r13, #0 C carry clear
81 ldr u1, [up], #-4
82 ldr w1, [rp], #-4
83 mov r7, #0
84 b L(mid)
85
86 L(b00): ldrd u0, u1, [up]
87 ldrd w0, w1, [rp]
88 mov r6, #0
89 umlal w0, r6, u0, v0
90 cmn r13, #0 C carry clear
91 mov r7, #0
92 str w0, [rp]
93 b L(mid)
94
95 L(b10): ldrd u0, u1, [up], #8
96 ldrd w0, w1, [rp]
97 mov r4, #0
98 umlal w0, r4, u0, v0
99 cmn r13, #0 C carry clear
100 mov r5, #0
101 str w0, [rp], #8
102 umlal w1, r5, u1, v0
103 tst n, n
104 bmi L(end)
105 b L(top)
106
107 L(b01): mov r4, #0
108 ldr u1, [up], #4
109 ldr w1, [rp], #4
110 mov r5, #0
111 umlal w1, r5, u1, v0
112 tst n, n
113 bmi L(end)
114
115 ALIGN(16)
116 L(top): ldrd u0, u1, [up, #0]
117 adcs r4, r4, w1
118 ldrd w0, w1, [rp, #0]
119 mov r6, #0
120 umlal w0, r6, u0, v0 C 1 2
121 adcs r5, r5, w0
122 mov r7, #0
123 strd r4, r5, [rp, #-4]
124 L(mid): umlal w1, r7, u1, v0 C 2 3
125 ldrd u0, u1, [up, #8]
126 adcs r6, r6, w1
127 ldrd w0, w1, [rp, #8]
128 mov r4, #0
129 umlal w0, r4, u0, v0 C 3 4
130 adcs r7, r7, w0
131 mov r5, #0
132 strd r6, r7, [rp, #4]
133 umlal w1, r5, u1, v0 C 0 1
134 sub n, n, #4
135 add up, up, #16
136 add rp, rp, #16
137 tst n, n
138 bpl L(top)
139
140 L(end): adcs r4, r4, w1
141 str r4, [rp, #-4]
142 adc r0, r5, #0
143 pop { r4-r11 }
144 bx r14
145 EPILOGUE()