diff options
author | Mike Pall <mike> | 2016-05-28 05:10:55 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2016-05-28 05:10:55 +0200 |
commit | d9986fbadb6c50b826e39e5f690bcf0b4cd6a20b (patch) | |
tree | c89961a1a8949c19872aa39269c2408dd6595733 /src/lj_target_mips.h | |
parent | e3c4c9af0f07a114fb754fed6ac358a102f49e2f (diff) | |
download | luajit-d9986fbadb6c50b826e39e5f690bcf0b4cd6a20b.tar.gz luajit-d9986fbadb6c50b826e39e5f690bcf0b4cd6a20b.tar.bz2 luajit-d9986fbadb6c50b826e39e5f690bcf0b4cd6a20b.zip |
MIPS64, part 1: Add MIPS64 support to interpreter.
Contributed by Djordje Kovacevic and Stefan Pejic from RT-RK.com.
Sponsored by Cisco Systems, Inc.
Diffstat (limited to 'src/lj_target_mips.h')
-rw-r--r-- | src/lj_target_mips.h | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/src/lj_target_mips.h b/src/lj_target_mips.h index bafa817a..ac72528d 100644 --- a/src/lj_target_mips.h +++ b/src/lj_target_mips.h | |||
@@ -82,11 +82,15 @@ enum { | |||
82 | #if LJ_SOFTFP | 82 | #if LJ_SOFTFP |
83 | #define RSET_FPR 0 | 83 | #define RSET_FPR 0 |
84 | #else | 84 | #else |
85 | #if LJ_32 | ||
85 | #define RSET_FPR \ | 86 | #define RSET_FPR \ |
86 | (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ | 87 | (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ |
87 | RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\ | 88 | RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\ |
88 | RID2RSET(RID_F16)|RID2RSET(RID_F18)|RID2RSET(RID_F20)|RID2RSET(RID_F22)|\ | 89 | RID2RSET(RID_F16)|RID2RSET(RID_F18)|RID2RSET(RID_F20)|RID2RSET(RID_F22)|\ |
89 | RID2RSET(RID_F24)|RID2RSET(RID_F26)|RID2RSET(RID_F28)|RID2RSET(RID_F30)) | 90 | RID2RSET(RID_F24)|RID2RSET(RID_F26)|RID2RSET(RID_F28)|RID2RSET(RID_F30)) |
91 | #else | ||
92 | #define RSET_FPR RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR) | ||
93 | #endif | ||
90 | #endif | 94 | #endif |
91 | #define RSET_ALL (RSET_GPR|RSET_FPR) | 95 | #define RSET_ALL (RSET_GPR|RSET_FPR) |
92 | #define RSET_INIT RSET_ALL | 96 | #define RSET_INIT RSET_ALL |
@@ -97,23 +101,37 @@ enum { | |||
97 | #if LJ_SOFTFP | 101 | #if LJ_SOFTFP |
98 | #define RSET_SCRATCH_FPR 0 | 102 | #define RSET_SCRATCH_FPR 0 |
99 | #else | 103 | #else |
104 | #if LJ_32 | ||
100 | #define RSET_SCRATCH_FPR \ | 105 | #define RSET_SCRATCH_FPR \ |
101 | (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ | 106 | (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ |
102 | RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\ | 107 | RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\ |
103 | RID2RSET(RID_F16)|RID2RSET(RID_F18)) | 108 | RID2RSET(RID_F16)|RID2RSET(RID_F18)) |
109 | #else | ||
110 | #define RSET_SCRATCH_FPR RSET_RANGE(RID_F0, RID_F24) | ||
111 | #endif | ||
104 | #endif | 112 | #endif |
105 | #define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) | 113 | #define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) |
106 | #define REGARG_FIRSTGPR RID_R4 | 114 | #define REGARG_FIRSTGPR RID_R4 |
115 | #if LJ_32 | ||
107 | #define REGARG_LASTGPR RID_R7 | 116 | #define REGARG_LASTGPR RID_R7 |
108 | #define REGARG_NUMGPR 4 | 117 | #define REGARG_NUMGPR 4 |
118 | #else | ||
119 | #define REGARG_LASTGPR RID_R11 | ||
120 | #define REGARG_NUMGPR 8 | ||
121 | #endif | ||
109 | #if LJ_ABI_SOFTFP | 122 | #if LJ_ABI_SOFTFP |
110 | #define REGARG_FIRSTFPR 0 | 123 | #define REGARG_FIRSTFPR 0 |
111 | #define REGARG_LASTFPR 0 | 124 | #define REGARG_LASTFPR 0 |
112 | #define REGARG_NUMFPR 0 | 125 | #define REGARG_NUMFPR 0 |
113 | #else | 126 | #else |
114 | #define REGARG_FIRSTFPR RID_F12 | 127 | #define REGARG_FIRSTFPR RID_F12 |
128 | #if LJ_32 | ||
115 | #define REGARG_LASTFPR RID_F14 | 129 | #define REGARG_LASTFPR RID_F14 |
116 | #define REGARG_NUMFPR 2 | 130 | #define REGARG_NUMFPR 2 |
131 | #else | ||
132 | #define REGARG_LASTFPR RID_F19 | ||
133 | #define REGARG_NUMFPR 8 | ||
134 | #endif | ||
117 | #endif | 135 | #endif |
118 | 136 | ||
119 | /* -- Spill slots --------------------------------------------------------- */ | 137 | /* -- Spill slots --------------------------------------------------------- */ |
@@ -125,7 +143,11 @@ enum { | |||
125 | ** | 143 | ** |
126 | ** SPS_FIRST: First spill slot for general use. | 144 | ** SPS_FIRST: First spill slot for general use. |
127 | */ | 145 | */ |
146 | #if LJ_32 | ||
128 | #define SPS_FIXED 5 | 147 | #define SPS_FIXED 5 |
148 | #else | ||
149 | #define SPS_FIXED 4 | ||
150 | #endif | ||
129 | #define SPS_FIRST 4 | 151 | #define SPS_FIRST 4 |
130 | 152 | ||
131 | #define SPOFS_TMP 0 | 153 | #define SPOFS_TMP 0 |
@@ -140,7 +162,7 @@ typedef struct { | |||
140 | #if !LJ_SOFTFP | 162 | #if !LJ_SOFTFP |
141 | lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ | 163 | lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ |
142 | #endif | 164 | #endif |
143 | int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ | 165 | intptr_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ |
144 | int32_t spill[256]; /* Spill slots. */ | 166 | int32_t spill[256]; /* Spill slots. */ |
145 | } ExitState; | 167 | } ExitState; |
146 | 168 | ||
@@ -172,7 +194,7 @@ static LJ_AINLINE uint32_t *exitstub_trace_addr_(uint32_t *p) | |||
172 | 194 | ||
173 | typedef enum MIPSIns { | 195 | typedef enum MIPSIns { |
174 | /* Integer instructions. */ | 196 | /* Integer instructions. */ |
175 | MIPSI_MOVE = 0x00000021, | 197 | MIPSI_MOVE = 0x00000025, |
176 | MIPSI_NOP = 0x00000000, | 198 | MIPSI_NOP = 0x00000000, |
177 | 199 | ||
178 | MIPSI_LI = 0x24000000, | 200 | MIPSI_LI = 0x24000000, |
@@ -204,15 +226,15 @@ typedef enum MIPSIns { | |||
204 | MIPSI_SLL = 0x00000000, | 226 | MIPSI_SLL = 0x00000000, |
205 | MIPSI_SRL = 0x00000002, | 227 | MIPSI_SRL = 0x00000002, |
206 | MIPSI_SRA = 0x00000003, | 228 | MIPSI_SRA = 0x00000003, |
207 | MIPSI_ROTR = 0x00200002, /* MIPS32R2 */ | 229 | MIPSI_ROTR = 0x00200002, /* MIPSXXR2 */ |
208 | MIPSI_SLLV = 0x00000004, | 230 | MIPSI_SLLV = 0x00000004, |
209 | MIPSI_SRLV = 0x00000006, | 231 | MIPSI_SRLV = 0x00000006, |
210 | MIPSI_SRAV = 0x00000007, | 232 | MIPSI_SRAV = 0x00000007, |
211 | MIPSI_ROTRV = 0x00000046, /* MIPS32R2 */ | 233 | MIPSI_ROTRV = 0x00000046, /* MIPSXXR2 */ |
212 | 234 | ||
213 | MIPSI_SEB = 0x7c000420, /* MIPS32R2 */ | 235 | MIPSI_SEB = 0x7c000420, /* MIPSXXR2 */ |
214 | MIPSI_SEH = 0x7c000620, /* MIPS32R2 */ | 236 | MIPSI_SEH = 0x7c000620, /* MIPSXXR2 */ |
215 | MIPSI_WSBH = 0x7c0000a0, /* MIPS32R2 */ | 237 | MIPSI_WSBH = 0x7c0000a0, /* MIPSXXR2 */ |
216 | 238 | ||
217 | MIPSI_B = 0x10000000, | 239 | MIPSI_B = 0x10000000, |
218 | MIPSI_J = 0x08000000, | 240 | MIPSI_J = 0x08000000, |
@@ -241,6 +263,15 @@ typedef enum MIPSIns { | |||
241 | MIPSI_LDC1 = 0xd4000000, | 263 | MIPSI_LDC1 = 0xd4000000, |
242 | MIPSI_SDC1 = 0xf4000000, | 264 | MIPSI_SDC1 = 0xf4000000, |
243 | 265 | ||
266 | /* MIPS64 instructions. */ | ||
267 | MIPSI_DSLL = 0x00000038, | ||
268 | MIPSI_LD = 0xdc000000, | ||
269 | MIPSI_DADDIU = 0x64000000, | ||
270 | MIPSI_SD = 0xfc000000, | ||
271 | MIPSI_DMFC1 = 0x44200000, | ||
272 | MIPSI_DSRA32 = 0x0000003f, | ||
273 | MIPSI_MFHC1 = 0x44600000, | ||
274 | |||
244 | /* FP instructions. */ | 275 | /* FP instructions. */ |
245 | MIPSI_MOV_S = 0x46000006, | 276 | MIPSI_MOV_S = 0x46000006, |
246 | MIPSI_MOV_D = 0x46200006, | 277 | MIPSI_MOV_D = 0x46200006, |