summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOded Gabbay <oded.gabbay@gmail.com>2015-11-17 12:38:45 +0200
committerOded Gabbay <oded.gabbay@gmail.com>2016-05-01 14:42:28 +0300
commit8467043948cb4a55bf113340b52144cae7167dab (patch)
tree2ea52c89c00f4cb94862827d6ca71d5e3c88bf87
parente0bd0410ad15476e47c2da5b87730e6243148099 (diff)
llvmpipe: Add detection of VSX capability
This patch adds detection of VSX capability. This capability was added to Power ISA v2.06, and it was first implemented in POWER7 architecture. Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
-rw-r--r--src/gallium/auxiliary/util/u_cpu_detect.c27
-rw-r--r--src/gallium/auxiliary/util/u_cpu_detect.h1
2 files changed, 28 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c b/src/gallium/auxiliary/util/u_cpu_detect.c
index 10b090216d..10ca8975aa 100644
--- a/src/gallium/auxiliary/util/u_cpu_detect.c
+++ b/src/gallium/auxiliary/util/u_cpu_detect.c
@@ -139,9 +139,35 @@ check_os_altivec_support(void)
}
#endif /* !PIPE_OS_APPLE */
}
+
+static void
+check_os_vsx_support(void)
+{
+#if !defined(PIPE_OS_APPLE)
+ /* not on Apple/Darwin, do it the brute-force way */
+ /* this is borrowed from the libmpeg2 library */
+ signal(SIGILL, sigill_handler);
+ if (setjmp(__lv_powerpc_jmpbuf)) {
+ signal(SIGILL, SIG_DFL);
+ } else {
+ __lv_powerpc_canjump = 1;
+
+ __asm __volatile
+ ("mtspr 256, %0\n\t"
+ "xxland %%vs0, %%vs0, %%vs0"
+ :
+ : "r" (-1));
+
+ signal(SIGILL, SIG_DFL);
+ util_cpu_caps.has_vsx = 1;
+ }
+#endif /* !PIPE_OS_APPLE */
+}
+
#endif /* PIPE_ARCH_PPC */
+
#if defined(PIPE_ARCH_X86) || defined (PIPE_ARCH_X86_64)
static int has_cpuid(void)
{
@@ -427,6 +453,7 @@ util_cpu_detect(void)
#if defined(PIPE_ARCH_PPC)
check_os_altivec_support();
+ check_os_vsx_support();
#endif /* PIPE_ARCH_PPC */
#ifdef DEBUG
diff --git a/src/gallium/auxiliary/util/u_cpu_detect.h b/src/gallium/auxiliary/util/u_cpu_detect.h
index 5ccfc93169..0a2a74b27c 100644
--- a/src/gallium/auxiliary/util/u_cpu_detect.h
+++ b/src/gallium/auxiliary/util/u_cpu_detect.h
@@ -71,6 +71,7 @@ struct util_cpu_caps {
unsigned has_xop:1;
unsigned has_altivec:1;
unsigned has_daz:1;
+ unsigned has_vsx:1;
};
extern struct util_cpu_caps