/*-----------------------------------------------------------------*/
extern void genpic14Code (iCode *);
+extern void assignConfigWordValue(int address, int value);
/* Global data */
static struct
int pic14_ptrRegReq; /* one byte pointer register required */
-static set *dynAllocRegs=NULL;
-static set *dynStackRegs=NULL;
-static set *dynProcessorRegs=NULL;
-static set *dynDirectRegs=NULL;
-static set *dynDirectBitRegs=NULL;
-static set *dynInternalRegs=NULL;
+set *dynAllocRegs=NULL;
+set *dynStackRegs=NULL;
+set *dynProcessorRegs=NULL;
+set *dynDirectRegs=NULL;
+set *dynDirectBitRegs=NULL;
+set *dynInternalRegs=NULL;
static hTab *dynDirectRegNames= NULL;
dReg->size = size;
dReg->alias = alias;
dReg->reg_alias = NULL;
+ dReg->reglives.usedpFlows = newSet();
+ dReg->reglives.assignedpFlows = newSet();
return dReg;
}
/*-----------------------------------------------------------------*/
/* RegWithIdx - returns pointer to register with index number */
/*-----------------------------------------------------------------*/
-static regs *
+regs *
typeRegWithIdx (int idx, int type, int fixed)
{
debugLog ("%s - requesting index = 0x%x\n", __FUNCTION__,idx);
+ switch (type) {
+
+ case REG_GPR:
+ if( (dReg = regWithIdx ( dynAllocRegs, idx, fixed)) != NULL) {
+
+ debugLog ("Found a Dynamic Register!\n");
+ return dReg;
+ }
+ if( (dReg = regWithIdx ( dynDirectRegs, idx, fixed)) != NULL ) {
+ debugLog ("Found a Direct Register!\n");
+ return dReg;
+ }
+
+ break;
+ case REG_STK:
+ if( (dReg = regWithIdx ( dynStackRegs, idx, fixed)) != NULL ) {
+ debugLog ("Found a Stack Register!\n");
+ return dReg;
+ }
+ break;
+ case REG_SFR:
+ if( (dReg = regWithIdx ( dynProcessorRegs, idx, fixed)) != NULL ) {
+ debugLog ("Found a Processor Register!\n");
+ return dReg;
+ }
+
+ case REG_CND:
+ case REG_PTR:
+ default:
+ break;
+ }
+
+#if 0
+
if( (dReg = regWithIdx ( dynAllocRegs, idx, fixed)) != NULL) {
debugLog ("Found a Dynamic Register!\n");
debugLog ("Found a Processor Register!\n");
return dReg;
}
-/*
- if( (dReg = regWithIdx ( dynDirectBitRegs, idx, fixed)) != NULL ) {
+#endif
+
+ /*
+ if( (dReg = regWithIdx ( dynDirectBitRegs, idx, fixed)) != NULL ) {
debugLog ("Found a bit Register!\n");
return dReg;
- }
-*/
-/*
- fprintf(stderr,"%s %d - requested register: 0x%x\n",__FUNCTION__,__LINE__,idx);
- werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
- "regWithIdx not found");
- exit (1);
-*/
+ }
+ */
+
return NULL;
}
regs *
pic14_regWithIdx (int idx)
{
+ regs *dReg;
+
+ if( (dReg = typeRegWithIdx(idx,REG_GPR,0)) != NULL)
+ return dReg;
+
+ if( (dReg = typeRegWithIdx(idx,REG_SFR,0)) != NULL)
+ return dReg;
+
+ if( (dReg = typeRegWithIdx(idx,REG_STK,0)) != NULL)
+ return dReg;
- return typeRegWithIdx(idx,-1,0);
+ return NULL;
}
/*-----------------------------------------------------------------*/
for (reg = setFirstItem(fregs) ; reg ;
reg = setNextItem(fregs)) {
- if(!reg->isEmitted)
+ if(!reg->isEmitted && reg->wasUsed)
fprintf (of, "%s\tEQU\t0x%03x\n",
reg->name,
reg->address);
assignFixedRegisters(dynStackRegs);
assignFixedRegisters(dynDirectRegs);
- assignRelocatableRegisters(dynInternalRegs,1);
+ assignRelocatableRegisters(dynInternalRegs,0);
assignRelocatableRegisters(dynAllocRegs,0);
assignRelocatableRegisters(dynStackRegs,0);
assignRelocatableRegisters(dynDirectRegs,0);
aliasEQUs(of,dynStackRegs);
}
+
#if 0
/*-----------------------------------------------------------------*/
/* allDefsOutOfRange - all definitions are out of a range */
DEFSETFUNC (deallocReg)
{
+ fprintf(stderr,"deallocting register %s\n",((regs *)item)->name);
((regs *)item)->isFree = 1;
((regs *)item)->wasUsed = 0;
setToNull ((void **) &_G.stackSpil);
setToNull ((void **) &_G.spiltSet);
/* mark all registers as free */
- pic14_freeAllRegs ();
+ //pic14_freeAllRegs ();
debugLog ("leaving\n<><><><><><><><><><><><><><><><><>\n");
debugLogClose ();