]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
ARM: Don't use argument GPRs to rematerialize FPR arguments.
authorMike Pall <mike>
Sun, 19 Aug 2012 16:43:04 +0000 (18:43 +0200)
committerMike Pall <mike>
Sun, 19 Aug 2012 16:43:04 +0000 (18:43 +0200)
src/lj_asm_arm.h

index 8574a2b3dd713e29f4d9b3805fb45d9c57308d3c..618bc5b70d02e0fec404149353a49e006dca7c23 100644 (file)
@@ -339,18 +339,27 @@ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args)
 {
   uint32_t n, nargs = CCI_NARGS(ci);
   int32_t ofs = 0;
+#if LJ_SOFTFP
   Reg gpr = REGARG_FIRSTGPR;
-#if !LJ_SOFTFP
-  Reg fpr = REGARG_FIRSTFPR, fprodd = 0;
+#else
+  Reg gpr, fpr = REGARG_FIRSTFPR, fprodd = 0;
 #endif
   if ((void *)ci->func)
     emit_call(as, (void *)ci->func);
+#if !LJ_SOFTFP
+  for (gpr = REGARG_FIRSTGPR; gpr <= REGARG_LASTGPR; gpr++)
+    as->cost[gpr] = REGCOST(~0u, 0u);
+  gpr = REGARG_FIRSTGPR;
+#endif
   for (n = 0; n < nargs; n++) {  /* Setup args. */
     IRRef ref = args[n];
     IRIns *ir = IR(ref);
 #if !LJ_SOFTFP
     if (irt_isfp(ir->t)) {
+      RegSet of = as->freeset;
       Reg src;
+      /* Workaround to protect argument GPRs from being used for remat. */
+      as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1);
       if (!LJ_ABI_SOFTFP && !(ci->flags & CCI_VARARG)) {
        if (irt_isnum(ir->t)) {
          if (fpr <= REGARG_LASTFPR) {
@@ -368,15 +377,17 @@ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args)
          fprodd = fpr++;
          continue;
        }
-       src = ra_alloc1(as, ref, RSET_FPR);
+       src = ra_alloc1(as, ref, RSET_FPR);  /* May alloc GPR to remat FPR. */
        fprodd = 0;
        goto stackfp;
       }
-      src = ra_alloc1(as, ref, RSET_FPR);
+      src = ra_alloc1(as, ref, RSET_FPR);  /* May alloc GPR to remat FPR. */
+      as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1));
       if (irt_isnum(ir->t)) gpr = (gpr+1) & ~1u;
       if (gpr <= REGARG_LASTGPR) {
        lua_assert(rset_test(as->freeset, gpr));  /* Must have been evicted. */
        if (irt_isnum(ir->t)) {
+         lua_assert(rset_test(as->freeset, gpr+1));  /* Ditto. */
          emit_dnm(as, ARMI_VMOV_RR_D, gpr, gpr+1, (src & 15));
          gpr += 2;
        } else {