From 9edf280fb25bee071c166123ac1aee41d4a4949e Mon Sep 17 00:00:00 2001
From: Josh Blum <josh@joshknows.com>
Date: Sat, 15 Jan 2011 17:29:15 -0800
Subject: volk: replace assembly and separate cases with gcc cpuid for all x86

---
 volk/include/volk/make_cpuid_x86_c.py |  3 ++-
 volk/include/volk/make_set_simd.py    | 33 +++++++++------------------------
 2 files changed, 11 insertions(+), 25 deletions(-)

(limited to 'volk/include')

diff --git a/volk/include/volk/make_cpuid_x86_c.py b/volk/include/volk/make_cpuid_x86_c.py
index 48a406fa40..2b2bd7c912 100644
--- a/volk/include/volk/make_cpuid_x86_c.py
+++ b/volk/include/volk/make_cpuid_x86_c.py
@@ -27,9 +27,10 @@ def make_cpuid_x86_c(dom) :
     tempstring = tempstring + "/*this file is auto_generated by volk_register.py*/\n\n";
     tempstring = tempstring + "#include <volk/volk_cpu.h>\n"
     tempstring = tempstring + "#include <volk/volk_config_fixed.h>\n\n"
+    tempstring = tempstring + "#include <gcc_x86_cpuid.h>\n\n"
     tempstring = tempstring + "struct VOLK_CPU volk_cpu;\n\n"
 
-    tempstring = tempstring + "extern void cpuid_x86 (unsigned int op, unsigned int result[4]);\n\n"
+    tempstring = tempstring + "#define cpuid_x86(op, r) __get_cpuid(op, r+0, r+1, r+2, r+3)\n\n"
     tempstring = tempstring + "static inline unsigned int cpuid_eax(unsigned int op) {\n";
     tempstring = tempstring + "    unsigned int regs[4];\n"
     tempstring = tempstring + "    cpuid_x86 (op, regs);\n"
diff --git a/volk/include/volk/make_set_simd.py b/volk/include/volk/make_set_simd.py
index 842366b181..275d3869f3 100644
--- a/volk/include/volk/make_set_simd.py
+++ b/volk/include/volk/make_set_simd.py
@@ -27,30 +27,15 @@ def make_set_simd(dom) :
     tempstring = tempstring + "  AC_MSG_CHECKING([proccpu])\n";
     tempstring = tempstring + "  case \"$MD_CPU\" in\n";
     tempstring = tempstring + "  (x86)\n";
-    tempstring = tempstring + "    case \"$MD_SUBCPU\" in\n";
-    tempstring = tempstring + "    (x86)\n";
-    tempstring = tempstring + "      if test -z \"`${CC} -o proccpu -I $srcdir/include/ -I$srcdir/lib $srcdir/lib/volk_proccpu_sim.c $srcdir/lib/volk_cpu_x86.c $srcdir/lib/cpuid_x86.S`\"\n";
-    tempstring = tempstring + "        then\n";
-    tempstring = tempstring + "          AC_MSG_RESULT(yes)\n";
-    tempstring = tempstring + "          lv_PROCCPU=\"`./proccpu`\"\n";
-    tempstring = tempstring + "          rm -f proccpu\n";
-    tempstring = tempstring + "        else\n";
-    tempstring = tempstring + "          AC_MSG_RESULT(no)\n";
-    tempstring = tempstring + "          lv_PROCCPU=no\n";
-    tempstring = tempstring + "      fi\n"
-    tempstring = tempstring + "    ;;\n"
-    tempstring = tempstring + "    (*)\n"
-    tempstring = tempstring + "      if test -z \"`${CC} -o proccpu -I$srcdir/include/ -I$srcdir/lib $srcdir/lib/volk_proccpu_sim.c $srcdir/lib/volk_cpu_x86.c $srcdir/lib/cpuid_x86_64.S`\"\n";
-    tempstring = tempstring + "        then\n";
-    tempstring = tempstring + "          AC_MSG_RESULT(yes)\n";
-    tempstring = tempstring + "          lv_PROCCPU=\"`./proccpu`\"\n";
-    tempstring = tempstring + "          rm -f proccpu\n";
-    tempstring = tempstring + "        else\n";
-    tempstring = tempstring + "          AC_MSG_RESULT(no)\n";
-    tempstring = tempstring + "          lv_PROCCPU=no\n";
-    tempstring = tempstring + "      fi\n"
-    tempstring = tempstring + "    ;;\n"
-    tempstring = tempstring + "    esac\n"
+    tempstring = tempstring + "    if test -z \"`${CC} -o proccpu -I$srcdir/include/ -I$srcdir/lib $srcdir/lib/volk_proccpu_sim.c $srcdir/lib/volk_cpu_x86.c 2>&1`\"\n";
+    tempstring = tempstring + "      then\n";
+    tempstring = tempstring + "        AC_MSG_RESULT(yes)\n";
+    tempstring = tempstring + "        lv_PROCCPU=\"`./proccpu`\"\n";
+    tempstring = tempstring + "        rm -f proccpu\n";
+    tempstring = tempstring + "      else\n";
+    tempstring = tempstring + "        AC_MSG_RESULT(no)\n";
+    tempstring = tempstring + "        lv_PROCCPU=no\n";
+    tempstring = tempstring + "    fi\n"
     tempstring = tempstring + "  ;;\n";
     tempstring = tempstring + "  (powerpc)\n";
     tempstring = tempstring + "    if test -z \"`${CC} -o proccpu -I$srcdir/include/ $srcdir/lib/volk_proccpu_sim.c $srcdir/lib/volk_cpu_powerpc.c 2>&1`\"\n";
-- 
cgit v1.2.3