static hTab *dynDirectRegNames= NULL;
// static hTab *regHash = NULL; /* a hash table containing ALL registers */
-static int dynrIdx=0x20;
-static int rDirectIdx=0;
+static int dynrIdx = 0x1000;
+static int rDirectIdx = 0x5000;
int pic14_nRegs = 128; // = sizeof (regspic14) / sizeof (regs);
static regs* newReg(short type, PIC_OPTYPE pc_type, int rIdx, char *name, int size, int alias)
{
- regs *dReg;
+ regs *dReg, *reg_alias;
/* check whether a matching register already exists */
dReg = dirregWithName( name );
if (dReg) {
- //printf( "%s: already present: %s\n", __FUNCTION__, name );
- return (dReg);
- }
- dReg = regWithIdx( dynDirectRegs, rIdx, 0 );
- if (!dReg) dReg = regWithIdx( dynDirectRegs, rIdx, 1 );
- if (dReg)
- {
- //printf( "%s: already present %s (idx:%d/%x)", __FUNCTION__, name, rIdx, rIdx );
- return (dReg);
+ //printf( "%s: already present: %s\n", __FUNCTION__, name );
+ return (dReg);
}
+ // check whether a register at that location exists
+ reg_alias = regWithIdx( dynDirectRegs, rIdx, 0 );
+ if (!reg_alias) reg_alias = regWithIdx( dynDirectRegs, rIdx, 1 );
+
+ // create a new register
dReg = Safe_calloc(1,sizeof(regs));
dReg->type = type;
dReg->pc_type = pc_type;
dReg->address = 0;
dReg->size = size;
dReg->alias = alias;
- dReg->reg_alias = NULL;
+ dReg->reg_alias = reg_alias;
dReg->reglives.usedpFlows = newSet();
dReg->reglives.assignedpFlows = newSet();
-
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
+ debugLog( "%s: Created register %s.\n", __FUNCTION__, dReg->name);
+
return dReg;
}
dReg = setNextItem(dRegs)) {
if(idx == dReg->rIdx && (fixed == (int)dReg->isFixed)) {
+ while (dReg->reg_alias) dReg = dReg->reg_alias;
return dReg;
}
}
while(reg) {
if(STRCASECMP(reg->name, name) == 0) {
+ // handle registers with multiple names
+ while (reg->reg_alias) reg = reg->reg_alias;
return(reg);
}
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 ||