Solve FS#12396 through rolling back r26592. This fixes distortions while mpc playback on Coldfire targets with GCC 4.5.2.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31054 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andree Buschmann 2011-11-25 19:42:26 +00:00
parent 65c46e8d77
commit fabbeba59a

View file

@ -56,50 +56,64 @@
#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; \
})
#if defined(CPU_COLDFIRE)
/* 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; \
})
#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;
}
#elif defined(CPU_ARM)
/* Calculate: result = (X*Y)>>14 */
#define MPC_MULTIPLY(X,Y) \