ARM64: Improve IR_UREF code generation.

Thanks to Peter Cawley. #1070
This commit is contained in:
Mike Pall 2023-09-09 17:19:02 +02:00
parent 435d8c6301
commit c2bdce399e

View File

@ -924,18 +924,16 @@ static void asm_uref(ASMState *as, IRIns *ir)
MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v;
emit_lsptr(as, A64I_LDRx, dest, v); emit_lsptr(as, A64I_LDRx, dest, v);
} else { } else {
Reg uv = ra_scratch(as, RSET_GPR);
Reg func = ra_alloc1(as, ir->op1, RSET_GPR);
if (ir->o == IR_UREFC) { if (ir->o == IR_UREFC) {
asm_guardcc(as, CC_NE); asm_guardcnb(as, A64I_CBZ, RID_TMP);
emit_n(as, (A64I_CMPx^A64I_K12) | A64F_U12(1), RID_TMP); emit_opk(as, A64I_ADDx, dest, dest,
emit_opk(as, A64I_ADDx, dest, uv,
(int32_t)offsetof(GCupval, tv), RSET_GPR); (int32_t)offsetof(GCupval, tv), RSET_GPR);
emit_lso(as, A64I_LDRB, RID_TMP, uv, (int32_t)offsetof(GCupval, closed)); emit_lso(as, A64I_LDRB, RID_TMP, dest,
(int32_t)offsetof(GCupval, closed));
} else { } else {
emit_lso(as, A64I_LDRx, dest, uv, (int32_t)offsetof(GCupval, v)); emit_lso(as, A64I_LDRx, dest, dest, (int32_t)offsetof(GCupval, v));
} }
emit_lso(as, A64I_LDRx, uv, func, emit_lso(as, A64I_LDRx, dest, ra_alloc1(as, ir->op1, RSET_GPR),
(int32_t)offsetof(GCfuncL, uvptr) + 8*(int32_t)(ir->op2 >> 8)); (int32_t)offsetof(GCfuncL, uvptr) + 8*(int32_t)(ir->op2 >> 8));
} }
} }