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
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 -------------------------------------------------------------------------*/
26 #include "SDCCicode.h"
27 #include "SDCCBBlock.h"
29 #define SDCCRALLOC_H 1
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,
47 #define REG_STK 0x10 /* Use a register as a psuedo stack */
49 /* definition for the registers */
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 */
58 char *name; /* name */
60 unsigned isFree:1; /* is currently unassigned */
61 unsigned wasUsed:1; /* becomes true if register has been used */
62 unsigned isFixed:1; /* True if address can't change */
63 unsigned isMapped:1; /* The Register's address has been mapped to physical RAM */
64 unsigned isBitField:1; /* True if reg is type bit OR is holder for several bits */
65 unsigned isEmitted:1; /* True if the reg has been written to a .asm file */
66 unsigned address; /* reg's address if isFixed | isMapped is true */
67 unsigned size; /* 0 for byte, 1 for int, 4 for long */
68 unsigned alias; /* Alias mask if register appears in multiple banks */
69 struct regs *reg_alias; /* If more than one register share the same address
70 * then they'll point to each other. (primarily for bits)*/
73 extern regs regspic14[];
74 extern int pic14_nRegs;
75 extern int Gstack_base_addr;
77 regs *pic14_regWithIdx (int);
78 regs *dirregWithName (char *name );
79 void pic14_freeAllRegs ();
80 void pic14_deallocateAllRegs ();
81 regs *pic14_findFreeReg(short type);
82 regs *pic14_allocWithIdx (int idx);
83 regs *allocDirReg (operand *op );
84 regs *allocRegByName (char *name, int size );
86 /* Define register address that are constant across PIC family */
94 #define IDX_PCLATH 0x0a
95 #define IDX_INTCON 0x0b
97 #define IDX_KZ 0x7fff /* Known zero - actually just a general purpose reg. */
98 #define IDX_WSAVE 0x7ffe
99 #define IDX_SSAVE 0x7ffd