* src/pic16/glue.c (pic16_emitConfigRegs, pic16_emitIDRegs): fixed
[fw/sdcc] / src / pic16 / ralloc.c
index f6c31e9a5ba7519c493f2e887c1496adefa61110..611142db48593b9f1a8f813824fae562902ce9b5 100644 (file)
@@ -374,7 +374,7 @@ static int regname2key(char const *name)
 /*-----------------------------------------------------------------*/
 /* 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;
@@ -1086,7 +1086,7 @@ regs *
 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);
@@ -1105,12 +1105,19 @@ pic16_allocWithIdx (int 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;