summaryrefslogtreecommitdiffstats
path: root/apps/dsp.h
diff options
context:
space:
mode:
authorThom Johansen <thomj@rockbox.org>2007-02-15 22:51:45 +0000
committerThom Johansen <thomj@rockbox.org>2007-02-15 22:51:45 +0000
commit96e5e9eef81a3758fd7bca3b21a5874c4e9f760e (patch)
treea5bd806ea64658d8d58f2a5e692d407023a62678 /apps/dsp.h
parent7ba8aec5af73d7ff4ce4d9a788d6a5911c621e88 (diff)
downloadrockbox-96e5e9eef81a3758fd7bca3b21a5874c4e9f760e.tar.gz
rockbox-96e5e9eef81a3758fd7bca3b21a5874c4e9f760e.tar.bz2
rockbox-96e5e9eef81a3758fd7bca3b21a5874c4e9f760e.zip
Optimise/touchup some asm macros in dsp.h, and also remove some now unneeded ones. Add config.h to dsp.c so that these macros actually get used, and also do some minor nitpicks to the resampler while I'm at it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12322 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/dsp.h')
-rw-r--r--apps/dsp.h119
1 files changed, 52 insertions, 67 deletions
diff --git a/apps/dsp.h b/apps/dsp.h
index 2f676d22bc..8e82b6118d 100644
--- a/apps/dsp.h
+++ b/apps/dsp.h
@@ -49,6 +49,9 @@ enum {
/* A bunch of fixed point assembler helper macros */
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
+/* These macros use the Coldfire EMAC extension and need the MACSR flags set
+ * to fractional mode with no rounding.
+ */
/* Multiply two S.31 fractional integers and return the sign bit and the
* 31 most significant bits of the result.
@@ -56,9 +59,9 @@ enum {
#define FRACMUL(x, y) \
({ \
long t; \
- asm volatile ("mac.l %[a], %[b], %%acc0\n\t" \
- "movclr.l %%acc0, %[t]\n\t" \
- : [t] "=r" (t) : [a] "r" (x), [b] "r" (y)); \
+ asm ("mac.l %[a], %[b], %%acc0\n\t" \
+ "movclr.l %%acc0, %[t]\n\t" \
+ : [t] "=r" (t) : [a] "r" (x), [b] "r" (y)); \
t; \
})
@@ -69,70 +72,50 @@ enum {
#define FRACMUL_SHL(x, y, z) \
({ \
long t, t2; \
- asm volatile ("mac.l %[a], %[b], %%acc0\n\t" \
- "moveq.l %[d], %[t]\n\t" \
- "move.l %%accext01, %[t2]\n\t" \
- "and.l %[mask], %[t2]\n\t" \
- "lsr.l %[t], %[t2]\n\t" \
- "movclr.l %%acc0, %[t]\n\t" \
- "asl.l %[c], %[t]\n\t" \
- "or.l %[t2], %[t]\n\t" \
- : [t] "=d" (t), [t2] "=d" (t2) \
- : [a] "r" (x), [b] "r" (y), [mask] "d" (0xff), \
- [c] "i" ((z)), [d] "i" (8 - (z))); \
+ asm ("mac.l %[a], %[b], %%acc0\n\t" \
+ "moveq.l %[d], %[t]\n\t" \
+ "move.l %%accext01, %[t2]\n\t" \
+ "and.l %[mask], %[t2]\n\t" \
+ "lsr.l %[t], %[t2]\n\t" \
+ "movclr.l %%acc0, %[t]\n\t" \
+ "asl.l %[c], %[t]\n\t" \
+ "or.l %[t2], %[t]\n\t" \
+ : [t] "=&d" (t), [t2] "=&d" (t2) \
+ : [a] "r" (x), [b] "r" (y), [mask] "d" (0xff), \
+ [c] "i" ((z)), [d] "i" (8 - (z))); \
t; \
})
/* Multiply one S.31-bit and one S8.23 fractional integer and return the
- * sign bit and the 31 most significant bits of the result.
- */
-#define FRACMUL_8(x, y) \
-({ \
- long t; \
- long u; \
- asm volatile ("mac.l %[a], %[b], %%acc0\n\t" \
- "move.l %%accext01, %[u]\n\t" \
- "movclr.l %%acc0, %[t]\n\t" \
- : [t] "=r" (t), [u] "=r" (u) : [a] "r" (x), [b] "r" (y)); \
- (t << 8) | (u & 0xff); \
-})
-
-/* Multiply one S.31-bit and one S8.23 fractional integer and return the
* sign bit and the 31 most significant bits of the result. Load next value
* to multiply with into x from s (and increase s); x must contain the
* initial value.
*/
-#define FRACMUL_8_LOOP_PART(x, s, d, y) \
-{ \
- long u; \
- asm volatile ("mac.l %[a], %[b], (%[c])+, %[a], %%acc0\n\t" \
- "move.l %%accext01, %[u]\n\t" \
- "movclr.l %%acc0, %[t]" \
- : [a] "+r" (x), [c] "+a" (s), [t] "=r" (d), [u] "=r" (u) \
- : [b] "r" (y)); \
- d = (d << 8) | (u & 0xff); \
-}
-
#define FRACMUL_8_LOOP(x, y, s, d) \
{ \
- long t; \
- FRACMUL_8_LOOP_PART(x, s, t, y); \
- asm volatile ("move.l %[t],(%[d])+" \
- : [d] "+a" (d)\
- : [t] "r" (t)); \
+ long t, t2; \
+ asm volatile ("mac.l %[a], %[b], (%[src])+, %[a], %%acc0\n\t" \
+ "move.l %%accext01, %[t2]\n\t" \
+ "movclr.l %%acc0, %[t]\n\t" \
+ "asl.l #8, %[t]\n\t" \
+ "move.b %[t2], %[t]\n\t" \
+ "move.l %[t], (%[dst])+\n\t" \
+ : [a] "+r" (x), [src] "+a" (s), [dst] "+a" (d), \
+ [t] "=r" (t), [t2] "=r" (t2) \
+ : [b] "r" (y)); \
}
#define ACC(acc, x, y) \
(void)acc; \
- asm volatile ("mac.l %[a], %[b], %%acc0" \
- : : [a] "i,r" (x), [b] "i,r" (y));
+ asm ("mac.l %[a], %[b], %%acc0" \
+ : : [a] "i,r" (x), [b] "i,r" (y));
#define GET_ACC(acc) \
({ \
long t; \
(void)acc; \
- asm volatile ("movclr.l %%acc0, %[t]" \
- : [t] "=r" (t)); \
+ asm ("movclr.l %%acc0, %[t]" \
+ : [t] "=r" (t)); \
t; \
})
@@ -145,11 +128,12 @@ enum {
*/
#define FRACMUL(x, y) \
({ \
- long t; \
- asm volatile ("smull r0, r1, %[a], %[b]\n\t" \
- "mov %[t], r1, asl #1\n\t" \
- "orr %[t], %[t], r0, lsr #31\n\t" \
- : [t] "=r" (t) : [a] "r" (x), [b] "r" (y) : "r0", "r1"); \
+ long t, t2; \
+ asm ("smull %[t], %[t2], %[a], %[b]\n\t" \
+ "mov %[t2], %[t2], asl #1\n\t" \
+ "orr %[t], %[t2], %[t], lsr #31\n\t" \
+ : [t] "=&r" (t), [t2] "=&r" (t2) \
+ : [a] "r" (x), [b] "r" (y)); \
t; \
})
@@ -158,14 +142,13 @@ enum {
*/
#define FRACMUL_SHL(x, y, z) \
({ \
- long t; \
- asm volatile ("smull r0, r1, %[a], %[b]\n\t" \
- "mov %[t], r1, asl %[c]\n\t" \
- "orr %[t], %[t], r0, lsr %[d]\n\t" \
- : [t] "=r" (t) \
- : [a] "r" (x), [b] "r" (y), \
- [c] "M" ((z) + 1), [d] "M" (31 - (z)) \
- : "r0", "r1"); \
+ long t, t2; \
+ asm ("smull %[t], %[t2], %[a], %[b]\n\t" \
+ "mov %[t2], %[t2], asl %[c]\n\t" \
+ "orr %[t], %[t2], %[t], lsr %[d]\n\t" \
+ : [t] "=&r" (t), [t2] "=&r" (t2) \
+ : [a] "r" (x), [b] "r" (y), \
+ [c] "M" ((z) + 1), [d] "M" (31 - (z))); \
t; \
})
@@ -180,10 +163,12 @@ enum {
*/
#define FRACMUL_8_LOOP(x, y, s, d) \
({ \
- asm volatile ("smull r0, r1, %[a], %[b]\n\t" \
- "mov %[t], r1, asl #9\n\t" \
- "orr %[t], %[t], r0, lsr #23\n\t" \
- : [t] "=r" (*(d)++) : [a] "r" (x), [b] "r" (y) : "r0", "r1"); \
+ long t, t2; \
+ asm volatile ("smull %[t], %[t2], %[a], %[b]\n\t" \
+ "mov %[t2], %[t2], asl #9\n\t" \
+ "orr %[d], %[t2], %[t], lsr #23\n\t" \
+ : [d] "=&r" (*(d)++), [t] "=&r" (t), [t2] "=&r" (t2) \
+ : [a] "r" (x), [b] "r" (y)); \
x = *(s)++; \
})
@@ -193,8 +178,8 @@ enum {
#define ACC(acc, x, y) acc += FRACMUL(x, y)
#define GET_ACC(acc) acc
#define FRACMUL(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 31))
-#define FRACMUL_SHL(x, y, z) ((long)(((((long long) (x)) * ((long long) (y))) >> (31 - (z)))))
-#define FRACMUL_8(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 23))
+#define FRACMUL_SHL(x, y, z) \
+((long)(((((long long) (x)) * ((long long) (y))) >> (31 - (z)))))
#define FRACMUL_8_LOOP(x, y, s, d) \
({ \
long t = x; \