X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fpic%2Fralloc.c;h=d4c62894012ffdfeeed72cf4f33057dca88a0971;hb=9adc1e115a66d97399e92f57a9298cdfbe68564a;hp=3a0ab79c178aab7b25dd9715622ec3f627fbfbe5;hpb=1e268ec9106bf4b907eff98c705e11689c9dcb64;p=fw%2Fsdcc diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index 3a0ab79c..d4c62894 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -26,12 +26,9 @@ #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 */ @@ -61,33 +58,88 @@ _G; int pic14_ptrRegReq; /* one byte pointer register required */ /* pic14 registers */ +/* A nasty, awful, disgusting hack for register declarations */ +#ifdef p16c84 + 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}, + +}; +#else + +int Gstack_base_addr=0x38; /* The starting address of registers that + * are used to pass and return parameters */ +regs regspic14[] = +{ + {REG_GPR, PO_GPR_TEMP, 0x20, "r0x20", "r0x20", 0x20, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x21, "r0x21", "r0x21", 0x21, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x22, "r0x22", "r0x22", 0x22, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x23, "r0x23", "r0x23", 0x23, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x24, "r0x24", "r0x24", 0x24, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x25, "r0x25", "r0x25", 0x25, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x26, "r0x26", "r0x26", 0x26, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x27, "r0x27", "r0x27", 0x27, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x28, "r0x28", "r0x28", 0x28, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x29, "r0x29", "r0x29", 0x29, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x2A, "r0x2A", "r0x2A", 0x2A, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x2B, "r0x2B", "r0x2B", 0x2B, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x2C, "r0x2C", "r0x2C", 0x2C, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x2D, "r0x2D", "r0x2D", 0x2D, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x2E, "r0x2E", "r0x2E", 0x2E, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x2F, "r0x2F", "r0x2F", 0x2F, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x30, "r0x30", "r0x30", 0x30, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x31, "r0x31", "r0x31", 0x31, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x32, "r0x32", "r0x32", 0x32, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x33, "r0x33", "r0x33", 0x33, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x34, "r0x34", "r0x34", 0x34, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x35, "r0x35", "r0x35", 0x35, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x36, "r0x36", "r0x36", 0x36, 1, 0}, + {REG_GPR, PO_GPR_TEMP, 0x37, "r0x37", "r0x37", 0x37, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x38, "r0x38", "r0x38", 0x38, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x39, "r0x39", "r0x39", 0x39, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x3A, "r0x3A", "r0x3A", 0x3A, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x3B, "r0x3B", "r0x3B", 0x3B, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x3C, "r0x3C", "r0x3C", 0x3C, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x3D, "r0x3D", "r0x3D", 0x3D, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x3E, "r0x3E", "r0x3E", 0x3E, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x3F, "r0x3F", "r0x3F", 0x3F, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x40, "r0x40", "r0x40", 0x40, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x41, "r0x41", "r0x41", 0x41, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x42, "r0x42", "r0x42", 0x42, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x43, "r0x43", "r0x43", 0x43, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x44, "r0x44", "r0x44", 0x44, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x45, "r0x45", "r0x45", 0x45, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x46, "r0x46", "r0x46", 0x46, 1, 0}, + {REG_STK, PO_GPR_TEMP, 0x47, "r0x47", "r0x47", 0x47, 1, 0}, + + {REG_PTR, PO_FSR, 4, "FSR", "FSR", 4, 1, 0}, }; +#endif + int pic14_nRegs = sizeof (regspic14) / sizeof (regs); static void spillThis (symbol *); static int debug = 1; @@ -105,7 +157,7 @@ debugLog (char *fmt,...) //char *bufferP=buffer; va_list ap; - if (!debug) + if (!debug || !srcFileName) return; @@ -319,20 +371,6 @@ decodeOp (unsigned int op) return "RANGE"; case FAR: return "FAR"; - case _XDATA: - return "_XDATA"; - case _CODE: - return "_CODE"; - case _GENERIC: - return "_GENERIC"; - case _NEAR: - return "_NEAR"; - case _PDATA: - return "_PDATA"; - case _IDATA: - return "_IDATA"; - case _EEPROM: - return "_EEPROM"; case CASE: return "CASE"; case DEFAULT: @@ -480,19 +518,35 @@ pic14_regWithIdx (int idx) { int i; - debugLog ("%s\n", __FUNCTION__); + debugLog ("%s - requesting index = 0x%x\n", __FUNCTION__,idx); for (i = 0; i < pic14_nRegs; i++) if (regspic14[i].rIdx == idx) return ®spic14[i]; - return ®spic14[0]; - + //return ®spic14[0]; + fprintf(stderr,"%s %d - requested register: 0x%x\n",__FUNCTION__,__LINE__,idx); werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "regWithIdx not found"); exit (1); } +/*-----------------------------------------------------------------*/ +/*-----------------------------------------------------------------*/ +regs * +pic14_findFreeReg(short type) +{ + int i; + + for (i = 0; i < pic14_nRegs; i++) { + if (!type && regspic14[i].isFree) + return ®spic14[i]; + if (regspic14[i].isFree && + regspic14[i].type == type) + return ®spic14[i]; + } + return NULL; +} /*-----------------------------------------------------------------*/ /* freeReg - frees a register */ /*-----------------------------------------------------------------*/ @@ -890,6 +944,7 @@ createStackSpil (symbol * sym) sloc->etype = getSpec (sloc->type); SPEC_SCLS (sloc->etype) = S_DATA; SPEC_EXTR (sloc->etype) = 0; + SPEC_STAT (sloc->etype) = 0; /* we don't allow it to be allocated` onto the external stack since : so we @@ -1544,19 +1599,24 @@ 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)) { + /* if this is local to this block then we might find a block spil */ + if (!(sym->liveFrom >= ebbs[i]->fSeq && sym->liveTo <= ebbs[i]->lSeq)) { + spillThis (sym); + continue; + } + } } } @@ -1566,7 +1626,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; @@ -1575,6 +1635,8 @@ serialRegAssign (eBBlock ** ebbs, int count) _G.regAssigned = bitVectSetBit (_G.regAssigned, sym->key); debugLog (" %d - \n", __LINE__); + if(debugF) + bitVectDebugOn(_G.regAssigned, debugF); for (j = 0; j < sym->nRegs; j++) { @@ -1801,7 +1863,7 @@ rematStr (symbol * sym) } /* we reached the end */ - sprintf (s, "%s\n", OP_SYMBOL (IC_LEFT (ic))->rname); + sprintf (s, "%s", OP_SYMBOL (IC_LEFT (ic))->rname); break; } @@ -1822,109 +1884,105 @@ regTypeNum () debugLog ("%s\n", __FUNCTION__); /* for each live range do */ for (sym = hTabFirstItem (liveRanges, &k); sym; - sym = hTabNextItem (liveRanges, &k)) - { - - debugLog (" %d - %s\n", __LINE__, sym->rname); - - /* if used zero times then no registers needed */ - if ((sym->liveTo - sym->liveFrom) == 0) - continue; + sym = hTabNextItem (liveRanges, &k)) { + debugLog (" %d - %s\n", __LINE__, sym->rname); - /* if the live range is a temporary */ - if (sym->isitmp) - { + /* if used zero times then no registers needed */ + if ((sym->liveTo - sym->liveFrom) == 0) + continue; - debugLog (" %d - \n", __LINE__); - - /* if the type is marked as a conditional */ - if (sym->regType == REG_CND) - continue; - /* if used in return only then we don't - need registers */ - if (sym->ruonly || sym->accuse) - { - if (IS_AGGREGATE (sym->type) || sym->isptr) - sym->type = aggrToPtr (sym->type, FALSE); - debugLog (" %d - \n", __LINE__); + /* if the live range is a temporary */ + if (sym->isitmp) { - continue; - } + debugLog (" %d - itemp register\n", __LINE__); - /* if the symbol has only one definition & - that definition is a get_pointer and the - pointer we are getting is rematerializable and - in "data" space */ + /* if the type is marked as a conditional */ + if (sym->regType == REG_CND) + continue; - if (bitVectnBitsOn (sym->defs) == 1 && - (ic = hTabItemWithKey (iCodehTab, - bitVectFirstBit (sym->defs))) && - POINTER_GET (ic) && - !IS_BITVAR (sym->etype)) - { + /* if used in return only then we don't + need registers */ + if (sym->ruonly || sym->accuse) { + if (IS_AGGREGATE (sym->type) || sym->isptr) + sym->type = aggrToPtr (sym->type, FALSE); + debugLog (" %d - no reg needed - used as a return\n", __LINE__); - debugLog (" %d - \n", __LINE__); + continue; + } - /* if remat in data space */ - if (OP_SYMBOL (IC_LEFT (ic))->remat && - DCL_TYPE (aggrToPtr (sym->type, FALSE)) == POINTER) - { + /* if the symbol has only one definition & + that definition is a get_pointer and the + pointer we are getting is rematerializable and + in "data" space */ + + if (bitVectnBitsOn (sym->defs) == 1 && + (ic = hTabItemWithKey (iCodehTab, + bitVectFirstBit (sym->defs))) && + POINTER_GET (ic) && + !sym->noSpilLoc && + !IS_BITVAR (sym->etype)) { + + + debugLog (" %d - \n", __LINE__); + + /* if remat in data space */ + if (OP_SYMBOL (IC_LEFT (ic))->remat && + DCL_TYPE (aggrToPtr (sym->type, FALSE)) == POINTER) { + + /* create a psuedo symbol & force a spil */ + symbol *psym = newSymbol (rematStr (OP_SYMBOL (IC_LEFT (ic))), 1); + psym->type = sym->type; + psym->etype = sym->etype; + strcpy (psym->rname, psym->name); + sym->isspilt = 1; + sym->usl.spillLoc = psym; + continue; + } - /* create a psuedo symbol & force a spil */ - symbol *psym = newSymbol (rematStr (OP_SYMBOL (IC_LEFT (ic))), 1); - psym->type = sym->type; - psym->etype = sym->etype; - strcpy (psym->rname, psym->name); - sym->isspilt = 1; - sym->usl.spillLoc = psym; - continue; - } + /* if in data space or idata space then try to + allocate pointer register */ - /* if in data space or idata space then try to - allocate pointer register */ + } - } + /* if not then we require registers */ + sym->nRegs = ((IS_AGGREGATE (sym->type) || sym->isptr) ? + getSize (sym->type = aggrToPtr (sym->type, FALSE)) : + getSize (sym->type)); - /* if not then we require registers */ - sym->nRegs = ((IS_AGGREGATE (sym->type) || sym->isptr) ? - getSize (sym->type = aggrToPtr (sym->type, FALSE)) : - getSize (sym->type)); + if (sym->nRegs > 4) { + fprintf (stderr, "allocated more than 4 or 0 registers for type "); + printTypeChain (sym->type, stderr); + fprintf (stderr, "\n"); + } - if (sym->nRegs > 4) - { - fprintf (stderr, "allocated more than 4 or 0 registers for type "); - printTypeChain (sym->type, stderr); - fprintf (stderr, "\n"); - } + /* determine the type of register required */ + if (sym->nRegs == 1 && + IS_PTR (sym->type) && + sym->uptr) + sym->regType = REG_PTR; + else + sym->regType = REG_GPR; - debugLog (" %d - \n", __LINE__); - /* determine the type of register required */ - if (sym->nRegs == 1 && - IS_PTR (sym->type) && - sym->uptr) - sym->regType = REG_PTR; - else - sym->regType = REG_GPR; - debugLog (" reg type %s\n", debugLogRegType (sym->regType)); + debugLog (" reg name %s, reg type %s\n", sym->rname, debugLogRegType (sym->regType)); - } - else - /* for the first run we don't provide */ - /* registers for true symbols we will */ - /* see how things go */ - sym->nRegs = 0; } + else + /* for the first run we don't provide */ + /* registers for true symbols we will */ + /* see how things go */ + sym->nRegs = 0; + } } /*-----------------------------------------------------------------*/ /* freeAllRegs - mark all registers as free */ /*-----------------------------------------------------------------*/ -static void -freeAllRegs () +void +pic14_freeAllRegs () { int i; @@ -1933,6 +1991,21 @@ freeAllRegs () 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 */ /*-----------------------------------------------------------------*/ @@ -2033,6 +2106,7 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) OP_SYMBOL (IC_RIGHT (ic))->isind || OP_LIVETO (IC_RIGHT (ic)) > ic->seq) { + debugLog (" %d - not packing - right side fails \n", __LINE__); return 0; } @@ -2137,6 +2211,7 @@ pack: /* found the definition */ /* replace the result with the result of */ /* this assignment and remove this assignment */ + bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key); IC_RESULT (dic) = IC_RESULT (ic); if (IS_ITEMP (IC_RESULT (dic)) && OP_SYMBOL (IC_RESULT (dic))->liveFrom > dic->seq) @@ -2154,6 +2229,7 @@ pack: } remiCodeFromeBBlock (ebp, ic); + bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key); hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL); OP_DEFS (IC_RESULT (dic)) = bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key); return 1; @@ -2271,6 +2347,7 @@ packRegsForSupport (iCode * ic, eBBlock * ebp) IC_RIGHT (dic)->operand.symOperand; IC_LEFT (ic)->key = IC_RIGHT (dic)->operand.symOperand->key; remiCodeFromeBBlock (ebp, dic); + bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key); hTabDeleteItem (&iCodehTab, dic->key, dic, DELETE_ITEM, NULL); change++; } @@ -2308,6 +2385,7 @@ right: IC_RIGHT (ic)->key = IC_RIGHT (dic)->operand.symOperand->key; remiCodeFromeBBlock (ebp, dic); + bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key); hTabDeleteItem (&iCodehTab, dic->key, dic, DELETE_ITEM, NULL); change++; } @@ -2486,6 +2564,12 @@ packRegsForAccUse (iCode * ic) iCode *uic; debugLog ("%s\n", __FUNCTION__); + + /* if this is an aggregate, e.g. a one byte char array */ + if (IS_AGGREGATE(operandType(IC_RESULT(ic)))) { + return; + } + /* if + or - then it has to be one byte result */ if ((ic->op == '+' || ic->op == '-') && getSize (operandType (IC_RESULT (ic))) > 1) @@ -2619,7 +2703,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)); @@ -2679,6 +2762,7 @@ packForPush (iCode * ic, eBBlock * ebp) IC_LEFT (ic) = IC_RIGHT (dic); remiCodeFromeBBlock (ebp, dic); + bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key); hTabDeleteItem (&iCodehTab, dic->key, dic, DELETE_ITEM, NULL); } @@ -2737,6 +2821,8 @@ packRegisters (eBBlock * ebp) !OP_SYMBOL (IC_LEFT (ic))->onStack) { + debugLog (" %d - %s. result is rematerializable\n", __LINE__,__FUNCTION__); + OP_SYMBOL (IC_RESULT (ic))->remat = 1; OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic; OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL; @@ -2751,6 +2837,7 @@ packRegisters (eBBlock * ebp) OP_SYMBOL (IC_RIGHT (ic))->remat && bitVectnBitsOn (OP_SYMBOL (IC_RESULT (ic))->defs) <= 1) { + debugLog (" %d - %s. straight rematerializable\n", __LINE__,__FUNCTION__); OP_SYMBOL (IC_RESULT (ic))->remat = OP_SYMBOL (IC_RIGHT (ic))->remat; @@ -2767,7 +2854,7 @@ packRegisters (eBBlock * ebp) bitVectnBitsOn (OP_DEFS (IC_RESULT (ic))) == 1 && IS_OP_LITERAL (IC_RIGHT (ic)))) { - + debugLog (" %d - %s. rematerializable because op is +/-\n", __LINE__,__FUNCTION__); //int i = operandLitValue (IC_RIGHT (ic)); OP_SYMBOL (IC_RESULT (ic))->remat = 1; @@ -2779,12 +2866,14 @@ packRegisters (eBBlock * ebp) if (POINTER_SET (ic)) { OP_SYMBOL (IC_RESULT (ic))->uptr = 1; - debugLog (" marking as a pointer (set)\n"); + debugLog (" marking as a pointer (set) =>"); + debugAopGet (" result:", IC_RESULT (ic)); } if (POINTER_GET (ic)) { OP_SYMBOL (IC_LEFT (ic))->uptr = 1; - debugLog (" marking as a pointer (get)\n"); + debugLog (" marking as a pointer (get) =>"); + debugAopGet (" left:", IC_LEFT (ic)); } if (!SKIP_IC2 (ic)) @@ -2883,8 +2972,10 @@ packRegisters (eBBlock * ebp) { if (IS_ARITHMETIC_OP (dic)) { + bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key); IC_RESULT (dic) = IC_RESULT (ic); remiCodeFromeBBlock (ebp, ic); + bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key); hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL); OP_DEFS (IC_RESULT (dic)) = bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key); ic = ic->prev; @@ -2898,13 +2989,15 @@ 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); if (dic) { + bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key); IC_RESULT (dic) = IC_RESULT (ic); + bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key); remiCodeFromeBBlock (ebp, ic); hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL); OP_DEFS (IC_RESULT (dic)) = bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key); @@ -3015,7 +3108,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 */ @@ -3047,7 +3140,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)); @@ -3064,7 +3157,7 @@ pic14_assignRegisters (eBBlock ** ebbs, int count) setToNull ((void **) &_G.stackSpil); setToNull ((void **) &_G.spiltSet); /* mark all registers as free */ - freeAllRegs (); + pic14_freeAllRegs (); debugLog ("leaving\n<><><><><><><><><><><><><><><><><>\n"); debugLogClose ();