diff options
Diffstat (limited to 'src/lj_asm_x86.h')
-rw-r--r-- | src/lj_asm_x86.h | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/lj_asm_x86.h b/src/lj_asm_x86.h index e9c53a09..9dba6b70 100644 --- a/src/lj_asm_x86.h +++ b/src/lj_asm_x86.h | |||
@@ -551,7 +551,7 @@ static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) | |||
551 | if (ra_hasreg(dest)) { | 551 | if (ra_hasreg(dest)) { |
552 | ra_free(as, dest); | 552 | ra_free(as, dest); |
553 | ra_modified(as, dest); | 553 | ra_modified(as, dest); |
554 | emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, | 554 | emit_rmro(as, irt_isnum(ir->t) ? XO_MOVSD : XO_MOVSS, |
555 | dest, RID_ESP, ofs); | 555 | dest, RID_ESP, ofs); |
556 | } | 556 | } |
557 | if ((ci->flags & CCI_CASTU64)) { | 557 | if ((ci->flags & CCI_CASTU64)) { |
@@ -662,8 +662,7 @@ static void asm_tointg(ASMState *as, IRIns *ir, Reg left) | |||
662 | asm_guardcc(as, CC_NE); | 662 | asm_guardcc(as, CC_NE); |
663 | emit_rr(as, XO_UCOMISD, left, tmp); | 663 | emit_rr(as, XO_UCOMISD, left, tmp); |
664 | emit_rr(as, XO_CVTSI2SD, tmp, dest); | 664 | emit_rr(as, XO_CVTSI2SD, tmp, dest); |
665 | if (!(as->flags & JIT_F_SPLIT_XMM)) | 665 | emit_rr(as, XO_XORPS, tmp, tmp); /* Avoid partial register stall. */ |
666 | emit_rr(as, XO_XORPS, tmp, tmp); /* Avoid partial register stall. */ | ||
667 | emit_rr(as, XO_CVTTSD2SI, dest, left); | 666 | emit_rr(as, XO_CVTTSD2SI, dest, left); |
668 | /* Can't fuse since left is needed twice. */ | 667 | /* Can't fuse since left is needed twice. */ |
669 | } | 668 | } |
@@ -719,8 +718,7 @@ static void asm_conv(ASMState *as, IRIns *ir) | |||
719 | emit_mrm(as, irt_isnum(ir->t) ? XO_CVTSI2SD : XO_CVTSI2SS, | 718 | emit_mrm(as, irt_isnum(ir->t) ? XO_CVTSI2SD : XO_CVTSI2SS, |
720 | dest|((LJ_64 && (st64 || st == IRT_U32)) ? REX_64 : 0), left); | 719 | dest|((LJ_64 && (st64 || st == IRT_U32)) ? REX_64 : 0), left); |
721 | } | 720 | } |
722 | if (!(as->flags & JIT_F_SPLIT_XMM)) | 721 | emit_rr(as, XO_XORPS, dest, dest); /* Avoid partial register stall. */ |
723 | emit_rr(as, XO_XORPS, dest, dest); /* Avoid partial register stall. */ | ||
724 | } else if (stfp) { /* FP to integer conversion. */ | 722 | } else if (stfp) { /* FP to integer conversion. */ |
725 | if (irt_isguard(ir->t)) { | 723 | if (irt_isguard(ir->t)) { |
726 | /* Checked conversions are only supported from number to int. */ | 724 | /* Checked conversions are only supported from number to int. */ |
@@ -728,9 +726,7 @@ static void asm_conv(ASMState *as, IRIns *ir) | |||
728 | asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); | 726 | asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); |
729 | } else { | 727 | } else { |
730 | Reg dest = ra_dest(as, ir, RSET_GPR); | 728 | Reg dest = ra_dest(as, ir, RSET_GPR); |
731 | x86Op op = st == IRT_NUM ? | 729 | x86Op op = st == IRT_NUM ? XO_CVTTSD2SI : XO_CVTTSS2SI; |
732 | ((ir->op2 & IRCONV_TRUNC) ? XO_CVTTSD2SI : XO_CVTSD2SI) : | ||
733 | ((ir->op2 & IRCONV_TRUNC) ? XO_CVTTSS2SI : XO_CVTSS2SI); | ||
734 | if (LJ_64 ? irt_isu64(ir->t) : irt_isu32(ir->t)) { | 730 | if (LJ_64 ? irt_isu64(ir->t) : irt_isu32(ir->t)) { |
735 | /* LJ_64: For inputs >= 2^63 add -2^64, convert again. */ | 731 | /* LJ_64: For inputs >= 2^63 add -2^64, convert again. */ |
736 | /* LJ_32: For inputs >= 2^31 add -2^31, convert again and add 2^31. */ | 732 | /* LJ_32: For inputs >= 2^31 add -2^31, convert again and add 2^31. */ |
@@ -824,8 +820,7 @@ static void asm_conv_fp_int64(ASMState *as, IRIns *ir) | |||
824 | if (ra_hasreg(dest)) { | 820 | if (ra_hasreg(dest)) { |
825 | ra_free(as, dest); | 821 | ra_free(as, dest); |
826 | ra_modified(as, dest); | 822 | ra_modified(as, dest); |
827 | emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, | 823 | emit_rmro(as, irt_isnum(ir->t) ? XO_MOVSD : XO_MOVSS, dest, RID_ESP, ofs); |
828 | dest, RID_ESP, ofs); | ||
829 | } | 824 | } |
830 | emit_rmro(as, irt_isnum(ir->t) ? XO_FSTPq : XO_FSTPd, | 825 | emit_rmro(as, irt_isnum(ir->t) ? XO_FSTPq : XO_FSTPd, |
831 | irt_isnum(ir->t) ? XOg_FSTPq : XOg_FSTPd, RID_ESP, ofs); | 826 | irt_isnum(ir->t) ? XOg_FSTPq : XOg_FSTPd, RID_ESP, ofs); |
@@ -853,7 +848,6 @@ static void asm_conv_int64_fp(ASMState *as, IRIns *ir) | |||
853 | Reg lo, hi; | 848 | Reg lo, hi; |
854 | lua_assert(st == IRT_NUM || st == IRT_FLOAT); | 849 | lua_assert(st == IRT_NUM || st == IRT_FLOAT); |
855 | lua_assert(dt == IRT_I64 || dt == IRT_U64); | 850 | lua_assert(dt == IRT_I64 || dt == IRT_U64); |
856 | lua_assert(((ir-1)->op2 & IRCONV_TRUNC)); | ||
857 | hi = ra_dest(as, ir, RSET_GPR); | 851 | hi = ra_dest(as, ir, RSET_GPR); |
858 | lo = ra_dest(as, ir-1, rset_exclude(RSET_GPR, hi)); | 852 | lo = ra_dest(as, ir-1, rset_exclude(RSET_GPR, hi)); |
859 | if (ra_used(ir-1)) emit_rmro(as, XO_MOV, lo, RID_ESP, 0); | 853 | if (ra_used(ir-1)) emit_rmro(as, XO_MOV, lo, RID_ESP, 0); |
@@ -1262,7 +1256,7 @@ static void asm_fxload(ASMState *as, IRIns *ir) | |||
1262 | case IRT_U8: xo = XO_MOVZXb; break; | 1256 | case IRT_U8: xo = XO_MOVZXb; break; |
1263 | case IRT_I16: xo = XO_MOVSXw; break; | 1257 | case IRT_I16: xo = XO_MOVSXw; break; |
1264 | case IRT_U16: xo = XO_MOVZXw; break; | 1258 | case IRT_U16: xo = XO_MOVZXw; break; |
1265 | case IRT_NUM: xo = XMM_MOVRM(as); break; | 1259 | case IRT_NUM: xo = XO_MOVSD; break; |
1266 | case IRT_FLOAT: xo = XO_MOVSS; break; | 1260 | case IRT_FLOAT: xo = XO_MOVSS; break; |
1267 | default: | 1261 | default: |
1268 | if (LJ_64 && irt_is64(ir->t)) | 1262 | if (LJ_64 && irt_is64(ir->t)) |
@@ -1376,7 +1370,7 @@ static void asm_ahuvload(ASMState *as, IRIns *ir) | |||
1376 | RegSet allow = irt_isnum(ir->t) ? RSET_FPR : RSET_GPR; | 1370 | RegSet allow = irt_isnum(ir->t) ? RSET_FPR : RSET_GPR; |
1377 | Reg dest = ra_dest(as, ir, allow); | 1371 | Reg dest = ra_dest(as, ir, allow); |
1378 | asm_fuseahuref(as, ir->op1, RSET_GPR); | 1372 | asm_fuseahuref(as, ir->op1, RSET_GPR); |
1379 | emit_mrm(as, dest < RID_MAX_GPR ? XO_MOV : XMM_MOVRM(as), dest, RID_MRM); | 1373 | emit_mrm(as, dest < RID_MAX_GPR ? XO_MOV : XO_MOVSD, dest, RID_MRM); |
1380 | } else { | 1374 | } else { |
1381 | asm_fuseahuref(as, ir->op1, RSET_GPR); | 1375 | asm_fuseahuref(as, ir->op1, RSET_GPR); |
1382 | } | 1376 | } |
@@ -1442,7 +1436,7 @@ static void asm_sload(ASMState *as, IRIns *ir) | |||
1442 | Reg left = ra_scratch(as, RSET_FPR); | 1436 | Reg left = ra_scratch(as, RSET_FPR); |
1443 | asm_tointg(as, ir, left); /* Frees dest reg. Do this before base alloc. */ | 1437 | asm_tointg(as, ir, left); /* Frees dest reg. Do this before base alloc. */ |
1444 | base = ra_alloc1(as, REF_BASE, RSET_GPR); | 1438 | base = ra_alloc1(as, REF_BASE, RSET_GPR); |
1445 | emit_rmro(as, XMM_MOVRM(as), left, base, ofs); | 1439 | emit_rmro(as, XO_MOVSD, left, base, ofs); |
1446 | t.irt = IRT_NUM; /* Continue with a regular number type check. */ | 1440 | t.irt = IRT_NUM; /* Continue with a regular number type check. */ |
1447 | #if LJ_64 | 1441 | #if LJ_64 |
1448 | } else if (irt_islightud(t)) { | 1442 | } else if (irt_islightud(t)) { |
@@ -1460,11 +1454,9 @@ static void asm_sload(ASMState *as, IRIns *ir) | |||
1460 | lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); | 1454 | lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); |
1461 | if ((ir->op2 & IRSLOAD_CONVERT)) { | 1455 | if ((ir->op2 & IRSLOAD_CONVERT)) { |
1462 | t.irt = irt_isint(t) ? IRT_NUM : IRT_INT; /* Check for original type. */ | 1456 | t.irt = irt_isint(t) ? IRT_NUM : IRT_INT; /* Check for original type. */ |
1463 | emit_rmro(as, irt_isint(t) ? XO_CVTSI2SD : XO_CVTSD2SI, dest, base, ofs); | 1457 | emit_rmro(as, irt_isint(t) ? XO_CVTSI2SD : XO_CVTTSD2SI, dest, base, ofs); |
1464 | } else if (irt_isnum(t)) { | ||
1465 | emit_rmro(as, XMM_MOVRM(as), dest, base, ofs); | ||
1466 | } else { | 1458 | } else { |
1467 | emit_rmro(as, XO_MOV, dest, base, ofs); | 1459 | emit_rmro(as, irt_isnum(t) ? XO_MOVSD : XO_MOV, dest, base, ofs); |
1468 | } | 1460 | } |
1469 | } else { | 1461 | } else { |
1470 | if (!(ir->op2 & IRSLOAD_TYPECHECK)) | 1462 | if (!(ir->op2 & IRSLOAD_TYPECHECK)) |
@@ -1696,7 +1688,7 @@ static void asm_fpmath(ASMState *as, IRIns *ir) | |||
1696 | if (ra_hasreg(dest)) { | 1688 | if (ra_hasreg(dest)) { |
1697 | ra_free(as, dest); | 1689 | ra_free(as, dest); |
1698 | ra_modified(as, dest); | 1690 | ra_modified(as, dest); |
1699 | emit_rmro(as, XMM_MOVRM(as), dest, RID_ESP, ofs); | 1691 | emit_rmro(as, XO_MOVSD, dest, RID_ESP, ofs); |
1700 | } | 1692 | } |
1701 | emit_rmro(as, XO_FSTPq, XOg_FSTPq, RID_ESP, ofs); | 1693 | emit_rmro(as, XO_FSTPq, XOg_FSTPq, RID_ESP, ofs); |
1702 | switch (fpm) { /* st0 = lj_vm_*(st0) */ | 1694 | switch (fpm) { /* st0 = lj_vm_*(st0) */ |