summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2008-10-03 09:33:36 +0000
committerJens Arnold <amiconn@rockbox.org>2008-10-03 09:33:36 +0000
commit46bf6bd49301cdfe254253725b7a104b32da1061 (patch)
tree00ed95eb0782527df6be4503df4b1b3076783f3b
parent6fcf2765dd01703e940dce5d891a16e28180a508 (diff)
downloadrockbox-46bf6bd49301cdfe254253725b7a104b32da1061.tar.gz
rockbox-46bf6bd49301cdfe254253725b7a104b32da1061.zip
Add preliminary ARMv5te optimisations (verified working, but can probably be sped up further), and fix a comment in the ARMv6 code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18693 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/demac/libdemac/filter.c2
-rw-r--r--apps/codecs/demac/libdemac/vector_math16_armv5te.h202
-rw-r--r--apps/codecs/demac/libdemac/vector_math16_armv6.h4
3 files changed, 205 insertions, 3 deletions
diff --git a/apps/codecs/demac/libdemac/filter.c b/apps/codecs/demac/libdemac/filter.c
index 0ff7148bf2..b191d47364 100644
--- a/apps/codecs/demac/libdemac/filter.c
+++ b/apps/codecs/demac/libdemac/filter.c
@@ -32,6 +32,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
32#include "vector_math16_cf.h" 32#include "vector_math16_cf.h"
33#elif ARM_ARCH >= 6 33#elif ARM_ARCH >= 6
34#include "vector_math16_armv6.h" 34#include "vector_math16_armv6.h"
35#elif ARM_ARCH >= 5 /* Assume all our ARMv5 targets are ARMv5te(j) */
36#include "vector_math16_armv5te.h"
35#elif defined CPU_ARM7TDMI 37#elif defined CPU_ARM7TDMI
36#include "vector_math16_arm7.h" 38#include "vector_math16_arm7.h"
37#else 39#else
diff --git a/apps/codecs/demac/libdemac/vector_math16_armv5te.h b/apps/codecs/demac/libdemac/vector_math16_armv5te.h
new file mode 100644
index 0000000000..fef99d9061
--- /dev/null
+++ b/apps/codecs/demac/libdemac/vector_math16_armv5te.h
@@ -0,0 +1,202 @@
1/*
2
3libdemac - A Monkey's Audio decoder
4
5$Id$
6
7Copyright (C) Dave Chapman 2007
8
9ARMv5te vector math copyright (C) 2008 Jens Arnold
10
11This program is free software; you can redistribute it and/or modify
12it under the terms of the GNU General Public License as published by
13the Free Software Foundation; either version 2 of the License, or
14(at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License
22along with this program; if not, write to the Free Software
23Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
24
25*/
26
27static inline void vector_add(int16_t* v1, int16_t* v2)
28{
29#if ORDER > 32
30 int order = (ORDER >> 5);
31 while (order--)
32#endif
33 {
34 *v1++ += *v2++;
35 *v1++ += *v2++;
36 *v1++ += *v2++;
37 *v1++ += *v2++;
38 *v1++ += *v2++;
39 *v1++ += *v2++;
40 *v1++ += *v2++;
41 *v1++ += *v2++;
42 *v1++ += *v2++;
43 *v1++ += *v2++;
44 *v1++ += *v2++;
45 *v1++ += *v2++;
46 *v1++ += *v2++;
47 *v1++ += *v2++;
48 *v1++ += *v2++;
49 *v1++ += *v2++;
50#if ORDER > 16
51 *v1++ += *v2++;
52 *v1++ += *v2++;
53 *v1++ += *v2++;
54 *v1++ += *v2++;
55 *v1++ += *v2++;
56 *v1++ += *v2++;
57 *v1++ += *v2++;
58 *v1++ += *v2++;
59 *v1++ += *v2++;
60 *v1++ += *v2++;
61 *v1++ += *v2++;
62 *v1++ += *v2++;
63 *v1++ += *v2++;
64 *v1++ += *v2++;
65 *v1++ += *v2++;
66 *v1++ += *v2++;
67#endif
68 }
69}
70
71static inline void vector_sub(int16_t* v1, int16_t* v2)
72{
73#if ORDER > 32
74 int order = (ORDER >> 5);
75 while (order--)
76#endif
77 {
78 *v1++ -= *v2++;
79 *v1++ -= *v2++;
80 *v1++ -= *v2++;
81 *v1++ -= *v2++;
82 *v1++ -= *v2++;
83 *v1++ -= *v2++;
84 *v1++ -= *v2++;
85 *v1++ -= *v2++;
86 *v1++ -= *v2++;
87 *v1++ -= *v2++;
88 *v1++ -= *v2++;
89 *v1++ -= *v2++;
90 *v1++ -= *v2++;
91 *v1++ -= *v2++;
92 *v1++ -= *v2++;
93 *v1++ -= *v2++;
94#if ORDER > 16
95 *v1++ -= *v2++;
96 *v1++ -= *v2++;
97 *v1++ -= *v2++;
98 *v1++ -= *v2++;
99 *v1++ -= *v2++;
100 *v1++ -= *v2++;
101 *v1++ -= *v2++;
102 *v1++ -= *v2++;
103 *v1++ -= *v2++;
104 *v1++ -= *v2++;
105 *v1++ -= *v2++;
106 *v1++ -= *v2++;
107 *v1++ -= *v2++;
108 *v1++ -= *v2++;
109 *v1++ -= *v2++;
110 *v1++ -= *v2++;
111#endif
112 }
113}
114
115/* This version fetches data as 32 bit words, and *requires* v1 to be
116 * 32 bit aligned, otherwise it will result either in a data abort, or
117 * incorrect results (if ARM aligncheck is disabled). */
118static inline int32_t scalarproduct(int16_t* v1, int16_t* v2)
119{
120 int res = 0;
121#if ORDER > 16
122 int cnt = ORDER>>4;
123#endif
124
125 asm volatile (
126 "tst %[v2], #2 \n"
127 "beq 20f \n"
128
129 "10: \n"
130 "ldrh r4, [%[v2]], #2 \n"
131 "mov r4, r4, lsl #16 \n"
132 "1: \n"
133 "ldmia %[v1]!, {r0-r3} \n"
134 "ldmia %[v2]!, {r5-r8} \n"
135 "smlabt %[res], r0, r4, %[res] \n"
136 "smlatb %[res], r0, r5, %[res] \n"
137 "smlabt %[res], r1, r5, %[res] \n"
138 "smlatb %[res], r1, r6, %[res] \n"
139 "smlabt %[res], r2, r6, %[res] \n"
140 "smlatb %[res], r2, r7, %[res] \n"
141 "smlabt %[res], r3, r7, %[res] \n"
142 "smlatb %[res], r3, r8, %[res] \n"
143 "mov r4, r8 \n"
144 "ldmia %[v1]!, {r0-r3} \n"
145 "ldmia %[v2]!, {r5-r8} \n"
146 "smlabt %[res], r0, r4, %[res] \n"
147 "smlatb %[res], r0, r5, %[res] \n"
148 "smlabt %[res], r1, r5, %[res] \n"
149 "smlatb %[res], r1, r6, %[res] \n"
150 "smlabt %[res], r2, r6, %[res] \n"
151 "smlatb %[res], r2, r7, %[res] \n"
152 "smlabt %[res], r3, r7, %[res] \n"
153 "smlatb %[res], r3, r8, %[res] \n"
154#if ORDER > 16
155 "mov r4, r8 \n"
156 "subs %[cnt], %[cnt], #1 \n"
157 "bne 1b \n"
158#endif
159 "b 99f \n"
160
161 "20: \n"
162 "1: \n"
163 "ldmia %[v1]!, {r0-r3} \n"
164 "ldmia %[v2]!, {r4-r7} \n"
165 "smlabb %[res], r0, r4, %[res] \n"
166 "smlatt %[res], r0, r4, %[res] \n"
167 "smlabb %[res], r1, r5, %[res] \n"
168 "smlatt %[res], r1, r5, %[res] \n"
169 "smlabb %[res], r2, r6, %[res] \n"
170 "smlatt %[res], r2, r6, %[res] \n"
171 "smlabb %[res], r3, r7, %[res] \n"
172 "smlatt %[res], r3, r7, %[res] \n"
173 "ldmia %[v1]!, {r0-r3} \n"
174 "ldmia %[v2]!, {r4-r7} \n"
175 "smlabb %[res], r0, r4, %[res] \n"
176 "smlatt %[res], r0, r4, %[res] \n"
177 "smlabb %[res], r1, r5, %[res] \n"
178 "smlatt %[res], r1, r5, %[res] \n"
179 "smlabb %[res], r2, r6, %[res] \n"
180 "smlatt %[res], r2, r6, %[res] \n"
181 "smlabb %[res], r3, r7, %[res] \n"
182 "smlatt %[res], r3, r7, %[res] \n"
183#if ORDER > 16
184 "subs %[cnt], %[cnt], #1 \n"
185 "bne 1b \n"
186#endif
187
188 "99: \n"
189 : /* outputs */
190#if ORDER > 16
191 [cnt]"+r"(cnt),
192#endif
193 [v1] "+r"(v1),
194 [v2] "+r"(v2),
195 [res]"+r"(res)
196 : /* inputs */
197 : /* clobbers */
198 "r0", "r1", "r2", "r3", "r4",
199 "r5", "r6", "r7", "r8"
200 );
201 return res;
202}
diff --git a/apps/codecs/demac/libdemac/vector_math16_armv6.h b/apps/codecs/demac/libdemac/vector_math16_armv6.h
index 7ecf372462..592e9dc7e6 100644
--- a/apps/codecs/demac/libdemac/vector_math16_armv6.h
+++ b/apps/codecs/demac/libdemac/vector_math16_armv6.h
@@ -205,9 +205,7 @@ static inline void vector_sub(int16_t* v1, int16_t* v2)
205 205
206/* This version fetches data as 32 bit words, and *requires* v1 to be 206/* This version fetches data as 32 bit words, and *requires* v1 to be
207 * 32 bit aligned, otherwise it will result either in a data abort, or 207 * 32 bit aligned, otherwise it will result either in a data abort, or
208 * incorrect results (if ARM aligncheck is disabled). It is optimised 208 * incorrect results (if ARM aligncheck is disabled). */
209 * for ARM7TDMI. Using it for ARM9 or higher results in worse performance
210 * than the C version. */
211static inline int32_t scalarproduct(int16_t* v1, int16_t* v2) 209static inline int32_t scalarproduct(int16_t* v1, int16_t* v2)
212{ 210{
213 int res = 0; 211 int res = 0;