Numerous bug fixes in PIC Port (pointers, shifting, bank selection,...)
[fw/sdcc] / src / pic / ralloc.h
index 37e37dbc6b09a1c722e9efc80c0de76f3d7367ab..f8af1de24e12e4794873f5653ef3360ac989c565 100644 (file)
@@ -44,6 +44,7 @@ enum
 #define REG_GPR 0x02
 #define REG_CND 0x04
 #define REG_SFR 0x08
+#define REG_STK 0x10  /* Use a register as a psuedo stack */
 
 /* definition for the registers */
 typedef struct regs
@@ -55,32 +56,46 @@ typedef struct regs
     short rIdx;                        /* index into register table */
     //    short otype;        
     char *name;                        /* name */
-    char *dname;               /* name when direct access needed */
-    //  char *base ;         /* base address */
-    short offset;              /* offset from the base */
+
     unsigned isFree:1;         /* is currently unassigned  */
     unsigned wasUsed:1;                /* becomes true if register has been used */
+    unsigned isFixed:1;         /* True if address can't change */
+    unsigned isMapped:1;        /* The Register's address has been mapped to physical RAM */
+    unsigned isBitField:1;      /* True if reg is type bit OR is holder for several bits */
+    unsigned isEmitted:1;       /* True if the reg has been written to a .asm file */
+    unsigned address;           /* reg's address if isFixed | isMapped is true */
+    unsigned size;              /* 0 for byte, 1 for int, 4 for long */
+    unsigned alias;             /* Alias mask if register appears in multiple banks */
+    struct regs *reg_alias;     /* If more than one register share the same address 
+                                * then they'll point to each other. (primarily for bits)*/
   }
 regs;
 extern regs regspic14[];
 extern int pic14_nRegs;
+extern int Gstack_base_addr;
 
 regs *pic14_regWithIdx (int);
+regs *dirregWithName (char *name );
 void  pic14_freeAllRegs ();
 void  pic14_deallocateAllRegs ();
-regs *pic14_findFreeReg(void);
+regs *pic14_findFreeReg(short type);
+regs *pic14_allocWithIdx (int idx);
+regs *allocDirReg (operand *op );
+regs *allocRegByName (char *name, int size );
 
-enum PIC_register_types
-  {
-    PIC_INDF,
-    PIC_TMR0,
-    PIC_FSR,
-    PIC_STATUS,
-    PIC_IOPORT,
-    PIC_IOTRIS,
-    PIC_GPR,                   /*  A general purpose file register */
-    PIC_SFR                    /*  A special function register */
-  };
+/* Define register address that are constant across PIC family */
+#define IDX_INDF    0
+#define IDX_TMR0    1
+#define IDX_PCL     2
+#define IDX_STATUS  3
+#define IDX_FSR     4
+#define IDX_PORTA   5
+#define IDX_PORTB   6
+#define IDX_PCLATH  0x0a
+#define IDX_INTCON  0x0b
 
+#define IDX_KZ      0x7fff   /* Known zero - actually just a general purpose reg. */
+#define IDX_WSAVE   0x7ffe
+#define IDX_SSAVE   0x7ffd
 
 #endif