diff options
Diffstat (limited to 'src/lj_ir.h')
-rw-r--r-- | src/lj_ir.h | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/lj_ir.h b/src/lj_ir.h index 060cf562..c46bbbe0 100644 --- a/src/lj_ir.h +++ b/src/lj_ir.h | |||
@@ -124,7 +124,7 @@ | |||
124 | _(XBAR, S , ___, ___) \ | 124 | _(XBAR, S , ___, ___) \ |
125 | \ | 125 | \ |
126 | /* Type conversions. */ \ | 126 | /* Type conversions. */ \ |
127 | _(CONV, N , ref, lit) \ | 127 | _(CONV, NW, ref, lit) \ |
128 | _(TOBIT, N , ref, ref) \ | 128 | _(TOBIT, N , ref, ref) \ |
129 | _(TOSTR, N , ref, ___) \ | 129 | _(TOSTR, N , ref, ___) \ |
130 | _(STRTO, N , ref, ___) \ | 130 | _(STRTO, N , ref, ___) \ |
@@ -345,8 +345,8 @@ typedef enum { | |||
345 | #define IRM_AW (IRM_A|IRM_W) | 345 | #define IRM_AW (IRM_A|IRM_W) |
346 | #define IRM_LW (IRM_L|IRM_W) | 346 | #define IRM_LW (IRM_L|IRM_W) |
347 | 347 | ||
348 | #define irm_op1(m) (cast(IRMode, (m)&3)) | 348 | #define irm_op1(m) ((IRMode)((m)&3)) |
349 | #define irm_op2(m) (cast(IRMode, ((m)>>2)&3)) | 349 | #define irm_op2(m) ((IRMode)(((m)>>2)&3)) |
350 | #define irm_iscomm(m) ((m) & IRM_C) | 350 | #define irm_iscomm(m) ((m) & IRM_C) |
351 | #define irm_kind(m) ((m) & IRM_S) | 351 | #define irm_kind(m) ((m) & IRM_S) |
352 | 352 | ||
@@ -401,8 +401,8 @@ typedef struct IRType1 { uint8_t irt; } IRType1; | |||
401 | #define IRTG(o, t) (IRT((o), IRT_GUARD|(t))) | 401 | #define IRTG(o, t) (IRT((o), IRT_GUARD|(t))) |
402 | #define IRTGI(o) (IRT((o), IRT_GUARD|IRT_INT)) | 402 | #define IRTGI(o) (IRT((o), IRT_GUARD|IRT_INT)) |
403 | 403 | ||
404 | #define irt_t(t) (cast(IRType, (t).irt)) | 404 | #define irt_t(t) ((IRType)(t).irt) |
405 | #define irt_type(t) (cast(IRType, (t).irt & IRT_TYPE)) | 405 | #define irt_type(t) ((IRType)((t).irt & IRT_TYPE)) |
406 | #define irt_sametype(t1, t2) ((((t1).irt ^ (t2).irt) & IRT_TYPE) == 0) | 406 | #define irt_sametype(t1, t2) ((((t1).irt ^ (t2).irt) & IRT_TYPE) == 0) |
407 | #define irt_typerange(t, first, last) \ | 407 | #define irt_typerange(t, first, last) \ |
408 | ((uint32_t)((t).irt & IRT_TYPE) - (uint32_t)(first) <= (uint32_t)(last-first)) | 408 | ((uint32_t)((t).irt & IRT_TYPE) - (uint32_t)(first) <= (uint32_t)(last-first)) |
@@ -441,18 +441,30 @@ typedef struct IRType1 { uint8_t irt; } IRType1; | |||
441 | 441 | ||
442 | static LJ_AINLINE IRType itype2irt(const TValue *tv) | 442 | static LJ_AINLINE IRType itype2irt(const TValue *tv) |
443 | { | 443 | { |
444 | if (tvisnum(tv)) | 444 | if (tvisint(tv)) |
445 | return IRT_INT; | ||
446 | else if (tvisnum(tv)) | ||
445 | return IRT_NUM; | 447 | return IRT_NUM; |
446 | #if LJ_64 | 448 | #if LJ_64 |
447 | else if (tvislightud(tv)) | 449 | else if (tvislightud(tv)) |
448 | return IRT_LIGHTUD; | 450 | return IRT_LIGHTUD; |
449 | #endif | 451 | #endif |
450 | else | 452 | else |
451 | return cast(IRType, ~itype(tv)); | 453 | return (IRType)~itype(tv); |
452 | } | 454 | } |
453 | 455 | ||
454 | #define irt_toitype(t) \ | 456 | static LJ_AINLINE uint32_t irt_toitype_(IRType t) |
455 | check_exp(!(LJ_64 && irt_islightud((t))), ~(uint32_t)irt_type((t))) | 457 | { |
458 | lua_assert(!LJ_64 || t != IRT_LIGHTUD); | ||
459 | if (LJ_DUALNUM && t > IRT_NUM) { | ||
460 | return LJ_TISNUM; | ||
461 | } else { | ||
462 | lua_assert(t <= IRT_NUM); | ||
463 | return ~(uint32_t)t; | ||
464 | } | ||
465 | } | ||
466 | |||
467 | #define irt_toitype(t) irt_toitype_(irt_type((t))) | ||
456 | 468 | ||
457 | #define irt_isguard(t) ((t).irt & IRT_GUARD) | 469 | #define irt_isguard(t) ((t).irt & IRT_GUARD) |
458 | #define irt_ismarked(t) ((t).irt & IRT_MARK) | 470 | #define irt_ismarked(t) ((t).irt & IRT_MARK) |