[xiph-commits] r13920 - in trunk/theora: . lib

sping at svn.xiph.org sping at svn.xiph.org
Tue Oct 2 13:25:17 PDT 2007


Author: sping
Date: 2007-10-02 13:25:17 -0700 (Tue, 02 Oct 2007)
New Revision: 13920

Added:
   trunk/theora/lib/cpu_asm_1_gcc.c
   trunk/theora/lib/cpu_asm_1_msvc.c
   trunk/theora/update_asm.sh
Modified:
   trunk/theora/lib/cpu.c
Log:
First step for automated GCC to MSVC inline assembly conversion
derf, this is what I want you to have a look at


Modified: trunk/theora/lib/cpu.c
===================================================================
--- trunk/theora/lib/cpu.c	2007-10-02 20:19:44 UTC (rev 13919)
+++ trunk/theora/lib/cpu.c	2007-10-02 20:25:17 UTC (rev 13920)
@@ -56,22 +56,13 @@
    :"a" (_op) \
    :"cc" \
   )
-  __asm__ __volatile__(
-   "pushfl\n\t"
-   "pushfl\n\t"
-   "popl          %0\n\t"
-   "movl          %0,%1\n\t"
-   "xorl   $0x200000,%0\n\t"
-   "pushl         %0\n\t"
-   "popfl\n\t"
-   "pushfl\n\t"
-   "popl          %0\n\t"
-   "popfl\n\t"
-   :"=r" (eax),
-    "=r" (ebx)
-   :
-   :"cc"
-  );
+
+#ifdef _MSC_VER
+# include "cpu_asm_1_msvc.c"
+#else
+# include "cpu_asm_1_gcc.c"
+#endif
+
   /*No cpuid.*/
   if(eax==ebx)return 0;
 #endif

Added: trunk/theora/lib/cpu_asm_1_gcc.c
===================================================================
--- trunk/theora/lib/cpu_asm_1_gcc.c	                        (rev 0)
+++ trunk/theora/lib/cpu_asm_1_gcc.c	2007-10-02 20:25:17 UTC (rev 13920)
@@ -0,0 +1,21 @@
+#ifdef USE_ASM
+
+  __asm__ __volatile__(
+   "pushfl\n\t"
+   "pushfl\n\t"
+   "popl          %0\n\t"
+   "movl          %0,%1\n\t"
+   "xorl   $0x200000,%0\n\t"
+   "pushl         %0\n\t"
+   "popfl\n\t"
+   "pushfl\n\t"
+   "popl          %0\n\t"
+   "popfl\n\t"
+   :"=r" (eax),
+    "=r" (ebx)
+   :
+   :"cc"
+  );
+
+#endif /* USE_ASM */
+

Added: trunk/theora/lib/cpu_asm_1_msvc.c
===================================================================
--- trunk/theora/lib/cpu_asm_1_msvc.c	                        (rev 0)
+++ trunk/theora/lib/cpu_asm_1_msvc.c	2007-10-02 20:25:17 UTC (rev 13920)
@@ -0,0 +1,14 @@
+#ifdef USE_ASM
+
+   pushfl
+   pushfl
+   popl          eax
+   movl          eax,ebx
+   xorl   0x200000,eax
+   pushl         eax
+   popfl
+   pushfl
+   popl          eax
+   popfl
+
+#endif /* USE_ASM */

Added: trunk/theora/update_asm.sh
===================================================================
--- trunk/theora/update_asm.sh	                        (rev 0)
+++ trunk/theora/update_asm.sh	2007-10-02 20:25:17 UTC (rev 13920)
@@ -0,0 +1,27 @@
+#! /bin/bash
+# ---------------------------------------
+# Written by Sebastian Pipping <sping at xiph.org>
+#
+# WORK IN PROGRESS!
+# ---------------------------------------
+
+IN_FILE="lib/cpu_asm_1_gcc.c"
+OUT_FILE="lib/cpu_asm_1_msvc.c"
+
+echo "#ifdef USE_ASM" > ${OUT_FILE}
+echo "" >> ${OUT_FILE}
+
+cat ${IN_FILE}\
+    | grep '\\n\\t'\
+    | sed -r 's/\\n\\t//'\
+    | sed -r 's/%0/eax/'\
+    | sed -r 's/%1/ebx/'\
+    | sed -r 's/"(.+)"/\1/'\
+    | sed -r 's/\$((0x)?[0-9]+)/\1/'\
+    >> lib/cpu_asm_1_msvc.c
+
+echo "" >> ${OUT_FILE}
+echo "#endif /* USE_ASM */" >> ${OUT_FILE}
+
+cat ${OUT_FILE}
+


Property changes on: trunk/theora/update_asm.sh
___________________________________________________________________
Name: svn:executable
   + *



More information about the commits mailing list