The function name in a pointer to function variable was getting declared
[fw/sdcc] / src / pic / ralloc.c
index a920ac09cc3e2759e19410c8732dcd1e4d86f99a..42ec8f8465c55a12a56807ee12f1f548e845128d 100644 (file)
@@ -35,6 +35,9 @@
 #define STRCASECMP strcasecmp
 #endif
 
+/* this should go in SDCCicode.h, but it doesn't. */
+#define IS_REF(op)       (IS_SYMOP(op) && op->operand.symOperand->isref == 1)
+
 /*-----------------------------------------------------------------*/
 /* At this point we start getting processor specific although      */
 /* some routines are non-processor specific & can be reused when   */
@@ -73,7 +76,7 @@ set *dynDirectBitRegs=NULL;
 set *dynInternalRegs=NULL;
 
 static hTab  *dynDirectRegNames= NULL;
-static hTab  *regHash = NULL;    /* a hash table containing ALL registers */
+// static hTab  *regHash = NULL;    /* a hash table containing ALL registers */
 
 static int dynrIdx=0x20;
 static int rDirectIdx=0;
@@ -102,14 +105,14 @@ debugLog (char *fmt,...)
   //char *bufferP=buffer;
   va_list ap;
 
-  if (!debug || !srcFileName)
+  if (!debug || !dstFileName)
     return;
 
 
   if (!debugF)
     {
       /* create the file name */
-      strcpy (buffer, srcFileName);
+      strcpy (buffer, dstFileName);
       strcat (buffer, ".d");
 
       if (!(debugF = fopen (buffer, (append ? "a+" : "w"))))
@@ -2436,14 +2439,22 @@ regTypeNum ()
 
       /* if used in return only then we don't 
         need registers */
-      if (sym->ruonly || sym->accuse) {
+      if (sym->accuse) {
        if (IS_AGGREGATE (sym->type) || sym->isptr)
          sym->type = aggrToPtr (sym->type, FALSE);
-       debugLog ("  %d - no reg needed - used as a return\n", __LINE__);
+       debugLog ("  %d - no reg needed - accumulator used\n", __LINE__);
 
        continue;
       }
 
+      if (sym->ruonly) {
+       //if (IS_AGGREGATE (sym->type) || sym->isptr)
+       //  sym->type = aggrToPtr (sym->type, FALSE);
+       debugLog ("  %d - used as a return\n", __LINE__);
+
+       //continue;
+      }
+
       /* if the symbol has only one definition &
         that definition is a get_pointer and the
         pointer we are getting is rematerializable and
@@ -2703,7 +2714,10 @@ packRegsForAssign (iCode * ic, eBBlock * ebp)
 
   if (!IS_ITEMP (IC_RIGHT (ic))) {
     debugLog ("  %d - not packing - right is not temp\n", __LINE__);
-    allocDirReg(IC_RIGHT (ic));
+
+    /* only pack if this is not a function pointer */
+    if (!IS_REF (IC_RIGHT (ic)))
+      allocDirReg(IC_RIGHT (ic));
     return 0;
   }
 
@@ -2839,7 +2853,7 @@ pack:
   remiCodeFromeBBlock (ebp, ic);
   bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
   hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
-  OP_DEFS (IC_RESULT (dic)) = bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
+  OP_DEFS(IC_RESULT (dic))=bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
   return 1;
 
 
@@ -3675,7 +3689,7 @@ packRegisters (eBBlock * ebp)
            remiCodeFromeBBlock (ebp, ic);
            bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
            hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
-           OP_DEFS (IC_RESULT (dic)) = bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
+           OP_DEFS(IC_RESULT (dic))=bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
            ic = ic->prev;
          }  else
                
@@ -3696,7 +3710,7 @@ packRegisters (eBBlock * ebp)
            bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
            remiCodeFromeBBlock (ebp, ic);
            hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
-           OP_DEFS (IC_RESULT (dic)) = bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
+           OP_DEFS(IC_RESULT (dic))=bitVectSetBit (OP_DEFS (IC_RESULT (dic)), dic->key);
            ic = ic->prev;
          }
        }