vsprintf (buffer, fmt, ap);
fprintf (debugF, "%s", buffer);
+ //fprintf (stderr, "%s", buffer);
/*
while (isspace((unsigned char)*bufferP)) bufferP++;
/*-----------------------------------------------------------------*/
/* newReg - allocate and init memory for a new register */
/*-----------------------------------------------------------------*/
-regs* newReg(short type, short pc_type, int rIdx, char *name, int size, int alias, operand *refop)
+regs* newReg(int type, short pc_type, int rIdx, char *name, unsigned size, int alias, operand *refop)
{
regs *dReg;
dReg->regop = refop;
if(!(type == REG_SFR && alias == 0x80))
- hTabAddItem(&dynDirectRegNames, regname2key(name), dReg);
+ hTabAddItem(&dynDirectRegNames, regname2key(dReg->name), dReg);
return dReg;
}
// (_inRegAllocator)?"ralloc":"", currFunc, reg->name, reg->rIdx);
#if 1
- if(_inRegAllocator && (dynrIdx > MAX_P16_NREGS)) {
-// debugf("allocating more registers than available\n", 0);
-// return (NULL);
- }
+ if(_inRegAllocator && (dynrIdx > MAX_P16_NREGS)) {
+ // debugf("allocating more registers than available\n", 0);
+ // return (NULL);
+ }
+
+ addSet(&pic16_dynAllocRegs, reg);
+ hTabAddItem(&dynAllocRegNames, regname2key(reg->name), reg);
+// fprintf(stderr, "%s:%d added reg to pic16_dynAllocRegs = %p\n", __FUNCTION__, __LINE__, pic16_dynAllocRegs);
#endif
}
-
- addSet(&pic16_dynAllocRegs, reg);
- hTabAddItem(&dynAllocRegNames, regname2key(reg->name), reg);
-
-// fprintf(stderr, "%s:%d added reg to pic16_dynAllocRegs = %p\n", __FUNCTION__, __LINE__, pic16_dynAllocRegs);
debugLog ("%s of type %s for register rIdx: %d (0x%x)\n", __FUNCTION__, debugLogRegType (type), dynrIdx-1, dynrIdx-1);
pic16_allocWithIdx (int idx)
{
- regs *dReg;
+ regs *dReg=NULL;
debugLog ("%s - allocating with index = 0x%x\n", __FUNCTION__,idx);
// fprintf(stderr, "%s - allocating with index = 0x%x\n", __FUNCTION__,idx);
debugLog ("Dynamic Register not found\n");
-// return (NULL);
- //fprintf(stderr,"%s %d - requested register: 0x%x\n",__FUNCTION__,__LINE__,idx);
- werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
- "allocWithIdx not found");
- exit (1);
+#if 1
+ dReg = newReg(REG_GPR, PO_GPR_TEMP, idx, NULL, 1, 0, NULL);
+ addSet(&pic16_dynAllocRegs, dReg);
+ hTabAddItem(&dynAllocRegNames, regname2key(dReg->name), dReg);
+#endif
+ if(!dReg) {
+// return (NULL);
+ //fprintf(stderr,"%s %d - requested register: 0x%x\n",__FUNCTION__,__LINE__,idx);
+ werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+ "allocWithIdx not found");
+ exit (1);
+ }
}
dReg->wasUsed = 1;
* if it fits for pic16, but I leave it here just in case */
/* if assignment then check that right is not a bit */
- if (ASSIGNMENT (dic) && !POINTER_SET (dic)) {
- sym_link *etype = operandType (IC_RIGHT (dic));
+ 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 (dic));
+ etype = operandType (IC_RESULT (ic));
if (!IS_BITFIELD (etype)) {
debugLog(" %d bitfields\n");
return 0;
regTypeNum ();
/* start counting function temporary registers from zero */
- dynrIdx = 0;
+ /* XXX: Resetting dynrIdx breaks register allocation,
+ * see #1489055, #1483693 (?), and #1445850! */
+ //dynrIdx = 0;
/* and serially allocate registers */
serialRegAssign (ebbs, count);