diff options
Diffstat (limited to 'src/lj_arch.h')
-rw-r--r-- | src/lj_arch.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/lj_arch.h b/src/lj_arch.h new file mode 100644 index 00000000..abdb5af9 --- /dev/null +++ b/src/lj_arch.h | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | ** Target architecture selection. | ||
3 | ** Copyright (C) 2005-2009 Mike Pall. See Copyright Notice in luajit.h | ||
4 | */ | ||
5 | |||
6 | #ifndef _LJ_ARCH_H | ||
7 | #define _LJ_ARCH_H | ||
8 | |||
9 | #include "lua.h" | ||
10 | |||
11 | |||
12 | /* Target endianess. */ | ||
13 | #define LUAJIT_LE 0 | ||
14 | #define LUAJIT_BE 1 | ||
15 | |||
16 | /* Target architectures. */ | ||
17 | #define LUAJIT_ARCH_X86 1 | ||
18 | #define LUAJIT_ARCH_x86 1 | ||
19 | #define LUAJIT_ARCH_X64 2 | ||
20 | #define LUAJIT_ARCH_x64 2 | ||
21 | |||
22 | |||
23 | /* Select native target if no target defined. */ | ||
24 | #ifndef LUAJIT_TARGET | ||
25 | |||
26 | #if defined(__i386) || defined(__i386__) || defined(_M_IX86) | ||
27 | #define LUAJIT_TARGET LUAJIT_ARCH_X86 | ||
28 | #elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) | ||
29 | #define LUAJIT_TARGET LUAJIT_ARCH_X64 | ||
30 | #else | ||
31 | #error "No support for this architecture (yet)" | ||
32 | #endif | ||
33 | |||
34 | #endif | ||
35 | |||
36 | /* Set target properties. */ | ||
37 | #if LUAJIT_TARGET == LUAJIT_ARCH_X86 | ||
38 | #define LJ_ARCH_NAME "x86" | ||
39 | #define LJ_ARCH_BITS 32 | ||
40 | #define LJ_ARCH_ENDIAN LUAJIT_LE | ||
41 | #define LJ_TARGET_X86 1 | ||
42 | #define LJ_TARGET_X86ORX64 1 | ||
43 | #define LJ_PAGESIZE 4096 | ||
44 | #elif LUAJIT_TARGET == LUAJIT_ARCH_X64 | ||
45 | #define LJ_ARCH_NAME "x64" | ||
46 | #define LJ_ARCH_BITS 64 | ||
47 | #define LJ_ARCH_ENDIAN LUAJIT_LE | ||
48 | #define LJ_TARGET_X64 1 | ||
49 | #define LJ_TARGET_X86ORX64 1 | ||
50 | #define LJ_PAGESIZE 4096 | ||
51 | #error "No support for x64 architecture (yet)" | ||
52 | #else | ||
53 | #error "No target architecture defined" | ||
54 | #endif | ||
55 | |||
56 | /* Disable or enable the JIT compiler. */ | ||
57 | #if defined(LUAJIT_DISABLE_JIT) || defined(LJ_ARCH_NOJIT) | ||
58 | #define LJ_HASJIT 0 | ||
59 | #else | ||
60 | #define LJ_HASJIT 1 | ||
61 | #endif | ||
62 | |||
63 | #if LJ_ARCH_ENDIAN == LUAJIT_BE | ||
64 | #define LJ_ENDIAN_SELECT(le, be) be | ||
65 | #define LJ_ENDIAN_LOHI(lo, hi) hi lo | ||
66 | #else | ||
67 | #define LJ_ENDIAN_SELECT(le, be) le | ||
68 | #define LJ_ENDIAN_LOHI(lo, hi) lo hi | ||
69 | #endif | ||
70 | |||
71 | #if LJ_ARCH_BITS == 32 | ||
72 | #define LJ_32 1 | ||
73 | #define LJ_64 0 | ||
74 | #elif LJ_ARCH_BITS == 64 | ||
75 | #define LJ_32 0 | ||
76 | #define LJ_64 1 | ||
77 | #else | ||
78 | #error "Bad LJ_ARCH_BITS setting" | ||
79 | #endif | ||
80 | |||
81 | /* Whether target CPU masks the shift count by the operand length or not. */ | ||
82 | #if LJ_TARGET_X86ORX64 | ||
83 | #define LJ_TARGET_MASKEDSHIFT 1 | ||
84 | #else | ||
85 | #define LJ_TARGET_MASKEDSHIFT 0 | ||
86 | #endif | ||
87 | |||
88 | #endif | ||