OSDN Git Service

5089553d0f482b37de99be6f5235d946be6f3c33
[pf3gnuchains/gcc-fork.git] / gcc / regs.h
1 /* Define per-register tables for data flow info and register allocation.
2    Copyright (C) 1987, 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21
22
23 #define REG_BYTES(R) mode_size[(int) GET_MODE (R)]
24
25 /* Get the number of consecutive hard regs required to hold the REG rtx R.
26    When something may be an explicit hard reg, REG_SIZE is the only
27    valid way to get this value.  You cannot get it from the regno.  */
28
29 #define REG_SIZE(R) \
30   ((mode_size[(int) GET_MODE (R)] + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
31
32 /* Maximum register number used in this function, plus one.  */
33
34 extern int max_regno;
35
36 /* Maximum number of SCRATCH rtx's in each block of this function.  */
37
38 extern int max_scratch;
39
40 /* Register information indexed by register number */
41 typedef struct reg_info_def {
42                                 /* fields set by reg_scan */
43   int first_uid;                /* UID of first insn to use (REG n) */
44   int last_uid;                 /* UID of last insn to use (REG n) */
45   int last_note_uid;            /* UID of last note to use (REG n) */
46
47                                 /* fields set by both reg_scan and flow_analysis */
48   int sets;                     /* # of times (REG n) is set */
49
50                                 /* fields set by flow_analysis */
51   int refs;                     /* # of times (REG n) is used or set */
52   int deaths;                   /* # of times (REG n) dies */
53   int live_length;              /* # of instructions (REG n) is live */
54   int calls_crossed;            /* # of calls (REG n) is live across */
55   int basic_block;              /* # of basic blocks (REG n) is used in */
56   char changes_size;            /* whether (SUBREG (REG n)) changes size */
57 } reg_info;
58
59 extern reg_info *reg_n_info;
60
61 /* Indexed by n, gives number of times (REG n) is used or set.
62    References within loops may be counted more times.  */
63
64 #define REG_N_REFS(N) (reg_n_info[(N)].refs)
65
66 /* Indexed by n, gives number of times (REG n) is set.
67    ??? both regscan and flow allocate space for this.  We should settle
68    on just copy.  */
69
70 #define REG_N_SETS(N) (reg_n_info[(N)].sets)
71
72 /* Indexed by N, gives number of insns in which register N dies.
73    Note that if register N is live around loops, it can die
74    in transitions between basic blocks, and that is not counted here.
75    So this is only a reliable indicator of how many regions of life there are
76    for registers that are contained in one basic block.  */
77
78 #define REG_N_DEATHS(N) (reg_n_info[(N)].deaths)
79
80 /* Indexed by N; says whether a pseudo register N was ever used
81    within a SUBREG that changes the size of the reg.  Some machines prohibit
82    such objects to be in certain (usually floating-point) registers.  */
83
84 #define REG_CHANGES_SIZE(N) (reg_n_info[(N)].changes_size)
85
86 /* Get the number of consecutive words required to hold pseudo-reg N.  */
87
88 #define PSEUDO_REGNO_SIZE(N) \
89   ((GET_MODE_SIZE (PSEUDO_REGNO_MODE (N)) + UNITS_PER_WORD - 1)         \
90    / UNITS_PER_WORD)
91
92 /* Get the number of bytes required to hold pseudo-reg N.  */
93
94 #define PSEUDO_REGNO_BYTES(N) \
95   GET_MODE_SIZE (PSEUDO_REGNO_MODE (N))
96
97 /* Get the machine mode of pseudo-reg N.  */
98
99 #define PSEUDO_REGNO_MODE(N) GET_MODE (regno_reg_rtx[N])
100
101 /* Indexed by N, gives number of CALL_INSNS across which (REG n) is live.  */
102
103 #define REG_N_CALLS_CROSSED(N) (reg_n_info[(N)].calls_crossed)
104
105 /* Total number of instructions at which (REG n) is live.
106    The larger this is, the less priority (REG n) gets for
107    allocation in a hard register (in global-alloc).
108    This is set in flow.c and remains valid for the rest of the compilation
109    of the function; it is used to control register allocation.
110
111    local-alloc.c may alter this number to change the priority.
112
113    Negative values are special.
114    -1 is used to mark a pseudo reg which has a constant or memory equivalent
115    and is used infrequently enough that it should not get a hard register.
116    -2 is used to mark a pseudo reg for a parameter, when a frame pointer
117    is not required.  global.c makes an allocno for this but does
118    not try to assign a hard register to it.  */
119
120 #define REG_LIVE_LENGTH(N) (reg_n_info[(N)].live_length)
121
122 /* Vector of substitutions of register numbers,
123    used to map pseudo regs into hardware regs.
124
125    This can't be folded into reg_n_info without changing all of the
126    machine dependent directories, since the reload functions
127    in the machine dependent files access it.  */
128
129 extern short *reg_renumber;
130
131 /* Vector indexed by hardware reg
132    saying whether that reg is ever used.  */
133
134 extern char regs_ever_live[FIRST_PSEUDO_REGISTER];
135
136 /* Vector indexed by hardware reg giving its name.  */
137
138 extern char *reg_names[FIRST_PSEUDO_REGISTER];
139
140 /* For each hard register, the widest mode object that it can contain.
141    This will be a MODE_INT mode if the register can hold integers.  Otherwise
142    it will be a MODE_FLOAT or a MODE_CC mode, whichever is valid for the
143    register.  */
144
145 extern enum machine_mode reg_raw_mode[FIRST_PSEUDO_REGISTER];
146
147 /* Vector indexed by regno; gives uid of first insn using that reg.
148    This is computed by reg_scan for use by cse and loop.
149    It is sometimes adjusted for subsequent changes during loop,
150    but not adjusted by cse even if cse invalidates it.  */
151
152 #define REGNO_FIRST_UID(N) (reg_n_info[(N)].first_uid)
153
154 /* Vector indexed by regno; gives uid of last insn using that reg.
155    This is computed by reg_scan for use by cse and loop.
156    It is sometimes adjusted for subsequent changes during loop,
157    but not adjusted by cse even if cse invalidates it.
158    This is harmless since cse won't scan through a loop end.  */
159
160 #define REGNO_LAST_UID(N) (reg_n_info[(N)].last_uid)
161
162 /* Similar, but includes insns that mention the reg in their notes.  */
163
164 #define REGNO_LAST_NOTE_UID(N) (reg_n_info[(N)].last_note_uid)
165
166 /* This is reset to LAST_VIRTUAL_REGISTER + 1 at the start of each function.
167    After rtl generation, it is 1 plus the largest register number used.  */
168
169 extern int reg_rtx_no;
170
171 /* Vector indexed by regno; contains 1 for a register is considered a pointer.
172    Reloading, etc. will use a pointer register rather than a non-pointer
173    as the base register in an address, when there is a choice of two regs.  */
174
175 extern char *regno_pointer_flag;
176 #define REGNO_POINTER_FLAG(REGNO) regno_pointer_flag[REGNO]
177 extern int regno_pointer_flag_length;
178
179 /* List made of EXPR_LIST rtx's which gives pairs of pseudo registers
180    that have to go in the same hard reg.  */
181 extern rtx regs_may_share;
182
183 /* Vector mapping pseudo regno into the REG rtx for that register.
184    This is computed by reg_scan.  */
185
186 extern rtx *regno_reg_rtx;
187
188 /* Flag set by local-alloc or global-alloc if they decide to allocate
189    something in a call-clobbered register.  */
190
191 extern int caller_save_needed;
192
193 /* Predicate to decide whether to give a hard reg to a pseudo which
194    is referenced REFS times and would need to be saved and restored
195    around a call CALLS times.  */
196
197 #ifndef CALLER_SAVE_PROFITABLE
198 #define CALLER_SAVE_PROFITABLE(REFS, CALLS)  (4 * (CALLS) < (REFS))
199 #endif
200
201 /* On most machines a register class is likely to be spilled if it
202    only has one register.  */
203 #ifndef CLASS_LIKELY_SPILLED_P
204 #define CLASS_LIKELY_SPILLED_P(CLASS) (reg_class_size[(int) (CLASS)] == 1)
205 #endif
206
207 /* Allocated in local_alloc.  */
208
209 /* A list of SCRATCH rtl allocated by local-alloc.  */
210 extern rtx *scratch_list;
211 /* The basic block in which each SCRATCH is used.  */
212 extern int *scratch_block;
213 /* The length of the arrays pointed to by scratch_block and scratch_list.  */
214 extern int scratch_list_length;
215
216 /* Allocate reg_n_info tables */
217 extern void allocate_reg_info PROTO((int, int, int));