libretro-common: Compiling tune-up for ARM architectures.

- Fixes a mismatched register warning in arm_enable_runfast_mode() when compiling for AArch64.
- Fix compiling check_arm_cpu_feature() on non-ARM architectures by being super explicit and pedantic about checking for __ARM_ARCH; none of this compiler-assumes-a-macro-equals-zero-if-undefined stuff.
This commit is contained in:
rogerman 2022-06-20 11:22:26 -07:00
parent a95e4c57c6
commit d4afd4977c
1 changed files with 10 additions and 3 deletions

View File

@ -300,10 +300,17 @@ static void arm_enable_runfast_mode(void)
static const unsigned y = 0x03000000; static const unsigned y = 0x03000000;
int r; int r;
__asm__ volatile( __asm__ volatile(
#if defined(__aarch64__) || defined(_M_ARM64)
"fmrx %w0, fpscr \n\t" /* w0 = FPSCR */
"and %w0, %w0, %w1 \n\t" /* w0 = w0 & 0x04086060 */
"orr %w0, %w0, %w2 \n\t" /* w0 = w0 | 0x03000000 */
"fmxr fpscr, %w0 \n\t" /* FPSCR = w0 */
#else
"fmrx %0, fpscr \n\t" /* r0 = FPSCR */ "fmrx %0, fpscr \n\t" /* r0 = FPSCR */
"and %0, %0, %1 \n\t" /* r0 = r0 & 0x04086060 */ "and %0, %0, %1 \n\t" /* r0 = r0 & 0x04086060 */
"orr %0, %0, %2 \n\t" /* r0 = r0 | 0x03000000 */ "orr %0, %0, %2 \n\t" /* r0 = r0 | 0x03000000 */
"fmxr fpscr, %0 \n\t" /* FPSCR = r0 */ "fmxr fpscr, %0 \n\t" /* FPSCR = r0 */
#endif
: "=r"(r) : "=r"(r)
: "r"(x), "r"(y) : "r"(x), "r"(y)
); );
@ -311,13 +318,13 @@ static void arm_enable_runfast_mode(void)
#endif #endif
#if defined(__linux__) && !defined(CPU_X86) #if defined(__linux__) && !defined(CPU_X86)
#if __ARM_ARCH #if defined(__ARM_ARCH) && (__ARM_ARCH > 0)
#include <sys/auxv.h> #include <sys/auxv.h>
#endif #endif
static unsigned char check_arm_cpu_feature(const char* feature) static unsigned char check_arm_cpu_feature(const char* feature)
{ {
#if __ARM_ARCH < 8 #if defined(__ARM_ARCH) && (__ARM_ARCH < 8)
uint64_t hwcap = getauxval(AT_HWCAP); uint64_t hwcap = getauxval(AT_HWCAP);
if (!strcmp(feature, "neon")) if (!strcmp(feature, "neon"))
return (hwcap & HWCAP_ARM_NEON) != 0; return (hwcap & HWCAP_ARM_NEON) != 0;
@ -326,7 +333,7 @@ static unsigned char check_arm_cpu_feature(const char* feature)
if (!strcmp(feature, "vfpv4")) if (!strcmp(feature, "vfpv4"))
return (hwcap & HWCAP_ARM_VFPv4) != 0; return (hwcap & HWCAP_ARM_VFPv4) != 0;
return 0; return 0;
#elif __ARM_ARCH == 8 #elif defined(__ARM_ARCH) && (__ARM_ARCH == 8)
uint64_t hwcap = getauxval(AT_HWCAP); uint64_t hwcap = getauxval(AT_HWCAP);
if (!strcmp(feature, "asimd")) if (!strcmp(feature, "asimd"))
return (hwcap & HWCAP_ASIMD) != 0; return (hwcap & HWCAP_ASIMD) != 0;