* fixed GCC 4.4.0 mingw compilation:
[fw/sdcc] / src / ds390 / ralloc.c
index f69b12c2f29f1385bc897c1d74ed0f9ce0e7e009..f166a647fb3cca1e62c3708363db33077df0e18a 100644 (file)
@@ -124,8 +124,7 @@ allocReg (short type)
             currFunc->regsUsed = bitVectSetBit (currFunc->regsUsed, i);
           return &regs390[i];
         }
-      /* otherwise look for specific type
-         of register */
+      /* otherwise look for specific type of register */
       if (regs390[i].isFree &&
           regs390[i].type == type)
         {
@@ -959,7 +958,6 @@ static regs *getRegGprNoSpil()
 /*-----------------------------------------------------------------*/
 /* getRegBitNoSpil - get it cannot be spilt                        */
 /*-----------------------------------------------------------------*/
-#if 0
 static regs *getRegBitNoSpil()
 {
   regs *reg;
@@ -977,7 +975,6 @@ static regs *getRegBitNoSpil()
   /* just to make the compiler happy */
   return 0;
 }
-#endif
 
 /*-----------------------------------------------------------------*/
 /* symHasReg - symbol has a given register                         */
@@ -1671,6 +1668,8 @@ static void fillGaps()
             for (i=0; i < sym->nRegs ; i++ ) {
                 if (sym->regType == REG_PTR)
                     sym->regs[i] = getRegPtrNoSpil ();
+                else if (sym->regType == REG_BIT)
+                    sym->regs[i] = getRegBitNoSpil ();
                 else
                     sym->regs[i] = getRegGprNoSpil ();
             }
@@ -1935,21 +1934,23 @@ createRegMask (eBBlock ** ebbs, int count)
 static char *
 rematStr (symbol * sym)
 {
-  char *s = buffer;
   iCode *ic = sym->rematiCode;
-
-  *s = 0;
+  int offset = 0;
 
   while (1)
     {
+      /* if plus adjust offset to right hand side */
+      if (ic->op == '+')
+        {
+          offset += (int) operandLitValue (IC_RIGHT (ic));
+          ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
+          continue;
+        }
 
-      /* if plus or minus print the right hand side */
-      if (ic->op == '+' || ic->op == '-')
+      /* if minus adjust offset to right hand side */
+      if (ic->op == '-')
         {
-          SNPRINTF (s, sizeof(buffer) - strlen(buffer),
-                    "0x%04x %c ", (int) operandLitValue (IC_RIGHT (ic)),
-                    ic->op);
-          s += strlen (s);
+          offset -= (int) operandLitValue (IC_RIGHT (ic));
           ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
           continue;
         }
@@ -1960,11 +1961,21 @@ rematStr (symbol * sym)
           continue;
       }
       /* we reached the end */
-      SNPRINTF (s, sizeof(buffer) - strlen(buffer),
-                "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
       break;
     }
 
+  if (offset)
+    {
+      SNPRINTF (buffer, sizeof(buffer),
+                "(%s %c 0x%04x)",
+                OP_SYMBOL (IC_LEFT (ic))->rname,
+                offset >= 0 ? '+' : '-',
+                abs (offset) & 0xffff);
+    }
+  else
+    {
+      strncpyz (buffer, OP_SYMBOL (IC_LEFT (ic))->rname, sizeof(buffer));
+    }
   return buffer;
 }
 
@@ -2464,8 +2475,6 @@ right:
   return change;
 }
 
-#define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly)
-
 
 /*-----------------------------------------------------------------*/
 /* packRegsDPTRnuse - color live ranges that can go into extra DPTRS */
@@ -3058,6 +3067,7 @@ packRegisters (eBBlock ** ebpp, int blockno)
           IS_SYMOP (IC_RIGHT (ic)) &&
           OP_SYMBOL (IC_RIGHT (ic))->remat &&
           !IS_CAST_ICODE(OP_SYMBOL (IC_RIGHT (ic))->rematiCode) &&
+          !isOperandGlobal(IC_RESULT(ic)) &&          /* due to bug 1618050 */
           bitVectnBitsOn (OP_SYMBOL (IC_RESULT (ic))->defs) <= 1)
         {
           OP_SYMBOL (IC_RESULT (ic))->remat =