xref: /OK3568_Linux_fs/buildroot/package/speex/0001-thumb2-support.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1Make speex Thumb2 compatible
2
3Patch written by Michael Hope from Linaro, available at
4http://lists.xiph.org/pipermail/speex-dev/2010-November/008041.html.
5
6Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
7[Bernd: rebased for 1.2.0]
8Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
9
10diff --git a/libspeex/filters_arm4.h b/libspeex/filters_arm4.h
11index 7a74042..6ec1f75 100644
12--- a/libspeex/filters_arm4.h
13+++ b/libspeex/filters_arm4.h
14@@ -47,8 +47,10 @@ int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int le
15
16          "\tldr %4, [%0], #4 \n"
17          "\tcmp %4, %1 \n"
18+         "\tit gt \n"
19          "\tmovgt %1, %4 \n"
20          "\tcmp %4, %3 \n"
21+         "\tit lt \n"
22          "\tmovlt %3, %4 \n"
23
24          "\tsubs %2, %2, #1 \n"
25@@ -56,6 +58,7 @@ int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int le
26
27          "\trsb %3, %3, #0 \n"
28          "\tcmp %1, %3 \n"
29+         "\tit lt \n"
30          "\tmovlt %1, %3 \n"
31    : "=r" (dead1), "=r" (max_val), "=r" (dead3), "=r" (dead4),
32    "=r" (dead5), "=r" (dead6)
33diff --git a/libspeex/fixed_arm4.h b/libspeex/fixed_arm4.h
34index b6981ca..b6218ca 100644
35--- a/libspeex/fixed_arm4.h
36+++ b/libspeex/fixed_arm4.h
37@@ -69,72 +69,90 @@ static inline short DIV32_16(int a, int b)
38    __asm__ __volatile__ (
39          "\teor %5, %0, %1\n"
40          "\tmovs %4, %0\n"
41+         "\tit mi \n"
42          "\trsbmi %0, %0, #0 \n"
43          "\tmovs %4, %1\n"
44+         "\tit mi \n"
45          "\trsbmi %1, %1, #0 \n"
46          "\tmov %4, #1\n"
47
48          "\tsubs %3, %0, %1, asl #14 \n"
49+         "\titt pl \n"
50          "\tmovpl %0, %3 \n"
51          "\torrpl %2, %2, %4, asl #14 \n"
52
53          "\tsubs %3, %0, %1, asl #13 \n"
54+         "\titt pl \n"
55          "\tmovpl %0, %3 \n"
56          "\torrpl %2, %2, %4, asl #13 \n"
57
58          "\tsubs %3, %0, %1, asl #12 \n"
59+         "\titt pl \n"
60          "\tmovpl %0, %3 \n"
61          "\torrpl %2, %2, %4, asl #12 \n"
62
63          "\tsubs %3, %0, %1, asl #11 \n"
64+         "\titt pl \n"
65          "\tmovpl %0, %3 \n"
66          "\torrpl %2, %2, %4, asl #11 \n"
67
68          "\tsubs %3, %0, %1, asl #10 \n"
69+         "\titt pl \n"
70          "\tmovpl %0, %3 \n"
71          "\torrpl %2, %2, %4, asl #10 \n"
72
73          "\tsubs %3, %0, %1, asl #9 \n"
74+         "\titt pl \n"
75          "\tmovpl %0, %3 \n"
76          "\torrpl %2, %2, %4, asl #9 \n"
77
78          "\tsubs %3, %0, %1, asl #8 \n"
79+         "\titt pl \n"
80          "\tmovpl %0, %3 \n"
81          "\torrpl %2, %2, %4, asl #8 \n"
82
83          "\tsubs %3, %0, %1, asl #7 \n"
84+         "\titt pl \n"
85          "\tmovpl %0, %3 \n"
86          "\torrpl %2, %2, %4, asl #7 \n"
87
88          "\tsubs %3, %0, %1, asl #6 \n"
89+         "\titt pl \n"
90          "\tmovpl %0, %3 \n"
91          "\torrpl %2, %2, %4, asl #6 \n"
92
93          "\tsubs %3, %0, %1, asl #5 \n"
94+         "\titt pl \n"
95          "\tmovpl %0, %3 \n"
96          "\torrpl %2, %2, %4, asl #5 \n"
97
98          "\tsubs %3, %0, %1, asl #4 \n"
99+         "\titt pl \n"
100          "\tmovpl %0, %3 \n"
101          "\torrpl %2, %2, %4, asl #4 \n"
102
103          "\tsubs %3, %0, %1, asl #3 \n"
104+         "\titt pl \n"
105          "\tmovpl %0, %3 \n"
106          "\torrpl %2, %2, %4, asl #3 \n"
107
108          "\tsubs %3, %0, %1, asl #2 \n"
109+         "\titt pl \n"
110          "\tmovpl %0, %3 \n"
111          "\torrpl %2, %2, %4, asl #2 \n"
112
113          "\tsubs %3, %0, %1, asl #1 \n"
114+         "\titt pl \n"
115          "\tmovpl %0, %3 \n"
116          "\torrpl %2, %2, %4, asl #1 \n"
117
118          "\tsubs %3, %0, %1 \n"
119+         "\titt pl \n"
120          "\tmovpl %0, %3 \n"
121          "\torrpl %2, %2, %4 \n"
122
123          "\tmovs %5, %5, lsr #31 \n"
124+         "\tit ne \n"
125          "\trsbne %2, %2, #0 \n"
126    : "=r" (dead1), "=r" (dead2), "=r" (res),
127    "=r" (dead3), "=r" (dead4), "=r" (dead5)
128diff --git a/libspeex/fixed_arm5e.h b/libspeex/fixed_arm5e.h
129index 9b4861c..bdadd02 100644
130--- a/libspeex/fixed_arm5e.h
131+++ b/libspeex/fixed_arm5e.h
132@@ -97,72 +97,90 @@ static inline short DIV32_16(int a, int b)
133    __asm__ __volatile__ (
134          "\teor %5, %0, %1\n"
135          "\tmovs %4, %0\n"
136+         "\tit mi \n"
137          "\trsbmi %0, %0, #0 \n"
138          "\tmovs %4, %1\n"
139+         "\tit mi \n"
140          "\trsbmi %1, %1, #0 \n"
141          "\tmov %4, #1\n"
142
143          "\tsubs %3, %0, %1, asl #14 \n"
144+         "\titt pl \n"
145          "\torrpl %2, %2, %4, asl #14 \n"
146          "\tmovpl %0, %3 \n"
147
148          "\tsubs %3, %0, %1, asl #13 \n"
149+         "\titt pl \n"
150          "\torrpl %2, %2, %4, asl #13 \n"
151          "\tmovpl %0, %3 \n"
152
153          "\tsubs %3, %0, %1, asl #12 \n"
154+         "\titt pl \n"
155          "\torrpl %2, %2, %4, asl #12 \n"
156          "\tmovpl %0, %3 \n"
157
158          "\tsubs %3, %0, %1, asl #11 \n"
159+         "\titt pl \n"
160          "\torrpl %2, %2, %4, asl #11 \n"
161          "\tmovpl %0, %3 \n"
162
163          "\tsubs %3, %0, %1, asl #10 \n"
164+         "\titt pl \n"
165          "\torrpl %2, %2, %4, asl #10 \n"
166          "\tmovpl %0, %3 \n"
167
168          "\tsubs %3, %0, %1, asl #9 \n"
169+         "\titt pl \n"
170          "\torrpl %2, %2, %4, asl #9 \n"
171          "\tmovpl %0, %3 \n"
172
173          "\tsubs %3, %0, %1, asl #8 \n"
174+         "\titt pl \n"
175          "\torrpl %2, %2, %4, asl #8 \n"
176          "\tmovpl %0, %3 \n"
177
178          "\tsubs %3, %0, %1, asl #7 \n"
179+         "\titt pl \n"
180          "\torrpl %2, %2, %4, asl #7 \n"
181          "\tmovpl %0, %3 \n"
182
183          "\tsubs %3, %0, %1, asl #6 \n"
184+         "\titt pl \n"
185          "\torrpl %2, %2, %4, asl #6 \n"
186          "\tmovpl %0, %3 \n"
187
188          "\tsubs %3, %0, %1, asl #5 \n"
189+         "\titt pl \n"
190          "\torrpl %2, %2, %4, asl #5 \n"
191          "\tmovpl %0, %3 \n"
192
193          "\tsubs %3, %0, %1, asl #4 \n"
194+         "\titt pl \n"
195          "\torrpl %2, %2, %4, asl #4 \n"
196          "\tmovpl %0, %3 \n"
197
198          "\tsubs %3, %0, %1, asl #3 \n"
199+         "\titt pl \n"
200          "\torrpl %2, %2, %4, asl #3 \n"
201          "\tmovpl %0, %3 \n"
202
203          "\tsubs %3, %0, %1, asl #2 \n"
204+         "\titt pl \n"
205          "\torrpl %2, %2, %4, asl #2 \n"
206          "\tmovpl %0, %3 \n"
207
208          "\tsubs %3, %0, %1, asl #1 \n"
209+         "\titt pl \n"
210          "\torrpl %2, %2, %4, asl #1 \n"
211          "\tmovpl %0, %3 \n"
212
213          "\tsubs %3, %0, %1 \n"
214+         "\titt pl \n"
215          "\torrpl %2, %2, %4 \n"
216          "\tmovpl %0, %3 \n"
217
218          "\tmovs %5, %5, lsr #31 \n"
219+         "\tit ne \n"
220          "\trsbne %2, %2, #0 \n"
221    : "=r" (dead1), "=r" (dead2), "=r" (res),
222    "=r" (dead3), "=r" (dead4), "=r" (dead5)
223