a fix for the initialized structs and some others, see
[fw/sdcc] / src / mcs51 / ralloc.c
index e5ab738986d8fef553f37bbc66271784027076df..1c8d487bdc67407d1878341b82cd38d8aeb0ad70 100644 (file)
@@ -2212,10 +2212,23 @@ packForPush (iCode * ic, eBBlock * ebp)
     if (bitVectBitValue(dbv,lic->key)) 
       return ;
   }
+  /* make sure they have the same type */
+  {
+    sym_link *itype=operandType(IC_LEFT(ic));
+    sym_link *ditype=operandType(IC_RIGHT(dic));
+
+    if (SPEC_USIGN(itype)!=SPEC_USIGN(ditype) ||
+       SPEC_LONG(itype)!=SPEC_LONG(ditype))
+      return;
+  }
+  /* extend the live range of replaced operand if needed */
+  if (OP_SYMBOL(IC_RIGHT(dic))->liveTo < ic->seq) {
+         OP_SYMBOL(IC_RIGHT(dic))->liveTo = ic->seq;
+  }
   /* we now we know that it has one & only one def & use
      and the that the definition is an assignment */
   IC_LEFT (ic) = IC_RIGHT (dic);
-
+   
   remiCodeFromeBBlock (ebp, dic);
   hTabDeleteItem (&iCodehTab, dic->key, dic, DELETE_ITEM, NULL);
 }
@@ -2413,7 +2426,7 @@ packRegisters (eBBlock * ebp)
              if (dic)
                {
                  if (IS_ARITHMETIC_OP (dic))
-                   {
+                   {                  
                      IC_RESULT (dic) = IC_RESULT (ic);
                      remiCodeFromeBBlock (ebp, ic);
                      hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
@@ -2429,7 +2442,7 @@ packRegisters (eBBlock * ebp)
 
              /* if the type from and type to are the same
                 then if this is the only use then packit */
-             if (checkType (operandType (IC_RIGHT (ic)),
+             if (compareType (operandType (IC_RIGHT (ic)),
                             operandType (IC_LEFT (ic))) == 1)
                {
                  iCode *dic = packRegsForOneuse (ic, IC_RIGHT (ic), ebp);
@@ -2501,7 +2514,7 @@ mcs51_assignRegisters (eBBlock ** ebbs, int count)
     packRegisters (ebbs[i]);
 
   if (options.dump_pack)
-    dumpEbbsToFileExt (".dumppack", ebbs, count);
+    dumpEbbsToFileExt (DUMP_PACK, ebbs, count);
 
   /* first determine for each live range the number of 
      registers & the type of registers required for each */
@@ -2534,8 +2547,8 @@ mcs51_assignRegisters (eBBlock ** ebbs, int count)
 
   if (options.dump_rassgn)
     {
-      dumpEbbsToFileExt (".dumprassgn", ebbs, count);
-      dumpLiveRanges (".dumplrange", liveRanges);
+      dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count);
+      dumpLiveRanges (DUMP_LRANGE, liveRanges);
     }
 
   /* do the overlaysegment stuff SDCCmem.c */