OSDN Git Service

* mangle.c (write_expression): Handle CAST_EXPR, STATIC_CAST_EXPR,
[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, 1996, 1997, 1998,
3    1999, 2000 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.  */
21
22
23 #include "varray.h"
24
25 #define REG_BYTES(R) mode_size[(int) GET_MODE (R)]
26
27 /* Get the number of consecutive hard regs required to hold the REG or
28    SUBREG rtx R.
29    When something may be an explicit hard reg, REG_SIZE is the only
30    valid way to get this value.  You cannot get it from the regno.
31
32    A target may override this definition, the case where you would do
33    this is where there are registers which are smaller than WORD_SIZE
34    such as the SFmode registers on sparc64.  */
35
36 #ifndef REG_SIZE
37 #define REG_SIZE(R) \
38   ((mode_size[(int) GET_MODE (R)] + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
39 #endif
40
41 /* When you only have the mode of a pseudo register before it has a hard
42    register chosen for it, this reports the size of each hard register
43    a pseudo in such a mode would get allocated to.  Like REG_SIZE, a
44    target may override this.  */
45
46 #ifndef REGMODE_NATURAL_SIZE
47 #define REGMODE_NATURAL_SIZE(MODE)      UNITS_PER_WORD
48 #endif
49
50 #ifndef SMALL_REGISTER_CLASSES
51 #define SMALL_REGISTER_CLASSES 0
52 #endif
53
54 /* Maximum register number used in this function, plus one.  */
55
56 extern int max_regno;
57
58 /* Register information indexed by register number */
59 typedef struct reg_info_def
60 {                               /* fields set by reg_scan */
61   int first_uid;                /* UID of first insn to use (REG n) */
62   int last_uid;                 /* UID of last insn to use (REG n) */
63   int last_note_uid;            /* UID of last note to use (REG n) */
64
65                                 /* fields set by reg_scan & flow_analysis */
66   int sets;                     /* # of times (REG n) is set */
67
68                                 /* fields set by flow_analysis */
69   int refs;                     /* # of times (REG n) is used or set */
70   int freq;                     /* # estimated frequency (REG n) is used or set */
71   int deaths;                   /* # of times (REG n) dies */
72   int live_length;              /* # of instructions (REG n) is live */
73   int calls_crossed;            /* # of calls (REG n) is live across */
74   int basic_block;              /* # of basic blocks (REG n) is used in */
75   char changes_mode;            /* whether (SUBREG (REG n)) exists and 
76                                    is illegal.  */
77 } reg_info;
78
79 extern varray_type reg_n_info;
80
81 /* Indexed by n, gives number of times (REG n) is used or set.  */
82
83 #define REG_N_REFS(N) (VARRAY_REG (reg_n_info, N)->refs)
84
85 /* Estimate frequency of references to register N.  */
86
87 #define REG_FREQ(N) (VARRAY_REG (reg_n_info, N)->freq)
88
89 /* The weights for each insn varries from 0 to REG_FREQ_BASE. 
90    This constant does not need to be high, as in infrequently executed
91    regions we want to count instructions equivalently to optimize for
92    size instead of speed.  */
93 #define REG_FREQ_MAX 1000
94
95 /* Compute register frequency from the BB frequency.  When optimizing for size,
96    or profile driven feedback is available and the function is never executed,
97    frequency is always equivalent.  Otherwise rescale the basic block
98    frequency.  */
99 #define REG_FREQ_FROM_BB(bb) (optimize_size                                   \
100                               || (flag_branch_probabilities                   \
101                                   && !ENTRY_BLOCK_PTR->count)                 \
102                               ? REG_FREQ_MAX                                  \
103                               : ((bb)->frequency * REG_FREQ_MAX / BB_FREQ_MAX)\
104                               ? ((bb)->frequency * REG_FREQ_MAX / BB_FREQ_MAX)\
105                               : 1)
106
107 /* Indexed by n, gives number of times (REG n) is set.
108    ??? both regscan and flow allocate space for this.  We should settle
109    on just copy.  */
110
111 #define REG_N_SETS(N) (VARRAY_REG (reg_n_info, N)->sets)
112
113 /* Indexed by N, gives number of insns in which register N dies.
114    Note that if register N is live around loops, it can die
115    in transitions between basic blocks, and that is not counted here.
116    So this is only a reliable indicator of how many regions of life there are
117    for registers that are contained in one basic block.  */
118
119 #define REG_N_DEATHS(N) (VARRAY_REG (reg_n_info, N)->deaths)
120
121 /* Indexed by N; says whether a pseudo register N was ever used
122    within a SUBREG that changes the mode of the reg in some way
123    that is illegal for a given class (usually floating-point)
124    of registers.  */
125
126 #define REG_CHANGES_MODE(N) (VARRAY_REG (reg_n_info, N)->changes_mode)
127
128 /* Get the number of consecutive words required to hold pseudo-reg N.  */
129
130 #define PSEUDO_REGNO_SIZE(N) \
131   ((GET_MODE_SIZE (PSEUDO_REGNO_MODE (N)) + UNITS_PER_WORD - 1)         \
132    / UNITS_PER_WORD)
133
134 /* Get the number of bytes required to hold pseudo-reg N.  */
135
136 #define PSEUDO_REGNO_BYTES(N) \
137   GET_MODE_SIZE (PSEUDO_REGNO_MODE (N))
138
139 /* Get the machine mode of pseudo-reg N.  */
140
141 #define PSEUDO_REGNO_MODE(N) GET_MODE (regno_reg_rtx[N])
142
143 /* Indexed by N, gives number of CALL_INSNS across which (REG n) is live.  */
144
145 #define REG_N_CALLS_CROSSED(N) (VARRAY_REG (reg_n_info, N)->calls_crossed)
146
147 /* Total number of instructions at which (REG n) is live.
148    The larger this is, the less priority (REG n) gets for
149    allocation in a hard register (in global-alloc).
150    This is set in flow.c and remains valid for the rest of the compilation
151    of the function; it is used to control register allocation.
152
153    local-alloc.c may alter this number to change the priority.
154
155    Negative values are special.
156    -1 is used to mark a pseudo reg which has a constant or memory equivalent
157    and is used infrequently enough that it should not get a hard register.
158    -2 is used to mark a pseudo reg for a parameter, when a frame pointer
159    is not required.  global.c makes an allocno for this but does
160    not try to assign a hard register to it.  */
161
162 #define REG_LIVE_LENGTH(N) (VARRAY_REG (reg_n_info, N)->live_length)
163
164 /* Vector of substitutions of register numbers,
165    used to map pseudo regs into hardware regs.
166
167    This can't be folded into reg_n_info without changing all of the
168    machine dependent directories, since the reload functions
169    in the machine dependent files access it.  */
170
171 extern short *reg_renumber;
172
173 /* Vector indexed by hardware reg
174    saying whether that reg is ever used.  */
175
176 extern char regs_ever_live[FIRST_PSEUDO_REGISTER];
177
178 /* Vector indexed by hardware reg giving its name.  */
179
180 extern const char * reg_names[FIRST_PSEUDO_REGISTER];
181
182 /* For each hard register, the widest mode object that it can contain.
183    This will be a MODE_INT mode if the register can hold integers.  Otherwise
184    it will be a MODE_FLOAT or a MODE_CC mode, whichever is valid for the
185    register.  */
186
187 extern enum machine_mode reg_raw_mode[FIRST_PSEUDO_REGISTER];
188
189 /* Vector indexed by regno; gives uid of first insn using that reg.
190    This is computed by reg_scan for use by cse and loop.
191    It is sometimes adjusted for subsequent changes during loop,
192    but not adjusted by cse even if cse invalidates it.  */
193
194 #define REGNO_FIRST_UID(N) (VARRAY_REG (reg_n_info, N)->first_uid)
195
196 /* Vector indexed by regno; gives uid of last insn using that reg.
197    This is computed by reg_scan for use by cse and loop.
198    It is sometimes adjusted for subsequent changes during loop,
199    but not adjusted by cse even if cse invalidates it.
200    This is harmless since cse won't scan through a loop end.  */
201
202 #define REGNO_LAST_UID(N) (VARRAY_REG (reg_n_info, N)->last_uid)
203
204 /* Similar, but includes insns that mention the reg in their notes.  */
205
206 #define REGNO_LAST_NOTE_UID(N) (VARRAY_REG (reg_n_info, N)->last_note_uid)
207
208 /* List made of EXPR_LIST rtx's which gives pairs of pseudo registers
209    that have to go in the same hard reg.  */
210 extern rtx regs_may_share;
211
212 /* Flag set by local-alloc or global-alloc if they decide to allocate
213    something in a call-clobbered register.  */
214
215 extern int caller_save_needed;
216
217 /* Predicate to decide whether to give a hard reg to a pseudo which
218    is referenced REFS times and would need to be saved and restored
219    around a call CALLS times.  */
220
221 #ifndef CALLER_SAVE_PROFITABLE
222 #define CALLER_SAVE_PROFITABLE(REFS, CALLS)  (4 * (CALLS) < (REFS))
223 #endif
224
225 /* On most machines a register class is likely to be spilled if it
226    only has one register.  */
227 #ifndef CLASS_LIKELY_SPILLED_P
228 #define CLASS_LIKELY_SPILLED_P(CLASS) (reg_class_size[(int) (CLASS)] == 1)
229 #endif
230
231 /* Select a register mode required for caller save of hard regno REGNO.  */
232 #ifndef HARD_REGNO_CALLER_SAVE_MODE
233 #define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE) \
234   choose_hard_reg_mode (REGNO, NREGS)
235 #endif
236
237 /* Registers that get partially clobbered by a call in a given mode. 
238    These must not be call used registers.  */
239 #ifndef HARD_REGNO_CALL_PART_CLOBBERED
240 #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO, MODE) 0
241 #endif
242
243 /* Allocate reg_n_info tables */
244 extern void allocate_reg_info PARAMS ((size_t, int, int));