diff options
Diffstat (limited to 'src/lj_ir.h')
-rw-r--r-- | src/lj_ir.h | 119 |
1 files changed, 87 insertions, 32 deletions
diff --git a/src/lj_ir.h b/src/lj_ir.h index da73a4b7..ed492e93 100644 --- a/src/lj_ir.h +++ b/src/lj_ir.h | |||
@@ -40,6 +40,7 @@ | |||
40 | _(USE, S , ref, ___) \ | 40 | _(USE, S , ref, ___) \ |
41 | _(PHI, S , ref, ref) \ | 41 | _(PHI, S , ref, ref) \ |
42 | _(RENAME, S , ref, lit) \ | 42 | _(RENAME, S , ref, lit) \ |
43 | _(PROF, S , ___, ___) \ | ||
43 | \ | 44 | \ |
44 | /* Constants. */ \ | 45 | /* Constants. */ \ |
45 | _(KPRI, N , ___, ___) \ | 46 | _(KPRI, N , ___, ___) \ |
@@ -74,7 +75,6 @@ | |||
74 | _(NEG, N , ref, ref) \ | 75 | _(NEG, N , ref, ref) \ |
75 | \ | 76 | \ |
76 | _(ABS, N , ref, ref) \ | 77 | _(ABS, N , ref, ref) \ |
77 | _(ATAN2, N , ref, ref) \ | ||
78 | _(LDEXP, N , ref, ref) \ | 78 | _(LDEXP, N , ref, ref) \ |
79 | _(MIN, C , ref, ref) \ | 79 | _(MIN, C , ref, ref) \ |
80 | _(MAX, C , ref, ref) \ | 80 | _(MAX, C , ref, ref) \ |
@@ -95,7 +95,9 @@ | |||
95 | _(UREFO, LW, ref, lit) \ | 95 | _(UREFO, LW, ref, lit) \ |
96 | _(UREFC, LW, ref, lit) \ | 96 | _(UREFC, LW, ref, lit) \ |
97 | _(FREF, R , ref, lit) \ | 97 | _(FREF, R , ref, lit) \ |
98 | _(TMPREF, S , ref, lit) \ | ||
98 | _(STRREF, N , ref, ref) \ | 99 | _(STRREF, N , ref, ref) \ |
100 | _(LREF, L , ___, ___) \ | ||
99 | \ | 101 | \ |
100 | /* Loads and Stores. These must be in the same order. */ \ | 102 | /* Loads and Stores. These must be in the same order. */ \ |
101 | _(ALOAD, L , ref, ___) \ | 103 | _(ALOAD, L , ref, ___) \ |
@@ -104,7 +106,8 @@ | |||
104 | _(FLOAD, L , ref, lit) \ | 106 | _(FLOAD, L , ref, lit) \ |
105 | _(XLOAD, L , ref, lit) \ | 107 | _(XLOAD, L , ref, lit) \ |
106 | _(SLOAD, L , lit, lit) \ | 108 | _(SLOAD, L , lit, lit) \ |
107 | _(VLOAD, L , ref, ___) \ | 109 | _(VLOAD, L , ref, lit) \ |
110 | _(ALEN, L , ref, ref) \ | ||
108 | \ | 111 | \ |
109 | _(ASTORE, S , ref, ref) \ | 112 | _(ASTORE, S , ref, ref) \ |
110 | _(HSTORE, S , ref, ref) \ | 113 | _(HSTORE, S , ref, ref) \ |
@@ -120,6 +123,11 @@ | |||
120 | _(CNEW, AW, ref, ref) \ | 123 | _(CNEW, AW, ref, ref) \ |
121 | _(CNEWI, NW, ref, ref) /* CSE is ok, not marked as A. */ \ | 124 | _(CNEWI, NW, ref, ref) /* CSE is ok, not marked as A. */ \ |
122 | \ | 125 | \ |
126 | /* Buffer operations. */ \ | ||
127 | _(BUFHDR, L , ref, lit) \ | ||
128 | _(BUFPUT, LW, ref, ref) \ | ||
129 | _(BUFSTR, AW, ref, ref) \ | ||
130 | \ | ||
123 | /* Barriers. */ \ | 131 | /* Barriers. */ \ |
124 | _(TBAR, S , ref, ___) \ | 132 | _(TBAR, S , ref, ___) \ |
125 | _(OBAR, S , ref, ref) \ | 133 | _(OBAR, S , ref, ref) \ |
@@ -128,12 +136,13 @@ | |||
128 | /* Type conversions. */ \ | 136 | /* Type conversions. */ \ |
129 | _(CONV, N , ref, lit) \ | 137 | _(CONV, N , ref, lit) \ |
130 | _(TOBIT, N , ref, ref) \ | 138 | _(TOBIT, N , ref, ref) \ |
131 | _(TOSTR, N , ref, ___) \ | 139 | _(TOSTR, N , ref, lit) \ |
132 | _(STRTO, N , ref, ___) \ | 140 | _(STRTO, N , ref, ___) \ |
133 | \ | 141 | \ |
134 | /* Calls. */ \ | 142 | /* Calls. */ \ |
135 | _(CALLN, N , ref, lit) \ | 143 | _(CALLN, NW, ref, lit) \ |
136 | _(CALLL, L , ref, lit) \ | 144 | _(CALLA, AW, ref, lit) \ |
145 | _(CALLL, LW, ref, lit) \ | ||
137 | _(CALLS, S , ref, lit) \ | 146 | _(CALLS, S , ref, lit) \ |
138 | _(CALLXS, S , ref, ref) \ | 147 | _(CALLXS, S , ref, ref) \ |
139 | _(CARG, N , ref, ref) \ | 148 | _(CARG, N , ref, ref) \ |
@@ -170,8 +179,7 @@ LJ_STATIC_ASSERT((int)IR_XLOAD + IRDELTA_L2S == (int)IR_XSTORE); | |||
170 | /* FPMATH sub-functions. ORDER FPM. */ | 179 | /* FPMATH sub-functions. ORDER FPM. */ |
171 | #define IRFPMDEF(_) \ | 180 | #define IRFPMDEF(_) \ |
172 | _(FLOOR) _(CEIL) _(TRUNC) /* Must be first and in this order. */ \ | 181 | _(FLOOR) _(CEIL) _(TRUNC) /* Must be first and in this order. */ \ |
173 | _(SQRT) _(EXP) _(EXP2) _(LOG) _(LOG2) _(LOG10) \ | 182 | _(SQRT) _(LOG) _(LOG2) \ |
174 | _(SIN) _(COS) _(TAN) \ | ||
175 | _(OTHER) | 183 | _(OTHER) |
176 | 184 | ||
177 | typedef enum { | 185 | typedef enum { |
@@ -186,6 +194,8 @@ IRFPMDEF(FPMENUM) | |||
186 | _(STR_LEN, offsetof(GCstr, len)) \ | 194 | _(STR_LEN, offsetof(GCstr, len)) \ |
187 | _(FUNC_ENV, offsetof(GCfunc, l.env)) \ | 195 | _(FUNC_ENV, offsetof(GCfunc, l.env)) \ |
188 | _(FUNC_PC, offsetof(GCfunc, l.pc)) \ | 196 | _(FUNC_PC, offsetof(GCfunc, l.pc)) \ |
197 | _(FUNC_FFID, offsetof(GCfunc, l.ffid)) \ | ||
198 | _(THREAD_ENV, offsetof(lua_State, env)) \ | ||
189 | _(TAB_META, offsetof(GCtab, metatable)) \ | 199 | _(TAB_META, offsetof(GCtab, metatable)) \ |
190 | _(TAB_ARRAY, offsetof(GCtab, array)) \ | 200 | _(TAB_ARRAY, offsetof(GCtab, array)) \ |
191 | _(TAB_NODE, offsetof(GCtab, node)) \ | 201 | _(TAB_NODE, offsetof(GCtab, node)) \ |
@@ -195,9 +205,15 @@ IRFPMDEF(FPMENUM) | |||
195 | _(UDATA_META, offsetof(GCudata, metatable)) \ | 205 | _(UDATA_META, offsetof(GCudata, metatable)) \ |
196 | _(UDATA_UDTYPE, offsetof(GCudata, udtype)) \ | 206 | _(UDATA_UDTYPE, offsetof(GCudata, udtype)) \ |
197 | _(UDATA_FILE, sizeof(GCudata)) \ | 207 | _(UDATA_FILE, sizeof(GCudata)) \ |
208 | _(SBUF_W, sizeof(GCudata) + offsetof(SBufExt, w)) \ | ||
209 | _(SBUF_E, sizeof(GCudata) + offsetof(SBufExt, e)) \ | ||
210 | _(SBUF_B, sizeof(GCudata) + offsetof(SBufExt, b)) \ | ||
211 | _(SBUF_L, sizeof(GCudata) + offsetof(SBufExt, L)) \ | ||
212 | _(SBUF_REF, sizeof(GCudata) + offsetof(SBufExt, cowref)) \ | ||
213 | _(SBUF_R, sizeof(GCudata) + offsetof(SBufExt, r)) \ | ||
198 | _(CDATA_CTYPEID, offsetof(GCcdata, ctypeid)) \ | 214 | _(CDATA_CTYPEID, offsetof(GCcdata, ctypeid)) \ |
199 | _(CDATA_PTR, sizeof(GCcdata)) \ | 215 | _(CDATA_PTR, sizeof(GCcdata)) \ |
200 | _(CDATA_INT, sizeof(GCcdata)) \ | 216 | _(CDATA_INT, sizeof(GCcdata)) \ |
201 | _(CDATA_INT64, sizeof(GCcdata)) \ | 217 | _(CDATA_INT64, sizeof(GCcdata)) \ |
202 | _(CDATA_INT64_4, sizeof(GCcdata) + 4) | 218 | _(CDATA_INT64_4, sizeof(GCcdata) + 4) |
203 | 219 | ||
@@ -208,18 +224,29 @@ IRFLDEF(FLENUM) | |||
208 | IRFL__MAX | 224 | IRFL__MAX |
209 | } IRFieldID; | 225 | } IRFieldID; |
210 | 226 | ||
227 | /* TMPREF mode bits, stored in op2. */ | ||
228 | #define IRTMPREF_IN1 0x01 /* First input value. */ | ||
229 | #define IRTMPREF_OUT1 0x02 /* First output value. */ | ||
230 | #define IRTMPREF_OUT2 0x04 /* Second output value. */ | ||
231 | |||
211 | /* SLOAD mode bits, stored in op2. */ | 232 | /* SLOAD mode bits, stored in op2. */ |
212 | #define IRSLOAD_PARENT 0x01 /* Coalesce with parent trace. */ | 233 | #define IRSLOAD_PARENT 0x01 /* Coalesce with parent trace. */ |
213 | #define IRSLOAD_FRAME 0x02 /* Load hiword of frame. */ | 234 | #define IRSLOAD_FRAME 0x02 /* Load 32 bits of ftsz. */ |
214 | #define IRSLOAD_TYPECHECK 0x04 /* Needs type check. */ | 235 | #define IRSLOAD_TYPECHECK 0x04 /* Needs type check. */ |
215 | #define IRSLOAD_CONVERT 0x08 /* Number to integer conversion. */ | 236 | #define IRSLOAD_CONVERT 0x08 /* Number to integer conversion. */ |
216 | #define IRSLOAD_READONLY 0x10 /* Read-only, omit slot store. */ | 237 | #define IRSLOAD_READONLY 0x10 /* Read-only, omit slot store. */ |
217 | #define IRSLOAD_INHERIT 0x20 /* Inherited by exits/side traces. */ | 238 | #define IRSLOAD_INHERIT 0x20 /* Inherited by exits/side traces. */ |
239 | #define IRSLOAD_KEYINDEX 0x40 /* Table traversal key index. */ | ||
218 | 240 | ||
219 | /* XLOAD mode, stored in op2. */ | 241 | /* XLOAD mode bits, stored in op2. */ |
220 | #define IRXLOAD_READONLY 1 /* Load from read-only data. */ | 242 | #define IRXLOAD_READONLY 0x01 /* Load from read-only data. */ |
221 | #define IRXLOAD_VOLATILE 2 /* Load from volatile data. */ | 243 | #define IRXLOAD_VOLATILE 0x02 /* Load from volatile data. */ |
222 | #define IRXLOAD_UNALIGNED 4 /* Unaligned load. */ | 244 | #define IRXLOAD_UNALIGNED 0x04 /* Unaligned load. */ |
245 | |||
246 | /* BUFHDR mode, stored in op2. */ | ||
247 | #define IRBUFHDR_RESET 0 /* Reset buffer. */ | ||
248 | #define IRBUFHDR_APPEND 1 /* Append to buffer. */ | ||
249 | #define IRBUFHDR_WRITE 2 /* Write to string buffer. */ | ||
223 | 250 | ||
224 | /* CONV mode, stored in op2. */ | 251 | /* CONV mode, stored in op2. */ |
225 | #define IRCONV_SRCMASK 0x001f /* Source IRType. */ | 252 | #define IRCONV_SRCMASK 0x001f /* Source IRType. */ |
@@ -227,7 +254,6 @@ IRFLDEF(FLENUM) | |||
227 | #define IRCONV_DSH 5 | 254 | #define IRCONV_DSH 5 |
228 | #define IRCONV_NUM_INT ((IRT_NUM<<IRCONV_DSH)|IRT_INT) | 255 | #define IRCONV_NUM_INT ((IRT_NUM<<IRCONV_DSH)|IRT_INT) |
229 | #define IRCONV_INT_NUM ((IRT_INT<<IRCONV_DSH)|IRT_NUM) | 256 | #define IRCONV_INT_NUM ((IRT_INT<<IRCONV_DSH)|IRT_NUM) |
230 | #define IRCONV_TRUNC 0x0400 /* Truncate number to integer. */ | ||
231 | #define IRCONV_SEXT 0x0800 /* Sign-extend integer to integer. */ | 257 | #define IRCONV_SEXT 0x0800 /* Sign-extend integer to integer. */ |
232 | #define IRCONV_MODEMASK 0x0fff | 258 | #define IRCONV_MODEMASK 0x0fff |
233 | #define IRCONV_CONVMASK 0xf000 | 259 | #define IRCONV_CONVMASK 0xf000 |
@@ -237,6 +263,12 @@ IRFLDEF(FLENUM) | |||
237 | #define IRCONV_ANY (1<<IRCONV_CSH) /* Any FP number is ok. */ | 263 | #define IRCONV_ANY (1<<IRCONV_CSH) /* Any FP number is ok. */ |
238 | #define IRCONV_INDEX (2<<IRCONV_CSH) /* Check + special backprop rules. */ | 264 | #define IRCONV_INDEX (2<<IRCONV_CSH) /* Check + special backprop rules. */ |
239 | #define IRCONV_CHECK (3<<IRCONV_CSH) /* Number checked for integerness. */ | 265 | #define IRCONV_CHECK (3<<IRCONV_CSH) /* Number checked for integerness. */ |
266 | #define IRCONV_NONE IRCONV_ANY /* INT|*64 no conv, but change type. */ | ||
267 | |||
268 | /* TOSTR mode, stored in op2. */ | ||
269 | #define IRTOSTR_INT 0 /* Convert integer to string. */ | ||
270 | #define IRTOSTR_NUM 1 /* Convert number to string. */ | ||
271 | #define IRTOSTR_CHAR 2 /* Convert char value to string. */ | ||
240 | 272 | ||
241 | /* -- IR operands --------------------------------------------------------- */ | 273 | /* -- IR operands --------------------------------------------------------- */ |
242 | 274 | ||
@@ -276,7 +308,9 @@ LJ_DATA const uint8_t lj_ir_mode[IR__MAX+1]; | |||
276 | 308 | ||
277 | /* -- IR instruction types ------------------------------------------------ */ | 309 | /* -- IR instruction types ------------------------------------------------ */ |
278 | 310 | ||
279 | /* Map of itypes to non-negative numbers. ORDER LJ_T. | 311 | #define IRTSIZE_PGC (LJ_GC64 ? 8 : 4) |
312 | |||
313 | /* Map of itypes to non-negative numbers and their sizes. ORDER LJ_T. | ||
280 | ** LJ_TUPVAL/LJ_TTRACE never appear in a TValue. Use these itypes for | 314 | ** LJ_TUPVAL/LJ_TTRACE never appear in a TValue. Use these itypes for |
281 | ** IRT_P32 and IRT_P64, which never escape the IR. | 315 | ** IRT_P32 and IRT_P64, which never escape the IR. |
282 | ** The various integers are only used in the IR and can only escape to | 316 | ** The various integers are only used in the IR and can only escape to |
@@ -284,12 +318,13 @@ LJ_DATA const uint8_t lj_ir_mode[IR__MAX+1]; | |||
284 | ** contiguous and next to IRT_NUM (see the typerange macros below). | 318 | ** contiguous and next to IRT_NUM (see the typerange macros below). |
285 | */ | 319 | */ |
286 | #define IRTDEF(_) \ | 320 | #define IRTDEF(_) \ |
287 | _(NIL, 4) _(FALSE, 4) _(TRUE, 4) _(LIGHTUD, LJ_64 ? 8 : 4) _(STR, 4) \ | 321 | _(NIL, 4) _(FALSE, 4) _(TRUE, 4) _(LIGHTUD, LJ_64 ? 8 : 4) \ |
288 | _(P32, 4) _(THREAD, 4) _(PROTO, 4) _(FUNC, 4) _(P64, 8) _(CDATA, 4) \ | 322 | _(STR, IRTSIZE_PGC) _(P32, 4) _(THREAD, IRTSIZE_PGC) _(PROTO, IRTSIZE_PGC) \ |
289 | _(TAB, 4) _(UDATA, 4) \ | 323 | _(FUNC, IRTSIZE_PGC) _(P64, 8) _(CDATA, IRTSIZE_PGC) _(TAB, IRTSIZE_PGC) \ |
324 | _(UDATA, IRTSIZE_PGC) \ | ||
290 | _(FLOAT, 4) _(NUM, 8) _(I8, 1) _(U8, 1) _(I16, 2) _(U16, 2) \ | 325 | _(FLOAT, 4) _(NUM, 8) _(I8, 1) _(U8, 1) _(I16, 2) _(U16, 2) \ |
291 | _(INT, 4) _(U32, 4) _(I64, 8) _(U64, 8) \ | 326 | _(INT, 4) _(U32, 4) _(I64, 8) _(U64, 8) \ |
292 | _(SOFTFP, 4) /* There is room for 9 more types. */ | 327 | _(SOFTFP, 4) /* There is room for 8 more types. */ |
293 | 328 | ||
294 | /* IR result type and flags (8 bit). */ | 329 | /* IR result type and flags (8 bit). */ |
295 | typedef enum { | 330 | typedef enum { |
@@ -300,6 +335,8 @@ IRTDEF(IRTENUM) | |||
300 | 335 | ||
301 | /* Native pointer type and the corresponding integer type. */ | 336 | /* Native pointer type and the corresponding integer type. */ |
302 | IRT_PTR = LJ_64 ? IRT_P64 : IRT_P32, | 337 | IRT_PTR = LJ_64 ? IRT_P64 : IRT_P32, |
338 | IRT_PGC = LJ_GC64 ? IRT_P64 : IRT_P32, | ||
339 | IRT_IGC = LJ_GC64 ? IRT_I64 : IRT_INT, | ||
303 | IRT_INTP = LJ_64 ? IRT_I64 : IRT_INT, | 340 | IRT_INTP = LJ_64 ? IRT_I64 : IRT_INT, |
304 | IRT_UINTP = LJ_64 ? IRT_U64 : IRT_U32, | 341 | IRT_UINTP = LJ_64 ? IRT_U64 : IRT_U32, |
305 | 342 | ||
@@ -353,7 +390,14 @@ typedef struct IRType1 { uint8_t irt; } IRType1; | |||
353 | #define irt_isaddr(t) (irt_typerange((t), IRT_LIGHTUD, IRT_UDATA)) | 390 | #define irt_isaddr(t) (irt_typerange((t), IRT_LIGHTUD, IRT_UDATA)) |
354 | #define irt_isint64(t) (irt_typerange((t), IRT_I64, IRT_U64)) | 391 | #define irt_isint64(t) (irt_typerange((t), IRT_I64, IRT_U64)) |
355 | 392 | ||
356 | #if LJ_64 | 393 | #if LJ_GC64 |
394 | /* Include IRT_NIL, so IR(ASMREF_L) (aka REF_NIL) is considered 64 bit. */ | ||
395 | #define IRT_IS64 \ | ||
396 | ((1u<<IRT_NUM)|(1u<<IRT_I64)|(1u<<IRT_U64)|(1u<<IRT_P64)|\ | ||
397 | (1u<<IRT_LIGHTUD)|(1u<<IRT_STR)|(1u<<IRT_THREAD)|(1u<<IRT_PROTO)|\ | ||
398 | (1u<<IRT_FUNC)|(1u<<IRT_CDATA)|(1u<<IRT_TAB)|(1u<<IRT_UDATA)|\ | ||
399 | (1u<<IRT_NIL)) | ||
400 | #elif LJ_64 | ||
357 | #define IRT_IS64 \ | 401 | #define IRT_IS64 \ |
358 | ((1u<<IRT_NUM)|(1u<<IRT_I64)|(1u<<IRT_U64)|(1u<<IRT_P64)|(1u<<IRT_LIGHTUD)) | 402 | ((1u<<IRT_NUM)|(1u<<IRT_I64)|(1u<<IRT_U64)|(1u<<IRT_P64)|(1u<<IRT_LIGHTUD)) |
359 | #else | 403 | #else |
@@ -374,7 +418,7 @@ static LJ_AINLINE IRType itype2irt(const TValue *tv) | |||
374 | return IRT_INT; | 418 | return IRT_INT; |
375 | else if (tvisnum(tv)) | 419 | else if (tvisnum(tv)) |
376 | return IRT_NUM; | 420 | return IRT_NUM; |
377 | #if LJ_64 | 421 | #if LJ_64 && !LJ_GC64 |
378 | else if (tvislightud(tv)) | 422 | else if (tvislightud(tv)) |
379 | return IRT_LIGHTUD; | 423 | return IRT_LIGHTUD; |
380 | #endif | 424 | #endif |
@@ -384,11 +428,12 @@ static LJ_AINLINE IRType itype2irt(const TValue *tv) | |||
384 | 428 | ||
385 | static LJ_AINLINE uint32_t irt_toitype_(IRType t) | 429 | static LJ_AINLINE uint32_t irt_toitype_(IRType t) |
386 | { | 430 | { |
387 | lua_assert(!LJ_64 || t != IRT_LIGHTUD); | 431 | lj_assertX(!LJ_64 || LJ_GC64 || t != IRT_LIGHTUD, |
432 | "no plain type tag for lightuserdata"); | ||
388 | if (LJ_DUALNUM && t > IRT_NUM) { | 433 | if (LJ_DUALNUM && t > IRT_NUM) { |
389 | return LJ_TISNUM; | 434 | return LJ_TISNUM; |
390 | } else { | 435 | } else { |
391 | lua_assert(t <= IRT_NUM); | 436 | lj_assertX(t <= IRT_NUM, "no plain type tag for IR type %d", t); |
392 | return ~(uint32_t)t; | 437 | return ~(uint32_t)t; |
393 | } | 438 | } |
394 | } | 439 | } |
@@ -451,6 +496,7 @@ typedef uint32_t TRef; | |||
451 | #define TREF_REFMASK 0x0000ffff | 496 | #define TREF_REFMASK 0x0000ffff |
452 | #define TREF_FRAME 0x00010000 | 497 | #define TREF_FRAME 0x00010000 |
453 | #define TREF_CONT 0x00020000 | 498 | #define TREF_CONT 0x00020000 |
499 | #define TREF_KEYINDEX 0x00100000 | ||
454 | 500 | ||
455 | #define TREF(ref, t) ((TRef)((ref) + ((t)<<24))) | 501 | #define TREF(ref, t) ((TRef)((ref) + ((t)<<24))) |
456 | 502 | ||
@@ -464,6 +510,7 @@ typedef uint32_t TRef; | |||
464 | #define tref_isnil(tr) (tref_istype((tr), IRT_NIL)) | 510 | #define tref_isnil(tr) (tref_istype((tr), IRT_NIL)) |
465 | #define tref_isfalse(tr) (tref_istype((tr), IRT_FALSE)) | 511 | #define tref_isfalse(tr) (tref_istype((tr), IRT_FALSE)) |
466 | #define tref_istrue(tr) (tref_istype((tr), IRT_TRUE)) | 512 | #define tref_istrue(tr) (tref_istype((tr), IRT_TRUE)) |
513 | #define tref_islightud(tr) (tref_istype((tr), IRT_LIGHTUD)) | ||
467 | #define tref_isstr(tr) (tref_istype((tr), IRT_STR)) | 514 | #define tref_isstr(tr) (tref_istype((tr), IRT_STR)) |
468 | #define tref_isfunc(tr) (tref_istype((tr), IRT_FUNC)) | 515 | #define tref_isfunc(tr) (tref_istype((tr), IRT_FUNC)) |
469 | #define tref_iscdata(tr) (tref_istype((tr), IRT_CDATA)) | 516 | #define tref_iscdata(tr) (tref_istype((tr), IRT_CDATA)) |
@@ -496,7 +543,9 @@ typedef uint32_t TRef; | |||
496 | ** +-------+-------+---+---+---+---+ | 543 | ** +-------+-------+---+---+---+---+ |
497 | ** | op1 | op2 | t | o | r | s | | 544 | ** | op1 | op2 | t | o | r | s | |
498 | ** +-------+-------+---+---+---+---+ | 545 | ** +-------+-------+---+---+---+---+ |
499 | ** | op12/i/gco | ot | prev | (alternative fields in union) | 546 | ** | op12/i/gco32 | ot | prev | (alternative fields in union) |
547 | ** +-------+-------+---+---+---+---+ | ||
548 | ** | TValue/gco64 | (2nd IR slot for 64 bit constants) | ||
500 | ** +---------------+-------+-------+ | 549 | ** +---------------+-------+-------+ |
501 | ** 32 16 16 | 550 | ** 32 16 16 |
502 | ** | 551 | ** |
@@ -524,21 +573,27 @@ typedef union IRIns { | |||
524 | ) | 573 | ) |
525 | }; | 574 | }; |
526 | int32_t i; /* 32 bit signed integer literal (overlaps op12). */ | 575 | int32_t i; /* 32 bit signed integer literal (overlaps op12). */ |
527 | GCRef gcr; /* GCobj constant (overlaps op12). */ | 576 | GCRef gcr; /* GCobj constant (overlaps op12 or entire slot). */ |
528 | MRef ptr; /* Pointer constant (overlaps op12). */ | 577 | MRef ptr; /* Pointer constant (overlaps op12 or entire slot). */ |
578 | TValue tv; /* TValue constant (overlaps entire slot). */ | ||
529 | } IRIns; | 579 | } IRIns; |
530 | 580 | ||
531 | #define ir_kgc(ir) check_exp((ir)->o == IR_KGC, gcref((ir)->gcr)) | 581 | #define ir_isk64(ir) \ |
582 | ((ir)->o == IR_KNUM || (ir)->o == IR_KINT64 || \ | ||
583 | (LJ_GC64 && \ | ||
584 | ((ir)->o == IR_KGC || (ir)->o == IR_KPTR || (ir)->o == IR_KKPTR))) | ||
585 | |||
586 | #define ir_kgc(ir) check_exp((ir)->o == IR_KGC, gcref((ir)[LJ_GC64].gcr)) | ||
532 | #define ir_kstr(ir) (gco2str(ir_kgc((ir)))) | 587 | #define ir_kstr(ir) (gco2str(ir_kgc((ir)))) |
533 | #define ir_ktab(ir) (gco2tab(ir_kgc((ir)))) | 588 | #define ir_ktab(ir) (gco2tab(ir_kgc((ir)))) |
534 | #define ir_kfunc(ir) (gco2func(ir_kgc((ir)))) | 589 | #define ir_kfunc(ir) (gco2func(ir_kgc((ir)))) |
535 | #define ir_kcdata(ir) (gco2cd(ir_kgc((ir)))) | 590 | #define ir_kcdata(ir) (gco2cd(ir_kgc((ir)))) |
536 | #define ir_knum(ir) check_exp((ir)->o == IR_KNUM, mref((ir)->ptr, cTValue)) | 591 | #define ir_knum(ir) check_exp((ir)->o == IR_KNUM, &(ir)[1].tv) |
537 | #define ir_kint64(ir) check_exp((ir)->o == IR_KINT64, mref((ir)->ptr,cTValue)) | 592 | #define ir_kint64(ir) check_exp((ir)->o == IR_KINT64, &(ir)[1].tv) |
538 | #define ir_k64(ir) \ | 593 | #define ir_k64(ir) check_exp(ir_isk64(ir), &(ir)[1].tv) |
539 | check_exp((ir)->o == IR_KNUM || (ir)->o == IR_KINT64, mref((ir)->ptr,cTValue)) | ||
540 | #define ir_kptr(ir) \ | 594 | #define ir_kptr(ir) \ |
541 | check_exp((ir)->o == IR_KPTR || (ir)->o == IR_KKPTR, mref((ir)->ptr, void)) | 595 | check_exp((ir)->o == IR_KPTR || (ir)->o == IR_KKPTR, \ |
596 | mref((ir)[LJ_GC64].ptr, void)) | ||
542 | 597 | ||
543 | /* A store or any other op with a non-weak guard has a side-effect. */ | 598 | /* A store or any other op with a non-weak guard has a side-effect. */ |
544 | static LJ_AINLINE int ir_sideeff(IRIns *ir) | 599 | static LJ_AINLINE int ir_sideeff(IRIns *ir) |