aboutsummaryrefslogtreecommitdiff
path: root/src/lj_asm_x86.h
diff options
context:
space:
mode:
authorMike Pall <mike>2016-05-23 00:25:29 +0200
committerMike Pall <mike>2016-05-23 00:25:29 +0200
commit7fb75ccc4cf17825c1c8fe9f44ebfb0668a1b033 (patch)
tree7317a542402fa2a135b6789c7c4868089d31fd2f /src/lj_asm_x86.h
parenta4067978b6d1c2a25d91d82b1b0d384d98abdbe5 (diff)
downloadluajit-7fb75ccc4cf17825c1c8fe9f44ebfb0668a1b033.tar.gz
luajit-7fb75ccc4cf17825c1c8fe9f44ebfb0668a1b033.tar.bz2
luajit-7fb75ccc4cf17825c1c8fe9f44ebfb0668a1b033.zip
Embed 64 bit constants directly in the IR, using two slots.
Contributed by Peter Cawley.
Diffstat (limited to 'src/lj_asm_x86.h')
-rw-r--r--src/lj_asm_x86.h26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/lj_asm_x86.h b/src/lj_asm_x86.h
index 69d1256e..0361a965 100644
--- a/src/lj_asm_x86.h
+++ b/src/lj_asm_x86.h
@@ -306,6 +306,16 @@ static void asm_fusexref(ASMState *as, IRRef ref, RegSet allow)
306 } 306 }
307} 307}
308 308
309/* Fuse load of 64 bit IR constant into memory operand. */
310static Reg asm_fuseloadk64(ASMState *as, IRIns *ir)
311{
312 const uint64_t *k = &ir_k64(ir)->u64;
313 as->mrm.ofs = ptr2addr(k);
314 as->mrm.base = RID_NONE;
315 as->mrm.idx = RID_NONE;
316 return RID_MRM;
317}
318
309/* Fuse load into memory operand. */ 319/* Fuse load into memory operand. */
310static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow) 320static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow)
311{ 321{
@@ -325,19 +335,13 @@ static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow)
325 if (ir->o == IR_KNUM) { 335 if (ir->o == IR_KNUM) {
326 RegSet avail = as->freeset & ~as->modset & RSET_FPR; 336 RegSet avail = as->freeset & ~as->modset & RSET_FPR;
327 lua_assert(allow != RSET_EMPTY); 337 lua_assert(allow != RSET_EMPTY);
328 if (!(avail & (avail-1))) { /* Fuse if less than two regs available. */ 338 if (!(avail & (avail-1))) /* Fuse if less than two regs available. */
329 as->mrm.ofs = ptr2addr(ir_knum(ir)); 339 return asm_fuseloadk64(as, ir);
330 as->mrm.base = as->mrm.idx = RID_NONE;
331 return RID_MRM;
332 }
333 } else if (ir->o == IR_KINT64) { 340 } else if (ir->o == IR_KINT64) {
334 RegSet avail = as->freeset & ~as->modset & RSET_GPR; 341 RegSet avail = as->freeset & ~as->modset & RSET_GPR;
335 lua_assert(allow != RSET_EMPTY); 342 lua_assert(allow != RSET_EMPTY);
336 if (!(avail & (avail-1))) { /* Fuse if less than two regs available. */ 343 if (!(avail & (avail-1))) /* Fuse if less than two regs available. */
337 as->mrm.ofs = ptr2addr(ir_kint64(ir)); 344 return asm_fuseloadk64(as, ir);
338 as->mrm.base = as->mrm.idx = RID_NONE;
339 return RID_MRM;
340 }
341 } else if (mayfuse(as, ref)) { 345 } else if (mayfuse(as, ref)) {
342 RegSet xallow = (allow & RSET_GPR) ? allow : RSET_GPR; 346 RegSet xallow = (allow & RSET_GPR) ? allow : RSET_GPR;
343 if (ir->o == IR_SLOAD) { 347 if (ir->o == IR_SLOAD) {
@@ -711,7 +715,7 @@ static void asm_conv(ASMState *as, IRIns *ir)
711 emit_rr(as, XO_CVTSD2SS, dest, dest); 715 emit_rr(as, XO_CVTSD2SS, dest, dest);
712 emit_rr(as, XO_SUBSD, dest, bias); /* Subtract 2^52+2^51 bias. */ 716 emit_rr(as, XO_SUBSD, dest, bias); /* Subtract 2^52+2^51 bias. */
713 emit_rr(as, XO_XORPS, dest, bias); /* Merge bias and integer. */ 717 emit_rr(as, XO_XORPS, dest, bias); /* Merge bias and integer. */
714 emit_loadn(as, bias, k); 718 emit_rma(as, XO_MOVSD, bias, k);
715 emit_mrm(as, XO_MOVD, dest, asm_fuseload(as, lref, RSET_GPR)); 719 emit_mrm(as, XO_MOVD, dest, asm_fuseload(as, lref, RSET_GPR));
716 return; 720 return;
717 } else { /* Integer to FP conversion. */ 721 } else { /* Integer to FP conversion. */