*** empty log message ***
[fw/sdcc] / src / pic / ralloc.h
1 /*-------------------------------------------------------------------------
2
3   SDCCralloc.h - header file register allocation
4
5                 Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1998)
6                 PIC port   - T. Scott Dattalo scott@dattalo.com (2000)
7
8    This program is free software; you can redistribute it and/or modify it
9    under the terms of the GNU General Public License as published by the
10    Free Software Foundation; either version 2, or (at your option) any
11    later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21    
22    In other words, you are welcome to use, share and improve this program.
23    You are forbidden to forbid anyone else to use, share and improve
24    what you give them.   Help stamp out software-hoarding!  
25 -------------------------------------------------------------------------*/
26 #include "SDCCicode.h"
27 #include "SDCCBBlock.h"
28 #ifndef SDCCRALLOC_H
29 #define SDCCRALLOC_H 1
30
31
32
33 enum
34   {
35     R2_IDX = 0, R3_IDX, R4_IDX,
36     R5_IDX, R6_IDX, R7_IDX,
37     R0_IDX, R1_IDX, X8_IDX,
38     X9_IDX, X10_IDX, X11_IDX,
39     X12_IDX, CND_IDX
40   };
41
42
43 #define REG_PTR 0x01
44 #define REG_GPR 0x02
45 #define REG_CND 0x04
46 #define REG_SFR 0x08
47 #define REG_STK 0x10  /* Use a register as a psuedo stack */
48
49 /* definition for the registers */
50 typedef struct regs
51   {
52     short type;                 /* can have value 
53                                  * REG_GPR, REG_PTR or REG_CND 
54                                  * This like the "meta-type" */
55     short pc_type;              /* pcode type */
56     short rIdx;                 /* index into register table */
57     //    short otype;        
58     char *name;                 /* name */
59     char *dname;                /* name when direct access needed */
60     //  char *base ;         /* base address */
61     short offset;               /* offset from the base */
62     unsigned isFree:1;          /* is currently unassigned  */
63     unsigned wasUsed:1;         /* becomes true if register has been used */
64   }
65 regs;
66 extern regs regspic14[];
67 extern int pic14_nRegs;
68 extern int Gstack_base_addr;
69
70 regs *pic14_regWithIdx (int);
71 void  pic14_freeAllRegs ();
72 void  pic14_deallocateAllRegs ();
73 regs *pic14_findFreeReg(short type);
74 regs *pic14_allocWithIdx (int idx);
75
76 /* Define register address that are constant across PIC family */
77 #define IDX_INDF    0
78 #define IDX_FSR     4
79 #define IDX_KZ      0x7fff   /* Known zero - actually just a general purpose reg. */
80
81 #endif