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 | |
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
-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 @@ #define MPC_SHR_RND(X, Y) ((X+(1<<(Y-1)))>>Y) #if defined(CPU_COLDFIRE) + /* Calculate: result = (X*Y)>>14 */ + #define MPC_MULTIPLY(X,Y) \ + ({ \ + MPC_SAMPLE_FORMAT t1; \ + MPC_SAMPLE_FORMAT t2; \ + asm volatile ( \ + "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \ + "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \ + "movclr.l %%acc0,%[t1] \n\t" /* get higher half */ \ + "moveq.l #17,%[t2] \n\t" \ + "asl.l %[t2],%[t1] \n\t" /* hi <<= 17, plus one free */ \ + "moveq.l #14,%[t2] \n\t" \ + "lsr.l %[t2],%[x] \n\t" /* (unsigned)lo >>= 14 */ \ + "or.l %[x],%[t1] \n" /* combine result */ \ + : [t1]"=&d"(t1), [t2]"=&d"(t2) \ + : [x]"d"((X)), [y] "d"((Y))); \ + t1; \ + }) - #define MPC_MULTIPLY(X,Y) mpc_multiply((X), (Y)) - #define MPC_MULTIPLY_EX(X,Y,Z) mpc_multiply_ex((X), (Y), (Z)) - - static inline MPC_SAMPLE_FORMAT mpc_multiply(MPC_SAMPLE_FORMAT x, - MPC_SAMPLE_FORMAT y) - { - MPC_SAMPLE_FORMAT t1, t2; - asm volatile ( - "mac.l %[x],%[y],%%acc0\n" /* multiply */ - "mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */ - "movclr.l %%acc0,%[t1] \n" /* get higher half */ - "moveq.l #17,%[t2] \n" - "asl.l %[t2],%[t1] \n" /* hi <<= 17, plus one free */ - "moveq.l #14,%[t2] \n" - "lsr.l %[t2],%[x] \n" /* (unsigned)lo >>= 14 */ - "or.l %[x],%[t1] \n" /* combine result */ - : /* outputs */ - [t1]"=&d"(t1), - [t2]"=&d"(t2), - [x] "+d" (x) - : /* inputs */ - [y] "d" (y) - ); - return t1; - } - - static inline MPC_SAMPLE_FORMAT mpc_multiply_ex(MPC_SAMPLE_FORMAT x, - MPC_SAMPLE_FORMAT y, - unsigned shift) - { - MPC_SAMPLE_FORMAT t1, t2; - asm volatile ( - "mac.l %[x],%[y],%%acc0\n" /* multiply */ - "mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */ - "movclr.l %%acc0,%[t1] \n" /* get higher half */ - "moveq.l #31,%[t2] \n" - "sub.l %[sh],%[t2] \n" /* t2 = 31 - shift */ - "ble.s 1f \n" - "asl.l %[t2],%[t1] \n" /* hi <<= 31 - shift */ - "lsr.l %[sh],%[x] \n" /* (unsigned)lo >>= shift */ - "or.l %[x],%[t1] \n" /* combine result */ - "bra.s 2f \n" - "1: \n" - "neg.l %[t2] \n" /* t2 = shift - 31 */ - "asr.l %[t2],%[t1] \n" /* hi >>= t2 */ - "2: \n" - : /* outputs */ - [t1]"=&d"(t1), - [t2]"=&d"(t2), - [x] "+d" (x) - : /* inputs */ - [y] "d" (y), - [sh]"d" (shift) - ); - return t1; - } + /* Calculate: result = (X*Y)>>Z */ + #define MPC_MULTIPLY_EX(X,Y,Z) \ + ({ \ + MPC_SAMPLE_FORMAT t1; \ + MPC_SAMPLE_FORMAT t2; \ + asm volatile ( \ + "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \ + "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \ + "movclr.l %%acc0,%[t1] \n\t" /* get higher half */ \ + "moveq.l #31,%[t2] \n\t" \ + "sub.l %[sh],%[t2] \n\t" /* t2 = 31 - shift */ \ + "ble.s 1f \n\t" \ + "asl.l %[t2],%[t1] \n\t" /* hi <<= 31 - shift */ \ + "lsr.l %[sh],%[x] \n\t" /* (unsigned)lo >>= shift */ \ + "or.l %[x],%[t1] \n\t" /* combine result */ \ + "bra.s 2f \n\t" \ + "1: \n\t" \ + "neg.l %[t2] \n\t" /* t2 = shift - 31 */ \ + "asr.l %[t2],%[t1] \n\t" /* hi >>= t2 */ \ + "2: \n" \ + : [t1]"=&d"(t1), [t2]"=&d"(t2) \ + : [x] "d"((X)), [y] "d"((Y)), [sh]"d"((Z))); \ + t1; \ + }) #elif defined(CPU_ARM) /* Calculate: result = (X*Y)>>14 */ #define MPC_MULTIPLY(X,Y) \ @@ -181,8 +167,8 @@ MPC_SAMPLE_FORMAT t; \ asm volatile ( \ "mac.l %[A], %[B], %%acc0\n\t" \ - "movclr.l %%acc0, %[t]\n\t" \ - "asr.l #1, %[t]\n\t" \ + "movclr.l %%acc0, %[t] \n\t" \ + "asr.l #1, %[t] \n\t" \ : [t] "=d" (t) \ : [A] "r" ((X)), [B] "r" ((Y))); \ t; \ |