OSDN Git Service

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