diff options
author | Mike Pall <mike> | 2011-01-25 18:50:24 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2011-01-25 18:50:24 +0100 |
commit | ed6c895ae56288b6982d1651c4ea638452c9e99b (patch) | |
tree | d6cfd052707979ce8d071c05c457872e130473db /src | |
parent | 705f593ffc91ecfc42f0de81b86fe4a6c3097958 (diff) | |
download | luajit-ed6c895ae56288b6982d1651c4ea638452c9e99b.tar.gz luajit-ed6c895ae56288b6982d1651c4ea638452c9e99b.tar.bz2 luajit-ed6c895ae56288b6982d1651c4ea638452c9e99b.zip |
ARM: Add ARM target architecture selection (disabled).
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 6 | ||||
-rw-r--r-- | src/buildvm.c | 3 | ||||
-rw-r--r-- | src/buildvm_asm.c | 14 | ||||
-rw-r--r-- | src/lib_jit.c | 2 | ||||
-rw-r--r-- | src/lj_arch.h | 42 | ||||
-rw-r--r-- | src/lj_err.c | 2 | ||||
-rw-r--r-- | src/lj_frame.h | 11 |
7 files changed, 70 insertions, 10 deletions
diff --git a/src/Makefile b/src/Makefile index d40a4927..fc7bbfcc 100644 --- a/src/Makefile +++ b/src/Makefile | |||
@@ -51,6 +51,7 @@ CCOPT= -O2 -fomit-frame-pointer | |||
51 | # | 51 | # |
52 | CCOPT_X86= -march=i686 | 52 | CCOPT_X86= -march=i686 |
53 | CCOPT_X64= | 53 | CCOPT_X64= |
54 | CCOPT_ARM= | ||
54 | CCOPT_PPCSPE= | 55 | CCOPT_PPCSPE= |
55 | # | 56 | # |
56 | CCDEBUG= | 57 | CCDEBUG= |
@@ -223,6 +224,10 @@ ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH))) | |||
223 | TARGET_CCARCH= x86 | 224 | TARGET_CCARCH= x86 |
224 | TARGET_XCFLAGS+= $(CCOPT_X86) | 225 | TARGET_XCFLAGS+= $(CCOPT_X86) |
225 | else | 226 | else |
227 | ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH))) | ||
228 | TARGET_CCARCH= arm | ||
229 | TARGET_XCFLAGS+= $(CCOPT_ARM) | ||
230 | else | ||
226 | ifneq (,$(findstring LJ_TARGET_PPCSPE ,$(TARGET_TESTARCH))) | 231 | ifneq (,$(findstring LJ_TARGET_PPCSPE ,$(TARGET_TESTARCH))) |
227 | TARGET_CCARCH= ppcspe | 232 | TARGET_CCARCH= ppcspe |
228 | TARGET_XCFLAGS+= $(CCOPT_PPCSPE) | 233 | TARGET_XCFLAGS+= $(CCOPT_PPCSPE) |
@@ -231,6 +236,7 @@ else | |||
231 | endif | 236 | endif |
232 | endif | 237 | endif |
233 | endif | 238 | endif |
239 | endif | ||
234 | 240 | ||
235 | ifneq (,$(PREFIX)) | 241 | ifneq (,$(PREFIX)) |
236 | ifneq (/usr/local,$(PREFIX)) | 242 | ifneq (/usr/local,$(PREFIX)) |
diff --git a/src/buildvm.c b/src/buildvm.c index 98f7e95a..d69fc1d6 100644 --- a/src/buildvm.c +++ b/src/buildvm.c | |||
@@ -77,6 +77,9 @@ static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type); | |||
77 | #else | 77 | #else |
78 | #include "buildvm_x64.h" | 78 | #include "buildvm_x64.h" |
79 | #endif | 79 | #endif |
80 | #elif LJ_TARGET_ARM | ||
81 | #include "../dynasm/dasm_arm.h" | ||
82 | #include "buildvm_arm.h" | ||
80 | #elif LJ_TARGET_PPCSPE | 83 | #elif LJ_TARGET_PPCSPE |
81 | #include "../dynasm/dasm_ppc.h" | 84 | #include "../dynasm/dasm_ppc.h" |
82 | #include "buildvm_ppcspe.h" | 85 | #include "buildvm_ppcspe.h" |
diff --git a/src/buildvm_asm.c b/src/buildvm_asm.c index 049d76ff..1f5d59a3 100644 --- a/src/buildvm_asm.c +++ b/src/buildvm_asm.c | |||
@@ -95,7 +95,9 @@ static void emit_asm_wordreloc(BuildCtx *ctx, uint8_t *p, int n, | |||
95 | uint32_t ins; | 95 | uint32_t ins; |
96 | emit_asm_words(ctx, p, n-4); | 96 | emit_asm_words(ctx, p, n-4); |
97 | ins = *(uint32_t *)(p+n-4); | 97 | ins = *(uint32_t *)(p+n-4); |
98 | #if LJ_TARGET_PPC | 98 | #if LJ_TARGET_ARM |
99 | UNUSED(sym); /* NYI */ | ||
100 | #elif LJ_TARGET_PPC | ||
99 | if ((ins >> 26) == 16) { | 101 | if ((ins >> 26) == 16) { |
100 | fprintf(ctx->fp, "\t%s %d, %d, %s\n", | 102 | fprintf(ctx->fp, "\t%s %d, %d, %s\n", |
101 | (ins & 1) ? "bcl" : "bc", (ins >> 21) & 31, (ins >> 16) & 31, sym); | 103 | (ins & 1) ? "bcl" : "bc", (ins >> 21) & 31, (ins >> 16) & 31, sym); |
@@ -113,6 +115,12 @@ static void emit_asm_wordreloc(BuildCtx *ctx, uint8_t *p, int n, | |||
113 | } | 115 | } |
114 | #endif | 116 | #endif |
115 | 117 | ||
118 | #if LJ_TARGET_ARM | ||
119 | #define ELFASM_PX "%%" | ||
120 | #else | ||
121 | #define ELFASM_PX "@" | ||
122 | #endif | ||
123 | |||
116 | /* Emit an assembler label. */ | 124 | /* Emit an assembler label. */ |
117 | static void emit_asm_label(BuildCtx *ctx, const char *name, int size, int isfunc) | 125 | static void emit_asm_label(BuildCtx *ctx, const char *name, int size, int isfunc) |
118 | { | 126 | { |
@@ -121,7 +129,7 @@ static void emit_asm_label(BuildCtx *ctx, const char *name, int size, int isfunc | |||
121 | fprintf(ctx->fp, | 129 | fprintf(ctx->fp, |
122 | "\n\t.globl %s\n" | 130 | "\n\t.globl %s\n" |
123 | "\t.hidden %s\n" | 131 | "\t.hidden %s\n" |
124 | "\t.type %s, @%s\n" | 132 | "\t.type %s, " ELFASM_PX "%s\n" |
125 | "\t.size %s, %d\n" | 133 | "\t.size %s, %d\n" |
126 | "%s:\n", | 134 | "%s:\n", |
127 | name, name, name, isfunc ? "function" : "object", name, size, name); | 135 | name, name, name, isfunc ? "function" : "object", name, size, name); |
@@ -204,7 +212,7 @@ void emit_asm(BuildCtx *ctx) | |||
204 | fprintf(ctx->fp, "\n"); | 212 | fprintf(ctx->fp, "\n"); |
205 | switch (ctx->mode) { | 213 | switch (ctx->mode) { |
206 | case BUILD_elfasm: | 214 | case BUILD_elfasm: |
207 | fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\",@progbits\n"); | 215 | fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n"); |
208 | #if LJ_TARGET_PPCSPE | 216 | #if LJ_TARGET_PPCSPE |
209 | /* Soft-float ABI + SPE. */ | 217 | /* Soft-float ABI + SPE. */ |
210 | fprintf(ctx->fp, "\t.gnu_attribute 4, 2\n\t.gnu_attribute 8, 3\n"); | 218 | fprintf(ctx->fp, "\t.gnu_attribute 4, 2\n\t.gnu_attribute 8, 3\n"); |
diff --git a/src/lib_jit.c b/src/lib_jit.c index ed0a581a..513a1c37 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
@@ -556,6 +556,8 @@ static uint32_t jit_cpudetect(lua_State *L) | |||
556 | luaL_error(L, "CPU does not support SSE2 (recompile without -DLUAJIT_CPU_SSE2)"); | 556 | luaL_error(L, "CPU does not support SSE2 (recompile without -DLUAJIT_CPU_SSE2)"); |
557 | #endif | 557 | #endif |
558 | #endif | 558 | #endif |
559 | #elif LJ_TARGET_ARM | ||
560 | /* NYI */ | ||
559 | #elif LJ_TARGET_PPC | 561 | #elif LJ_TARGET_PPC |
560 | /* Nothing to do. */ | 562 | /* Nothing to do. */ |
561 | #else | 563 | #else |
diff --git a/src/lj_arch.h b/src/lj_arch.h index 199e3b19..e7722315 100644 --- a/src/lj_arch.h +++ b/src/lj_arch.h | |||
@@ -17,10 +17,12 @@ | |||
17 | #define LUAJIT_ARCH_x86 1 | 17 | #define LUAJIT_ARCH_x86 1 |
18 | #define LUAJIT_ARCH_X64 2 | 18 | #define LUAJIT_ARCH_X64 2 |
19 | #define LUAJIT_ARCH_x64 2 | 19 | #define LUAJIT_ARCH_x64 2 |
20 | #define LUAJIT_ARCH_PPC 3 | 20 | #define LUAJIT_ARCH_ARM 3 |
21 | #define LUAJIT_ARCH_ppc 3 | 21 | #define LUAJIT_ARCH_arm 3 |
22 | #define LUAJIT_ARCH_PPCSPE 4 | 22 | #define LUAJIT_ARCH_PPC 4 |
23 | #define LUAJIT_ARCH_ppcspe 4 | 23 | #define LUAJIT_ARCH_ppc 4 |
24 | #define LUAJIT_ARCH_PPCSPE 5 | ||
25 | #define LUAJIT_ARCH_ppcspe 5 | ||
24 | 26 | ||
25 | /* Target OS. */ | 27 | /* Target OS. */ |
26 | #define LUAJIT_OS_OTHER 0 | 28 | #define LUAJIT_OS_OTHER 0 |
@@ -37,6 +39,8 @@ | |||
37 | #define LUAJIT_TARGET LUAJIT_ARCH_X86 | 39 | #define LUAJIT_TARGET LUAJIT_ARCH_X86 |
38 | #elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) | 40 | #elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) |
39 | #define LUAJIT_TARGET LUAJIT_ARCH_X64 | 41 | #define LUAJIT_TARGET LUAJIT_ARCH_X64 |
42 | #elif defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM) | ||
43 | #define LUAJIT_TARGET LUAJIT_ARCH_ARM | ||
40 | #elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC) | 44 | #elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC) |
41 | #ifdef __NO_FPRS__ | 45 | #ifdef __NO_FPRS__ |
42 | #define LUAJIT_TARGET LUAJIT_ARCH_PPCSPE | 46 | #define LUAJIT_TARGET LUAJIT_ARCH_PPCSPE |
@@ -117,6 +121,22 @@ | |||
117 | #define LJ_TARGET_MASKSHIFT 1 | 121 | #define LJ_TARGET_MASKSHIFT 1 |
118 | #define LJ_TARGET_MASKROT 1 | 122 | #define LJ_TARGET_MASKROT 1 |
119 | 123 | ||
124 | #elif LUAJIT_TARGET == LUAJIT_ARCH_ARM | ||
125 | |||
126 | #error "No support for ARM CPUs (yet)" | ||
127 | #define LJ_ARCH_NAME "arm" | ||
128 | #define LJ_ARCH_BITS 32 | ||
129 | #define LJ_ARCH_ENDIAN LUAJIT_LE | ||
130 | #define LJ_ARCH_HASFPU 0 | ||
131 | #define LJ_ABI_SOFTFP 1 | ||
132 | #define LJ_ABI_EABI 1 | ||
133 | #define LJ_TARGET_ARM 1 | ||
134 | #define LJ_TARGET_EHRETREG 0 | ||
135 | #define LJ_TARGET_MASKSHIFT 0 | ||
136 | #define LJ_TARGET_MASKROT 1 | ||
137 | #define LJ_ARCH_NOFFI 1 | ||
138 | #define LJ_ARCH_NOJIT 1 | ||
139 | |||
120 | #elif LUAJIT_TARGET == LUAJIT_ARCH_PPC | 140 | #elif LUAJIT_TARGET == LUAJIT_ARCH_PPC |
121 | 141 | ||
122 | #error "No support for plain PowerPC CPUs (yet)" | 142 | #error "No support for plain PowerPC CPUs (yet)" |
@@ -150,7 +170,7 @@ | |||
150 | #if __GNUC__ < 4 | 170 | #if __GNUC__ < 4 |
151 | #error "Need at least GCC 4.0 or newer" | 171 | #error "Need at least GCC 4.0 or newer" |
152 | #endif | 172 | #endif |
153 | #elif LJ_TARGET_PPC | 173 | #elif LJ_TARGET_ARM || LJ_TARGET_PPC |
154 | #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3) | 174 | #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3) |
155 | #error "Need at least GCC 4.3 or newer" | 175 | #error "Need at least GCC 4.3 or newer" |
156 | #endif | 176 | #endif |
@@ -163,7 +183,17 @@ | |||
163 | 183 | ||
164 | /* Check target-specific constraints. */ | 184 | /* Check target-specific constraints. */ |
165 | #ifndef _BUILDVM_H | 185 | #ifndef _BUILDVM_H |
166 | #if LJ_TARGET_PPC | 186 | #if LJ_TARGET_ARM |
187 | #if defined(__ARMEB__) | ||
188 | #error "No support for big-endian ARM" | ||
189 | #endif | ||
190 | #if defined(__thumb__) || defined(__thumb2__) | ||
191 | #error "No support for Thumb instruction set (yet)" | ||
192 | #endif | ||
193 | #if !__ARM_EABI__ | ||
194 | #error "Only ARM EABI is supported" | ||
195 | #endif | ||
196 | #elif LJ_TARGET_PPC | ||
167 | #if defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE) | 197 | #if defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE) |
168 | #error "No support for PowerPC CPUs without double-precision FPU" | 198 | #error "No support for PowerPC CPUs without double-precision FPU" |
169 | #endif | 199 | #endif |
diff --git a/src/lj_err.c b/src/lj_err.c index 600433d4..239f6e4f 100644 --- a/src/lj_err.c +++ b/src/lj_err.c | |||
@@ -526,7 +526,7 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode) | |||
526 | 526 | ||
527 | /* -- External frame unwinding -------------------------------------------- */ | 527 | /* -- External frame unwinding -------------------------------------------- */ |
528 | 528 | ||
529 | #if defined(__GNUC__) | 529 | #if defined(__GNUC__) && !LJ_TARGET_ARM |
530 | 530 | ||
531 | #include <unwind.h> | 531 | #include <unwind.h> |
532 | 532 | ||
diff --git a/src/lj_frame.h b/src/lj_frame.h index aea3c55c..21074724 100644 --- a/src/lj_frame.h +++ b/src/lj_frame.h | |||
@@ -90,6 +90,17 @@ enum { | |||
90 | #define CFRAME_SIZE_JIT (CFRAME_SIZE + 16) | 90 | #define CFRAME_SIZE_JIT (CFRAME_SIZE + 16) |
91 | #define CFRAME_SHIFT_MULTRES 0 | 91 | #define CFRAME_SHIFT_MULTRES 0 |
92 | #endif | 92 | #endif |
93 | #elif LJ_TARGET_ARM | ||
94 | /* NYI: Dummy definitions for now. */ | ||
95 | #define CFRAME_OFS_ERRF 28 | ||
96 | #define CFRAME_OFS_NRES 24 | ||
97 | #define CFRAME_OFS_PREV 20 | ||
98 | #define CFRAME_OFS_L 16 | ||
99 | #define CFRAME_OFS_PC 12 | ||
100 | #define CFRAME_OFS_MULTRES 8 | ||
101 | #define CFRAME_SIZE 64 | ||
102 | #define CFRAME_SIZE_JIT CFRAME_SIZE | ||
103 | #define CFRAME_SHIFT_MULTRES 3 | ||
93 | #elif LJ_TARGET_PPCSPE | 104 | #elif LJ_TARGET_PPCSPE |
94 | #define CFRAME_OFS_ERRF 28 | 105 | #define CFRAME_OFS_ERRF 28 |
95 | #define CFRAME_OFS_NRES 24 | 106 | #define CFRAME_OFS_NRES 24 |