X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fpic%2Fralloc.c;h=d5ab8566417d142f99a87858425c822a38a73eb0;hb=ef6c54dcfb7e493adac6af8e9904df3c1a8b949b;hp=47f44544a40ba9a9e07ec2192384fb6af06f33c8;hpb=2ac436263eb41eda4ad7c56f84e2743c121e45b6;p=fw%2Fsdcc diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index 47f44544..d5ab8566 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -58,6 +58,9 @@ _G; int pic14_ptrRegReq; /* one byte pointer register required */ /* pic14 registers */ +/* A nasty, awful, disgusting hack for register declarations */ +#ifdef p16c84 + regs regspic14[] = { @@ -83,8 +86,65 @@ regs regspic14[] = {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_SFR, PO_GPR_REGISTER, IDX_KZ, "KZ", "KZ", IDX_KZ, 1, 0}, /* Known zero */ + + + {REG_STK, PO_FSR, IDX_FSR, "FSR", "FSR", IDX_FSR, 1, 0}, + {REG_STK, PO_INDF, IDX_INDF, "INDF", "INDF", IDX_INDF, 1, 0}, + + }; +#endif + int pic14_nRegs = sizeof (regspic14) / sizeof (regs); static void spillThis (symbol *); static int debug = 1; @@ -316,20 +376,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: @@ -477,30 +523,56 @@ 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); } /*-----------------------------------------------------------------*/ +/* pic14_regWithIdx - returns pointer to register wit index number */ /*-----------------------------------------------------------------*/ regs * -pic14_findFreeReg(void) +pic14_allocWithIdx (int idx) { int i; + debugLog ("%s - allocating with index = 0x%x\n", __FUNCTION__,idx); + for (i = 0; i < pic14_nRegs; i++) - if (regspic14[i].isFree) + if (regspic14[i].rIdx == idx){ + debugLog ("%s - alloc fount index = 0x%x\n", __FUNCTION__,idx); + regspic14[i].wasUsed = 1; + regspic14[i].isFree = 0; return ®spic14[i]; + } + //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; } /*-----------------------------------------------------------------*/ @@ -547,34 +619,6 @@ nfreeRegsType (int type) return nFreeRegs (type); } - -/*-----------------------------------------------------------------*/ -/* allDefsOutOfRange - all definitions are out of a range */ -/*-----------------------------------------------------------------*/ -static bool -allDefsOutOfRange (bitVect * defs, int fseq, int toseq) -{ - int i; - - debugLog ("%s\n", __FUNCTION__); - if (!defs) - return TRUE; - - for (i = 0; i < defs->size; i++) - { - iCode *ic; - - if (bitVectBitValue (defs, i) && - (ic = hTabItemWithKey (iCodehTab, i)) && - (ic->seq >= fseq && ic->seq <= toseq)) - - return FALSE; - - } - - return TRUE; -} - /*-----------------------------------------------------------------*/ /* computeSpillable - given a point find the spillable live ranges */ /*-----------------------------------------------------------------*/ @@ -657,18 +701,6 @@ rematable (symbol * sym, eBBlock * ebp, iCode * ic) return sym->remat; } -/*-----------------------------------------------------------------*/ -/* notUsedInBlock - not used in this block */ -/*-----------------------------------------------------------------*/ -static int -notUsedInBlock (symbol * sym, eBBlock * ebp, iCode * ic) -{ - debugLog ("%s\n", __FUNCTION__); - return (!bitVectBitsInCommon (sym->defs, ebp->usesDefs) && - allDefsOutOfRange (sym->defs, ebp->fSeq, ebp->lSeq)); -/* return (!bitVectBitsInCommon(sym->defs,ebp->usesDefs)); */ -} - /*-----------------------------------------------------------------*/ /* notUsedInRemaining - not used or defined in remain of the block */ /*-----------------------------------------------------------------*/ @@ -900,6 +932,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 @@ -1554,19 +1587,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; + } + } } } @@ -1585,6 +1623,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++) { @@ -1832,101 +1872,97 @@ regTypeNum () debugLog ("%s\n", __FUNCTION__); /* for each live range do */ for (sym = hTabFirstItem (liveRanges, &k); sym; - sym = hTabNextItem (liveRanges, &k)) - { + 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; + debugLog (" %d - %s\n", __LINE__, sym->rname); + /* if used zero times then no registers needed */ + if ((sym->liveTo - sym->liveFrom) == 0) + continue; - /* if the live range is a temporary */ - if (sym->isitmp) - { - debugLog (" %d - \n", __LINE__); + /* if the live range is a temporary */ + if (sym->isitmp) { - /* if the type is marked as a conditional */ - if (sym->regType == REG_CND) - continue; + debugLog (" %d - itemp register\n", __LINE__); - /* 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__); - - continue; - } - - /* 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; + } } @@ -1952,8 +1988,10 @@ pic14_deallocateAllRegs () debugLog ("%s\n", __FUNCTION__); for (i = 0; i < pic14_nRegs; i++) { - regspic14[i].isFree = 1; - regspic14[i].wasUsed = 0; + if(regspic14[i].pc_type == PO_GPR_TEMP) { + regspic14[i].isFree = 1; + regspic14[i].wasUsed = 0; + } } } @@ -2058,6 +2096,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; } @@ -2094,7 +2133,7 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) if (IS_TRUE_SYMOP (IC_RESULT (dic)) && IS_OP_VOLATILE (IC_RESULT (dic))) { - debugLog (" %d - \n", __LINE__); + debugLog (" %d - dic is VOLATILE \n", __LINE__); dic = NULL; break; } @@ -2102,7 +2141,9 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) if (IS_SYMOP (IC_RESULT (dic)) && IC_RESULT (dic)->key == IC_RIGHT (ic)->key) { - debugLog (" %d - dic key == ic key -- pointer set=%c\n", __LINE__, ((POINTER_SET (dic)) ? 'Y' : 'N')); + /* A previous result was assigned to the same register - we'll our definition */ + debugLog (" %d - dic result key == ic right key -- pointer set=%c\n", + __LINE__, ((POINTER_SET (dic)) ? 'Y' : 'N')); if (POINTER_SET (dic)) dic = NULL; @@ -2113,7 +2154,7 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) (IC_RIGHT (dic)->key == IC_RESULT (ic)->key || IC_RIGHT (dic)->key == IC_RIGHT (ic)->key)) { - debugLog (" %d - \n", __LINE__); + debugLog (" %d - dic right key == ic rightor result key\n", __LINE__); dic = NULL; break; } @@ -2122,7 +2163,7 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) (IC_LEFT (dic)->key == IC_RESULT (ic)->key || IC_LEFT (dic)->key == IC_RIGHT (ic)->key)) { - debugLog (" %d - \n", __LINE__); + debugLog (" %d - dic left key == ic rightor result key\n", __LINE__); dic = NULL; break; } @@ -2130,7 +2171,8 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) if (POINTER_SET (dic) && IC_RESULT (dic)->key == IC_RESULT (ic)->key) { - debugLog (" %d - \n", __LINE__); + debugLog (" %d - dic result key == ic result key -- pointer set=Y\n", + __LINE__); dic = NULL; break; } @@ -2159,9 +2201,11 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) } pack: debugLog (" packing. removing %s\n", OP_SYMBOL (IC_RIGHT (ic))->rname); + debugLog (" replacing with %s\n", OP_SYMBOL (IC_RESULT (dic))->rname); /* 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) @@ -2179,6 +2223,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; @@ -2296,6 +2341,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++; } @@ -2333,6 +2379,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++; } @@ -2394,7 +2441,8 @@ packRegsForOneuse (iCode * ic, operand * op, eBBlock * ebp) a function call */ if (dic->op == CALL || dic->op == PCALL) { - if (ic->op != SEND && ic->op != RETURN) + if (ic->op != SEND && ic->op != RETURN && + !POINTER_SET(ic) && !POINTER_GET(ic)) { OP_SYMBOL (op)->ruonly = 1; return dic; @@ -2511,6 +2559,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) @@ -2644,7 +2698,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)); @@ -2704,6 +2757,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); } @@ -2762,6 +2816,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; @@ -2776,6 +2832,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; @@ -2792,7 +2849,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; @@ -2804,12 +2861,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)) @@ -2908,8 +2967,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; @@ -2923,13 +2984,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); @@ -3027,7 +3090,7 @@ pic14_assignRegisters (eBBlock ** ebbs, int count) int i; debugLog ("<><><><><><><><><><><><><><><><><>\nstarting\t%s:%s", __FILE__, __FUNCTION__); - debugLog ("ebbs before optimizing:\n"); + debugLog ("\nebbs before optimizing:\n"); dumpEbbsToDebug (ebbs, count); setToNull ((void *) &_G.funcrUsed); @@ -3040,7 +3103,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 */ @@ -3072,7 +3135,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));