From 2423118e239e9c85dd68403bf8b97b30965df38e Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Wed, 15 Apr 2009 10:38:37 -0400 Subject: [PATCH] Add support for doing ARM simd detection on Windows --- pixman/pixman-arm-detect-win32.asm | 10 ++++++++++ pixman/pixman-arm-simd.h | 2 +- pixman/pixman-pict.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 pixman/pixman-arm-detect-win32.asm diff --git a/pixman/pixman-arm-detect-win32.asm b/pixman/pixman-arm-detect-win32.asm new file mode 100644 index 0000000..dfe363e --- /dev/null +++ b/pixman/pixman-arm-detect-win32.asm @@ -0,0 +1,10 @@ + area pixman_msvc, code, readonly + + export pixman_msvc_try_armv6_op + +pixman_msvc_try_armv6_op + uqadd8 r0,r0,r1 + mov pc,lr + endp + + end diff --git a/pixman/pixman-arm-simd.h b/pixman/pixman-arm-simd.h index ecaace5..fae7b94 100644 --- a/pixman/pixman-arm-simd.h +++ b/pixman/pixman-arm-simd.h @@ -28,7 +28,7 @@ #ifdef USE_ARM_SIMD -static inline pixman_bool_t pixman_have_arm_simd(void) { return TRUE; } +pixman_bool_t pixman_have_arm_simd(void); #else #define pixman_have_arm_simd() FALSE diff --git a/pixman/pixman-pict.c b/pixman/pixman-pict.c index 5f3ddd2..82d7160 100644 --- a/pixman/pixman-pict.c +++ b/pixman/pixman-pict.c @@ -37,6 +37,11 @@ #include "pixman-arm-simd.h" #include "pixman-combine32.h" +#if defined(USE_ARM_SIMD) && defined(_MSC_VER) +/* Needed for EXCEPTION_ILLEGAL_INSTRUCTION */ +#include +#endif + #define FbFullMask(n) ((n) == 32 ? (uint32_t)-1 : ((((uint32_t) 1) << n) - 1)) #undef READ @@ -2190,6 +2195,31 @@ pixman_bool_t pixman_have_vmx (void) { #endif /* __APPLE__ */ #endif /* USE_VMX */ +#ifdef USE_ARM_SIMD +pixman_bool_t +pixman_have_arm_simd (void) +{ +#ifdef _MSC_VER + static pixman_bool_t initialized = FALSE; + static pixman_bool_t have_arm_simd = FALSE; + + if (!initialized) { + __try { + pixman_msvc_try_armv6_op(); + have_arm_simd = TRUE; + } __except(GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION) { + have_arm_simd = FALSE; + } + initialized = TRUE; + } + + return have_arm_simd; +#else + return TRUE; +#endif +} +#endif + #ifdef USE_MMX /* The CPU detection code needs to be in a file not compiled with * "-mmmx -msse", as gcc would generate CMOV instructions otherwise -- 2.34.1