diff options
author | Mike Pall <mike> | 2011-05-26 17:58:29 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2011-05-26 17:58:29 +0200 |
commit | ae3179926af3deca671437c978375b39df6350e1 (patch) | |
tree | 1c923f5e39ebc41d39168114d20aa972d773259c /src | |
parent | 185554b682c1e3dab74d4fa310797033a32815ef (diff) | |
download | luajit-ae3179926af3deca671437c978375b39df6350e1.tar.gz luajit-ae3179926af3deca671437c978375b39df6350e1.tar.bz2 luajit-ae3179926af3deca671437c978375b39df6350e1.zip |
ARM: Add CPU detection.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib_jit.c | 26 | ||||
-rw-r--r-- | src/lj_def.h | 2 | ||||
-rw-r--r-- | src/lj_jit.h | 8 |
3 files changed, 34 insertions, 2 deletions
diff --git a/src/lib_jit.c b/src/lib_jit.c index 259a03e1..6e16d45b 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
@@ -520,6 +520,10 @@ JIT_PARAMDEF(JIT_PARAMINIT) | |||
520 | }; | 520 | }; |
521 | #endif | 521 | #endif |
522 | 522 | ||
523 | #if LJ_TARGET_ARM && LJ_TARGET_LINUX | ||
524 | #include <sys/utsname.h> | ||
525 | #endif | ||
526 | |||
523 | /* Arch-dependent CPU detection. */ | 527 | /* Arch-dependent CPU detection. */ |
524 | static uint32_t jit_cpudetect(lua_State *L) | 528 | static uint32_t jit_cpudetect(lua_State *L) |
525 | { | 529 | { |
@@ -563,7 +567,27 @@ static uint32_t jit_cpudetect(lua_State *L) | |||
563 | #endif | 567 | #endif |
564 | #endif | 568 | #endif |
565 | #elif LJ_TARGET_ARM | 569 | #elif LJ_TARGET_ARM |
566 | /* NYI */ | 570 | /* Compile-time ARM CPU detection. */ |
571 | #if __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ | ||
572 | flags |= JIT_F_ARMV6|JIT_F_ARMV6T2|JIT_F_ARMV7; | ||
573 | #elif __ARM_ARCH_6T2__ | ||
574 | flags |= JIT_F_ARMV6|JIT_F_ARMV6T2; | ||
575 | #elif __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6Z__ || __ARM_ARCH_6ZK__ | ||
576 | flags |= JIT_F_ARMV6; | ||
577 | #endif | ||
578 | /* Runtime ARM CPU detection. */ | ||
579 | #if LJ_TARGET_LINUX | ||
580 | if (!(flags & JIT_F_ARMV7)) { | ||
581 | struct utsname ut; | ||
582 | uname(&ut); | ||
583 | if (strncmp(ut.machine, "armv", 4) == 0) { | ||
584 | if (ut.machine[4] >= '7') | ||
585 | flags |= JIT_F_ARMV6|JIT_F_ARMV6T2|JIT_F_ARMV7; | ||
586 | else if (ut.machine[4] == '6') | ||
587 | flags |= JIT_F_ARMV6; | ||
588 | } | ||
589 | } | ||
590 | #endif | ||
567 | #elif LJ_TARGET_PPC | 591 | #elif LJ_TARGET_PPC |
568 | /* Nothing to do. */ | 592 | /* Nothing to do. */ |
569 | #else | 593 | #else |
diff --git a/src/lj_def.h b/src/lj_def.h index 86f041a4..197df291 100644 --- a/src/lj_def.h +++ b/src/lj_def.h | |||
@@ -136,7 +136,7 @@ static LJ_AINLINE uint32_t lj_bswap(uint32_t x) | |||
136 | { | 136 | { |
137 | uint32_t r; | 137 | uint32_t r; |
138 | #if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\ | 138 | #if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\ |
139 | __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ | 139 | __ARM_ARCH_6ZK__ || __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ |
140 | __asm__("rev %0, %1" : "=r" (r) : "r" (x)); | 140 | __asm__("rev %0, %1" : "=r" (r) : "r" (x)); |
141 | return r; | 141 | return r; |
142 | #else | 142 | #else |
diff --git a/src/lj_jit.h b/src/lj_jit.h index 63584355..ea2dd4ad 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h | |||
@@ -26,6 +26,14 @@ | |||
26 | /* Names for the CPU-specific flags. Must match the order above. */ | 26 | /* Names for the CPU-specific flags. Must match the order above. */ |
27 | #define JIT_F_CPU_FIRST JIT_F_CMOV | 27 | #define JIT_F_CPU_FIRST JIT_F_CMOV |
28 | #define JIT_F_CPUSTRING "\4CMOV\4SSE2\4SSE3\6SSE4.1\2P4\3AMD\2K8\4ATOM" | 28 | #define JIT_F_CPUSTRING "\4CMOV\4SSE2\4SSE3\6SSE4.1\2P4\3AMD\2K8\4ATOM" |
29 | #elif LJ_TARGET_ARM | ||
30 | #define JIT_F_ARMV6 0x00000010 | ||
31 | #define JIT_F_ARMV6T2 0x00000020 | ||
32 | #define JIT_F_ARMV7 0x00000040 | ||
33 | |||
34 | /* Names for the CPU-specific flags. Must match the order above. */ | ||
35 | #define JIT_F_CPU_FIRST JIT_F_ARMV6 | ||
36 | #define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7" | ||
29 | #else | 37 | #else |
30 | #define JIT_F_CPU_FIRST 0 | 38 | #define JIT_F_CPU_FIRST 0 |
31 | #define JIT_F_CPUSTRING "" | 39 | #define JIT_F_CPUSTRING "" |