Use HIOP for XSTORE in SPLIT pass.
This commit is contained in:
@@ -162,22 +162,24 @@ static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow)
|
||||
|
||||
/* Fuse XLOAD/XSTORE reference into load/store operand. */
|
||||
static void asm_fusexref(ASMState *as, PPCIns pi, Reg rt, IRRef ref,
|
||||
RegSet allow)
|
||||
RegSet allow, int32_t ofs)
|
||||
{
|
||||
IRIns *ir = IR(ref);
|
||||
int32_t ofs = 0;
|
||||
Reg base;
|
||||
if (ra_noreg(ir->r) && mayfuse(as, ref)) {
|
||||
if (ir->o == IR_ADD) {
|
||||
if (irref_isk(ir->op2) && (ofs = IR(ir->op2)->i, checki16(ofs))) {
|
||||
int32_t ofs2;
|
||||
if (irref_isk(ir->op2) && (ofs2 = ofs + IR(ir->op2)->i, checki16(ofs2))) {
|
||||
ofs = ofs2;
|
||||
ref = ir->op1;
|
||||
} else {
|
||||
} else if (ofs == 0) {
|
||||
Reg right, left = ra_alloc2(as, ir, allow);
|
||||
right = (left >> 8); left &= 255;
|
||||
emit_fab(as, PPCI_LWZX | ((pi >> 20) & 0x780), rt, left, right);
|
||||
return;
|
||||
}
|
||||
} else if (ir->o == IR_STRREF) {
|
||||
lua_assert(ofs == 0);
|
||||
ofs = (int32_t)sizeof(GCstr);
|
||||
if (irref_isk(ir->op2)) {
|
||||
ofs += IR(ir->op2)->i;
|
||||
@@ -904,13 +906,13 @@ static void asm_xload(ASMState *as, IRIns *ir)
|
||||
lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED));
|
||||
if (irt_isi8(ir->t))
|
||||
emit_as(as, PPCI_EXTSB, dest, dest);
|
||||
asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR);
|
||||
asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0);
|
||||
}
|
||||
|
||||
static void asm_xstore(ASMState *as, IRIns *ir)
|
||||
static void asm_xstore(ASMState *as, IRIns *ir, int32_t ofs)
|
||||
{
|
||||
IRIns *irb;
|
||||
if (mayfuse(as, ir->op2) && (irb = IR(ir->op2))->o == IR_BSWAP &&
|
||||
if (ofs == 0 && mayfuse(as, ir->op2) && (irb = IR(ir->op2))->o == IR_BSWAP &&
|
||||
ra_noreg(irb->r) && (irt_isint(ir->t) || irt_isu32(ir->t))) {
|
||||
/* Fuse BSWAP with XSTORE to stwbrx. */
|
||||
Reg src = ra_alloc1(as, irb->op1, RSET_GPR);
|
||||
@@ -918,7 +920,7 @@ static void asm_xstore(ASMState *as, IRIns *ir)
|
||||
} else {
|
||||
Reg src = ra_alloc1(as, ir->op2, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR);
|
||||
asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1,
|
||||
rset_exclude(RSET_GPR, src));
|
||||
rset_exclude(RSET_GPR, src), ofs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1743,6 +1745,11 @@ static void asm_hiop(ASMState *as, IRIns *ir)
|
||||
as->curins--; /* Always skip the loword comparison. */
|
||||
asm_comp64(as, ir);
|
||||
return;
|
||||
} else if ((ir-1)->o == IR_XSTORE) {
|
||||
as->curins--; /* Handle both stores here. */
|
||||
asm_xstore(as, ir, 0);
|
||||
asm_xstore(as, ir-1, 4);
|
||||
return;
|
||||
}
|
||||
if (!usehi) return; /* Skip unused hiword op for all remaining ops. */
|
||||
switch ((ir-1)->o) {
|
||||
@@ -2035,7 +2042,7 @@ static void asm_ir(ASMState *as, IRIns *ir)
|
||||
|
||||
case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break;
|
||||
case IR_FSTORE: asm_fstore(as, ir); break;
|
||||
case IR_XSTORE: asm_xstore(as, ir); break;
|
||||
case IR_XSTORE: asm_xstore(as, ir, 0); break;
|
||||
|
||||
/* Allocations. */
|
||||
case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break;
|
||||
|
||||
Reference in New Issue
Block a user