X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fpic%2Fralloc.c;h=d8b5d8df9a6a0f979f3301a8f847e06f1f39f690;hb=2f6ebbfbb6ffa1dbfbf6bc1a9e4d3038443ce171;hp=7d58ccbdf2300e38ddabe24fcdad0c53d71f03ad;hpb=b21f90fcfcda291d97c4fda8295df83dcde6f730;p=fw%2Fsdcc diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index 7d58ccbd..d8b5d8df 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -52,7 +52,7 @@ /*-----------------------------------------------------------------*/ extern void genpic14Code (iCode *); -extern void assignConfigWordValue(int address, int value); +extern void pic14_assignConfigWordValue(int address, int value); /* Global data */ static struct @@ -134,6 +134,7 @@ static void vsprintf (buffer, fmt, ap); fprintf (debugF, "%s", buffer); + //if (options.verbose) fprintf (stderr, "%s: %s", __FUNCTION__, buffer); /* while (isspace((unsigned char)*bufferP)) bufferP++; @@ -339,7 +340,7 @@ static regs *regWithIdx (set *dRegs, int idx, int fixed); /*-----------------------------------------------------------------*/ /* newReg - allocate and init memory for a new register */ /*-----------------------------------------------------------------*/ -static regs* newReg(short type, short pc_type, int rIdx, char *name, int size, int alias) +static regs* newReg(short type, PIC_OPTYPE pc_type, int rIdx, char *name, int size, int alias) { regs *dReg; @@ -369,7 +370,7 @@ static regs* newReg(short type, short pc_type, int rIdx, char *name, int size, i dReg->name = Safe_strdup(buffer); } dReg->isFree = 0; - dReg->wasUsed = 1; + dReg->wasUsed = 0; if (type == REG_SFR) dReg->isFixed = 1; else @@ -386,8 +387,14 @@ static regs* newReg(short type, short pc_type, int rIdx, char *name, int size, i dReg->reglives.usedpFlows = newSet(); dReg->reglives.assignedpFlows = newSet(); - hTabAddItem(&dynDirectRegNames, regname2key(name), dReg); - + hTabAddItem(&dynDirectRegNames, regname2key(dReg->name), dReg); +#ifdef __GNUC__ + debugLog( "%s: Created register %s (%p).\n", + __FUNCTION__, dReg->name, __builtin_return_address(0) ); +#else + debugLog( "%s: Created register %s.\n", + __FUNCTION__, dReg->name); +#endif return dReg; } @@ -486,7 +493,7 @@ regFindFree (set *dRegs) return NULL; } /*-----------------------------------------------------------------*/ -/* initStack - allocate registers for a psuedo stack */ +/* initStack - allocate registers for a pseudo stack */ /*-----------------------------------------------------------------*/ void initStack(int base_address, int size) { @@ -526,7 +533,7 @@ allocProcessorRegister(int rIdx, char * name, short po_type, int alias) *-----------------------------------------------------------------*/ regs * -allocInternalRegister(int rIdx, char * name, short po_type, int alias) +allocInternalRegister(int rIdx, char * name, PIC_OPTYPE po_type, int alias) { regs * reg = newReg(REG_GPR, po_type, rIdx, name,1,alias); @@ -596,7 +603,7 @@ dirregWithName (char *name) int IS_CONFIG_ADDRESS(int address) { - return address == 0x2007; + return ((address == 0x2007) || (address == 0x2008)); } /*-----------------------------------------------------------------*/ @@ -2740,7 +2747,7 @@ regTypeNum () debugLog (" %d - \n", __LINE__); - /* create a psuedo symbol & force a spil */ + /* create a pseudo symbol & force a spil */ //X symbol *psym = newSymbol (rematStr (OP_SYMBOL (IC_LEFT (ic))), 1); psym = rematStr (OP_SYMBOL (IC_LEFT (ic))); psym->type = sym->type; @@ -2954,7 +2961,7 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) if(IS_VALOP(IC_RIGHT(ic))) { debugLog (" setting config word to %x\n", (int) floatFromVal (IC_RIGHT(ic)->operand.valOperand)); - assignConfigWordValue( SPEC_ADDR ( OP_SYM_ETYPE(IC_RESULT(ic))), + pic14_assignConfigWordValue( SPEC_ADDR ( OP_SYM_ETYPE(IC_RESULT(ic))), (int) floatFromVal (IC_RIGHT(ic)->operand.valOperand)); } @@ -3077,6 +3084,19 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) if (!dic) return 0; /* did not find */ + /* if assignment then check that right is not a bit */ + if (ASSIGNMENT (ic) && !POINTER_SET (ic)) + { + sym_link *etype = operandType (IC_RESULT (dic)); + if (IS_BITFIELD (etype)) + { + /* if result is a bit too then it's ok */ + etype = operandType (IC_RESULT (ic)); + if (!IS_BITFIELD (etype)) + return 0; + } + } + /* if the result is on stack or iaccess then it must be the same at least one of the operands */ if (OP_SYMBOL (IC_RESULT (ic))->onStack || @@ -3747,7 +3767,7 @@ packRegisters (eBBlock * ebp) /* TrueSym := iTempNN:1 */ for (ic = ebp->sch; ic; ic = ic->next) { - + /* find assignment of the form TrueSym := iTempNN:1 */ if (ic->op == '=' && !POINTER_SET (ic)) change += packRegsForAssign (ic, ebp); @@ -4127,8 +4147,8 @@ pic14_assignRegisters (ebbIndex * ebbi) iCode *ic; int i; - debugLog ("<><><><><><><><><><><><><><><><><>\nstarting\t%s:%s", __FILE__, __FUNCTION__); - debugLog ("\nebbs before optimizing:\n"); + debugLog ("<><><><><><><><><><><><><><><><><>\nstarting\t%s:%s\n", __FILE__, __FUNCTION__); + debugLog ("ebbs before optimizing:\n"); dumpEbbsToDebug (ebbs, count); setToNull ((void *) &_G.funcrUsed);