]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
ARM/PPC: Detect more target arch variants. Detect console OS.
authorMike Pall <mike>
Sat, 9 Jun 2012 18:53:22 +0000 (20:53 +0200)
committerMike Pall <mike>
Sat, 9 Jun 2012 18:53:22 +0000 (20:53 +0200)
src/lib_jit.c
src/lj_arch.h

index 7d5e0aef8c08b37730694875d093a93815d4541b..db6bcfa8c9e69b288b94d3fca7aa5347503d3eb7 100644 (file)
@@ -591,11 +591,11 @@ static uint32_t jit_cpudetect(lua_State *L)
 #elif LJ_TARGET_ARM
 #if LJ_HASJIT
   /* Compile-time ARM CPU detection. */
-#if __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__
+#if LJ_ARCH_VERSION >= 70
   flags |= JIT_F_ARMV6|JIT_F_ARMV6T2|JIT_F_ARMV7;
-#elif __ARM_ARCH_6T2__
+#elif LJ_ARCH_VERSION >= 61
   flags |= JIT_F_ARMV6|JIT_F_ARMV6T2;
-#elif __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6Z__ || __ARM_ARCH_6ZK__
+#elif LJ_ARCH_VERSION >= 60
   flags |= JIT_F_ARMV6;
 #endif
   /* Runtime ARM CPU detection. */
@@ -612,12 +612,28 @@ static uint32_t jit_cpudetect(lua_State *L)
   }
 #endif
 #endif
-#elif LJ_TARGET_PPC || LJ_TARGET_PPCSPE
+#elif LJ_TARGET_PPC
+#if LJ_ARCH_PPC64
+  flags |= JIT_F_PPC64;
+#endif
+#if LJ_ARCH_SQRT
+  flags |= JIT_F_SQRT;
+#endif
+#if LJ_ARCH_ROUND
+  flags |= JIT_F_ROUND;
+#endif
+#if LJ_ARCH_CELL
+  flags |= JIT_F_CELL;
+#endif
+#if LJ_ARCH_XENON
+  flags |= JIT_F_XENON;
+#endif
+#elif LJ_TARGET_PPCSPE
   /* Nothing to do. */
 #elif LJ_TARGET_MIPS
 #if LJ_HASJIT
   /* Compile-time MIPS CPU detection. */
-#if _MIPS_ARCH_MIPS32R2
+#if LJ_ARCH_VERSION >= 20
   flags |= JIT_F_MIPS32R2;
 #endif
   /* Runtime MIPS CPU detection. */
index 5f7885025808cd442751cb5a4bc56353816b0f87..476c1241a859ddedbc8a3aac881b0244d3363c65 100644 (file)
@@ -60,7 +60,7 @@
 /* Select native OS if no target OS defined. */
 #ifndef LUAJIT_OS
 
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(_XBOX_VER)
 #define LUAJIT_OS      LUAJIT_OS_WINDOWS
 #elif defined(__linux__)
 #define LUAJIT_OS      LUAJIT_OS_LINUX
 #define LJ_TARGET_POSIX                (LUAJIT_OS > LUAJIT_OS_WINDOWS)
 #define LJ_TARGET_DLOPEN       LJ_TARGET_POSIX
 
+#ifdef __CELLOS_LV2__
+#define LJ_TARGET_PS3          1
+#define LJ_TARGET_CONSOLE      1
+#endif
+
+#if _XBOX_VER >= 200
+#define LJ_TARGET_XBOX360      1
+#define LJ_TARGET_CONSOLE      1
+#endif
+
 #define LJ_NUMMODE_SINGLE      0       /* Single-number mode only. */
 #define LJ_NUMMODE_SINGLE_DUAL 1       /* Default to single-number mode. */
 #define LJ_NUMMODE_DUAL                2       /* Dual-number mode only. */
 #define LJ_TARGET_UNIFYROT     2       /* Want only IR_BROR. */
 #define LJ_ARCH_NUMMODE                LJ_NUMMODE_DUAL
 
+#if __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__
+#define LJ_ARCH_VERSION                70
+#elif __ARM_ARCH_6T2__
+#define LJ_ARCH_VERSION                61
+#elif __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6K__ || __ARM_ARCH_6Z__ || __ARM_ARCH_6ZK__
+#define LJ_ARCH_VERSION                60
+#else
+#define LJ_ARCH_VERSION                50
+#endif
+
 #elif LUAJIT_TARGET == LUAJIT_ARCH_PPC
 
 #define LJ_ARCH_NAME           "ppc"
 #define LJ_TARGET_UNIFYROT     1       /* Want only IR_BROL. */
 #define LJ_ARCH_NUMMODE                LJ_NUMMODE_DUAL_SINGLE
 
+#if _ARCH_PWR7
+#define LJ_ARCH_VERSION                70
+#elif _ARCH_PWR6
+#define LJ_ARCH_VERSION                60
+#elif _ARCH_PWR5X
+#define LJ_ARCH_VERSION                51
+#elif _ARCH_PWR5
+#define LJ_ARCH_VERSION                50
+#elif _ARCH_PWR4
+#define LJ_ARCH_VERSION                40
+#else
+#define LJ_ARCH_VERSION                0
+#endif
+#if __PPC64__ || __powerpc64__ || LJ_TARGET_XBOX360
+#define LJ_ARCH_PPC64          1
+#endif
+#if _ARCH_PPCSQ
+#define LJ_ARCH_SQRT           1
+#endif
+#if _ARCH_PPC5X
+#define LJ_ARCH_ROUND          1
+#endif
+#if __PPU__
+#define LJ_ARCH_CELL           1
+#endif
+#if LJ_TARGET_XBOX360
+#define LJ_ARCH_XENON          1
+#endif
+
 #elif LUAJIT_TARGET == LUAJIT_ARCH_PPCSPE
 
 #define LJ_ARCH_NAME           "ppcspe"
 #define LJ_TARGET_UNIFYROT     2       /* Want only IR_BROR. */
 #define LJ_ARCH_NUMMODE                LJ_NUMMODE_SINGLE
 
+#if _MIPS_ARCH_MIPS32R2
+#define LJ_ARCH_VERSION                20
+#else
+#define LJ_ARCH_VERSION                10
+#endif
+
 #else
 #error "No target architecture defined"
 #endif
 #if defined(__ARM_PCS_VFP)
 #error "No support for ARM hard-float ABI (yet)"
 #endif
+#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__
+#error "No support for Cortex-M CPUs"
+#endif
 #if !(__ARM_EABI__ || LJ_TARGET_IOS)
 #error "Only ARM EABI or iOS 3.0+ ABI is supported"
 #endif
 #define LJ_DUALNUM             0
 #endif
 
-#if LJ_TARGET_IOS
+#if LJ_TARGET_IOS || LJ_TARGET_CONSOLE
 /* Runtime code generation is restricted on iOS. Complain to Apple, not me. */
+/* Ditto for the consoles. Complain to Sony or MS, not me. */
 #ifndef LUAJIT_ENABLE_JIT
 #define LJ_OS_NOJIT            1
 #endif
 #define LUAJIT_NO_EXP2
 #endif
 
-#if defined(__symbian__) || LJ_TARGET_IOS
+#if defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3
 #define LUAJIT_NO_UNWIND
 #endif