Announce SDCC 4.5.0 RC3.
[sdcc.git] / sdcc / src / pic14 / ralloc.h
blobbcc1704dfbf83fd8fff88f8339061d08a9fbd5aa
1 /*-------------------------------------------------------------------------
3 SDCCralloc.h - header file register allocation
5 Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998)
6 PIC port - T. Scott Dattalo scott@dattalo.com (2000)
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.
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.
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.
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 -------------------------------------------------------------------------*/
27 #ifndef SDCCRALLOC_H
28 #define SDCCRALLOC_H 1
30 #include "common.h"
32 #include "pcoderegs.h"
35 enum {
36 REG_PTR=1,
37 REG_GPR,
38 REG_CND,
39 REG_SFR,
40 REG_STK,
41 REG_TMP
44 /* definition for the registers */
45 typedef struct reg_info
47 short type; /* can have value
48 * REG_GPR, REG_PTR or REG_CND
49 * This like the "meta-type" */
50 short pc_type; /* pcode type */
51 short rIdx; /* index into register table */
52 char *name; /* name */
54 unsigned isFree:1; /* is currently unassigned */
55 unsigned wasUsed:1; /* becomes true if register has been used */
56 unsigned isFixed:1; /* True if address can't change */
57 unsigned isMapped:1; /* The Register's address has been mapped to physical RAM */
58 unsigned isBitField:1; /* True if reg is type bit OR is holder for several bits */
59 unsigned isEmitted:1; /* True if the reg has been written to a .asm file */
60 unsigned isPublic:1; /* True if the reg is not static and can be modified in another module (ie a another c or asm file) */
61 unsigned isExtern:1; /* True if the reg is in another module */
62 unsigned address; /* reg's address if isFixed | isMapped is true */
63 unsigned size; /* 0 for byte, 1 for int, 4 for long */
64 unsigned alias; /* Alias mask if register appears in multiple banks */
65 struct reg_info *reg_alias; /* If more than one register share the same address
66 * then they'll point to each other. (primarily for bits)*/
67 pCodeRegLives reglives; /* live range mapping */
69 reg_info;
70 extern reg_info regspic14[];
71 extern int Gstack_base_addr;
74 As registers are created, they're added to a set (based on the
75 register type). Here are the sets of registers that are supported
76 in the PIC port:
78 extern set *dynAllocRegs;
79 extern set *dynStackRegs;
80 extern set *dynProcessorRegs;
81 extern set *dynDirectRegs;
82 extern set *dynDirectBitRegs;
83 extern set *dynInternalRegs;
86 void initStack(int base_address, int size, int shared);
87 reg_info *pic14_regWithIdx(int);
88 reg_info *dirregWithName(const char *name);
89 void pic14_assignRegisters(ebbIndex *ebbi);
90 reg_info *pic14_findFreeReg(short type);
91 reg_info *pic14_allocWithIdx (int idx);
92 reg_info *typeRegWithIdx(int idx, int type, int fixed);
93 reg_info *regFindWithName(const char *name);
95 void pic14_debugLogClose(void);
96 void writeUsedRegs(FILE *of);
98 reg_info *allocDirReg(operand *op );
99 reg_info *allocInternalRegister(int rIdx, const char *name, PIC_OPTYPE po_type, int alias);
100 reg_info *allocProcessorRegister(int rIdx, const char *name, short po_type, int alias);
101 reg_info *allocRegByName(const char *name, int size );
102 reg_info *allocNewDirReg(sym_link *symlnk, const char *name);
104 /* Define register address that are constant across PIC family */
105 #define IDX_INDF 0
106 #define IDX_INDF0 0
107 #define IDX_TMR0 1
108 #define IDX_PCL 2
109 #define IDX_STATUS 3
110 #define IDX_FSR 4
111 #define IDX_FSR0L 4
112 #define IDX_FSR0H 5
113 #define IDX_PCLATH 0x0a
114 #define IDX_INTCON 0x0b
116 #define IDX_KZ 0x7fff /* Known zero - actually just a general purpose reg. */
117 #define IDX_WSAVE 0x7ffe
118 #define IDX_SSAVE 0x7ffd
119 #define IDX_PSAVE 0x7ffc
121 #define pic14_nRegs 128
123 #endif