summaryrefslogtreecommitdiff
path: root/src/lj_target_mips.h
diff options
context:
space:
mode:
authorMike Pall <mike>2012-03-30 01:36:55 +0200
committerMike Pall <mike>2012-03-30 01:36:55 +0200
commitbcd459aa0e5ab8e6df4a89c75c4f9f00ec7d0176 (patch)
tree1c2a3b358455eda1abcf45bbdc6600f1e4e58810 /src/lj_target_mips.h
parent2225c9aafc9245e12b22d34b68be8017c42febd8 (diff)
downloadluajit-bcd459aa0e5ab8e6df4a89c75c4f9f00ec7d0176.tar.gz
luajit-bcd459aa0e5ab8e6df4a89c75c4f9f00ec7d0176.tar.bz2
luajit-bcd459aa0e5ab8e6df4a89c75c4f9f00ec7d0176.zip
MIPS: Integrate and enable JIT compiler.
Diffstat (limited to '')
-rw-r--r--src/lj_target_mips.h117
1 files changed, 109 insertions, 8 deletions
diff --git a/src/lj_target_mips.h b/src/lj_target_mips.h
index 88d066d6..e81d55bd 100644
--- a/src/lj_target_mips.h
+++ b/src/lj_target_mips.h
@@ -12,7 +12,7 @@
12 _(R0) _(R1) _(R2) _(R3) _(R4) _(R5) _(R6) _(R7) \ 12 _(R0) _(R1) _(R2) _(R3) _(R4) _(R5) _(R6) _(R7) \
13 _(R8) _(R9) _(R10) _(R11) _(R12) _(R13) _(R14) _(R15) \ 13 _(R8) _(R9) _(R10) _(R11) _(R12) _(R13) _(R14) _(R15) \
14 _(R16) _(R17) _(R18) _(R19) _(R20) _(R21) _(R22) _(R23) \ 14 _(R16) _(R17) _(R18) _(R19) _(R20) _(R21) _(R22) _(R23) \
15 _(R24) _(R25) _(SYS1) _(SYS2) _(GP) _(SP) _(R30) _(RA) 15 _(R24) _(R25) _(SYS1) _(SYS2) _(R28) _(SP) _(R30) _(RA)
16#define FPRDEF(_) \ 16#define FPRDEF(_) \
17 _(F0) _(F1) _(F2) _(F3) _(F4) _(F5) _(F6) _(F7) \ 17 _(F0) _(F1) _(F2) _(F3) _(F4) _(F5) _(F6) _(F7) \
18 _(F8) _(F9) _(F10) _(F11) _(F12) _(F13) _(F14) _(F15) \ 18 _(F8) _(F9) _(F10) _(F11) _(F12) _(F13) _(F14) _(F15) \
@@ -26,6 +26,7 @@ enum {
26 GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ 26 GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */
27 FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ 27 FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */
28 RID_MAX, 28 RID_MAX,
29 RID_ZERO = RID_R0,
29 RID_TMP = RID_RA, 30 RID_TMP = RID_RA,
30 31
31 /* Calling conventions. */ 32 /* Calling conventions. */
@@ -38,6 +39,7 @@ enum {
38 RID_RETLO = RID_R3, 39 RID_RETLO = RID_R3,
39#endif 40#endif
40 RID_FPRET = RID_F0, 41 RID_FPRET = RID_F0,
42 RID_CFUNCADDR = RID_R25,
41 43
42 /* These definitions must match with the *.dasc file(s): */ 44 /* These definitions must match with the *.dasc file(s): */
43 RID_BASE = RID_R16, /* Interpreter BASE. */ 45 RID_BASE = RID_R16, /* Interpreter BASE. */
@@ -52,7 +54,7 @@ enum {
52 RID_MIN_FPR = RID_F0, 54 RID_MIN_FPR = RID_F0,
53 RID_MAX_FPR = RID_F31+1, 55 RID_MAX_FPR = RID_F31+1,
54 RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, 56 RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR,
55 RID_NUM_FPR = (RID_MAX_FPR - RID_MIN_FPR)/2 57 RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR /* Only even regs are used. */
56}; 58};
57 59
58#define RID_NUM_KREF RID_NUM_GPR 60#define RID_NUM_KREF RID_NUM_GPR
@@ -60,10 +62,10 @@ enum {
60 62
61/* -- Register sets ------------------------------------------------------- */ 63/* -- Register sets ------------------------------------------------------- */
62 64
63/* Make use of all registers, except TMP, SP, SYS1, SYS2 and JGL. */ 65/* Make use of all registers, except ZERO, TMP, SP, SYS1, SYS2 and JGL. */
64#define RSET_FIXED \ 66#define RSET_FIXED \
65 (RID2RSET(RID_TMP)|RID2RSET(RID_SP)|RID2RSET(RID_SYS1)|\ 67 (RID2RSET(RID_ZERO)|RID2RSET(RID_TMP)|RID2RSET(RID_SP)|\
66 RID2RSET(RID_SYS2)|RID2RSET(RID_JGL)) 68 RID2RSET(RID_SYS1)|RID2RSET(RID_SYS2)|RID2RSET(RID_JGL))
67#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR) - RSET_FIXED) 69#define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR) - RSET_FIXED)
68#define RSET_FPR \ 70#define RSET_FPR \
69 (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ 71 (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\
@@ -75,7 +77,7 @@ enum {
75 77
76#define RSET_SCRATCH_GPR \ 78#define RSET_SCRATCH_GPR \
77 (RSET_RANGE(RID_R1, RID_R15+1)|\ 79 (RSET_RANGE(RID_R1, RID_R15+1)|\
78 RID2RSET(RID_R24)|RID2RSET(RID_R25)|RID2RSET(RID_GP)|RID2RSET(RID_RA)) 80 RID2RSET(RID_R24)|RID2RSET(RID_R25)|RID2RSET(RID_R28))
79#define RSET_SCRATCH_FPR \ 81#define RSET_SCRATCH_FPR \
80 (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ 82 (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\
81 RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\ 83 RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\
@@ -115,8 +117,15 @@ typedef struct {
115/* Highest exit + 1 indicates stack check. */ 117/* Highest exit + 1 indicates stack check. */
116#define EXITSTATE_CHECKEXIT 1 118#define EXITSTATE_CHECKEXIT 1
117 119
118#define EXITSTUB_SPACING 8 120/* Return the address of a per-trace exit stub. */
119#define EXITSTUBS_PER_GROUP 16 121static LJ_AINLINE uint32_t *exitstub_trace_addr_(uint32_t *p)
122{
123 while (*p == 0x00000000) p++; /* Skip MIPSI_NOP. */
124 return p;
125}
126/* Avoid dependence on lj_jit.h if only including lj_target.h. */
127#define exitstub_trace_addr(T, exitno) \
128 exitstub_trace_addr_((MCode *)((char *)(T)->mcode + (T)->szmcode))
120 129
121/* -- Instructions -------------------------------------------------------- */ 130/* -- Instructions -------------------------------------------------------- */
122 131
@@ -140,14 +149,106 @@ typedef enum MIPSIns {
140 MIPSI_LU = 0x34000000, 149 MIPSI_LU = 0x34000000,
141 MIPSI_LUI = 0x3c000000, 150 MIPSI_LUI = 0x3c000000,
142 151
152 MIPSI_ADDIU = 0x24000000,
153 MIPSI_ANDI = 0x30000000,
143 MIPSI_ORI = 0x34000000, 154 MIPSI_ORI = 0x34000000,
155 MIPSI_XORI = 0x38000000,
156 MIPSI_SLTI = 0x28000000,
157 MIPSI_SLTIU = 0x2c000000,
158
159 MIPSI_ADDU = 0x00000021,
160 MIPSI_SUBU = 0x00000023,
161 MIPSI_MUL = 0x70000002,
162 MIPSI_AND = 0x00000024,
163 MIPSI_OR = 0x00000025,
164 MIPSI_XOR = 0x00000026,
165 MIPSI_NOR = 0x00000027,
166 MIPSI_SLT = 0x0000002a,
167 MIPSI_SLTU = 0x0000002b,
168 MIPSI_MOVZ = 0x0000000a,
169 MIPSI_MOVN = 0x0000000b,
170
171 MIPSI_SLL = 0x00000000,
172 MIPSI_SRL = 0x00000002,
173 MIPSI_SRA = 0x00000003,
174 MIPSI_ROTR = 0x00200002, /* MIPS32R2 */
175 MIPSI_SLLV = 0x00000004,
176 MIPSI_SRLV = 0x00000006,
177 MIPSI_SRAV = 0x00000007,
178 MIPSI_ROTRV = 0x00000046, /* MIPS32R2 */
179
180 MIPSI_SEB = 0x7c000420, /* MIPS32R2 */
181 MIPSI_SEH = 0x7c000620, /* MIPS32R2 */
182 MIPSI_WSBH = 0x7c0000a0, /* MIPS32R2 */
144 183
145 MIPSI_B = 0x10000000, 184 MIPSI_B = 0x10000000,
185 MIPSI_J = 0x08000000,
186 MIPSI_JAL = 0x0c000000,
146 MIPSI_JR = 0x00000008, 187 MIPSI_JR = 0x00000008,
188 MIPSI_JALR = 0x0000f809,
189
190 MIPSI_BEQ = 0x10000000,
191 MIPSI_BNE = 0x14000000,
192 MIPSI_BLEZ = 0x18000000,
193 MIPSI_BGTZ = 0x1c000000,
194 MIPSI_BLTZ = 0x04000000,
195 MIPSI_BGEZ = 0x04010000,
147 196
148 /* Load/store instructions. */ 197 /* Load/store instructions. */
149 MIPSI_LW = 0x8c000000, 198 MIPSI_LW = 0x8c000000,
150 MIPSI_SW = 0xac000000, 199 MIPSI_SW = 0xac000000,
200 MIPSI_LB = 0x80000000,
201 MIPSI_SB = 0xa0000000,
202 MIPSI_LH = 0x84000000,
203 MIPSI_SH = 0xa4000000,
204 MIPSI_LBU = 0x90000000,
205 MIPSI_LHU = 0x94000000,
206 MIPSI_LWC1 = 0xc4000000,
207 MIPSI_SWC1 = 0xe4000000,
208 MIPSI_LDC1 = 0xd4000000,
209 MIPSI_SDC1 = 0xf4000000,
210
211 /* FP instructions. */
212 MIPSI_MOV_S = 0x46000006,
213 MIPSI_MOV_D = 0x46200006,
214 MIPSI_MOVT_D = 0x46210011,
215 MIPSI_MOVF_D = 0x46200011,
216
217 MIPSI_ABS_D = 0x46200005,
218 MIPSI_NEG_D = 0x46200007,
219
220 MIPSI_ADD_D = 0x46200000,
221 MIPSI_SUB_D = 0x46200001,
222 MIPSI_MUL_D = 0x46200002,
223 MIPSI_DIV_D = 0x46200003,
224
225 MIPSI_ADD_S = 0x46000000,
226 MIPSI_SUB_S = 0x46000001,
227
228 MIPSI_CVT_D_S = 0x46000021,
229 MIPSI_CVT_W_S = 0x46000024,
230 MIPSI_CVT_S_D = 0x46200020,
231 MIPSI_CVT_W_D = 0x46200024,
232 MIPSI_CVT_S_W = 0x46800020,
233 MIPSI_CVT_D_W = 0x46800021,
234
235 MIPSI_TRUNC_W_S = 0x4600000d,
236 MIPSI_TRUNC_W_D = 0x4620000d,
237 MIPSI_FLOOR_W_S = 0x4600000f,
238 MIPSI_FLOOR_W_D = 0x4620000f,
239
240 MIPSI_MFC1 = 0x44000000,
241 MIPSI_MTC1 = 0x44800000,
242
243 MIPSI_BC1F = 0x45000000,
244 MIPSI_BC1T = 0x45010000,
245
246 MIPSI_C_EQ_D = 0x46200032,
247 MIPSI_C_OLT_D = 0x46200034,
248 MIPSI_C_ULT_D = 0x46200035,
249 MIPSI_C_OLE_D = 0x46200036,
250 MIPSI_C_ULE_D = 0x46200037,
251
151} MIPSIns; 252} MIPSIns;
152 253
153#endif 254#endif