#include "common.h"
#include "ralloc.h"
+#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 */
regs regspic14[] =
{
- {REG_GPR, 0x0C, "r0x0C", "r0x0C", 0x0C, 1, 0},
- {REG_GPR, 0x0D, "r0x0D", "r0x0C", 0x0D, 1, 0},
- {REG_GPR, 0x0E, "r0x0E", "r0x0C", 0x0E, 1, 0},
- {REG_GPR, 0x0F, "r0x0F", "r0x0C", 0x0F, 1, 0},
- {REG_GPR, 0x10, "r0x10", "r0x10", 0x10, 1, 0},
- {REG_GPR, 0x11, "r0x11", "r0x11", 0x11, 1, 0},
- {REG_GPR, 0x12, "r0x12", "r0x12", 0x12, 1, 0},
- {REG_GPR, 0x13, "r0x13", "r0x13", 0x13, 1, 0},
- {REG_GPR, 0x14, "r0x14", "r0x14", 0x14, 1, 0},
- {REG_GPR, 0x15, "r0x15", "r0x15", 0x15, 1, 0},
- {REG_GPR, 0x16, "r0x16", "r0x16", 0x16, 1, 0},
- {REG_GPR, 0x17, "r0x17", "r0x17", 0x17, 1, 0},
- {REG_GPR, 0x18, "r0x18", "r0x18", 0x18, 1, 0},
- {REG_GPR, 0x19, "r0x19", "r0x19", 0x19, 1, 0},
- {REG_GPR, 0x1A, "r0x1A", "r0x1A", 0x1A, 1, 0},
- {REG_GPR, 0x1B, "r0x1B", "r0x1B", 0x1B, 1, 0},
- {REG_GPR, 0x1C, "r0x1C", "r0x1C", 0x1C, 1, 0},
- {REG_GPR, 0x1D, "r0x1D", "r0x1D", 0x1D, 1, 0},
- {REG_GPR, 0x1E, "r0x1E", "r0x1E", 0x1E, 1, 0},
- {REG_GPR, 0x1F, "r0x1F", "r0x1F", 0x1F, 1, 0},
- {REG_PTR, 4, "FSR", "FSR", 4, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x0C, "r0x0C", "r0x0C", 0x0C, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x0D, "r0x0D", "r0x0C", 0x0D, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x0E, "r0x0E", "r0x0C", 0x0E, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x0F, "r0x0F", "r0x0C", 0x0F, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x10, "r0x10", "r0x10", 0x10, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x11, "r0x11", "r0x11", 0x11, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x12, "r0x12", "r0x12", 0x12, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x13, "r0x13", "r0x13", 0x13, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x14, "r0x14", "r0x14", 0x14, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x15, "r0x15", "r0x15", 0x15, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x16, "r0x16", "r0x16", 0x16, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x17, "r0x17", "r0x17", 0x17, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x18, "r0x18", "r0x18", 0x18, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x19, "r0x19", "r0x19", 0x19, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x1A, "r0x1A", "r0x1A", 0x1A, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x1B, "r0x1B", "r0x1B", 0x1B, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x1C, "r0x1C", "r0x1C", 0x1C, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x1D, "r0x1D", "r0x1D", 0x1D, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x1E, "r0x1E", "r0x1E", 0x1E, 1, 0},
+ {REG_GPR, PO_GPR_TEMP, 0x1F, "r0x1F", "r0x1F", 0x1F, 1, 0},
+ {REG_PTR, PO_FSR, 4, "FSR", "FSR", 4, 1, 0},
};
//char *bufferP=buffer;
va_list ap;
- if (!debug)
+ if (!debug || !srcFileName)
return;
exit (1);
}
+/*-----------------------------------------------------------------*/
+/*-----------------------------------------------------------------*/
+regs *
+pic14_findFreeReg(void)
+{
+ int i;
+
+ for (i = 0; i < pic14_nRegs; i++)
+ if (regspic14[i].isFree)
+ return ®spic14[i];
+
+ return NULL;
+}
/*-----------------------------------------------------------------*/
/* freeReg - frees a register */
/*-----------------------------------------------------------------*/
/* 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;
+ }
}
}
/* 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;
}
/* we reached the end */
- sprintf (s, "%s\n", OP_SYMBOL (IC_LEFT (ic))->rname);
+ sprintf (s, "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
break;
}
/*-----------------------------------------------------------------*/
/* freeAllRegs - mark all registers as free */
/*-----------------------------------------------------------------*/
-static void
-freeAllRegs ()
+void
+pic14_freeAllRegs ()
{
int i;
regspic14[i].isFree = 1;
}
+/*-----------------------------------------------------------------*/
+/*-----------------------------------------------------------------*/
+void
+pic14_deallocateAllRegs ()
+{
+ int i;
+
+ debugLog ("%s\n", __FUNCTION__);
+ for (i = 0; i < pic14_nRegs; i++) {
+ regspic14[i].isFree = 1;
+ regspic14[i].wasUsed = 0;
+ }
+}
+
+
/*-----------------------------------------------------------------*/
/* deallocStackSpil - this will set the stack pointer back */
/*-----------------------------------------------------------------*/
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));
/* 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);
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 */
redoStackOffsets ();
if (options.dump_rassgn)
- dumpEbbsToFileExt (".dumprassgn", ebbs, count);
+ dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count);
/* now get back the chain */
ic = iCodeLabelOptimize (iCodeFromeBBlock (ebbs, count));
setToNull ((void **) &_G.stackSpil);
setToNull ((void **) &_G.spiltSet);
/* mark all registers as free */
- freeAllRegs ();
+ pic14_freeAllRegs ();
debugLog ("leaving\n<><><><><><><><><><><><><><><><><>\n");
debugLogClose ();