if(name)
dReg->name = Safe_strdup(name);
else {
- if(xinst && pc_type == PO_GPR_TEMP) {
+ if(pic16_options.xinst && pc_type == PO_GPR_TEMP) {
sprintf(buffer,"0x%02x", dReg->rIdx);
} else {
sprintf(buffer,"r0x%02x", dReg->rIdx);
return NULL;
}
-/*-----------------------------------------------------------------*/
-/* pic16_initStack - allocate registers for a pseudo stack */
-/*-----------------------------------------------------------------*/
-void pic16_initStack(int base_address, int size)
-{
-
- int i;
-
- pic16_Gstack_base_addr = base_address;
- //fprintf(stderr,"initStack");
-
- for(i = 0; i<size; i++)
- addSet(&pic16_dynStackRegs,newReg(REG_STK, PO_GPR_TEMP,base_address++,NULL,1,0, NULL));
-}
-
/*-----------------------------------------------------------------*
*-----------------------------------------------------------------*/
regs *
pic16_dump_isection(of, rel_idataSymSet, 0);
pic16_dump_isection(of, fix_idataSymSet, 1);
- if(!xinst) {
+ if(!pic16_options.xinst) {
/* dump internal registers */
pic16_dump_int_registers(of, pic16_int_regs);
}
noSpilLoc (symbol * sym, eBBlock * ebp, iCode * ic)
{
debugLog ("%s\n", __FUNCTION__);
- return (sym->usl.spillLoc ? 0 : 1);
+ return (SYM_SPIL_LOC (sym) ? 0 : 1);
}
/*-----------------------------------------------------------------*/
hasSpilLoc (symbol * sym, eBBlock * ebp, iCode * ic)
{
debugLog ("%s\n", __FUNCTION__);
- return (sym->usl.spillLoc ? 1 : 0);
+ return (SYM_SPIL_LOC (sym) ? 1 : 0);
}
/*-----------------------------------------------------------------*/
directSpilLoc (symbol * sym, eBBlock * ebp, iCode * ic)
{
debugLog ("%s\n", __FUNCTION__);
- if (sym->usl.spillLoc &&
- (IN_DIRSPACE (SPEC_OCLS (sym->usl.spillLoc->etype))))
+ if (SYM_SPIL_LOC (sym) &&
+ (IN_DIRSPACE (SPEC_OCLS (SYM_SPIL_LOC (sym)->etype))))
return 1;
else
return 0;
hasSpilLocnoUptr (symbol * sym, eBBlock * ebp, iCode * ic)
{
debugLog ("%s\n", __FUNCTION__);
- return ((sym->usl.spillLoc && !sym->uptr) ? 1 : 0);
+ return ((SYM_SPIL_LOC (sym) && !sym->uptr) ? 1 : 0);
}
/*-----------------------------------------------------------------*/
if (applyToSet (_G.stackSpil, isFree, &sloc, sym))
{
/* found a free one : just update & return */
- sym->usl.spillLoc = sloc;
+ SYM_SPIL_LOC (sym) = sloc;
sym->stackSpil = 1;
sloc->isFree = 0;
addSetHead (&sloc->usl.itmpStack, sym);
/* add it to the _G.stackSpil set */
addSetHead (&_G.stackSpil, sloc);
- sym->usl.spillLoc = sloc;
+ SYM_SPIL_LOC (sym) = sloc;
sym->stackSpil = 1;
/* add it to the set of itempStack set
/* if (sym->_G.stackSpil) */
/* return TRUE; */
- if (!sym->usl.spillLoc)
+ if (!SYM_SPIL_LOC (sym))
return FALSE;
- etype = getSpec (sym->usl.spillLoc->type);
+ etype = getSpec (SYM_SPIL_LOC (sym)->type);
if (IN_STACK (etype))
return TRUE;
/* if this is rematerializable or has a spillLocation
we are okay, else we need to create a spillLocation
for it */
- if (!(sym->remat || sym->usl.spillLoc))
+ if (!(sym->remat || SYM_SPIL_LOC (sym)))
createStackSpil (sym);
spillLRWithPtrReg (sym);
}
- if (sym->usl.spillLoc && !sym->remat)
- sym->usl.spillLoc->allocreq = 1;
+ if (SYM_SPIL_LOC (sym) && !sym->remat)
+ SYM_SPIL_LOC (sym)->allocreq = 1;
return;
}
if ((selectS = liveRangesWith (lrcs, directSpilLoc, ebp, ic)))
{
sym = leastUsedLR (selectS);
- strcpy (sym->rname, (sym->usl.spillLoc->rname[0] ?
- sym->usl.spillLoc->rname :
- sym->usl.spillLoc->name));
+ strcpy (sym->rname, (SYM_SPIL_LOC (sym)->rname[0] ?
+ SYM_SPIL_LOC (sym)->rname :
+ SYM_SPIL_LOC (sym)->name));
sym->spildir = 1;
/* mark it as allocation required */
- sym->usl.spillLoc->allocreq = 1;
+ SYM_SPIL_LOC (sym)->allocreq = 1;
return sym;
}
sym = leastUsedLR (selectS);
/* mark this as allocation required */
- sym->usl.spillLoc->allocreq = 1;
+ SYM_SPIL_LOC (sym)->allocreq = 1;
return sym;
}
{
sym = leastUsedLR (selectS);
- sym->usl.spillLoc->allocreq = 1;
+ SYM_SPIL_LOC (sym)->allocreq = 1;
return sym;
}
/* return a created spil location */
sym = createStackSpil (leastUsedLR (selectS));
- sym->usl.spillLoc->allocreq = 1;
+ SYM_SPIL_LOC (sym)->allocreq = 1;
return sym;
}
{
if (sym->stackSpil)
{
- sym->usl.spillLoc->isFree = 1;
+ SYM_SPIL_LOC (sym)->isFree = 1;
sym->stackSpil = 0;
}
continue;
)
{
-
-// for (i = 0; i < max (sym->nRegs, result->nRegs); i++)
- /* the above does not free the unsued registers in sym,
- * leaving them marked as used, and increasing register usage
- * until the end of the function - VR 23/11/05 */
-
for (i = 0; i < result->nRegs; i++)
if (i < sym->nRegs)
result->regs[i] = sym->regs[i];
result->regs[i] = getRegGpr (ic, ebp, result);
_G.regAssigned = bitVectSetBit (_G.regAssigned, result->key);
+
}
/* free the remaining */
int ptrRegSet = 0;
/* Make sure any spill location is definately allocated */
- if (sym->isspilt && !sym->remat && sym->usl.spillLoc &&
- !sym->usl.spillLoc->allocreq)
+ if (sym->isspilt && !sym->remat && SYM_SPIL_LOC (sym) &&
+ !SYM_SPIL_LOC (sym)->allocreq)
{
- sym->usl.spillLoc->allocreq++;
+ SYM_SPIL_LOC (sym)->allocreq++;
}
/* if it does not need or is spilt
have been allocated after sym->liveFrom but freed
before ic->seq. This is complicated, so spill this
symbol instead and let fillGaps handle the allocation. */
-#if 0
if (sym->liveFrom < ic->seq)
{
spillThis (sym);
continue;
}
-#endif
+
/* if it has a spillocation & is used less than
all other live ranges then spill this */
if (willCS) {
- if (sym->usl.spillLoc) {
+ if (SYM_SPIL_LOC (sym)) {
symbol *leastUsed = leastUsedLR (liveRangesWith (spillable,
allLRs, ebbs[i], ic));
if (leastUsed && leastUsed->used > sym->used) {
static symbol *
rematStr (symbol * sym)
{
- char *s = buffer;
iCode *ic = sym->rematiCode;
symbol *psym = NULL;
+ int offset = 0;
debugLog ("%s\n", __FUNCTION__);
- //printf ("%s\n", s);
+ while (ic->op == '+' || ic->op == '-') {
+ /* if plus or minus print the right hand side */
- /* if plus or minus print the right hand side */
+ offset += (int) operandLitValue (IC_RIGHT (ic));
+ ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
+ } // while
- if (ic->op == '+' || ic->op == '-') {
-
- iCode *ric = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
-
- sprintf (s, "(%s %c 0x%04x)",
- OP_SYMBOL (IC_LEFT (ric))->rname,
- ic->op,
- (int) operandLitValue (IC_RIGHT (ic)));
-
-
- //fprintf(stderr, "ralloc.c:%d OOPS %s\n",__LINE__,s);
-
- psym = newSymbol (OP_SYMBOL (IC_LEFT (ric))->rname, 1);
- psym->offset = (int) operandLitValue (IC_RIGHT (ic));
-
- return psym;
- }
-
- sprintf (s, "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
psym = newSymbol (OP_SYMBOL (IC_LEFT (ic))->rname, 1);
-
- //printf ("ralloc.c:%d %s\n", __LINE__,buffer);
+ psym->offset = offset;
return psym;
}
psym->psbase = ptrBaseRematSym (OP_SYMBOL (IC_LEFT (ic)));
strcpy (psym->rname, psym->name);
sym->isspilt = 1;
- sym->usl.spillLoc = psym;
+ SYM_SPIL_LOC (sym) = psym;
continue;
}
- /* we now we know that it has one & only one def & use
- and the that the definition is an assignment */
- IC_LEFT (ic) = IC_RIGHT (dic);
+ /*
+ * The following code causes segfaults, e.g.,
+ * #2496919 Internal error with pic16 sdcc
+ * and is thus disabled for now.
+ */
+ if (0)
+ {
+ /* we now we know that it has one & only one def & use
+ and the that the definition is an assignment */
+ IC_LEFT (ic) = IC_RIGHT (dic);
- iLine = printILine(dic);
- debugf("remiCodeFromeBBlock: %s\n", iLine);
- dbuf_free(iLine);
+ iLine = printILine(dic);
+ debugf("remiCodeFromeBBlock: %s\n", iLine);
+ dbuf_free(iLine);
- remiCodeFromeBBlock (ebp, dic);
- bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key);
- hTabDeleteItem (&iCodehTab, dic->key, dic, DELETE_ITEM, NULL);
+ remiCodeFromeBBlock (ebp, dic);
+ bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key);
+ hTabDeleteItem (&iCodehTab, dic->key, dic, DELETE_ITEM, NULL);
+ } // if
}
static void printSymType(char * str, sym_link *sl)
OP_SYMBOL (IC_RESULT (ic))->remat = 1;
OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
- OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
+ SPIL_LOC (IC_RESULT (ic)) = NULL;
}
operandLitValue (IC_RIGHT (ic));
OP_SYMBOL (IC_RESULT (ic))->remat = 1;
OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic;
- OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL;
+ SPIL_LOC (IC_RESULT (ic)) = NULL;
}
#endif
/* mark the pointer usages */
- if (POINTER_SET (ic))
+ if (POINTER_SET (ic) && IS_SYMOP (IC_RESULT (ic)))
{
OP_SYMBOL (IC_RESULT (ic))->uptr = 1;
debugLog (" marking as a pointer (set) =>");