* device/include/pic16/pic18f*.h: add bit aliases in INTCONbits_t
[fw/sdcc] / src / z80 / ralloc.c
index b9cba56cbc94373a0853b816afb3408fdd98fb21..aebe825eeddc600a167d0fcc6e015b29b6099a22 100644 (file)
@@ -146,7 +146,7 @@ allocReg (short type)
             {
               currFunc->regsUsed = bitVectSetBit (currFunc->regsUsed, i);
             }
-          D (D_ALLOC, ("allocReg: alloced %p\n", &regsZ80[i]));
+          D (D_ALLOC, ("allocReg: alloced %s\n", regsZ80[i].name));
           return &regsZ80[i];
         }
     }
@@ -1039,11 +1039,11 @@ tryAllocatingRegPair (symbol * sym)
               currFunc->regsUsed =
                 bitVectSetBit (currFunc->regsUsed, i + 1);
             }
-          D (D_ALLOC, ("tryAllocRegPair: succeded for sym %p\n", sym));
+          D (D_ALLOC, ("tryAllocatingRegPair: succeded for sym %p\n", sym));
           return TRUE;
         }
     }
-  D (D_ALLOC, ("tryAllocRegPair: failed on sym %p\n", sym));
+  D (D_ALLOC, ("tryAllocatingRegPair: failed on sym %p\n", sym));
   return FALSE;
 }
 
@@ -1234,6 +1234,14 @@ serialRegAssign (eBBlock ** ebbs, int count)
                             break;
                         }
                     }
+                  /* Make sure we didn't allocate a register pair with bytes swapped */
+                  if(sym->nRegs == 2 && sym->regs[0] == sym->regs[1] + 1 && sym->regs[0] != &regsZ80[2])
+                  {
+                       freeReg(sym->regs[0]);
+                       freeReg(sym->regs[1]);
+                       if(!tryAllocatingRegPair(sym))
+                               wassertl(0, "Failed to swap register pair bytes back.");
+                  }
                 }
               /* if it shares registers with operands make sure
                  that they are in the same position */
@@ -2894,7 +2902,7 @@ packRegsForAccUse2 (iCode * ic)
                 D (D_ACCUSE2, ("  + Dropping as last in list and next doesn't start a block\n"));
                 return;
               }
-          } /*This caused bug #1292721 */
+          } //This caused bug #1292721 */
         else if (scan->next == NULL)
           {
             D (D_ACCUSE2, ("  + Dropping as hit the end of the list\n"));