Improve assertions.
This commit is contained in:
@@ -8,8 +8,9 @@
|
||||
|
||||
/* -- Constant encoding --------------------------------------------------- */
|
||||
|
||||
static uint64_t get_k64val(IRIns *ir)
|
||||
static uint64_t get_k64val(ASMState *as, IRRef ref)
|
||||
{
|
||||
IRIns *ir = IR(ref);
|
||||
if (ir->o == IR_KINT64) {
|
||||
return ir_kint64(ir)->u64;
|
||||
} else if (ir->o == IR_KGC) {
|
||||
@@ -17,7 +18,8 @@ static uint64_t get_k64val(IRIns *ir)
|
||||
} else if (ir->o == IR_KPTR || ir->o == IR_KKPTR) {
|
||||
return (uint64_t)ir_kptr(ir);
|
||||
} else {
|
||||
lua_assert(ir->o == IR_KINT || ir->o == IR_KNULL);
|
||||
lj_assertA(ir->o == IR_KINT || ir->o == IR_KNULL,
|
||||
"bad 64 bit const IR op %d", ir->o);
|
||||
return ir->i; /* Sign-extended. */
|
||||
}
|
||||
}
|
||||
@@ -122,7 +124,7 @@ static int emit_checkofs(A64Ins ai, int64_t ofs)
|
||||
static void emit_lso(ASMState *as, A64Ins ai, Reg rd, Reg rn, int64_t ofs)
|
||||
{
|
||||
int ot = emit_checkofs(ai, ofs), sc = (ai >> 30) & 3;
|
||||
lua_assert(ot);
|
||||
lj_assertA(ot, "load/store offset %d out of range", ofs);
|
||||
/* Combine LDR/STR pairs to LDP/STP. */
|
||||
if ((sc == 2 || sc == 3) &&
|
||||
(!(ai & 0x400000) || rd != rn) &&
|
||||
@@ -166,10 +168,10 @@ static int emit_kdelta(ASMState *as, Reg rd, uint64_t k, int lim)
|
||||
while (work) {
|
||||
Reg r = rset_picktop(work);
|
||||
IRRef ref = regcost_ref(as->cost[r]);
|
||||
lua_assert(r != rd);
|
||||
lj_assertA(r != rd, "dest reg %d not free", rd);
|
||||
if (ref < REF_TRUE) {
|
||||
uint64_t kx = ra_iskref(ref) ? (uint64_t)ra_krefk(as, ref) :
|
||||
get_k64val(IR(ref));
|
||||
get_k64val(as, ref);
|
||||
int64_t delta = (int64_t)(k - kx);
|
||||
if (delta == 0) {
|
||||
emit_dm(as, A64I_MOVx, rd, r);
|
||||
@@ -312,7 +314,7 @@ static void emit_cond_branch(ASMState *as, A64CC cond, MCode *target)
|
||||
{
|
||||
MCode *p = --as->mcp;
|
||||
ptrdiff_t delta = target - p;
|
||||
lua_assert(A64F_S_OK(delta, 19));
|
||||
lj_assertA(A64F_S_OK(delta, 19), "branch target out of range");
|
||||
*p = A64I_BCC | A64F_S19(delta) | cond;
|
||||
}
|
||||
|
||||
@@ -320,7 +322,7 @@ static void emit_branch(ASMState *as, A64Ins ai, MCode *target)
|
||||
{
|
||||
MCode *p = --as->mcp;
|
||||
ptrdiff_t delta = target - p;
|
||||
lua_assert(A64F_S_OK(delta, 26));
|
||||
lj_assertA(A64F_S_OK(delta, 26), "branch target out of range");
|
||||
*p = ai | A64F_S26(delta);
|
||||
}
|
||||
|
||||
@@ -328,7 +330,8 @@ static void emit_tnb(ASMState *as, A64Ins ai, Reg r, uint32_t bit, MCode *target
|
||||
{
|
||||
MCode *p = --as->mcp;
|
||||
ptrdiff_t delta = target - p;
|
||||
lua_assert(bit < 63 && A64F_S_OK(delta, 14));
|
||||
lj_assertA(bit < 63, "bit number out of range");
|
||||
lj_assertA(A64F_S_OK(delta, 14), "branch target out of range");
|
||||
if (bit > 31) ai |= A64I_X;
|
||||
*p = ai | A64F_BIT(bit & 31) | A64F_S14(delta) | r;
|
||||
}
|
||||
@@ -337,7 +340,7 @@ static void emit_cnb(ASMState *as, A64Ins ai, Reg r, MCode *target)
|
||||
{
|
||||
MCode *p = --as->mcp;
|
||||
ptrdiff_t delta = target - p;
|
||||
lua_assert(A64F_S_OK(delta, 19));
|
||||
lj_assertA(A64F_S_OK(delta, 19), "branch target out of range");
|
||||
*p = ai | A64F_S19(delta) | r;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user