1
0
Fork 0
forked from len0rd/rockbox

Make libdemac compile again on OSX x86 and x86_64 by replacing .rept with fancy preprocessor stuff.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27490 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2010-07-19 10:04:54 +00:00
parent e749794884
commit 2e73e53679

View file

@ -26,8 +26,29 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
#define FUSED_VECTOR_MATH
#define __E(__e) #__e
#define __S(__e) __E(__e)
#define REPEAT_MB3(x, n) x(n) x(n+8) x(n+16)
#define REPEAT_MB7(x, n) x(n) x(n+8) x(n+16) x(n+24) x(n+32) x(n+40) x(n+48)
#define REPEAT_MB8(x, n) REPEAT_MB7(x, n) x(n+56)
#if ORDER == 16 /* 3 times */
#define REPEAT_MB(x) REPEAT_MB3(x, 8)
#elif ORDER == 32 /* 7 times */
#define REPEAT_MB(x) REPEAT_MB7(x, 8)
#elif ORDER == 64 /* 5*3 == 15 times */
#define REPEAT_MB(x) REPEAT_MB3(x, 8) REPEAT_MB3(x, 32) REPEAT_MB3(x, 56) \
REPEAT_MB3(x, 80) REPEAT_MB3(x, 104)
#elif ORDER == 256 /* 9*7 == 63 times */
#define REPEAT_MB(x) REPEAT_MB7(x, 8) REPEAT_MB7(x, 64) REPEAT_MB7(x, 120) \
REPEAT_MB7(x, 176) REPEAT_MB7(x, 232) REPEAT_MB7(x, 288) \
REPEAT_MB7(x, 344) REPEAT_MB7(x, 400) REPEAT_MB7(x, 456)
#elif ORDER == 1280 /* 8*8 == 64 times */
#define REPEAT_MB(x) REPEAT_MB8(x, 0) REPEAT_MB8(x, 64) REPEAT_MB8(x, 128) \
REPEAT_MB8(x, 192) REPEAT_MB8(x, 256) REPEAT_MB8(x, 320) \
REPEAT_MB8(x, 384) REPEAT_MB8(x, 448)
#else
#error unsupported order
#endif
static inline int32_t vector_sp_add(int16_t* v1, int16_t* f2, int16_t *s2)
{
@ -39,27 +60,25 @@ static inline int32_t vector_sp_add(int16_t* v1, int16_t* f2, int16_t *s2)
asm volatile (
#if ORDER > 256
"pxor %%mm2, %%mm2 \n"
".set ofs, 0 \n"
"1: \n"
".rept 64 \n"
#else
"movq (%[v1]), %%mm2 \n"
"movq %%mm2, %%mm0 \n"
"pmaddwd (%[f2]), %%mm2 \n"
"paddw (%[s2]), %%mm0 \n"
"movq %%mm0, (%[v1]) \n"
".set ofs, 8 \n"
".rept " __S(ORDER>>2 - 1) "\n"
#endif
"movq ofs(%[v1]), %%mm1 \n"
"movq %%mm1, %%mm0 \n"
"pmaddwd ofs(%[f2]), %%mm1 \n"
"paddw ofs(%[s2]), %%mm0 \n"
"movq %%mm0, ofs(%[v1]) \n"
"paddd %%mm1, %%mm2 \n"
".set ofs, ofs + 8 \n"
".endr \n"
#define SP_ADD_BLOCK(n) \
"movq " #n "(%[v1]), %%mm1 \n" \
"movq %%mm1, %%mm0 \n" \
"pmaddwd " #n "(%[f2]), %%mm1 \n" \
"paddw " #n "(%[s2]), %%mm0 \n" \
"movq %%mm0, " #n "(%[v1]) \n" \
"paddd %%mm1, %%mm2 \n"
REPEAT_MB(SP_ADD_BLOCK)
#if ORDER > 256
"add $512, %[v1] \n"
"add $512, %[s2] \n"
@ -105,27 +124,25 @@ static inline int32_t vector_sp_sub(int16_t* v1, int16_t* f2, int16_t *s2)
asm volatile (
#if ORDER > 256
"pxor %%mm2, %%mm2 \n"
".set ofs, 0 \n"
"1: \n"
".rept 64 \n"
#else
"movq (%[v1]), %%mm2 \n"
"movq %%mm2, %%mm0 \n"
"pmaddwd (%[f2]), %%mm2 \n"
"psubw (%[s2]), %%mm0 \n"
"movq %%mm0, (%[v1]) \n"
".set ofs, 8 \n"
".rept " __S(ORDER>>2 - 1) "\n"
#endif
"movq ofs(%[v1]), %%mm1 \n"
"movq %%mm1, %%mm0 \n"
"pmaddwd ofs(%[f2]), %%mm1 \n"
"psubw ofs(%[s2]), %%mm0 \n"
"movq %%mm0, ofs(%[v1]) \n"
"paddd %%mm1, %%mm2 \n"
".set ofs, ofs + 8 \n"
".endr \n"
#define SP_SUB_BLOCK(n) \
"movq " #n "(%[v1]), %%mm1 \n" \
"movq %%mm1, %%mm0 \n" \
"pmaddwd " #n "(%[f2]), %%mm1 \n" \
"psubw " #n "(%[s2]), %%mm0 \n" \
"movq %%mm0, " #n "(%[v1]) \n" \
"paddd %%mm1, %%mm2 \n"
REPEAT_MB(SP_SUB_BLOCK)
#if ORDER > 256
"add $512, %[v1] \n"
"add $512, %[s2] \n"
@ -171,21 +188,19 @@ static inline int32_t scalarproduct(int16_t* v1, int16_t* v2)
asm volatile (
#if ORDER > 256
"pxor %%mm1, %%mm1 \n"
".set ofs, 0 \n"
"1: \n"
".rept 64 \n"
#else
"movq (%[v1]), %%mm1 \n"
"pmaddwd (%[v2]), %%mm1 \n"
".set ofs, 8 \n"
".rept " __S(ORDER>>2 - 1) "\n"
#endif
"movq ofs(%[v1]), %%mm0 \n"
"pmaddwd ofs(%[v2]), %%mm0 \n"
"paddd %%mm0, %%mm1 \n"
".set ofs, ofs + 8 \n"
".endr \n"
#define SP_BLOCK(n) \
"movq " #n "(%[v1]), %%mm0 \n" \
"pmaddwd " #n "(%[v2]), %%mm0 \n" \
"paddd %%mm0, %%mm1 \n"
REPEAT_MB(SP_BLOCK)
#if ORDER > 256
"add $512, %[v1] \n"
"add $512, %[v2] \n"