[vlc-commits] Define CPU capabilities for AVX, AVX2, XOP and FMA4

Rémi Denis-Courmont git at videolan.org
Sat Aug 4 16:29:08 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Aug  4 17:27:34 2012 +0300| [3bc25406ef65b2d260119ec25b33b0692efffd35] | committer: Rémi Denis-Courmont

Define CPU capabilities for AVX, AVX2, XOP and FMA4

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3bc25406ef65b2d260119ec25b33b0692efffd35
---

 include/vlc_cpu.h |   28 ++++++++++++++++++++++++++++
 src/misc/cpu.c    |   20 ++++++++++++--------
 2 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/include/vlc_cpu.h b/include/vlc_cpu.h
index 83a85be..ec2a816 100644
--- a/include/vlc_cpu.h
+++ b/include/vlc_cpu.h
@@ -40,6 +40,10 @@ VLC_API unsigned vlc_CPU(void);
 #  define VLC_CPU_SSE4_1 1024
 #  define VLC_CPU_SSE4_2 2048
 #  define VLC_CPU_SSE4A  4096
+#  define VLC_CPU_AVX    8192
+#  define VLC_CPU_AVX2   16384
+#  define VLC_CPU_XOP    32768
+#  define VLC_CPU_FMA4   65536
 
 # if defined (__MMX__)
 #  define vlc_CPU_MMX() (1)
@@ -103,12 +107,36 @@ VLC_API unsigned vlc_CPU(void);
 #  define vlc_CPU_SSE4A() ((vlc_CPU() & VLC_CPU_SSE4A) != 0)
 # endif
 
+# ifdef __AVX__
+#  define vlc_CPU_AVX() (1)
+# else
+#  define vlc_CPU_AVX() ((vlc_CPU() & VLC_CPU_AVX) != 0)
+# endif
+
+# ifdef __AVX2__
+#  define vlc_CPU_AVX2() (1)
+# else
+#  define vlc_CPU_AVX2() ((vlc_CPU() & VLC_CPU_AVX2) != 0)
+# endif
+
 # ifdef __3dNOW__
 #  define vlc_CPU_3dNOW() (1)
 # else
 #  define vlc_CPU_3dNOW() ((vlc_CPU() & VLC_CPU_3dNOW) != 0)
 # endif
 
+# ifdef __XOP__
+#  define vlc_CPU_XOP() (1)
+# else
+#  define vlc_CPU_XOP() ((vlc_CPU() & VLC_CPU_XOP) != 0)
+# endif
+
+# ifdef __FMA4__
+#  define vlc_CPU_FMA4() (1)
+# else
+#  define vlc_CPU_FMA4() ((vlc_CPU() & VLC_CPU_FMA4) != 0)
+# endif
+
 # elif defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
 #  define HAVE_FPU 1
 #  define VLC_CPU_ALTIVEC 2
diff --git a/src/misc/cpu.c b/src/misc/cpu.c
index 6b284a8..4923d3e 100644
--- a/src/misc/cpu.c
+++ b/src/misc/cpu.c
@@ -330,14 +330,18 @@ void vlc_CPU_dump (vlc_object_t *obj)
 #if defined (__i386__) || defined (__x86_64__)
     if (vlc_CPU_MMX()) p += sprintf (p, "MMX ");
     if (vlc_CPU_MMXEXT()) p += sprintf (p, "MMXEXT ");
-    if (vlc_CPU_SSE()) p += sprintf (p, "SSE ");;
-    if (vlc_CPU_SSE2()) p += sprintf (p, "SSE2 ");;
-    if (vlc_CPU_SSE3()) p += sprintf (p, "SSE2 ");;
-    if (vlc_CPU_SSSE3()) p += sprintf (p, "SSSE3 ");;
-    if (vlc_CPU_SSE4_1()) p += sprintf (p, "SSE4.1 ");;
-    if (vlc_CPU_SSE4_2()) p += sprintf (p, "SSE4.2 ");;
-    if (vlc_CPU_SSE4A()) p += sprintf (p, "SSE4A ");;
-    if (vlc_CPU_3dNOW()) p += sprintf (p, "3DNow! ");;
+    if (vlc_CPU_SSE()) p += sprintf (p, "SSE ");
+    if (vlc_CPU_SSE2()) p += sprintf (p, "SSE2 ");
+    if (vlc_CPU_SSE3()) p += sprintf (p, "SSE2 ");
+    if (vlc_CPU_SSSE3()) p += sprintf (p, "SSSE3 ");
+    if (vlc_CPU_SSE4_1()) p += sprintf (p, "SSE4.1 ");
+    if (vlc_CPU_SSE4_2()) p += sprintf (p, "SSE4.2 ");
+    if (vlc_CPU_SSE4A()) p += sprintf (p, "SSE4A ");
+    if (vlc_CPU_AVX()) p += sprintf (p, "AVX ");
+    if (vlc_CPU_AVX2()) p += sprintf (p, "AVX ");
+    if (vlc_CPU_3dNOW()) p += sprintf (p, "3DNow! ");
+    if (vlc_CPU_XOP()) p += sprintf (p, "XOP ");
+    if (vlc_CPU_FMA4()) p += sprintf (p, "FMA4 ");
 
 #elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__)
     if (vlc_CPU_ALTIVEC())  p += sprintf (p, "AltiVec");



More information about the vlc-commits mailing list