struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / src / mos6502 / ralloc.h
blob1b3e22053c136c8cae0ce0cdbfb9ed05fe2e2d0a
1 /*-------------------------------------------------------------------------
3 SDCCralloc.h - header file register allocation
5 Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998)
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
10 later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 In other words, you are welcome to use, share and improve this program.
22 You are forbidden to forbid anyone else to use, share and improve
23 what you give them. Help stamp out software-hoarding!
24 -------------------------------------------------------------------------*/
26 #ifndef SDCCRALLOC_H
27 #define SDCCRALLOC_H 1
29 #include "common.h"
31 enum
33 A_IDX,
34 X_IDX,
35 Y_IDX,
36 // Z_IDX,
37 CND_IDX,
38 XA_IDX,
39 // YA_IDX,
40 YX_IDX,
41 SP_IDX
44 enum
46 REG_PTR = 1,
47 REG_GPR = 2,
48 REG_CND = 4,
51 /* Must preserve the relation M6502MASK_Y > M6502MASK_X > M6502MASK_A */
52 /* so that M6502MASK_REV can be automatically applied when reversing */
53 /* the usual register pair ordering. */
54 #define M6502MASK_A 0x01
55 #define M6502MASK_X 0x02
56 #define M6502MASK_Y 0x04
57 //#define M6502MASK_Z 0x10
58 //#define M6502MASK_REV 0x80
59 #define M6502MASK_XA (M6502MASK_X | M6502MASK_A)
60 //#define M6502MASK_YA (M6502MASK_Y | M6502MASK_A)
61 #define M6502MASK_YX (M6502MASK_Y | M6502MASK_X)
63 /* definition for the registers */
64 typedef struct reg_info
66 short type; /* can have value
67 REG_GPR, REG_PTR or REG_CND */
68 short rIdx; /* index into register table */
69 char *name; /* name */
70 short mask; /* bitmask for pair allocation */
71 struct asmop *aop; /* last operand */
72 int aopofs; /* last operand offset */
73 unsigned isFree:1; /* is currently unassigned */
74 unsigned isDead:1; /* does not need to survive current instruction */
75 unsigned isLitConst:1; /* has an literal constant loaded */
76 int litConst; /* last literal constant */
77 } reg_info;
79 typedef enum {
80 M6502OP_REG,
81 M6502OP_LD,
82 M6502OP_ST,
83 M6502OP_RMW,
84 M6502OP_INH,
85 M6502OP_SPH,
86 M6502OP_SPL,
87 M6502OP_JMP,
88 M6502OP_BR,
89 M6502OP_BBR,
90 M6502OP_IDD,
91 M6502OP_IDI,
92 M6502OP_CMP
93 } m6505_op_type;
95 /* opcode table */
96 typedef struct m6502opcodedata
98 char name[6];
99 m6505_op_type type;
100 int dest;
101 unsigned char flags;
102 /* info for registers used and/or modified by an instruction will be added here */
104 m6502opcodedata;
106 extern reg_info regsm6502[];
107 extern reg_info *m6502_reg_a;
108 extern reg_info *m6502_reg_x;
109 extern reg_info *m6502_reg_y;
110 extern reg_info *m6502_reg_xa;
111 //extern reg_info *m6502_reg_ya;
112 extern reg_info *m6502_reg_yx;
113 extern reg_info *m6502_reg_sp;
115 reg_info *m6502_regWithIdx (int);
116 void m6502_useReg (reg_info * reg);
117 void m6502_freeReg (reg_info * reg);
118 void m6502_dirtyReg (reg_info * reg);
119 bitVect *m6502_rUmaskForOp (operand * op);
121 const m6502opcodedata *m6502_getOpcodeData(const char *inst);
122 int m6502_opcodeSize(const m6502opcodedata *opcode, const char *arg);
124 iCode *m6502_ralloc2_cc(ebbIndex *ebbi);
126 void m6502RegFix (eBBlock **ebbs, int count);
128 #endif