* src/z80/gen.c (_vemit2): suppress compiler warning
[fw/sdcc] / src / pic / ralloc.c
index 9b181ce601f15b6bdb783cd5b5ef5d5076c233ff..8c4c3e9901e30efca04707487bf66737ed5d40a7 100644 (file)
   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
 
-#include "common.h"
-#include "ralloc.h"
 #include "device.h"
-#include "pcode.h"
 #include "gen.h"
+#include "ralloc.h"
+
+
+set *dynAllocRegs=NULL;
+set *dynStackRegs=NULL;
+set *dynProcessorRegs=NULL;
+set *dynDirectRegs=NULL;
+set *dynDirectBitRegs=NULL;
+set *dynInternalRegs=NULL;
 
 
 #define FENTRY2                 1 ? (void)0 : printf
@@ -45,9 +51,6 @@
 /* since the pack the registers depending strictly on the MCU      */
 /*-----------------------------------------------------------------*/
 
-extern void genpic14Code (iCode *);
-extern void pic14_assignConfigWordValue(int address, int value);
-
 /* Global data */
 static struct
 {
@@ -62,38 +65,23 @@ static struct
 }
 _G;
 
-/* Shared with gen.c */
-int pic14_ptrRegReq;            /* one byte pointer register required */
-
-
-set *dynAllocRegs=NULL;
-set *dynStackRegs=NULL;
-set *dynProcessorRegs=NULL;
-set *dynDirectRegs=NULL;
-set *dynDirectBitRegs=NULL;
-set *dynInternalRegs=NULL;
+static int pic14_ptrRegReq;            /* one byte pointer register required */
 
 static hTab  *dynDirectRegNames= NULL;
 // static hTab  *regHash = NULL;    /* a hash table containing ALL registers */
 
 static int dynrIdx = 0x1000;
 
-int pic14_nRegs = 128;   // = sizeof (regspic14) / sizeof (regs);
-
 int Gstack_base_addr=0; /* The starting address of registers that
                          * are used to pass and return parameters */
-int Gstack_size = 0;
-
+static int Gstack_size = 0;
 
-
-
-static void spillThis (symbol *);
 static int debug = 0;   // should be 0 when committed, creates .d files
 static FILE *debugF = NULL;
+
 /*-----------------------------------------------------------------*/
 /* debugLog - open a file for debugging information                */
 /*-----------------------------------------------------------------*/
-//static void debugLog(char *inst,char *fmt, ...)
 static void
 debugLog (char *fmt,...)
 {
@@ -148,7 +136,6 @@ pic14_debugLogClose (void)
                  debugF = NULL;
         }
 }
-#define AOP(op) op->aop
 
 static char *
 debugAopGet (char *str, operand * op)
@@ -316,7 +303,26 @@ static int regname2key(char const *name)
 
 }
 
-static regs *regWithIdx (set *dRegs, int idx, int fixed);
+/*-----------------------------------------------------------------*/
+/* regWithIdx - Search through a set of registers that matches idx */
+/*-----------------------------------------------------------------*/
+static regs *
+regWithIdx (set *dRegs, int idx, int fixed)
+{
+        regs *dReg;
+
+        for (dReg = setFirstItem(dRegs) ; dReg ;
+        dReg = setNextItem(dRegs)) {
+
+                if(idx == dReg->rIdx && (fixed == (int)dReg->isFixed)) {
+                        while (dReg->reg_alias) dReg = dReg->reg_alias;
+                        return dReg;
+                }
+        }
+
+        return NULL;
+}
+
 /*-----------------------------------------------------------------*/
 /* newReg - allocate and init memory for a new register            */
 /*-----------------------------------------------------------------*/
@@ -370,26 +376,6 @@ static regs* newReg(short type, PIC_OPTYPE pc_type, int rIdx, char *name, int si
         return dReg;
 }
 
-/*-----------------------------------------------------------------*/
-/* regWithIdx - Search through a set of registers that matches idx */
-/*-----------------------------------------------------------------*/
-static regs *
-regWithIdx (set *dRegs, int idx, int fixed)
-{
-        regs *dReg;
-
-        for (dReg = setFirstItem(dRegs) ; dReg ;
-        dReg = setNextItem(dRegs)) {
-
-                if(idx == dReg->rIdx && (fixed == (int)dReg->isFixed)) {
-                        while (dReg->reg_alias) dReg = dReg->reg_alias;
-                        return dReg;
-                }
-        }
-
-        return NULL;
-}
-
 /*-----------------------------------------------------------------*/
 /* regWithName - Search through a set of registers that matches name */
 /*-----------------------------------------------------------------*/
@@ -576,12 +562,6 @@ dirregWithName (char *name)
         return NULL; // name wasn't found in the hash table
 }
 
-int IS_CONFIG_ADDRESS(int address)
-{
-
-        return ((address == 0x2007) || (address == 0x2008));
-}
-
 /*-----------------------------------------------------------------*/
 /* allocNewDirReg - allocates a new register of given type         */
 /*-----------------------------------------------------------------*/
@@ -1042,7 +1022,8 @@ nfreeRegsType (int type)
         return nFreeRegs (type);
 }
 
-void writeSetUsedRegs(FILE *of, set *dRegs)
+#if 0
+static void writeSetUsedRegs(FILE *of, set *dRegs)
 {
 
         regs *dReg;
@@ -1055,9 +1036,9 @@ void writeSetUsedRegs(FILE *of, set *dRegs)
         }
 
 }
-extern void dump_map(void);
+#endif
 
-void packBits(set *bregs)
+static void packBits(set *bregs)
 {
         set *regset;
         regs *breg;
@@ -1124,7 +1105,7 @@ void packBits(set *bregs)
 
 
 
-void bitEQUs(FILE *of, set *bregs)
+static void bitEQUs(FILE *of, set *bregs)
 {
         regs *breg,*bytereg;
         int bit_no=0;
@@ -1155,7 +1136,8 @@ void bitEQUs(FILE *of, set *bregs)
 
 }
 
-void aliasEQUs(FILE *of, set *fregs, int use_rIdx)
+#if 0
+static void aliasEQUs(FILE *of, set *fregs, int use_rIdx)
 {
         regs *reg;
 
@@ -1163,7 +1145,6 @@ void aliasEQUs(FILE *of, set *fregs, int use_rIdx)
         for (reg = setFirstItem(fregs) ; reg ;
         reg = setNextItem(fregs)) {
 
-                //if(!reg->isEmitted && reg->wasUsed) {
                 if(reg->wasUsed) {
                         if(use_rIdx)
                                 fprintf (of, "%s\tEQU\t0x%03x\n",
@@ -1177,14 +1158,13 @@ void aliasEQUs(FILE *of, set *fregs, int use_rIdx)
         }
 
 }
+#endif
 
 void writeUsedRegs(FILE *of)
 {
 
         packBits(dynDirectBitRegs);
 
-        //dump_map();
-
         bitEQUs(of,dynDirectBitRegs);
 }
 
@@ -2716,6 +2696,9 @@ regTypeNum ()
         }
 
 }
+
+#if 0
+static
 DEFSETFUNC (markRegFree)
 {
         ((regs *)item)->isFree = 1;
@@ -2723,6 +2706,7 @@ DEFSETFUNC (markRegFree)
         return 0;
 }
 
+static
 DEFSETFUNC (deallocReg)
 {
         fprintf(stderr,"deallocting register %s\n",((regs *)item)->name);
@@ -2731,10 +2715,11 @@ DEFSETFUNC (deallocReg)
 
         return 0;
 }
+
 /*-----------------------------------------------------------------*/
 /* freeAllRegs - mark all registers as free                        */
 /*-----------------------------------------------------------------*/
-void
+static void
 pic14_freeAllRegs ()
 {
         //  int i;
@@ -2752,7 +2737,7 @@ pic14_freeAllRegs ()
 
 /*-----------------------------------------------------------------*/
 /*-----------------------------------------------------------------*/
-void
+static void
 pic14_deallocateAllRegs ()
 {
         //  int i;
@@ -2770,6 +2755,7 @@ pic14_deallocateAllRegs ()
         }
         */
 }
+#endif
 
 
 /*-----------------------------------------------------------------*/
@@ -3609,7 +3595,7 @@ packForPush (iCode * ic, eBBlock * ebp)
         hTabDeleteItem (&iCodehTab, dic->key, dic, DELETE_ITEM, NULL);
 }
 
-void printSymType(char * str, sym_link *sl)
+static void printSymType(char * str, sym_link *sl)
 {
         if (debug) {
                 debugLog ("    %s Symbol type: ",str);
@@ -3623,7 +3609,7 @@ void printSymType(char * str, sym_link *sl)
 * the function checkSClass in src/SDCCsymt.c dinks with
 * the S_TYPE in ways the PIC port doesn't fully like...*/
 /*-----------------------------------------------------------------*/
-void isData(sym_link *sl)
+static void isData(sym_link *sl)
 {
         FILE *of = stderr;