Get debugger working
[fw/sdcc] / src / pic / ralloc.c
index e3b92273b04474590f9a3975dac2e204d4634e8e..dcda469f175490e57b975c23d116994c3f108eef 100644 (file)
 #include "pcode.h"
 #include "gen.h"
 
-#if defined(_MSC_VER)
-#define __FUNCTION__ __FILE__
-#endif
-
 /*-----------------------------------------------------------------*/
 /* At this point we start getting processor specific although      */
 /* some routines are non-processor specific & can be reused when   */
@@ -1558,19 +1554,21 @@ serialRegAssign (eBBlock ** ebbs, int count)
 
              /* if it has a spillocation & is used less than
                 all other live ranges then spill this */
-             if (willCS && sym->usl.spillLoc)
-               {
-
-                 symbol *leastUsed =
-                 leastUsedLR (liveRangesWith (spillable,
-                                              allLRs,
-                                              ebbs[i],
-                                              ic));
-                 if (leastUsed &&
-                     leastUsed->used > sym->used)
-                   {
-                     spillThis (sym);
-                     continue;
+               if (willCS) {
+                   if (sym->usl.spillLoc) {
+                       symbol *leastUsed = leastUsedLR (liveRangesWith (spillable,
+                                                                        allLRs, ebbs[i], ic));
+                       if (leastUsed && leastUsed->used > sym->used) {
+                           spillThis (sym);
+                           continue;
+                       }
+                   } else {
+                       /* if none of the liveRanges have a spillLocation then better
+                          to spill this one than anything else already assigned to registers */
+                       if (liveRangesWith(spillable,noSpilLoc,ebbs[i],ic)) {
+                           spillThis (sym);
+                           continue;
+                       }
                    }
                }
 
@@ -1580,7 +1578,7 @@ serialRegAssign (eBBlock ** ebbs, int count)
              /* if we need ptr regs for the right side
                 then mark it */
              if (POINTER_GET (ic) && getSize (OP_SYMBOL (IC_LEFT (ic))->type)
-                 <= PTRSIZE)
+                 <= (unsigned) PTRSIZE)
                {
                  pic14_ptrRegReq++;
                  ptrRegSet = 1;
@@ -2648,7 +2646,6 @@ static void
 packForReceive (iCode * ic, eBBlock * ebp)
 {
   iCode *dic;
-  bool can_remove = 1;         // assume that we can remove temporary
 
   debugLog ("%s\n", __FUNCTION__);
   debugAopGet ("  result:", IC_RESULT (ic));
@@ -2927,7 +2924,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);
@@ -3044,7 +3041,7 @@ pic14_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 */
@@ -3076,7 +3073,7 @@ pic14_assignRegisters (eBBlock ** ebbs, int count)
   redoStackOffsets ();
 
   if (options.dump_rassgn)
-    dumpEbbsToFileExt (".dumprassgn", ebbs, count);
+    dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count);
 
   /* now get back the chain */
   ic = iCodeLabelOptimize (iCodeFromeBBlock (ebbs, count));