OSDN Git Service

* arm.c (arm_handle_notshared_attribute): Wrap declaration and use
[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, 2003, 2004 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 #ifndef GCC_REGS_H
23 #define GCC_REGS_H
24
25 #include "varray.h"
26 #include "hard-reg-set.h"
27 #include "basic-block.h"
28
29 #define REG_BYTES(R) mode_size[(int) GET_MODE (R)]
30
31 /* When you only have the mode of a pseudo register before it has a hard
32    register chosen for it, this reports the size of each hard register
33    a pseudo in such a mode would get allocated to.  A target may
34    override this.  */
35
36 #ifndef REGMODE_NATURAL_SIZE
37 #define REGMODE_NATURAL_SIZE(MODE)      UNITS_PER_WORD
38 #endif
39
40 #ifndef SMALL_REGISTER_CLASSES
41 #define SMALL_REGISTER_CLASSES 0
42 #endif
43
44 /* Maximum register number used in this function, plus one.  */
45
46 extern int max_regno;
47
48 /* Register information indexed by register number */
49 typedef struct reg_info_def
50 {                               /* fields set by reg_scan */
51   int first_uid;                /* UID of first insn to use (REG n) */
52   int last_uid;                 /* UID of last insn to use (REG n) */
53
54                                 /* fields set by reg_scan & flow_analysis */
55   int sets;                     /* # of times (REG n) is set */
56
57                                 /* fields set by flow_analysis */
58   int refs;                     /* # of times (REG n) is used or set */
59   int freq;                     /* # estimated frequency (REG n) is used or set */
60   int deaths;                   /* # of times (REG n) dies */
61   int live_length;              /* # of instructions (REG n) is live */
62   int calls_crossed;            /* # of calls (REG n) is live across */
63   int basic_block;              /* # of basic blocks (REG n) is used in */
64 } reg_info;
65
66 extern varray_type reg_n_info;
67
68 /* Indexed by n, gives number of times (REG n) is used or set.  */
69
70 #define REG_N_REFS(N) (VARRAY_REG (reg_n_info, N)->refs)
71
72 /* Estimate frequency of references to register N.  */
73
74 #define REG_FREQ(N) (VARRAY_REG (reg_n_info, N)->freq)
75
76 /* The weights for each insn varries from 0 to REG_FREQ_BASE.
77    This constant does not need to be high, as in infrequently executed
78    regions we want to count instructions equivalently to optimize for
79    size instead of speed.  */
80 #define REG_FREQ_MAX 1000
81
82 /* Compute register frequency from the BB frequency.  When optimizing for size,
83    or profile driven feedback is available and the function is never executed,
84    frequency is always equivalent.  Otherwise rescale the basic block
85    frequency.  */
86 #define REG_FREQ_FROM_BB(bb) (optimize_size                                   \
87                               || (flag_branch_probabilities                   \
88                                   && !ENTRY_BLOCK_PTR->count)                 \
89                               ? REG_FREQ_MAX                                  \
90                               : ((bb)->frequency * REG_FREQ_MAX / BB_FREQ_MAX)\
91                               ? ((bb)->frequency * REG_FREQ_MAX / BB_FREQ_MAX)\
92                               : 1)
93
94 /* Indexed by n, gives number of times (REG n) is set.
95    ??? both regscan and flow allocate space for this.  We should settle
96    on just copy.  */
97
98 #define REG_N_SETS(N) (VARRAY_REG (reg_n_info, N)->sets)
99
100 /* Indexed by N, gives number of insns in which register N dies.
101    Note that if register N is live around loops, it can die
102    in transitions between basic blocks, and that is not counted here.
103    So this is only a reliable indicator of how many regions of life there are
104    for registers that are contained in one basic block.  */
105
106 #define REG_N_DEATHS(N) (VARRAY_REG (reg_n_info, N)->deaths)
107
108 /* Get the number of consecutive words required to hold pseudo-reg N.  */
109
110 #define PSEUDO_REGNO_SIZE(N) \
111   ((GET_MODE_SIZE (PSEUDO_REGNO_MODE (N)) + UNITS_PER_WORD - 1)         \
112    / UNITS_PER_WORD)
113
114 /* Get the number of bytes required to hold pseudo-reg N.  */
115
116 #define PSEUDO_REGNO_BYTES(N) \
117   GET_MODE_SIZE (PSEUDO_REGNO_MODE (N))
118
119 /* Get the machine mode of pseudo-reg N.  */
120
121 #define PSEUDO_REGNO_MODE(N) GET_MODE (regno_reg_rtx[N])
122
123 /* Indexed by N, gives number of CALL_INSNS across which (REG n) is live.  */
124
125 #define REG_N_CALLS_CROSSED(N) (VARRAY_REG (reg_n_info, N)->calls_crossed)
126
127 /* Total number of instructions at which (REG n) is live.
128    The larger this is, the less priority (REG n) gets for
129    allocation in a hard register (in global-alloc).
130    This is set in flow.c and remains valid for the rest of the compilation
131    of the function; it is used to control register allocation.
132
133    local-alloc.c may alter this number to change the priority.
134
135    Negative values are special.
136    -1 is used to mark a pseudo reg which has a constant or memory equivalent
137    and is used infrequently enough that it should not get a hard register.
138    -2 is used to mark a pseudo reg for a parameter, when a frame pointer
139    is not required.  global.c makes an allocno for this but does
140    not try to assign a hard register to it.  */
141
142 #define REG_LIVE_LENGTH(N) (VARRAY_REG (reg_n_info, N)->live_length)
143
144 /* Vector of substitutions of register numbers,
145    used to map pseudo regs into hardware regs.
146
147    This can't be folded into reg_n_info without changing all of the
148    machine dependent directories, since the reload functions
149    in the machine dependent files access it.  */
150
151 extern short *reg_renumber;
152
153 /* Vector indexed by hardware reg saying whether that reg is ever used.  */
154
155 extern char regs_ever_live[FIRST_PSEUDO_REGISTER];
156
157 /* Like regs_ever_live, but saying whether reg is set by asm statements.  */
158
159 extern char regs_asm_clobbered[FIRST_PSEUDO_REGISTER];
160
161 /* Vector indexed by machine mode saying whether there are regs of that mode.  */
162
163 extern bool have_regs_of_mode [MAX_MACHINE_MODE];
164
165 /* For each hard register, the widest mode object that it can contain.
166    This will be a MODE_INT mode if the register can hold integers.  Otherwise
167    it will be a MODE_FLOAT or a MODE_CC mode, whichever is valid for the
168    register.  */
169
170 extern enum machine_mode reg_raw_mode[FIRST_PSEUDO_REGISTER];
171
172 /* Vector indexed by regno; gives uid of first insn using that reg.
173    This is computed by reg_scan for use by cse and loop.
174    It is sometimes adjusted for subsequent changes during loop,
175    but not adjusted by cse even if cse invalidates it.  */
176
177 #define REGNO_FIRST_UID(N) (VARRAY_REG (reg_n_info, N)->first_uid)
178
179 /* Vector indexed by regno; gives uid of last insn using that reg.
180    This is computed by reg_scan for use by cse and loop.
181    It is sometimes adjusted for subsequent changes during loop,
182    but not adjusted by cse even if cse invalidates it.
183    This is harmless since cse won't scan through a loop end.  */
184
185 #define REGNO_LAST_UID(N) (VARRAY_REG (reg_n_info, N)->last_uid)
186
187 /* List made of EXPR_LIST rtx's which gives pairs of pseudo registers
188    that have to go in the same hard reg.  */
189 extern rtx regs_may_share;
190
191 /* Flag set by local-alloc or global-alloc if they decide to allocate
192    something in a call-clobbered register.  */
193
194 extern int caller_save_needed;
195
196 /* Predicate to decide whether to give a hard reg to a pseudo which
197    is referenced REFS times and would need to be saved and restored
198    around a call CALLS times.  */
199
200 #ifndef CALLER_SAVE_PROFITABLE
201 #define CALLER_SAVE_PROFITABLE(REFS, CALLS)  (4 * (CALLS) < (REFS))
202 #endif
203
204 /* On most machines a register class is likely to be spilled if it
205    only has one register.  */
206 #ifndef CLASS_LIKELY_SPILLED_P
207 #define CLASS_LIKELY_SPILLED_P(CLASS) (reg_class_size[(int) (CLASS)] == 1)
208 #endif
209
210 /* Select a register mode required for caller save of hard regno REGNO.  */
211 #ifndef HARD_REGNO_CALLER_SAVE_MODE
212 #define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE) \
213   choose_hard_reg_mode (REGNO, NREGS, false)
214 #endif
215
216 /* Registers that get partially clobbered by a call in a given mode.
217    These must not be call used registers.  */
218 #ifndef HARD_REGNO_CALL_PART_CLOBBERED
219 #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO, MODE) 0
220 #endif
221
222 /* Allocate reg_n_info tables */
223 extern void allocate_reg_info (size_t, int, int);
224
225 /* Specify number of hard registers given machine mode occupy.  */
226 extern unsigned char hard_regno_nregs[FIRST_PSEUDO_REGISTER][MAX_MACHINE_MODE];
227
228 #endif /* GCC_REGS_H */