From e80e63788eb6ceb2b987db17fe77225c0446e956 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 30 Dec 2013 07:58:18 +0100 Subject: [PATCH] (ARM) (NEON) Enable ARM runfast mode - see http://infocenter.arm.com/help/topic/com.arm.doc.ddi0274h/Chdiihcd.html - found this inside the code for Mupen64 (glN64 ES2 driver) --- performance.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/performance.c b/performance.c index 446f755b56..34798e94f7 100644 --- a/performance.c +++ b/performance.c @@ -259,6 +259,23 @@ static uint64_t xgetbv_x86(uint32_t index) } #endif +#ifdef HAVE_NEON +static void arm_enable_runfast_mode(void) +{ + static const unsigned int x = 0x04086060; + static const unsigned int y = 0x03000000; + int r; + asm volatile( + "fmrx %0, fpscr \n\t" //r0 = FPSCR + "and %0, %0, %1 \n\t" //r0 = r0 & 0x04086060 + "orr %0, %0, %2 \n\t" //r0 = r0 | 0x03000000 + "fmxr fpscr, %0 \n\t" //FPSCR = r0 + : "=r"(r) + : "r"(x), "r"(y) + ); +} +#endif + uint64_t rarch_get_cpu_features(void) { uint64_t cpu = 0; @@ -305,13 +322,20 @@ uint64_t rarch_get_cpu_features(void) RARCH_LOG("[CPUID]: AVX: %u\n", !!(cpu & RETRO_SIMD_AVX)); #elif defined(ANDROID) && defined(ANDROID_ARM) uint64_t cpu_flags = android_getCpuFeatures(); + (void)cpu_flags; +#ifdef HAVE_NEON if (cpu_flags & ANDROID_CPU_ARM_FEATURE_NEON) + { cpu |= RETRO_SIMD_NEON; + arm_enable_runfast_mode(); + } +#endif RARCH_LOG("[CPUID]: NEON: %u\n", !!(cpu & RETRO_SIMD_NEON)); #elif defined(HAVE_NEON) cpu |= RETRO_SIMD_NEON; + arm_enable_runfast_mode(); RARCH_LOG("[CPUID]: NEON: %u\n", !!(cpu & RETRO_SIMD_NEON)); #elif defined(__CELLOS_LV2__) cpu |= RETRO_SIMD_VMX;