aboutsummaryrefslogtreecommitdiff
path: root/src/lj_asm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_asm.c')
-rw-r--r--src/lj_asm.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c
index ebcff43c..9dae2707 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -1149,24 +1149,30 @@ static void asm_tvptr(ASMState *as, Reg dest, IRRef ref, MSize mode);
1149static void asm_bufhdr(ASMState *as, IRIns *ir) 1149static void asm_bufhdr(ASMState *as, IRIns *ir)
1150{ 1150{
1151 Reg sb = ra_dest(as, ir, RSET_GPR); 1151 Reg sb = ra_dest(as, ir, RSET_GPR);
1152 if ((ir->op2 & IRBUFHDR_APPEND)) { 1152 switch (ir->op2) {
1153 case IRBUFHDR_RESET: {
1154 Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, sb));
1155 IRIns irbp;
1156 irbp.ot = IRT(0, IRT_PTR); /* Buffer data pointer type. */
1157 emit_storeofs(as, &irbp, tmp, sb, offsetof(SBuf, w));
1158 emit_loadofs(as, &irbp, tmp, sb, offsetof(SBuf, b));
1159 break;
1160 }
1161 case IRBUFHDR_APPEND: {
1153 /* Rematerialize const buffer pointer instead of likely spill. */ 1162 /* Rematerialize const buffer pointer instead of likely spill. */
1154 IRIns *irp = IR(ir->op1); 1163 IRIns *irp = IR(ir->op1);
1155 if (!(ra_hasreg(irp->r) || irp == ir-1 || 1164 if (!(ra_hasreg(irp->r) || irp == ir-1 ||
1156 (irp == ir-2 && !ra_used(ir-1)))) { 1165 (irp == ir-2 && !ra_used(ir-1)))) {
1157 while (!(irp->o == IR_BUFHDR && !(irp->op2 & IRBUFHDR_APPEND))) 1166 while (!(irp->o == IR_BUFHDR && irp->op2 == IRBUFHDR_RESET))
1158 irp = IR(irp->op1); 1167 irp = IR(irp->op1);
1159 if (irref_isk(irp->op1)) { 1168 if (irref_isk(irp->op1)) {
1160 ra_weak(as, ra_allocref(as, ir->op1, RSET_GPR)); 1169 ra_weak(as, ra_allocref(as, ir->op1, RSET_GPR));
1161 ir = irp; 1170 ir = irp;
1162 } 1171 }
1163 } 1172 }
1164 } else { 1173 break;
1165 Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, sb)); 1174 }
1166 IRIns irbp; 1175 default: lj_assertA(0, "bad BUFHDR op2 %d", ir->op2); break;
1167 irbp.ot = IRT(0, IRT_PTR); /* Buffer data pointer type. */
1168 emit_storeofs(as, &irbp, tmp, sb, offsetof(SBuf, w));
1169 emit_loadofs(as, &irbp, tmp, sb, offsetof(SBuf, b));
1170 } 1176 }
1171#if LJ_TARGET_X86ORX64 1177#if LJ_TARGET_X86ORX64
1172 ra_left(as, sb, ir->op1); 1178 ra_left(as, sb, ir->op1);