[Ffmpeg-devel] Mac OS X Intel part 2: Assembler macros in fdct_mmx.c

John Dalgliesh johnd
Wed Aug 9 16:05:39 CEST 2006


OK, next patch. The file libavcodec/i386/fdct_mmx.c uses assembler macros, 
i.e. macros implemented by as and not cpp. The macro syntax in Apple's 
cctools 'as' differs to that in recent GNU binutils 'gas'.

To avoid the problem entirely, the simplest solution would be to switch to 
using cpp macros. However others have already posted such patches without 
a positive reception.

An alternative is to just wrap the differences in cpp macros. An 
indicative patch is attached. The assembler type would be detected by 
configure. I have tried not to make it too ugly, but there is room to 
improve.

Would this alternative be acceptable? Or is the cpp one OK but no-one 
gave a good-enough patch yet? Or neither?

TIA

{P^/
-------------- next part --------------
Index: fdct_mmx.c
===================================================================
--- fdct_mmx.c	(revision 5955)
+++ fdct_mmx.c	(working copy)
@@ -351,27 +351,27 @@
 static always_inline void fdct_row_sse2(const int16_t *in, int16_t *out)
 {
     asm volatile(
-        ".macro FDCT_ROW_SSE2_H1 i t    \n\t"
-        "movq      \\i(%0), %%xmm2      \n\t"
-        "movq      \\i+8(%0), %%xmm0    \n\t"
-        "movdqa    \\t+32(%1), %%xmm3   \n\t"
-        "movdqa    \\t+48(%1), %%xmm7   \n\t"
-        "movdqa    \\t(%1), %%xmm4      \n\t"
-        "movdqa    \\t+16(%1), %%xmm5   \n\t"
-        ".endm                          \n\t"
-        ".macro FDCT_ROW_SSE2_H2 i t    \n\t"
-        "movq      \\i(%0), %%xmm2      \n\t"
-        "movq      \\i+8(%0), %%xmm0    \n\t"
-        "movdqa    \\t+32(%1), %%xmm3   \n\t"
-        "movdqa    \\t+48(%1), %%xmm7   \n\t"
-        ".endm                          \n\t"
-        ".macro FDCT_ROW_SSE2 i         \n\t"
+        MACRO_BEG( FDCT_ROW_SSE2_H1, i t )
+        "movq    " MACRO_ARG(i,0) "(%0), %%xmm2      \n\t"
+        "movq    " MACRO_ARG(i,0) "+8(%0), %%xmm0    \n\t"
+        "movdqa  " MACRO_ARG(t,1) "+32(%1), %%xmm3   \n\t"
+        "movdqa  " MACRO_ARG(t,1) "+48(%1), %%xmm7   \n\t"
+        "movdqa  " MACRO_ARG(t,1) "(%1), %%xmm4      \n\t"
+        "movdqa  " MACRO_ARG(t,1) "+16(%1), %%xmm5   \n\t"
+        MACRO_END
+        MACRO_BEG( FDCT_ROW_SSE2_H2, i t )
+        "movq    " MACRO_ARG(i,0) "(%0), %%xmm2      \n\t"
+        "movq    " MACRO_ARG(i,0) "+8(%0), %%xmm0    \n\t"
+        "movdqa  " MACRO_ARG(t,1) "+32(%1), %%xmm3   \n\t"
+        "movdqa  " MACRO_ARG(t,1) "+48(%1), %%xmm7   \n\t"
+        MACRO_END
+        MACRO_BEG( FDCT_ROW_SSE2, i )
         "movq      %%xmm2, %%xmm1       \n\t"
-        "pshuflw   $27, %%xmm0, %%xmm0  \n\t"
+        "pshuflw " MACRO_CONST($27) ", %%xmm0, %%xmm0\n\t"
         "paddsw    %%xmm0, %%xmm1       \n\t"
         "psubsw    %%xmm0, %%xmm2       \n\t"
         "punpckldq %%xmm2, %%xmm1       \n\t"
-        "pshufd    $78, %%xmm1, %%xmm2  \n\t"
+        "pshufd  " MACRO_CONST($78) ", %%xmm1, %%xmm2\n\t"
         "pmaddwd   %%xmm2, %%xmm3       \n\t"
         "pmaddwd   %%xmm1, %%xmm7       \n\t"
         "pmaddwd   %%xmm5, %%xmm2       \n\t"
@@ -380,11 +380,11 @@
         "paddd     %%xmm2, %%xmm1       \n\t"
         "paddd     %%xmm6, %%xmm3       \n\t"
         "paddd     %%xmm6, %%xmm1       \n\t"
-        "psrad     %3, %%xmm3           \n\t"
-        "psrad     %3, %%xmm1           \n\t"
+        "psrad   " MACRO_CONST(%3) ", %%xmm3          \n\t"
+        "psrad   " MACRO_CONST(%3) ", %%xmm1          \n\t"
         "packssdw  %%xmm3, %%xmm1       \n\t"
-        "movdqa    %%xmm1, \\i(%4)      \n\t"
-        ".endm                          \n\t"
+        "movdqa    %%xmm1," MACRO_ARG(i,0) "(%4)      \n\t"
+        MACRO_END
         "movdqa    (%2), %%xmm6         \n\t"
         "FDCT_ROW_SSE2_H1 0 0           \n\t"
         "FDCT_ROW_SSE2 0                \n\t"



More information about the ffmpeg-devel mailing list