Clean up ARM capability flags. Only set highest arch version.

This commit is contained in:
Mike Pall 2012-07-08 22:20:11 +02:00
parent c00ffcb870
commit b23a7830d2
2 changed files with 18 additions and 16 deletions

View File

@ -590,27 +590,23 @@ static uint32_t jit_cpudetect(lua_State *L)
#endif #endif
#elif LJ_TARGET_ARM #elif LJ_TARGET_ARM
#if LJ_HASJIT #if LJ_HASJIT
/* Compile-time ARM CPU detection. */ int ver = LJ_ARCH_VERSION; /* Compile-time ARM CPU detection. */
#if LJ_ARCH_VERSION >= 70
flags |= JIT_F_ARMV6|JIT_F_ARMV6T2|JIT_F_ARMV7;
#elif LJ_ARCH_VERSION >= 61
flags |= JIT_F_ARMV6|JIT_F_ARMV6T2;
#elif LJ_ARCH_VERSION >= 60
flags |= JIT_F_ARMV6;
#endif
/* Runtime ARM CPU detection. */
#if LJ_TARGET_LINUX #if LJ_TARGET_LINUX
if (!(flags & JIT_F_ARMV7)) { if (ver < 70) { /* Runtime ARM CPU detection. */
struct utsname ut; struct utsname ut;
uname(&ut); uname(&ut);
if (strncmp(ut.machine, "armv", 4) == 0) { if (strncmp(ut.machine, "armv", 4) == 0) {
if (ut.machine[4] >= '7') if (ut.machine[4] >= '7')
flags |= JIT_F_ARMV6|JIT_F_ARMV6T2|JIT_F_ARMV7; ver = 70;
else if (ut.machine[4] == '6') else if (ut.machine[4] == '6')
flags |= JIT_F_ARMV6; ver = 60;
} }
} }
#endif #endif
flags |= ver >= 70 ? JIT_F_ARMV7 :
ver >= 61 ? JIT_F_ARMV6T2_ :
ver >= 60 ? JIT_F_ARMV6_ : 0;
flags |= LJ_ARCH_HASFPU == 0 ? 0 : ver >= 70 ? JIT_F_VFPV3 : JIT_F_VFPV2;
#endif #endif
#elif LJ_TARGET_PPC #elif LJ_TARGET_PPC
#if LJ_HASJIT #if LJ_HASJIT

View File

@ -27,13 +27,19 @@
#define JIT_F_CPU_FIRST JIT_F_CMOV #define JIT_F_CPU_FIRST JIT_F_CMOV
#define JIT_F_CPUSTRING "\4CMOV\4SSE2\4SSE3\6SSE4.1\2P4\3AMD\2K8\4ATOM" #define JIT_F_CPUSTRING "\4CMOV\4SSE2\4SSE3\6SSE4.1\2P4\3AMD\2K8\4ATOM"
#elif LJ_TARGET_ARM #elif LJ_TARGET_ARM
#define JIT_F_ARMV6 0x00000010 #define JIT_F_ARMV6_ 0x00000010
#define JIT_F_ARMV6T2 0x00000020 #define JIT_F_ARMV6T2_ 0x00000020
#define JIT_F_ARMV7 0x00000040 #define JIT_F_ARMV7 0x00000040
#define JIT_F_VFPV2 0x00000080
#define JIT_F_VFPV3 0x00000100
#define JIT_F_ARMV6 (JIT_F_ARMV6_|JIT_F_ARMV6T2_|JIT_F_ARMV7)
#define JIT_F_ARMV6T2 (JIT_F_ARMV6T2_|JIT_F_ARMV7)
#define JIT_F_VFP (JIT_F_VFPV2|JIT_F_VFPV3)
/* Names for the CPU-specific flags. Must match the order above. */ /* Names for the CPU-specific flags. Must match the order above. */
#define JIT_F_CPU_FIRST JIT_F_ARMV6 #define JIT_F_CPU_FIRST JIT_F_ARMV6_
#define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7" #define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7\5VFPv2\5VFPv3"
#elif LJ_TARGET_PPC #elif LJ_TARGET_PPC
#define JIT_F_SQRT 0x00000010 #define JIT_F_SQRT 0x00000010
#define JIT_F_ROUND 0x00000020 #define JIT_F_ROUND 0x00000020