mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Cleanup various endianess issues in assembler backend.
This commit is contained in:
parent
e80478c44b
commit
ff7f7a7180
31
src/lj_asm.c
31
src/lj_asm.c
@ -703,14 +703,14 @@ static void ra_leftov(ASMState *as, Reg dest, IRRef lref)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !LJ_TARGET_X86ORX64
|
#if !LJ_TARGET_X86ORX64
|
||||||
/* Force a RID_RET/RID_RETHI destination register pair (marked as free). */
|
/* Force a RID_RETLO/RID_RETHI destination register pair (marked as free). */
|
||||||
static void ra_destpair(ASMState *as, IRIns *ir)
|
static void ra_destpair(ASMState *as, IRIns *ir)
|
||||||
{
|
{
|
||||||
Reg destlo = ir->r, desthi = (ir+1)->r;
|
Reg destlo = ir->r, desthi = (ir+1)->r;
|
||||||
/* First spill unrelated refs blocking the destination registers. */
|
/* First spill unrelated refs blocking the destination registers. */
|
||||||
if (!rset_test(as->freeset, RID_RET) &&
|
if (!rset_test(as->freeset, RID_RETLO) &&
|
||||||
destlo != RID_RET && desthi != RID_RET)
|
destlo != RID_RETLO && desthi != RID_RETLO)
|
||||||
ra_restore(as, regcost_ref(as->cost[RID_RET]));
|
ra_restore(as, regcost_ref(as->cost[RID_RETLO]));
|
||||||
if (!rset_test(as->freeset, RID_RETHI) &&
|
if (!rset_test(as->freeset, RID_RETHI) &&
|
||||||
destlo != RID_RETHI && desthi != RID_RETHI)
|
destlo != RID_RETHI && desthi != RID_RETHI)
|
||||||
ra_restore(as, regcost_ref(as->cost[RID_RETHI]));
|
ra_restore(as, regcost_ref(as->cost[RID_RETHI]));
|
||||||
@ -719,7 +719,7 @@ static void ra_destpair(ASMState *as, IRIns *ir)
|
|||||||
ra_free(as, destlo);
|
ra_free(as, destlo);
|
||||||
ra_modified(as, destlo);
|
ra_modified(as, destlo);
|
||||||
} else {
|
} else {
|
||||||
destlo = RID_RET;
|
destlo = RID_RETLO;
|
||||||
}
|
}
|
||||||
if (ra_hasreg(desthi)) {
|
if (ra_hasreg(desthi)) {
|
||||||
ra_free(as, desthi);
|
ra_free(as, desthi);
|
||||||
@ -729,24 +729,24 @@ static void ra_destpair(ASMState *as, IRIns *ir)
|
|||||||
}
|
}
|
||||||
/* Check for conflicts and shuffle the registers as needed. */
|
/* Check for conflicts and shuffle the registers as needed. */
|
||||||
if (destlo == RID_RETHI) {
|
if (destlo == RID_RETHI) {
|
||||||
if (desthi == RID_RET) {
|
if (desthi == RID_RETLO) {
|
||||||
emit_movrr(as, ir, RID_RETHI, RID_TMP);
|
emit_movrr(as, ir, RID_RETHI, RID_TMP);
|
||||||
emit_movrr(as, ir, RID_RET, RID_RETHI);
|
emit_movrr(as, ir, RID_RETLO, RID_RETHI);
|
||||||
emit_movrr(as, ir, RID_TMP, RID_RET);
|
emit_movrr(as, ir, RID_TMP, RID_RETLO);
|
||||||
} else {
|
} else {
|
||||||
emit_movrr(as, ir, RID_RETHI, RID_RET);
|
emit_movrr(as, ir, RID_RETHI, RID_RETLO);
|
||||||
if (desthi != RID_RETHI) emit_movrr(as, ir, desthi, RID_RETHI);
|
if (desthi != RID_RETHI) emit_movrr(as, ir, desthi, RID_RETHI);
|
||||||
}
|
}
|
||||||
} else if (desthi == RID_RET) {
|
} else if (desthi == RID_RETLO) {
|
||||||
emit_movrr(as, ir, RID_RET, RID_RETHI);
|
emit_movrr(as, ir, RID_RETLO, RID_RETHI);
|
||||||
if (destlo != RID_RET) emit_movrr(as, ir, destlo, RID_RET);
|
if (destlo != RID_RETLO) emit_movrr(as, ir, destlo, RID_RETLO);
|
||||||
} else {
|
} else {
|
||||||
if (desthi != RID_RETHI) emit_movrr(as, ir, desthi, RID_RETHI);
|
if (desthi != RID_RETHI) emit_movrr(as, ir, desthi, RID_RETHI);
|
||||||
if (destlo != RID_RET) emit_movrr(as, ir, destlo, RID_RET);
|
if (destlo != RID_RETLO) emit_movrr(as, ir, destlo, RID_RETLO);
|
||||||
}
|
}
|
||||||
/* Restore spill slots (if any). */
|
/* Restore spill slots (if any). */
|
||||||
if (ra_hasspill((ir+1)->s)) ra_save(as, ir+1, RID_RETHI);
|
if (ra_hasspill((ir+1)->s)) ra_save(as, ir+1, RID_RETHI);
|
||||||
if (ra_hasspill(ir->s)) ra_save(as, ir, RID_RET);
|
if (ra_hasspill(ir->s)) ra_save(as, ir, RID_RETLO);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1519,6 +1519,9 @@ static void asm_setup_regsp(ASMState *as)
|
|||||||
case IR_CALLN: case IR_CALLXS:
|
case IR_CALLN: case IR_CALLXS:
|
||||||
#if LJ_SOFTFP
|
#if LJ_SOFTFP
|
||||||
case IR_MIN: case IR_MAX:
|
case IR_MIN: case IR_MAX:
|
||||||
|
#endif
|
||||||
|
#if LJ_BE
|
||||||
|
(ir-1)->prev = REGSP_HINT(RID_RETLO);
|
||||||
#endif
|
#endif
|
||||||
ir->prev = REGSP_HINT(RID_RETHI);
|
ir->prev = REGSP_HINT(RID_RETHI);
|
||||||
continue;
|
continue;
|
||||||
|
@ -516,7 +516,7 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge)
|
|||||||
int destused = ra_used(ir);
|
int destused = ra_used(ir);
|
||||||
Reg dest = ra_dest(as, ir, allow);
|
Reg dest = ra_dest(as, ir, allow);
|
||||||
Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest));
|
Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest));
|
||||||
Reg key = 0, keyhi = 0, keynumhi = RID_NONE, tmp = RID_LR;
|
Reg key = 0, keyhi = 0, keynumhi = RID_NONE, tmp = RID_TMP;
|
||||||
IRRef refkey = ir->op2;
|
IRRef refkey = ir->op2;
|
||||||
IRIns *irkey = IR(refkey);
|
IRIns *irkey = IR(refkey);
|
||||||
IRType1 kt = irkey->t;
|
IRType1 kt = irkey->t;
|
||||||
@ -1213,7 +1213,7 @@ static void asm_fpmin_max(ASMState *as, IRIns *ir, int cc)
|
|||||||
ra_evictset(as, drop);
|
ra_evictset(as, drop);
|
||||||
ra_destpair(as, ir);
|
ra_destpair(as, ir);
|
||||||
emit_dm(as, ARMF_CC(ARMI_MOV, cc), RID_RETHI, RID_R3);
|
emit_dm(as, ARMF_CC(ARMI_MOV, cc), RID_RETHI, RID_R3);
|
||||||
emit_dm(as, ARMF_CC(ARMI_MOV, cc), RID_RET, RID_R2);
|
emit_dm(as, ARMF_CC(ARMI_MOV, cc), RID_RETLO, RID_R2);
|
||||||
emit_call(as, (void *)ci->func);
|
emit_call(as, (void *)ci->func);
|
||||||
for (r = RID_R0; r <= RID_R3; r++)
|
for (r = RID_R0; r <= RID_R3; r++)
|
||||||
ra_leftov(as, r, args[r-RID_R0]);
|
ra_leftov(as, r, args[r-RID_R0]);
|
||||||
@ -1407,7 +1407,7 @@ static void asm_hiop(ASMState *as, IRIns *ir)
|
|||||||
case IR_CALLS:
|
case IR_CALLS:
|
||||||
case IR_CALLXS:
|
case IR_CALLXS:
|
||||||
if (!uselo)
|
if (!uselo)
|
||||||
ra_allocref(as, ir->op1, RID2RSET(RID_RET)); /* Mark lo op as used. */
|
ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */
|
||||||
break;
|
break;
|
||||||
case IR_ASTORE: case IR_HSTORE: case IR_USTORE:
|
case IR_ASTORE: case IR_HSTORE: case IR_USTORE:
|
||||||
case IR_TOSTR: case IR_CNEWI:
|
case IR_TOSTR: case IR_CNEWI:
|
||||||
|
@ -479,7 +479,7 @@ static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci)
|
|||||||
dest, RID_ESP, ofs);
|
dest, RID_ESP, ofs);
|
||||||
}
|
}
|
||||||
if ((ci->flags & CCI_CASTU64)) {
|
if ((ci->flags & CCI_CASTU64)) {
|
||||||
emit_movtomro(as, RID_RET, RID_ESP, ofs);
|
emit_movtomro(as, RID_RETLO, RID_ESP, ofs);
|
||||||
emit_movtomro(as, RID_RETHI, RID_ESP, ofs+4);
|
emit_movtomro(as, RID_RETHI, RID_ESP, ofs+4);
|
||||||
} else {
|
} else {
|
||||||
emit_rmro(as, irt_isnum(ir->t) ? XO_FSTPq : XO_FSTPd,
|
emit_rmro(as, irt_isnum(ir->t) ? XO_FSTPq : XO_FSTPd,
|
||||||
@ -2180,7 +2180,7 @@ static void asm_hiop(ASMState *as, IRIns *ir)
|
|||||||
case IR_CALLXS:
|
case IR_CALLXS:
|
||||||
ra_destreg(as, ir, RID_RETHI);
|
ra_destreg(as, ir, RID_RETHI);
|
||||||
if (!uselo)
|
if (!uselo)
|
||||||
ra_allocref(as, ir->op1, RID2RSET(RID_RET)); /* Mark call as used. */
|
ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark call as used. */
|
||||||
break;
|
break;
|
||||||
case IR_CNEWI:
|
case IR_CNEWI:
|
||||||
/* Nothing to do here. Handled by CNEWI itself. */
|
/* Nothing to do here. Handled by CNEWI itself. */
|
||||||
|
@ -195,7 +195,7 @@ IRFPMDEF(FPMENUM)
|
|||||||
_(CDATA_TYPEID, offsetof(GCcdata, typeid)) \
|
_(CDATA_TYPEID, offsetof(GCcdata, typeid)) \
|
||||||
_(CDATA_PTR, sizeof(GCcdata)) \
|
_(CDATA_PTR, sizeof(GCcdata)) \
|
||||||
_(CDATA_INT64, sizeof(GCcdata)) \
|
_(CDATA_INT64, sizeof(GCcdata)) \
|
||||||
_(CDATA_INT64HI, sizeof(GCcdata) + 4)
|
_(CDATA_INT64_4, sizeof(GCcdata) + 4)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
#define FLENUM(name, ofs) IRFL_##name,
|
#define FLENUM(name, ofs) IRFL_##name,
|
||||||
|
@ -411,7 +411,7 @@ static void split_ir(jit_State *J)
|
|||||||
break;
|
break;
|
||||||
case IR_FLOAD:
|
case IR_FLOAD:
|
||||||
lua_assert(ir->op2 == IRFL_CDATA_INT64);
|
lua_assert(ir->op2 == IRFL_CDATA_INT64);
|
||||||
hi = split_emit(J, IRTI(IR_FLOAD), nir->op1, IRFL_CDATA_INT64HI);
|
hi = split_emit(J, IRTI(IR_FLOAD), nir->op1, IRFL_CDATA_INT64_4);
|
||||||
#if LJ_BE
|
#if LJ_BE
|
||||||
ir->prev = hi; hi = nref;
|
ir->prev = hi; hi = nref;
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,6 +28,7 @@ enum {
|
|||||||
|
|
||||||
/* Calling conventions. */
|
/* Calling conventions. */
|
||||||
RID_RET = RID_R0,
|
RID_RET = RID_R0,
|
||||||
|
RID_RETLO = RID_R0,
|
||||||
RID_RETHI = RID_R1,
|
RID_RETHI = RID_R1,
|
||||||
RID_FPRET = RID_R0,
|
RID_FPRET = RID_R0,
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ enum {
|
|||||||
#if LJ_64
|
#if LJ_64
|
||||||
RID_FPRET = RID_XMM0,
|
RID_FPRET = RID_XMM0,
|
||||||
#else
|
#else
|
||||||
|
RID_RETLO = RID_EAX,
|
||||||
RID_RETHI = RID_EDX,
|
RID_RETHI = RID_EDX,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user