diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2010-06-05 17:52:31 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2010-06-05 17:52:31 +0000 |
commit | 45ab395c2fb42445382a377314bd63ae216f40c4 (patch) | |
tree | 72e25f321ea4f1e1d6ce82ccafd0b71e27553fdc /apps | |
parent | 9becb7a085a5bf5878ca1774f20a3aac71d1650a (diff) | |
download | rockbox-45ab395c2fb42445382a377314bd63ae216f40c4.tar.gz rockbox-45ab395c2fb42445382a377314bd63ae216f40c4.zip |
Some asm code beautification in the mpc decoder.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26592 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/codecs/libmusepack/mpcdec_math.h | 102 |
1 files changed, 44 insertions, 58 deletions
diff --git a/apps/codecs/libmusepack/mpcdec_math.h b/apps/codecs/libmusepack/mpcdec_math.h index bb79a52e6f..f4c87324b5 100644 --- a/apps/codecs/libmusepack/mpcdec_math.h +++ b/apps/codecs/libmusepack/mpcdec_math.h | |||
@@ -57,63 +57,49 @@ | |||
57 | #define MPC_SHR_RND(X, Y) ((X+(1<<(Y-1)))>>Y) | 57 | #define MPC_SHR_RND(X, Y) ((X+(1<<(Y-1)))>>Y) |
58 | 58 | ||
59 | #if defined(CPU_COLDFIRE) | 59 | #if defined(CPU_COLDFIRE) |
60 | /* Calculate: result = (X*Y)>>14 */ | ||
61 | #define MPC_MULTIPLY(X,Y) \ | ||
62 | ({ \ | ||
63 | MPC_SAMPLE_FORMAT t1; \ | ||
64 | MPC_SAMPLE_FORMAT t2; \ | ||
65 | asm volatile ( \ | ||
66 | "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \ | ||
67 | "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \ | ||
68 | "movclr.l %%acc0,%[t1] \n\t" /* get higher half */ \ | ||
69 | "moveq.l #17,%[t2] \n\t" \ | ||
70 | "asl.l %[t2],%[t1] \n\t" /* hi <<= 17, plus one free */ \ | ||
71 | "moveq.l #14,%[t2] \n\t" \ | ||
72 | "lsr.l %[t2],%[x] \n\t" /* (unsigned)lo >>= 14 */ \ | ||
73 | "or.l %[x],%[t1] \n" /* combine result */ \ | ||
74 | : [t1]"=&d"(t1), [t2]"=&d"(t2) \ | ||
75 | : [x]"d"((X)), [y] "d"((Y))); \ | ||
76 | t1; \ | ||
77 | }) | ||
60 | 78 | ||
61 | #define MPC_MULTIPLY(X,Y) mpc_multiply((X), (Y)) | 79 | /* Calculate: result = (X*Y)>>Z */ |
62 | #define MPC_MULTIPLY_EX(X,Y,Z) mpc_multiply_ex((X), (Y), (Z)) | 80 | #define MPC_MULTIPLY_EX(X,Y,Z) \ |
63 | 81 | ({ \ | |
64 | static inline MPC_SAMPLE_FORMAT mpc_multiply(MPC_SAMPLE_FORMAT x, | 82 | MPC_SAMPLE_FORMAT t1; \ |
65 | MPC_SAMPLE_FORMAT y) | 83 | MPC_SAMPLE_FORMAT t2; \ |
66 | { | 84 | asm volatile ( \ |
67 | MPC_SAMPLE_FORMAT t1, t2; | 85 | "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \ |
68 | asm volatile ( | 86 | "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \ |
69 | "mac.l %[x],%[y],%%acc0\n" /* multiply */ | 87 | "movclr.l %%acc0,%[t1] \n\t" /* get higher half */ \ |
70 | "mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */ | 88 | "moveq.l #31,%[t2] \n\t" \ |
71 | "movclr.l %%acc0,%[t1] \n" /* get higher half */ | 89 | "sub.l %[sh],%[t2] \n\t" /* t2 = 31 - shift */ \ |
72 | "moveq.l #17,%[t2] \n" | 90 | "ble.s 1f \n\t" \ |
73 | "asl.l %[t2],%[t1] \n" /* hi <<= 17, plus one free */ | 91 | "asl.l %[t2],%[t1] \n\t" /* hi <<= 31 - shift */ \ |
74 | "moveq.l #14,%[t2] \n" | 92 | "lsr.l %[sh],%[x] \n\t" /* (unsigned)lo >>= shift */ \ |
75 | "lsr.l %[t2],%[x] \n" /* (unsigned)lo >>= 14 */ | 93 | "or.l %[x],%[t1] \n\t" /* combine result */ \ |
76 | "or.l %[x],%[t1] \n" /* combine result */ | 94 | "bra.s 2f \n\t" \ |
77 | : /* outputs */ | 95 | "1: \n\t" \ |
78 | [t1]"=&d"(t1), | 96 | "neg.l %[t2] \n\t" /* t2 = shift - 31 */ \ |
79 | [t2]"=&d"(t2), | 97 | "asr.l %[t2],%[t1] \n\t" /* hi >>= t2 */ \ |
80 | [x] "+d" (x) | 98 | "2: \n" \ |
81 | : /* inputs */ | 99 | : [t1]"=&d"(t1), [t2]"=&d"(t2) \ |
82 | [y] "d" (y) | 100 | : [x] "d"((X)), [y] "d"((Y)), [sh]"d"((Z))); \ |
83 | ); | 101 | t1; \ |
84 | return t1; | 102 | }) |
85 | } | ||
86 | |||
87 | static inline MPC_SAMPLE_FORMAT mpc_multiply_ex(MPC_SAMPLE_FORMAT x, | ||
88 | MPC_SAMPLE_FORMAT y, | ||
89 | unsigned shift) | ||
90 | { | ||
91 | MPC_SAMPLE_FORMAT t1, t2; | ||
92 | asm volatile ( | ||
93 | "mac.l %[x],%[y],%%acc0\n" /* multiply */ | ||
94 | "mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */ | ||
95 | "movclr.l %%acc0,%[t1] \n" /* get higher half */ | ||
96 | "moveq.l #31,%[t2] \n" | ||
97 | "sub.l %[sh],%[t2] \n" /* t2 = 31 - shift */ | ||
98 | "ble.s 1f \n" | ||
99 | "asl.l %[t2],%[t1] \n" /* hi <<= 31 - shift */ | ||
100 | "lsr.l %[sh],%[x] \n" /* (unsigned)lo >>= shift */ | ||
101 | "or.l %[x],%[t1] \n" /* combine result */ | ||
102 | "bra.s 2f \n" | ||
103 | "1: \n" | ||
104 | "neg.l %[t2] \n" /* t2 = shift - 31 */ | ||
105 | "asr.l %[t2],%[t1] \n" /* hi >>= t2 */ | ||
106 | "2: \n" | ||
107 | : /* outputs */ | ||
108 | [t1]"=&d"(t1), | ||
109 | [t2]"=&d"(t2), | ||
110 | [x] "+d" (x) | ||
111 | : /* inputs */ | ||
112 | [y] "d" (y), | ||
113 | [sh]"d" (shift) | ||
114 | ); | ||
115 | return t1; | ||
116 | } | ||
117 | #elif defined(CPU_ARM) | 103 | #elif defined(CPU_ARM) |
118 | /* Calculate: result = (X*Y)>>14 */ | 104 | /* Calculate: result = (X*Y)>>14 */ |
119 | #define MPC_MULTIPLY(X,Y) \ | 105 | #define MPC_MULTIPLY(X,Y) \ |
@@ -181,8 +167,8 @@ | |||
181 | MPC_SAMPLE_FORMAT t; \ | 167 | MPC_SAMPLE_FORMAT t; \ |
182 | asm volatile ( \ | 168 | asm volatile ( \ |
183 | "mac.l %[A], %[B], %%acc0\n\t" \ | 169 | "mac.l %[A], %[B], %%acc0\n\t" \ |
184 | "movclr.l %%acc0, %[t]\n\t" \ | 170 | "movclr.l %%acc0, %[t] \n\t" \ |
185 | "asr.l #1, %[t]\n\t" \ | 171 | "asr.l #1, %[t] \n\t" \ |
186 | : [t] "=d" (t) \ | 172 | : [t] "=d" (t) \ |
187 | : [A] "r" ((X)), [B] "r" ((Y))); \ | 173 | : [A] "r" ((X)), [B] "r" ((Y))); \ |
188 | t; \ | 174 | t; \ |