diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2010-05-29 14:56:25 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2010-05-29 14:56:25 +0000 |
commit | 9ab57e510e5ff64c5ce3d6bf47d7bf1ff8261e01 (patch) | |
tree | 64b75043581d949accee5c9cdaec74275ed6ec74 | |
parent | 56220785c11d9ad62b552a8f1ba44d779d5edf48 (diff) | |
download | rockbox-9ab57e510e5ff64c5ce3d6bf47d7bf1ff8261e01.tar.gz rockbox-9ab57e510e5ff64c5ce3d6bf47d7bf1ff8261e01.zip |
Small changes to asm for better readability.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26375 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/codecs/libatrac/fixp_math.h | 39 | ||||
-rw-r--r-- | apps/codecs/libmusepack/mpcdec_math.h | 56 |
2 files changed, 49 insertions, 46 deletions
diff --git a/apps/codecs/libatrac/fixp_math.h b/apps/codecs/libatrac/fixp_math.h index ac53310cd2..8d2e0783b8 100644 --- a/apps/codecs/libatrac/fixp_math.h +++ b/apps/codecs/libatrac/fixp_math.h | |||
@@ -31,30 +31,33 @@ | |||
31 | /* Fixed point math routines for use in atrac3.c */ | 31 | /* Fixed point math routines for use in atrac3.c */ |
32 | 32 | ||
33 | #if defined(CPU_ARM) | 33 | #if defined(CPU_ARM) |
34 | /* Calculates: result = (X*Y)>>16 */ | ||
34 | #define fixmul16(X,Y) \ | 35 | #define fixmul16(X,Y) \ |
35 | ({ \ | 36 | ({ \ |
36 | int32_t low; \ | 37 | int32_t lo; \ |
37 | int32_t high; \ | 38 | int32_t hi; \ |
38 | asm volatile ( /* calculates: result = (X*Y)>>16 */ \ | 39 | asm volatile ( \ |
39 | "smull %0,%1,%2,%3 \n\t" /* 64 = 32x32 multiply */ \ | 40 | "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ |
40 | "mov %0, %0, lsr #16 \n\t" /* %0 = %0 >> 16 */ \ | 41 | "mov %[lo], %[lo], lsr #16 \n\t" /* lo >>= 16 */ \ |
41 | "orr %0, %0, %1, lsl #16 \n\t"/* result = %0 OR (%1 << 16) */ \ | 42 | "orr %[lo], %[lo], %[hi], lsl #16" /* lo |= (hi << 16) */ \ |
42 | : "=&r"(low), "=&r" (high) \ | 43 | : [lo]"=&r"(lo), [hi]"=&r"(hi) \ |
43 | : "r"(X),"r"(Y)); \ | 44 | : [x]"r"(X), [y]"r"(Y)); \ |
44 | low; \ | 45 | lo; \ |
45 | }) | 46 | }) |
46 | 47 | ||
48 | /* Calculates: result = (X*Y)>>31 */ | ||
49 | /* Use scratch register r12 */ | ||
47 | #define fixmul31(X,Y) \ | 50 | #define fixmul31(X,Y) \ |
48 | ({ \ | 51 | ({ \ |
49 | int32_t low; \ | 52 | int32_t lo; \ |
50 | int32_t high; \ | 53 | int32_t hi; \ |
51 | asm volatile ( /* calculates: result = (X*Y)>>31 */ \ | 54 | asm volatile ( \ |
52 | "smull %0,%1,%2,%3 \n\t" /* 64 = 32x32 multiply */ \ | 55 | "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ |
53 | "mov %0, %0, lsr #31 \n\t" /* %0 = %0 >> 31 */ \ | 56 | "mov %[lo], %[lo], lsr #31 \n\t" /* lo >>= 31 */ \ |
54 | "orr %0, %0, %1, lsl #1 \n\t" /* result = %0 OR (%1 << 1) */ \ | 57 | "orr %[lo], %[lo], %[hi], lsl #1" /* lo |= (hi << 1) */ \ |
55 | : "=&r"(low), "=&r" (high) \ | 58 | : [lo]"=&r"(lo), [hi]"=&r"(hi) \ |
56 | : "r"(X),"r"(Y)); \ | 59 | : [x]"r"(X), [y]"r"(Y)); \ |
57 | low; \ | 60 | lo; \ |
58 | }) | 61 | }) |
59 | #elif defined(CPU_COLDFIRE) | 62 | #elif defined(CPU_COLDFIRE) |
60 | #define fixmul16(X,Y) \ | 63 | #define fixmul16(X,Y) \ |
diff --git a/apps/codecs/libmusepack/mpcdec_math.h b/apps/codecs/libmusepack/mpcdec_math.h index 55295dba32..bb79a52e6f 100644 --- a/apps/codecs/libmusepack/mpcdec_math.h +++ b/apps/codecs/libmusepack/mpcdec_math.h | |||
@@ -115,32 +115,32 @@ | |||
115 | return t1; | 115 | return t1; |
116 | } | 116 | } |
117 | #elif defined(CPU_ARM) | 117 | #elif defined(CPU_ARM) |
118 | // borrowed and adapted from libMAD | 118 | /* Calculate: result = (X*Y)>>14 */ |
119 | #define MPC_MULTIPLY(X,Y) \ | 119 | #define MPC_MULTIPLY(X,Y) \ |
120 | ({ \ | 120 | ({ \ |
121 | MPC_SAMPLE_FORMAT low; \ | 121 | MPC_SAMPLE_FORMAT lo; \ |
122 | MPC_SAMPLE_FORMAT high; \ | 122 | MPC_SAMPLE_FORMAT hi; \ |
123 | asm volatile ( /* will calculate: result = (X*Y)>>14 */ \ | 123 | asm volatile ( \ |
124 | "smull %0,%1,%2,%3 \n\t" /* multiply with result %0 [0..31], %1 [32..63] */ \ | 124 | "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ |
125 | "mov %0, %0, lsr #14 \n\t" /* %0 = %0 >> 14 */ \ | 125 | "mov %[lo], %[lo], lsr #14 \n\t" /* lo >>= 14 */ \ |
126 | "orr %0, %0, %1, lsl #18 \n\t"/* result = %0 OR (%1 << 18) */ \ | 126 | "orr %[lo], %[lo], %[hi], lsl #18" /* lo |= (hi << 18) */ \ |
127 | : "=&r"(low), "=&r" (high) \ | 127 | : [lo]"=&r"(lo), [hi]"=&r"(hi) \ |
128 | : "r"(X),"r"(Y)); \ | 128 | : [x]"r"(X), [y]"r"(Y)); \ |
129 | low; \ | 129 | lo; \ |
130 | }) | 130 | }) |
131 | 131 | ||
132 | // borrowed and adapted from libMAD | 132 | /* Calculate: result = (X*Y)>>Z */ |
133 | #define MPC_MULTIPLY_EX(X,Y,Z) \ | 133 | #define MPC_MULTIPLY_EX(X,Y,Z) \ |
134 | ({ \ | 134 | ({ \ |
135 | MPC_SAMPLE_FORMAT low; \ | 135 | MPC_SAMPLE_FORMAT lo; \ |
136 | MPC_SAMPLE_FORMAT high; \ | 136 | MPC_SAMPLE_FORMAT hi; \ |
137 | asm volatile ( /* will calculate: result = (X*Y)>>Z */ \ | 137 | asm volatile ( \ |
138 | "smull %0,%1,%2,%3 \n\t" /* multiply with result %0 [0..31], %1 [32..63] */ \ | 138 | "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ |
139 | "mov %0, %0, lsr %4 \n\t" /* %0 = %0 >> Z */ \ | 139 | "mov %[lo], %[lo], lsr %[shr] \n\t" /* lo >>= Z */ \ |
140 | "orr %0, %0, %1, lsl %5 \n\t" /* result = %0 OR (%1 << (32-Z)) */ \ | 140 | "orr %[lo], %[lo], %[hi], lsl %[shl]" /* lo |= (hi << (32-Z)) */ \ |
141 | : "=&r"(low), "=&r" (high) \ | 141 | : [lo]"=&r"(lo), [hi]"=&r"(hi) \ |
142 | : "r"(X),"r"(Y),"r"(Z),"r"(32-Z)); \ | 142 | : [x]"r"(X), [y]"r"(Y), [shr]"r"(Z), [shl]"r"(32-Z)); \ |
143 | low; \ | 143 | lo; \ |
144 | }) | 144 | }) |
145 | #else /* libmusepack standard */ | 145 | #else /* libmusepack standard */ |
146 | 146 | ||
@@ -188,16 +188,16 @@ | |||
188 | t; \ | 188 | t; \ |
189 | }) | 189 | }) |
190 | #elif defined(CPU_ARM) | 190 | #elif defined(CPU_ARM) |
191 | // borrowed and adapted from libMAD | 191 | /* Calculate: result = (X*Y)>>32, without need for >>32 */ |
192 | #define MPC_MULTIPLY_FRACT(X,Y) \ | 192 | #define MPC_MULTIPLY_FRACT(X,Y) \ |
193 | ({ \ | 193 | ({ \ |
194 | MPC_SAMPLE_FORMAT low; \ | 194 | MPC_SAMPLE_FORMAT lo; \ |
195 | MPC_SAMPLE_FORMAT high; \ | 195 | MPC_SAMPLE_FORMAT hi; \ |
196 | asm volatile ( /* will calculate: result = (X*Y)>>32 */ \ | 196 | asm volatile ( \ |
197 | "smull %0,%1,%2,%3 \n\t" /* multiply with result %0 [0..31], %1 [32..63] */ \ | 197 | "smull %[lo], %[hi], %[x], %[y]" /* hi = result */ \ |
198 | : "=&r"(low), "=&r" (high) /* result = %1 [32..63], saves the >>32 */ \ | 198 | : [lo]"=&r"(lo), [hi]"=&r"(hi) \ |
199 | : "r"(X),"r"(Y)); \ | 199 | : [x]"r"(X), [y]"r"(Y)); \ |
200 | high; \ | 200 | hi; \ |
201 | }) | 201 | }) |
202 | #else | 202 | #else |
203 | #define MPC_MULTIPLY_FRACT(X,Y) MPC_MULTIPLY_EX(X,Y,32) | 203 | #define MPC_MULTIPLY_FRACT(X,Y) MPC_MULTIPLY_EX(X,Y,32) |