aboutsummaryrefslogtreecommitdiff
path: root/src/lj_jit.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_jit.h')
-rw-r--r--src/lj_jit.h94
1 files changed, 51 insertions, 43 deletions
diff --git a/src/lj_jit.h b/src/lj_jit.h
index f179f17f..a9c602f0 100644
--- a/src/lj_jit.h
+++ b/src/lj_jit.h
@@ -9,47 +9,49 @@
9#include "lj_obj.h" 9#include "lj_obj.h"
10#include "lj_ir.h" 10#include "lj_ir.h"
11 11
12/* JIT engine flags. */ 12/* -- JIT engine flags ---------------------------------------------------- */
13
14/* General JIT engine flags. 4 bits. */
13#define JIT_F_ON 0x00000001 15#define JIT_F_ON 0x00000001
14 16
15/* CPU-specific JIT engine flags. */ 17/* CPU-specific JIT engine flags. 12 bits. Flags and strings must match. */
18#define JIT_F_CPU 0x00000010
19
16#if LJ_TARGET_X86ORX64 20#if LJ_TARGET_X86ORX64
17#define JIT_F_SSE2 0x00000010 21
18#define JIT_F_SSE3 0x00000020 22#define JIT_F_SSE3 (JIT_F_CPU << 0)
19#define JIT_F_SSE4_1 0x00000040 23#define JIT_F_SSE4_1 (JIT_F_CPU << 1)
20#define JIT_F_PREFER_IMUL 0x00000080 24#define JIT_F_BMI2 (JIT_F_CPU << 2)
21#define JIT_F_LEA_AGU 0x00000100 25
22#define JIT_F_BMI2 0x00000200 26
23 27#define JIT_F_CPUSTRING "\4SSE3\6SSE4.1\4BMI2"
24/* Names for the CPU-specific flags. Must match the order above. */ 28
25#define JIT_F_CPU_FIRST JIT_F_SSE2
26#define JIT_F_CPUSTRING "\4SSE2\4SSE3\6SSE4.1\3AMD\4ATOM\4BMI2"
27#elif LJ_TARGET_ARM 29#elif LJ_TARGET_ARM
28#define JIT_F_ARMV6_ 0x00000010 30
29#define JIT_F_ARMV6T2_ 0x00000020 31#define JIT_F_ARMV6_ (JIT_F_CPU << 0)
30#define JIT_F_ARMV7 0x00000040 32#define JIT_F_ARMV6T2_ (JIT_F_CPU << 1)
31#define JIT_F_VFPV2 0x00000080 33#define JIT_F_ARMV7 (JIT_F_CPU << 2)
32#define JIT_F_VFPV3 0x00000100 34#define JIT_F_ARMV8 (JIT_F_CPU << 3)
33 35#define JIT_F_VFPV2 (JIT_F_CPU << 4)
34#define JIT_F_ARMV6 (JIT_F_ARMV6_|JIT_F_ARMV6T2_|JIT_F_ARMV7) 36#define JIT_F_VFPV3 (JIT_F_CPU << 5)
35#define JIT_F_ARMV6T2 (JIT_F_ARMV6T2_|JIT_F_ARMV7) 37
38#define JIT_F_ARMV6 (JIT_F_ARMV6_|JIT_F_ARMV6T2_|JIT_F_ARMV7|JIT_F_ARMV8)
39#define JIT_F_ARMV6T2 (JIT_F_ARMV6T2_|JIT_F_ARMV7|JIT_F_ARMV8)
36#define JIT_F_VFP (JIT_F_VFPV2|JIT_F_VFPV3) 40#define JIT_F_VFP (JIT_F_VFPV2|JIT_F_VFPV3)
37 41
38/* Names for the CPU-specific flags. Must match the order above. */ 42#define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7\5ARMv8\5VFPv2\5VFPv3"
39#define JIT_F_CPU_FIRST JIT_F_ARMV6_ 43
40#define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7\5VFPv2\5VFPv3"
41#elif LJ_TARGET_PPC 44#elif LJ_TARGET_PPC
42#define JIT_F_SQRT 0x00000010
43#define JIT_F_ROUND 0x00000020
44 45
45/* Names for the CPU-specific flags. Must match the order above. */ 46#define JIT_F_SQRT (JIT_F_CPU << 0)
46#define JIT_F_CPU_FIRST JIT_F_SQRT 47#define JIT_F_ROUND (JIT_F_CPU << 1)
48
47#define JIT_F_CPUSTRING "\4SQRT\5ROUND" 49#define JIT_F_CPUSTRING "\4SQRT\5ROUND"
50
48#elif LJ_TARGET_MIPS 51#elif LJ_TARGET_MIPS
49#define JIT_F_MIPSXXR2 0x00000010
50 52
51/* Names for the CPU-specific flags. Must match the order above. */ 53#define JIT_F_MIPSXXR2 (JIT_F_CPU << 0)
52#define JIT_F_CPU_FIRST JIT_F_MIPSXXR2 54
53#if LJ_TARGET_MIPS32 55#if LJ_TARGET_MIPS32
54#if LJ_TARGET_MIPSR6 56#if LJ_TARGET_MIPSR6
55#define JIT_F_CPUSTRING "\010MIPS32R6" 57#define JIT_F_CPUSTRING "\010MIPS32R6"
@@ -63,27 +65,29 @@
63#define JIT_F_CPUSTRING "\010MIPS64R2" 65#define JIT_F_CPUSTRING "\010MIPS64R2"
64#endif 66#endif
65#endif 67#endif
68
66#else 69#else
67#define JIT_F_CPU_FIRST 0 70
68#define JIT_F_CPUSTRING "" 71#define JIT_F_CPUSTRING ""
72
69#endif 73#endif
70 74
71/* Optimization flags. */ 75/* Optimization flags. 12 bits. */
76#define JIT_F_OPT 0x00010000
72#define JIT_F_OPT_MASK 0x0fff0000 77#define JIT_F_OPT_MASK 0x0fff0000
73 78
74#define JIT_F_OPT_FOLD 0x00010000 79#define JIT_F_OPT_FOLD (JIT_F_OPT << 0)
75#define JIT_F_OPT_CSE 0x00020000 80#define JIT_F_OPT_CSE (JIT_F_OPT << 1)
76#define JIT_F_OPT_DCE 0x00040000 81#define JIT_F_OPT_DCE (JIT_F_OPT << 2)
77#define JIT_F_OPT_FWD 0x00080000 82#define JIT_F_OPT_FWD (JIT_F_OPT << 3)
78#define JIT_F_OPT_DSE 0x00100000 83#define JIT_F_OPT_DSE (JIT_F_OPT << 4)
79#define JIT_F_OPT_NARROW 0x00200000 84#define JIT_F_OPT_NARROW (JIT_F_OPT << 5)
80#define JIT_F_OPT_LOOP 0x00400000 85#define JIT_F_OPT_LOOP (JIT_F_OPT << 6)
81#define JIT_F_OPT_ABC 0x00800000 86#define JIT_F_OPT_ABC (JIT_F_OPT << 7)
82#define JIT_F_OPT_SINK 0x01000000 87#define JIT_F_OPT_SINK (JIT_F_OPT << 8)
83#define JIT_F_OPT_FUSE 0x02000000 88#define JIT_F_OPT_FUSE (JIT_F_OPT << 9)
84 89
85/* Optimizations names for -O. Must match the order above. */ 90/* Optimizations names for -O. Must match the order above. */
86#define JIT_F_OPT_FIRST JIT_F_OPT_FOLD
87#define JIT_F_OPTSTRING \ 91#define JIT_F_OPTSTRING \
88 "\4fold\3cse\3dce\3fwd\3dse\6narrow\4loop\3abc\4sink\4fuse" 92 "\4fold\3cse\3dce\3fwd\3dse\6narrow\4loop\3abc\4sink\4fuse"
89 93
@@ -95,6 +99,8 @@
95 JIT_F_OPT_FWD|JIT_F_OPT_DSE|JIT_F_OPT_ABC|JIT_F_OPT_SINK|JIT_F_OPT_FUSE) 99 JIT_F_OPT_FWD|JIT_F_OPT_DSE|JIT_F_OPT_ABC|JIT_F_OPT_SINK|JIT_F_OPT_FUSE)
96#define JIT_F_OPT_DEFAULT JIT_F_OPT_3 100#define JIT_F_OPT_DEFAULT JIT_F_OPT_3
97 101
102/* -- JIT engine parameters ----------------------------------------------- */
103
98#if LJ_TARGET_WINDOWS || LJ_64 104#if LJ_TARGET_WINDOWS || LJ_64
99/* See: http://blogs.msdn.com/oldnewthing/archive/2003/10/08/55239.aspx */ 105/* See: http://blogs.msdn.com/oldnewthing/archive/2003/10/08/55239.aspx */
100#define JIT_P_sizemcode_DEFAULT 64 106#define JIT_P_sizemcode_DEFAULT 64
@@ -137,6 +143,8 @@ JIT_PARAMDEF(JIT_PARAMENUM)
137#define JIT_PARAMSTR(len, name, value) #len #name 143#define JIT_PARAMSTR(len, name, value) #len #name
138#define JIT_P_STRING JIT_PARAMDEF(JIT_PARAMSTR) 144#define JIT_P_STRING JIT_PARAMDEF(JIT_PARAMSTR)
139 145
146/* -- JIT engine data structures ------------------------------------------ */
147
140/* Trace compiler state. */ 148/* Trace compiler state. */
141typedef enum { 149typedef enum {
142 LJ_TRACE_IDLE, /* Trace compiler idle. */ 150 LJ_TRACE_IDLE, /* Trace compiler idle. */