diff options
author | Mike Pall <mike> | 2010-08-25 13:00:42 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2010-08-25 13:00:42 +0200 |
commit | 5526fa23122a0192c4315a1955a44bbaa2607d43 (patch) | |
tree | 49c6041ac9853c289122d748891f5ab947810840 | |
parent | 06ae534328c3337851ff8c786d0202bb2f1074ca (diff) | |
download | luajit-5526fa23122a0192c4315a1955a44bbaa2607d43.tar.gz luajit-5526fa23122a0192c4315a1955a44bbaa2607d43.tar.bz2 luajit-5526fa23122a0192c4315a1955a44bbaa2607d43.zip |
PPC: Add PowerPC target architecture selection.
-rw-r--r-- | src/Makefile.dep | 13 | ||||
-rw-r--r-- | src/buildvm.c | 13 | ||||
-rw-r--r-- | src/buildvm_fold.c | 3 | ||||
-rw-r--r-- | src/buildvm_lib.c | 3 | ||||
-rw-r--r-- | src/lj_arch.h | 47 |
5 files changed, 61 insertions, 18 deletions
diff --git a/src/Makefile.dep b/src/Makefile.dep index 9968a563..f2914d6d 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep | |||
@@ -1,12 +1,13 @@ | |||
1 | buildvm.o: buildvm.c lua.h luaconf.h luajit.h lj_obj.h lj_def.h lj_arch.h \ | 1 | buildvm.o: buildvm.c buildvm.h lj_def.h lua.h luaconf.h lj_arch.h \ |
2 | lj_gc.h lj_bc.h lj_ir.h lj_frame.h lj_dispatch.h lj_jit.h buildvm.h \ | 2 | lj_obj.h lj_gc.h lj_bc.h lj_ir.h lj_frame.h lj_dispatch.h lj_jit.h \ |
3 | luajit.h \ | ||
3 | lj_traceerr.h | 4 | lj_traceerr.h |
4 | buildvm_asm.o: buildvm_asm.c buildvm.h lj_def.h lua.h luaconf.h lj_arch.h \ | 5 | buildvm_asm.o: buildvm_asm.c buildvm.h lj_def.h lua.h luaconf.h lj_arch.h \ |
5 | lj_bc.h | 6 | lj_bc.h |
6 | buildvm_fold.o: buildvm_fold.c lj_obj.h lua.h luaconf.h lj_def.h \ | 7 | buildvm_fold.o: buildvm_fold.c buildvm.h lj_def.h lua.h luaconf.h \ |
7 | lj_arch.h lj_ir.h buildvm.h | 8 | lj_arch.h lj_obj.h lj_ir.h |
8 | buildvm_lib.o: buildvm_lib.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | 9 | buildvm_lib.o: buildvm_lib.c buildvm.h lj_def.h lua.h luaconf.h lj_arch.h \ |
9 | lj_lib.h buildvm.h | 10 | lj_obj.h lj_lib.h |
10 | buildvm_peobj.o: buildvm_peobj.c buildvm.h lj_def.h lua.h luaconf.h \ | 11 | buildvm_peobj.o: buildvm_peobj.c buildvm.h lj_def.h lua.h luaconf.h \ |
11 | lj_arch.h lj_bc.h | 12 | lj_arch.h lj_bc.h |
12 | lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \ | 13 | lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \ |
diff --git a/src/buildvm.c b/src/buildvm.c index 817d4bc4..e6eeabd2 100644 --- a/src/buildvm.c +++ b/src/buildvm.c | |||
@@ -14,22 +14,19 @@ | |||
14 | ** It's a one-shot tool -- any effort fixing this would be wasted. | 14 | ** It's a one-shot tool -- any effort fixing this would be wasted. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "lua.h" | ||
18 | #include "luajit.h" | ||
19 | |||
20 | #ifdef LUA_USE_WIN | 17 | #ifdef LUA_USE_WIN |
21 | #include <fcntl.h> | 18 | #include <fcntl.h> |
22 | #include <io.h> | 19 | #include <io.h> |
23 | #endif | 20 | #endif |
24 | 21 | ||
22 | #include "buildvm.h" | ||
25 | #include "lj_obj.h" | 23 | #include "lj_obj.h" |
26 | #include "lj_gc.h" | 24 | #include "lj_gc.h" |
27 | #include "lj_bc.h" | 25 | #include "lj_bc.h" |
28 | #include "lj_ir.h" | 26 | #include "lj_ir.h" |
29 | #include "lj_frame.h" | 27 | #include "lj_frame.h" |
30 | #include "lj_dispatch.h" | 28 | #include "lj_dispatch.h" |
31 | 29 | #include "luajit.h" | |
32 | #include "buildvm.h" | ||
33 | 30 | ||
34 | /* ------------------------------------------------------------------------ */ | 31 | /* ------------------------------------------------------------------------ */ |
35 | 32 | ||
@@ -422,6 +419,12 @@ int main(int argc, char **argv) | |||
422 | BuildCtx *ctx = &ctx_; | 419 | BuildCtx *ctx = &ctx_; |
423 | int status, binmode; | 420 | int status, binmode; |
424 | 421 | ||
422 | if (sizeof(void *) != 4*LJ_32+8*LJ_64) { | ||
423 | fprintf(stderr,"Error: pointer size mismatch in cross-build.\n"); | ||
424 | fprintf(stderr,"Try: make CC=\"gcc -m32\" CROSS=... TARGET=...\n\n"); | ||
425 | return 1; | ||
426 | } | ||
427 | |||
425 | UNUSED(argc); | 428 | UNUSED(argc); |
426 | parseargs(ctx, argv); | 429 | parseargs(ctx, argv); |
427 | 430 | ||
diff --git a/src/buildvm_fold.c b/src/buildvm_fold.c index bd872534..97632c56 100644 --- a/src/buildvm_fold.c +++ b/src/buildvm_fold.c | |||
@@ -3,11 +3,10 @@ | |||
3 | ** Copyright (C) 2005-2010 Mike Pall. See Copyright Notice in luajit.h | 3 | ** Copyright (C) 2005-2010 Mike Pall. See Copyright Notice in luajit.h |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "buildvm.h" | ||
6 | #include "lj_obj.h" | 7 | #include "lj_obj.h" |
7 | #include "lj_ir.h" | 8 | #include "lj_ir.h" |
8 | 9 | ||
9 | #include "buildvm.h" | ||
10 | |||
11 | /* Context for the folding hash table generator. */ | 10 | /* Context for the folding hash table generator. */ |
12 | static int lineno; | 11 | static int lineno; |
13 | static int funcidx; | 12 | static int funcidx; |
diff --git a/src/buildvm_lib.c b/src/buildvm_lib.c index ed55bf5d..0a758ebd 100644 --- a/src/buildvm_lib.c +++ b/src/buildvm_lib.c | |||
@@ -3,11 +3,10 @@ | |||
3 | ** Copyright (C) 2005-2010 Mike Pall. See Copyright Notice in luajit.h | 3 | ** Copyright (C) 2005-2010 Mike Pall. See Copyright Notice in luajit.h |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "buildvm.h" | ||
6 | #include "lj_obj.h" | 7 | #include "lj_obj.h" |
7 | #include "lj_lib.h" | 8 | #include "lj_lib.h" |
8 | 9 | ||
9 | #include "buildvm.h" | ||
10 | |||
11 | /* Context for library definitions. */ | 10 | /* Context for library definitions. */ |
12 | static uint8_t obuf[8192]; | 11 | static uint8_t obuf[8192]; |
13 | static uint8_t *optr; | 12 | static uint8_t *optr; |
diff --git a/src/lj_arch.h b/src/lj_arch.h index 86a2d5ed..d87575ed 100644 --- a/src/lj_arch.h +++ b/src/lj_arch.h | |||
@@ -18,6 +18,10 @@ | |||
18 | #define LUAJIT_ARCH_x86 1 | 18 | #define LUAJIT_ARCH_x86 1 |
19 | #define LUAJIT_ARCH_X64 2 | 19 | #define LUAJIT_ARCH_X64 2 |
20 | #define LUAJIT_ARCH_x64 2 | 20 | #define LUAJIT_ARCH_x64 2 |
21 | #define LUAJIT_ARCH_PPC 3 | ||
22 | #define LUAJIT_ARCH_ppc 3 | ||
23 | #define LUAJIT_ARCH_PPCSPE 4 | ||
24 | #define LUAJIT_ARCH_ppcspe 4 | ||
21 | 25 | ||
22 | 26 | ||
23 | /* Select native target if no target defined. */ | 27 | /* Select native target if no target defined. */ |
@@ -27,6 +31,12 @@ | |||
27 | #define LUAJIT_TARGET LUAJIT_ARCH_X86 | 31 | #define LUAJIT_TARGET LUAJIT_ARCH_X86 |
28 | #elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) | 32 | #elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) |
29 | #define LUAJIT_TARGET LUAJIT_ARCH_X64 | 33 | #define LUAJIT_TARGET LUAJIT_ARCH_X64 |
34 | #elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC) | ||
35 | #ifdef __NO_FPRS__ | ||
36 | #define LUAJIT_TARGET LUAJIT_ARCH_PPCSPE | ||
37 | #else | ||
38 | #define LUAJIT_TARGET LUAJIT_ARCH_PPC | ||
39 | #endif | ||
30 | #else | 40 | #else |
31 | #error "No support for this architecture (yet)" | 41 | #error "No support for this architecture (yet)" |
32 | #endif | 42 | #endif |
@@ -35,23 +45,56 @@ | |||
35 | 45 | ||
36 | /* Set target properties. */ | 46 | /* Set target properties. */ |
37 | #if LUAJIT_TARGET == LUAJIT_ARCH_X86 | 47 | #if LUAJIT_TARGET == LUAJIT_ARCH_X86 |
48 | |||
38 | #define LJ_ARCH_NAME "x86" | 49 | #define LJ_ARCH_NAME "x86" |
39 | #define LJ_ARCH_BITS 32 | 50 | #define LJ_ARCH_BITS 32 |
40 | #define LJ_ARCH_ENDIAN LUAJIT_LE | 51 | #define LJ_ARCH_ENDIAN LUAJIT_LE |
41 | #define LJ_TARGET_X86 1 | 52 | #define LJ_TARGET_X86 1 |
42 | #define LJ_TARGET_X86ORX64 1 | 53 | #define LJ_TARGET_X86ORX64 1 |
43 | #define LJ_PAGESIZE 4096 | 54 | #define LJ_PAGESIZE 4096 |
55 | #define LJ_TARGET_MASKEDSHIFT 1 | ||
56 | |||
44 | #elif LUAJIT_TARGET == LUAJIT_ARCH_X64 | 57 | #elif LUAJIT_TARGET == LUAJIT_ARCH_X64 |
58 | |||
45 | #define LJ_ARCH_NAME "x64" | 59 | #define LJ_ARCH_NAME "x64" |
46 | #define LJ_ARCH_BITS 64 | 60 | #define LJ_ARCH_BITS 64 |
47 | #define LJ_ARCH_ENDIAN LUAJIT_LE | 61 | #define LJ_ARCH_ENDIAN LUAJIT_LE |
48 | #define LJ_TARGET_X64 1 | 62 | #define LJ_TARGET_X64 1 |
49 | #define LJ_TARGET_X86ORX64 1 | 63 | #define LJ_TARGET_X86ORX64 1 |
50 | #define LJ_PAGESIZE 4096 | 64 | #define LJ_PAGESIZE 4096 |
65 | #define LJ_TARGET_MASKEDSHIFT 1 | ||
66 | |||
67 | #elif LUAJIT_TARGET == LUAJIT_ARCH_PPC | ||
68 | |||
69 | #error "No support for plain PowerPC CPUs (yet)" | ||
70 | |||
71 | #elif LUAJIT_TARGET == LUAJIT_ARCH_PPCSPE | ||
72 | |||
73 | #define LJ_ARCH_NAME "ppcspe" | ||
74 | #define LJ_ARCH_BITS 32 | ||
75 | #define LJ_ARCH_ENDIAN LUAJIT_BE | ||
76 | #define LJ_TARGET_PPC 1 | ||
77 | #define LJ_TARGET_PPCSPE 1 | ||
78 | #define LJ_PAGESIZE 4096 | ||
79 | #define LJ_TARGET_MASKEDSHIFT 1 | ||
80 | #define LJ_ARCH_NOJIT 1 | ||
81 | |||
51 | #else | 82 | #else |
52 | #error "No target architecture defined" | 83 | #error "No target architecture defined" |
53 | #endif | 84 | #endif |
54 | 85 | ||
86 | /* Check target-specific constraints. */ | ||
87 | #ifndef _BUILDVM_H | ||
88 | #if LJ_TARGET_PPC | ||
89 | #if defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE) | ||
90 | #error "No support for PowerPC CPUs without double-precision FPU" | ||
91 | #endif | ||
92 | #if defined(_LITTLE_ENDIAN) | ||
93 | #error "No support for little-endian PowerPC" | ||
94 | #endif | ||
95 | #endif | ||
96 | #endif | ||
97 | |||
55 | /* Disable or enable the JIT compiler. */ | 98 | /* Disable or enable the JIT compiler. */ |
56 | #if defined(LUAJIT_DISABLE_JIT) || defined(LJ_ARCH_NOJIT) | 99 | #if defined(LUAJIT_DISABLE_JIT) || defined(LJ_ARCH_NOJIT) |
57 | #define LJ_HASJIT 0 | 100 | #define LJ_HASJIT 0 |
@@ -78,9 +121,7 @@ | |||
78 | #endif | 121 | #endif |
79 | 122 | ||
80 | /* Whether target CPU masks the shift count by the operand length or not. */ | 123 | /* Whether target CPU masks the shift count by the operand length or not. */ |
81 | #if LJ_TARGET_X86ORX64 | 124 | #ifndef LJ_TARGET_MASKEDSHIFT |
82 | #define LJ_TARGET_MASKEDSHIFT 1 | ||
83 | #else | ||
84 | #define LJ_TARGET_MASKEDSHIFT 0 | 125 | #define LJ_TARGET_MASKEDSHIFT 0 |
85 | #endif | 126 | #endif |
86 | 127 | ||