diff options
| author | Mike Pall <mike> | 2012-03-30 01:34:17 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2012-03-30 01:34:17 +0200 |
| commit | 2225c9aafc9245e12b22d34b68be8017c42febd8 (patch) | |
| tree | 7bbd093737535404e793384014c1f7d11df5e542 /src | |
| parent | aaaf0e0f5fe573e7c089ece1bd491a8f8b8b3e9a (diff) | |
| download | luajit-2225c9aafc9245e12b22d34b68be8017c42febd8.tar.gz luajit-2225c9aafc9245e12b22d34b68be8017c42febd8.tar.bz2 luajit-2225c9aafc9245e12b22d34b68be8017c42febd8.zip | |
MIPS: Add MIPS32R2 compile-time/runtime CPU detection.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib_jit.c | 16 | ||||
| -rw-r--r-- | src/lj_jit.h | 6 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/lib_jit.c b/src/lib_jit.c index 05a79d51..7d5e0aef 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
| @@ -615,7 +615,21 @@ static uint32_t jit_cpudetect(lua_State *L) | |||
| 615 | #elif LJ_TARGET_PPC || LJ_TARGET_PPCSPE | 615 | #elif LJ_TARGET_PPC || LJ_TARGET_PPCSPE |
| 616 | /* Nothing to do. */ | 616 | /* Nothing to do. */ |
| 617 | #elif LJ_TARGET_MIPS | 617 | #elif LJ_TARGET_MIPS |
| 618 | /* NYI */ | 618 | #if LJ_HASJIT |
| 619 | /* Compile-time MIPS CPU detection. */ | ||
| 620 | #if _MIPS_ARCH_MIPS32R2 | ||
| 621 | flags |= JIT_F_MIPS32R2; | ||
| 622 | #endif | ||
| 623 | /* Runtime MIPS CPU detection. */ | ||
| 624 | #if defined(__GNUC__) | ||
| 625 | if (!(flags & JIT_F_MIPS32R2)) { | ||
| 626 | int x; | ||
| 627 | /* On MIPS32R1 rotr is treated as srl. rotr r2,r2,1 -> srl r2,r2,1. */ | ||
| 628 | __asm__("li $2, 1\n\t.long 0x00221042\n\tmove %0, $2" : "=r"(x) : : "$2"); | ||
| 629 | if (x) flags |= JIT_F_MIPS32R2; /* Either 0x80000000 (R2) or 0 (R1). */ | ||
| 630 | } | ||
| 631 | #endif | ||
| 632 | #endif | ||
| 619 | #else | 633 | #else |
| 620 | #error "Missing CPU detection for this architecture" | 634 | #error "Missing CPU detection for this architecture" |
| 621 | #endif | 635 | #endif |
diff --git a/src/lj_jit.h b/src/lj_jit.h index 1033e792..dd0c08d8 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h | |||
| @@ -34,6 +34,12 @@ | |||
| 34 | /* Names for the CPU-specific flags. Must match the order above. */ | 34 | /* Names for the CPU-specific flags. Must match the order above. */ |
| 35 | #define JIT_F_CPU_FIRST JIT_F_ARMV6 | 35 | #define JIT_F_CPU_FIRST JIT_F_ARMV6 |
| 36 | #define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7" | 36 | #define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7" |
| 37 | #elif LJ_TARGET_MIPS | ||
| 38 | #define JIT_F_MIPS32R2 0x00000010 | ||
| 39 | |||
| 40 | /* Names for the CPU-specific flags. Must match the order above. */ | ||
| 41 | #define JIT_F_CPU_FIRST JIT_F_MIPS32R2 | ||
| 42 | #define JIT_F_CPUSTRING "\010MIPS32R2" | ||
| 37 | #else | 43 | #else |
| 38 | #define JIT_F_CPU_FIRST 0 | 44 | #define JIT_F_CPU_FIRST 0 |
| 39 | #define JIT_F_CPUSTRING "" | 45 | #define JIT_F_CPUSTRING "" |
