aboutsummaryrefslogtreecommitdiff
path: root/src/lj_asm_mips.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_asm_mips.h')
-rw-r--r--src/lj_asm_mips.h82
1 files changed, 57 insertions, 25 deletions
diff --git a/src/lj_asm_mips.h b/src/lj_asm_mips.h
index f775d08b..058df8be 100644
--- a/src/lj_asm_mips.h
+++ b/src/lj_asm_mips.h
@@ -193,6 +193,9 @@ static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow)
193 return ra_allock(as, ofs-(int16_t)ofs, allow); 193 return ra_allock(as, ofs-(int16_t)ofs, allow);
194 } 194 }
195 } 195 }
196 } else if (ir->o == IR_TMPREF) {
197 *ofsp = (int32_t)(offsetof(global_State, tmptv)-32768);
198 return RID_JGL;
196 } 199 }
197 } 200 }
198 *ofsp = 0; 201 *ofsp = 0;
@@ -839,34 +842,63 @@ static void asm_tvstore64(ASMState *as, Reg base, int32_t ofs, IRRef ref)
839#endif 842#endif
840 843
841/* Get pointer to TValue. */ 844/* Get pointer to TValue. */
842static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) 845static void asm_tvptr(ASMState *as, Reg dest, IRRef ref, MSize mode)
843{ 846{
844 IRIns *ir = IR(ref); 847 int32_t tmpofs = (int32_t)(offsetof(global_State, tmptv)-32768);
845 if (irt_isnum(ir->t)) { 848 if ((mode & IRTMPREF_IN1)) {
846 if (irref_isk(ref)) /* Use the number constant itself as a TValue. */ 849 IRIns *ir = IR(ref);
847 ra_allockreg(as, igcptr(ir_knum(ir)), dest); 850 if (irt_isnum(ir->t)) {
848 else /* Otherwise force a spill and use the spill slot. */ 851 if ((mode & IRTMPREF_OUT1)) {
849 emit_tsi(as, MIPSI_AADDIU, dest, RID_SP, ra_spill(as, ir)); 852#if LJ_SOFTFP
850 } else { 853 emit_tsi(as, MIPSI_AADDIU, dest, RID_JGL, tmpofs);
851 /* Otherwise use g->tmptv to hold the TValue. */ 854#if LJ_64
855 emit_setgl(as, ra_alloc1(as, ref, RSET_GPR), tmptv.u64);
856#else
857 lj_assertA(irref_isk(ref), "unsplit FP op");
858 emit_setgl(as,
859 ra_allock(as, (int32_t)ir_knum(ir)->u32.lo, RSET_GPR),
860 tmptv.u32.lo);
861 emit_setgl(as,
862 ra_allock(as, (int32_t)ir_knum(ir)->u32.hi, RSET_GPR),
863 tmptv.u32.hi);
864#endif
865#else
866 Reg src = ra_alloc1(as, ref, RSET_FPR);
867 emit_tsi(as, MIPSI_AADDIU, dest, RID_JGL, tmpofs);
868 emit_tsi(as, MIPSI_SDC1, (src & 31), RID_JGL, tmpofs);
869#endif
870 } else if (irref_isk(ref)) {
871 /* Use the number constant itself as a TValue. */
872 ra_allockreg(as, igcptr(ir_knum(ir)), dest);
873 } else {
874#if LJ_SOFTFP
875 lj_assertA(0, "unsplit FP op");
876#else
877 /* Otherwise force a spill and use the spill slot. */
878 emit_tsi(as, MIPSI_AADDIU, dest, RID_SP, ra_spill(as, ir));
879#endif
880 }
881 } else {
882 /* Otherwise use g->tmptv to hold the TValue. */
852#if LJ_32 883#if LJ_32
853 RegSet allow = rset_exclude(RSET_GPR, dest); 884 Reg type;
854 Reg type; 885 emit_tsi(as, MIPSI_ADDIU, dest, RID_JGL, tmpofs);
855 emit_tsi(as, MIPSI_ADDIU, dest, RID_JGL, (int32_t)(offsetof(global_State, tmptv)-32768)); 886 if (!irt_ispri(ir->t)) {
856 if (!irt_ispri(ir->t)) { 887 Reg src = ra_alloc1(as, ref, RSET_GPR);
857 Reg src = ra_alloc1(as, ref, allow); 888 emit_setgl(as, src, tmptv.gcr);
858 emit_setgl(as, src, tmptv.gcr); 889 }
859 } 890 if (LJ_SOFTFP && (ir+1)->o == IR_HIOP && !irt_isnil((ir+1)->t))
860 if (LJ_SOFTFP && (ir+1)->o == IR_HIOP) 891 type = ra_alloc1(as, ref+1, RSET_GPR);
861 type = ra_alloc1(as, ref+1, allow); 892 else
862 else 893 type = ra_allock(as, (int32_t)irt_toitype(ir->t), RSET_GPR);
863 type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); 894 emit_setgl(as, type, tmptv.it);
864 emit_setgl(as, type, tmptv.it);
865#else 895#else
866 asm_tvstore64(as, dest, 0, ref); 896 asm_tvstore64(as, dest, 0, ref);
867 emit_tsi(as, MIPSI_DADDIU, dest, RID_JGL, 897 emit_tsi(as, MIPSI_DADDIU, dest, RID_JGL, tmpofs);
868 (int32_t)(offsetof(global_State, tmptv)-32768));
869#endif 898#endif
899 }
900 } else {
901 emit_tsi(as, MIPSI_AADDIU, dest, RID_JGL, tmpofs);
870 } 902 }
871} 903}
872 904
@@ -2415,7 +2447,7 @@ static void asm_hiop(ASMState *as, IRIns *ir)
2415 ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ 2447 ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */
2416 break; 2448 break;
2417#if LJ_SOFTFP 2449#if LJ_SOFTFP
2418 case IR_ASTORE: case IR_HSTORE: case IR_USTORE: case IR_TOSTR: 2450 case IR_ASTORE: case IR_HSTORE: case IR_USTORE: case IR_TOSTR: case IR_TMPREF:
2419#endif 2451#endif
2420 case IR_CNEWI: 2452 case IR_CNEWI:
2421 /* Nothing to do here. Handled by lo op itself. */ 2453 /* Nothing to do here. Handled by lo op itself. */