diff options
| -rw-r--r-- | src/lj_asm_mips.h | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/lj_asm_mips.h b/src/lj_asm_mips.h index 299b4439..14ebd1b3 100644 --- a/src/lj_asm_mips.h +++ b/src/lj_asm_mips.h | |||
| @@ -227,9 +227,12 @@ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) | |||
| 227 | { | 227 | { |
| 228 | uint32_t n, nargs = CCI_NARGS(ci); | 228 | uint32_t n, nargs = CCI_NARGS(ci); |
| 229 | int32_t ofs = 16; | 229 | int32_t ofs = 16; |
| 230 | Reg gpr = REGARG_FIRSTGPR, fpr = REGARG_FIRSTFPR; | 230 | Reg gpr, fpr = REGARG_FIRSTFPR; |
| 231 | if ((void *)ci->func) | 231 | if ((void *)ci->func) |
| 232 | emit_call(as, (void *)ci->func); | 232 | emit_call(as, (void *)ci->func); |
| 233 | for (gpr = REGARG_FIRSTGPR; gpr <= REGARG_LASTGPR; gpr++) | ||
| 234 | as->cost[gpr] = REGCOST(~0u, 0u); | ||
| 235 | gpr = REGARG_FIRSTGPR; | ||
| 233 | for (n = 0; n < nargs; n++) { /* Setup args. */ | 236 | for (n = 0; n < nargs; n++) { /* Setup args. */ |
| 234 | IRRef ref = args[n]; | 237 | IRRef ref = args[n]; |
| 235 | if (ref) { | 238 | if (ref) { |
| @@ -245,16 +248,22 @@ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) | |||
| 245 | if (irt_isnum(ir->t)) gpr = (gpr+1) & ~1; | 248 | if (irt_isnum(ir->t)) gpr = (gpr+1) & ~1; |
| 246 | if (gpr <= REGARG_LASTGPR) { | 249 | if (gpr <= REGARG_LASTGPR) { |
| 247 | lua_assert(rset_test(as->freeset, gpr)); /* Already evicted. */ | 250 | lua_assert(rset_test(as->freeset, gpr)); /* Already evicted. */ |
| 248 | if (irt_isnum(ir->t)) { | 251 | if (irt_isfp(ir->t)) { |
| 249 | Reg r = ra_alloc1(as, ref, RSET_FPR); | 252 | RegSet of = as->freeset; |
| 250 | emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?0:1), r+1); | 253 | Reg r; |
| 251 | emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?1:0), r); | 254 | /* Workaround to protect argument GPRs from being used for remat. */ |
| 252 | lua_assert(rset_test(as->freeset, gpr+1)); /* Already evicted. */ | 255 | as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1); |
| 253 | gpr += 2; | 256 | r = ra_alloc1(as, ref, RSET_FPR); |
| 254 | } else if (irt_isfloat(ir->t)) { | 257 | as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1)); |
| 255 | Reg r = ra_alloc1(as, ref, RSET_FPR); | 258 | if (irt_isnum(ir->t)) { |
| 256 | emit_tg(as, MIPSI_MFC1, gpr, r); | 259 | emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?0:1), r+1); |
| 257 | gpr++; | 260 | emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?1:0), r); |
| 261 | lua_assert(rset_test(as->freeset, gpr+1)); /* Already evicted. */ | ||
| 262 | gpr += 2; | ||
| 263 | } else if (irt_isfloat(ir->t)) { | ||
| 264 | emit_tg(as, MIPSI_MFC1, gpr, r); | ||
| 265 | gpr++; | ||
| 266 | } | ||
| 258 | } else { | 267 | } else { |
| 259 | ra_leftov(as, gpr, ref); | 268 | ra_leftov(as, gpr, ref); |
| 260 | gpr++; | 269 | gpr++; |
