aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2012-06-09 20:53:22 +0200
committerMike Pall <mike>2012-06-09 20:53:22 +0200
commit9f443e8b8919e094100bf1eb94981aec905be783 (patch)
tree1137bf976577f3634ed82486fd3998f86644626d /src
parent9d7bd04faed5feed273d9b9a11962f01e3cc7edf (diff)
downloadluajit-9f443e8b8919e094100bf1eb94981aec905be783.tar.gz
luajit-9f443e8b8919e094100bf1eb94981aec905be783.tar.bz2
luajit-9f443e8b8919e094100bf1eb94981aec905be783.zip
ARM/PPC: Detect more target arch variants. Detect console OS.
Diffstat (limited to 'src')
-rw-r--r--src/lib_jit.c26
-rw-r--r--src/lj_arch.h65
2 files changed, 83 insertions, 8 deletions
diff --git a/src/lib_jit.c b/src/lib_jit.c
index 7d5e0aef..db6bcfa8 100644
--- a/src/lib_jit.c
+++ b/src/lib_jit.c
@@ -591,11 +591,11 @@ static uint32_t jit_cpudetect(lua_State *L)
591#elif LJ_TARGET_ARM 591#elif LJ_TARGET_ARM
592#if LJ_HASJIT 592#if LJ_HASJIT
593 /* Compile-time ARM CPU detection. */ 593 /* Compile-time ARM CPU detection. */
594#if __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ 594#if LJ_ARCH_VERSION >= 70
595 flags |= JIT_F_ARMV6|JIT_F_ARMV6T2|JIT_F_ARMV7; 595 flags |= JIT_F_ARMV6|JIT_F_ARMV6T2|JIT_F_ARMV7;
596#elif __ARM_ARCH_6T2__ 596#elif LJ_ARCH_VERSION >= 61
597 flags |= JIT_F_ARMV6|JIT_F_ARMV6T2; 597 flags |= JIT_F_ARMV6|JIT_F_ARMV6T2;
598#elif __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6Z__ || __ARM_ARCH_6ZK__ 598#elif LJ_ARCH_VERSION >= 60
599 flags |= JIT_F_ARMV6; 599 flags |= JIT_F_ARMV6;
600#endif 600#endif
601 /* Runtime ARM CPU detection. */ 601 /* Runtime ARM CPU detection. */
@@ -612,12 +612,28 @@ static uint32_t jit_cpudetect(lua_State *L)
612 } 612 }
613#endif 613#endif
614#endif 614#endif
615#elif LJ_TARGET_PPC || LJ_TARGET_PPCSPE 615#elif LJ_TARGET_PPC
616#if LJ_ARCH_PPC64
617 flags |= JIT_F_PPC64;
618#endif
619#if LJ_ARCH_SQRT
620 flags |= JIT_F_SQRT;
621#endif
622#if LJ_ARCH_ROUND
623 flags |= JIT_F_ROUND;
624#endif
625#if LJ_ARCH_CELL
626 flags |= JIT_F_CELL;
627#endif
628#if LJ_ARCH_XENON
629 flags |= JIT_F_XENON;
630#endif
631#elif LJ_TARGET_PPCSPE
616 /* Nothing to do. */ 632 /* Nothing to do. */
617#elif LJ_TARGET_MIPS 633#elif LJ_TARGET_MIPS
618#if LJ_HASJIT 634#if LJ_HASJIT
619 /* Compile-time MIPS CPU detection. */ 635 /* Compile-time MIPS CPU detection. */
620#if _MIPS_ARCH_MIPS32R2 636#if LJ_ARCH_VERSION >= 20
621 flags |= JIT_F_MIPS32R2; 637 flags |= JIT_F_MIPS32R2;
622#endif 638#endif
623 /* Runtime MIPS CPU detection. */ 639 /* Runtime MIPS CPU detection. */
diff --git a/src/lj_arch.h b/src/lj_arch.h
index 5f788502..476c1241 100644
--- a/src/lj_arch.h
+++ b/src/lj_arch.h
@@ -60,7 +60,7 @@
60/* Select native OS if no target OS defined. */ 60/* Select native OS if no target OS defined. */
61#ifndef LUAJIT_OS 61#ifndef LUAJIT_OS
62 62
63#if defined(_WIN32) 63#if defined(_WIN32) && !defined(_XBOX_VER)
64#define LUAJIT_OS LUAJIT_OS_WINDOWS 64#define LUAJIT_OS LUAJIT_OS_WINDOWS
65#elif defined(__linux__) 65#elif defined(__linux__)
66#define LUAJIT_OS LUAJIT_OS_LINUX 66#define LUAJIT_OS LUAJIT_OS_LINUX
@@ -100,6 +100,16 @@
100#define LJ_TARGET_POSIX (LUAJIT_OS > LUAJIT_OS_WINDOWS) 100#define LJ_TARGET_POSIX (LUAJIT_OS > LUAJIT_OS_WINDOWS)
101#define LJ_TARGET_DLOPEN LJ_TARGET_POSIX 101#define LJ_TARGET_DLOPEN LJ_TARGET_POSIX
102 102
103#ifdef __CELLOS_LV2__
104#define LJ_TARGET_PS3 1
105#define LJ_TARGET_CONSOLE 1
106#endif
107
108#if _XBOX_VER >= 200
109#define LJ_TARGET_XBOX360 1
110#define LJ_TARGET_CONSOLE 1
111#endif
112
103#define LJ_NUMMODE_SINGLE 0 /* Single-number mode only. */ 113#define LJ_NUMMODE_SINGLE 0 /* Single-number mode only. */
104#define LJ_NUMMODE_SINGLE_DUAL 1 /* Default to single-number mode. */ 114#define LJ_NUMMODE_SINGLE_DUAL 1 /* Default to single-number mode. */
105#define LJ_NUMMODE_DUAL 2 /* Dual-number mode only. */ 115#define LJ_NUMMODE_DUAL 2 /* Dual-number mode only. */
@@ -151,6 +161,16 @@
151#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ 161#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */
152#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL 162#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL
153 163
164#if __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__
165#define LJ_ARCH_VERSION 70
166#elif __ARM_ARCH_6T2__
167#define LJ_ARCH_VERSION 61
168#elif __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6K__ || __ARM_ARCH_6Z__ || __ARM_ARCH_6ZK__
169#define LJ_ARCH_VERSION 60
170#else
171#define LJ_ARCH_VERSION 50
172#endif
173
154#elif LUAJIT_TARGET == LUAJIT_ARCH_PPC 174#elif LUAJIT_TARGET == LUAJIT_ARCH_PPC
155 175
156#define LJ_ARCH_NAME "ppc" 176#define LJ_ARCH_NAME "ppc"
@@ -165,6 +185,35 @@
165#define LJ_TARGET_UNIFYROT 1 /* Want only IR_BROL. */ 185#define LJ_TARGET_UNIFYROT 1 /* Want only IR_BROL. */
166#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL_SINGLE 186#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL_SINGLE
167 187
188#if _ARCH_PWR7
189#define LJ_ARCH_VERSION 70
190#elif _ARCH_PWR6
191#define LJ_ARCH_VERSION 60
192#elif _ARCH_PWR5X
193#define LJ_ARCH_VERSION 51
194#elif _ARCH_PWR5
195#define LJ_ARCH_VERSION 50
196#elif _ARCH_PWR4
197#define LJ_ARCH_VERSION 40
198#else
199#define LJ_ARCH_VERSION 0
200#endif
201#if __PPC64__ || __powerpc64__ || LJ_TARGET_XBOX360
202#define LJ_ARCH_PPC64 1
203#endif
204#if _ARCH_PPCSQ
205#define LJ_ARCH_SQRT 1
206#endif
207#if _ARCH_PPC5X
208#define LJ_ARCH_ROUND 1
209#endif
210#if __PPU__
211#define LJ_ARCH_CELL 1
212#endif
213#if LJ_TARGET_XBOX360
214#define LJ_ARCH_XENON 1
215#endif
216
168#elif LUAJIT_TARGET == LUAJIT_ARCH_PPCSPE 217#elif LUAJIT_TARGET == LUAJIT_ARCH_PPCSPE
169 218
170#define LJ_ARCH_NAME "ppcspe" 219#define LJ_ARCH_NAME "ppcspe"
@@ -202,6 +251,12 @@
202#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ 251#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */
203#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE 252#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE
204 253
254#if _MIPS_ARCH_MIPS32R2
255#define LJ_ARCH_VERSION 20
256#else
257#define LJ_ARCH_VERSION 10
258#endif
259
205#else 260#else
206#error "No target architecture defined" 261#error "No target architecture defined"
207#endif 262#endif
@@ -240,6 +295,9 @@
240#if defined(__ARM_PCS_VFP) 295#if defined(__ARM_PCS_VFP)
241#error "No support for ARM hard-float ABI (yet)" 296#error "No support for ARM hard-float ABI (yet)"
242#endif 297#endif
298#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__
299#error "No support for Cortex-M CPUs"
300#endif
243#if !(__ARM_EABI__ || LJ_TARGET_IOS) 301#if !(__ARM_EABI__ || LJ_TARGET_IOS)
244#error "Only ARM EABI or iOS 3.0+ ABI is supported" 302#error "Only ARM EABI or iOS 3.0+ ABI is supported"
245#endif 303#endif
@@ -269,8 +327,9 @@
269#define LJ_DUALNUM 0 327#define LJ_DUALNUM 0
270#endif 328#endif
271 329
272#if LJ_TARGET_IOS 330#if LJ_TARGET_IOS || LJ_TARGET_CONSOLE
273/* Runtime code generation is restricted on iOS. Complain to Apple, not me. */ 331/* Runtime code generation is restricted on iOS. Complain to Apple, not me. */
332/* Ditto for the consoles. Complain to Sony or MS, not me. */
274#ifndef LUAJIT_ENABLE_JIT 333#ifndef LUAJIT_ENABLE_JIT
275#define LJ_OS_NOJIT 1 334#define LJ_OS_NOJIT 1
276#endif 335#endif
@@ -320,7 +379,7 @@
320#define LUAJIT_NO_EXP2 379#define LUAJIT_NO_EXP2
321#endif 380#endif
322 381
323#if defined(__symbian__) || LJ_TARGET_IOS 382#if defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3
324#define LUAJIT_NO_UNWIND 383#define LUAJIT_NO_UNWIND
325#endif 384#endif
326 385