annotate gcc/ira-costs.c @ 118:fd00160c1b76

ifdef TARGET_64BIT
author mir3636
date Tue, 27 Feb 2018 15:01:35 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1 /* IRA hard register and memory cost calculation for allocnos or pseudos.
111
kono
parents: 67
diff changeset
2 Copyright (C) 2006-2017 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Vladimir Makarov <vmakarov@redhat.com>.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #include "config.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "coretypes.h"
111
kono
parents: 67
diff changeset
24 #include "backend.h"
kono
parents: 67
diff changeset
25 #include "target.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 #include "rtl.h"
111
kono
parents: 67
diff changeset
27 #include "tree.h"
kono
parents: 67
diff changeset
28 #include "predict.h"
kono
parents: 67
diff changeset
29 #include "memmodel.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 #include "tm_p.h"
111
kono
parents: 67
diff changeset
31 #include "insn-config.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 #include "regs.h"
111
kono
parents: 67
diff changeset
33 #include "ira.h"
kono
parents: 67
diff changeset
34 #include "ira-int.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 #include "addresses.h"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
36 #include "reload.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
38 /* The flags is set up every time when we calculate pseudo register
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
39 classes through function ira_set_pseudo_classes. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
40 static bool pseudo_classes_defined_p = false;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
41
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
42 /* TRUE if we work with allocnos. Otherwise we work with pseudos. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
43 static bool allocno_p;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
44
111
kono
parents: 67
diff changeset
45 /* Number of elements in array `costs'. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
46 static int cost_elements_num;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 /* The `costs' struct records the cost of using hard registers of each
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 class considered for the calculation and of using memory for each
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
50 allocno or pseudo. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 struct costs
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 int mem_cost;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 /* Costs for register classes start here. We process only some
111
kono
parents: 67
diff changeset
55 allocno classes. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 int cost[1];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
59 #define max_struct_costs_size \
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
60 (this_target_ira_int->x_max_struct_costs_size)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
61 #define init_cost \
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
62 (this_target_ira_int->x_init_cost)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
63 #define temp_costs \
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
64 (this_target_ira_int->x_temp_costs)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
65 #define op_costs \
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
66 (this_target_ira_int->x_op_costs)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
67 #define this_op_costs \
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
68 (this_target_ira_int->x_this_op_costs)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
70 /* Costs of each class for each allocno or pseudo. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
71 static struct costs *costs;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
72
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
73 /* Accumulated costs of each class for each allocno. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
74 static struct costs *total_allocno_costs;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 /* It is the current size of struct costs. */
111
kono
parents: 67
diff changeset
77 static size_t struct_costs_size;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
79 /* Return pointer to structure containing costs of allocno or pseudo
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
80 with given NUM in array ARR. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
81 #define COSTS(arr, num) \
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 ((struct costs *) ((char *) (arr) + (num) * struct_costs_size))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
84 /* Return index in COSTS when processing reg with REGNO. */
111
kono
parents: 67
diff changeset
85 #define COST_INDEX(regno) (allocno_p \
kono
parents: 67
diff changeset
86 ? ALLOCNO_NUM (ira_curr_regno_allocno_map[regno]) \
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
87 : (int) regno)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
89 /* Record register class preferences of each allocno or pseudo. Null
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
90 value means no preferences. It happens on the 1st iteration of the
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
91 cost calculation. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
92 static enum reg_class *pref;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
94 /* Allocated buffers for pref. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
95 static enum reg_class *pref_buffer;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
96
111
kono
parents: 67
diff changeset
97 /* Record allocno class of each allocno with the same regno. */
kono
parents: 67
diff changeset
98 static enum reg_class *regno_aclass;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
100 /* Record cost gains for not allocating a register with an invariant
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
101 equivalence. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
102 static int *regno_equiv_gains;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
103
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 /* Execution frequency of the current insn. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 static int frequency;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108
111
kono
parents: 67
diff changeset
109 /* Info about reg classes whose costs are calculated for a pseudo. */
kono
parents: 67
diff changeset
110 struct cost_classes
kono
parents: 67
diff changeset
111 {
kono
parents: 67
diff changeset
112 /* Number of the cost classes in the subsequent array. */
kono
parents: 67
diff changeset
113 int num;
kono
parents: 67
diff changeset
114 /* Container of the cost classes. */
kono
parents: 67
diff changeset
115 enum reg_class classes[N_REG_CLASSES];
kono
parents: 67
diff changeset
116 /* Map reg class -> index of the reg class in the previous array.
kono
parents: 67
diff changeset
117 -1 if it is not a cost class. */
kono
parents: 67
diff changeset
118 int index[N_REG_CLASSES];
kono
parents: 67
diff changeset
119 /* Map hard regno index of first class in array CLASSES containing
kono
parents: 67
diff changeset
120 the hard regno, -1 otherwise. */
kono
parents: 67
diff changeset
121 int hard_regno_index[FIRST_PSEUDO_REGISTER];
kono
parents: 67
diff changeset
122 };
kono
parents: 67
diff changeset
123
kono
parents: 67
diff changeset
124 /* Types of pointers to the structure above. */
kono
parents: 67
diff changeset
125 typedef struct cost_classes *cost_classes_t;
kono
parents: 67
diff changeset
126 typedef const struct cost_classes *const_cost_classes_t;
kono
parents: 67
diff changeset
127
kono
parents: 67
diff changeset
128 /* Info about cost classes for each pseudo. */
kono
parents: 67
diff changeset
129 static cost_classes_t *regno_cost_classes;
kono
parents: 67
diff changeset
130
kono
parents: 67
diff changeset
131 /* Helper for cost_classes hashing. */
kono
parents: 67
diff changeset
132
kono
parents: 67
diff changeset
133 struct cost_classes_hasher : pointer_hash <cost_classes>
kono
parents: 67
diff changeset
134 {
kono
parents: 67
diff changeset
135 static inline hashval_t hash (const cost_classes *);
kono
parents: 67
diff changeset
136 static inline bool equal (const cost_classes *, const cost_classes *);
kono
parents: 67
diff changeset
137 static inline void remove (cost_classes *);
kono
parents: 67
diff changeset
138 };
kono
parents: 67
diff changeset
139
kono
parents: 67
diff changeset
140 /* Returns hash value for cost classes info HV. */
kono
parents: 67
diff changeset
141 inline hashval_t
kono
parents: 67
diff changeset
142 cost_classes_hasher::hash (const cost_classes *hv)
kono
parents: 67
diff changeset
143 {
kono
parents: 67
diff changeset
144 return iterative_hash (&hv->classes, sizeof (enum reg_class) * hv->num, 0);
kono
parents: 67
diff changeset
145 }
kono
parents: 67
diff changeset
146
kono
parents: 67
diff changeset
147 /* Compares cost classes info HV1 and HV2. */
kono
parents: 67
diff changeset
148 inline bool
kono
parents: 67
diff changeset
149 cost_classes_hasher::equal (const cost_classes *hv1, const cost_classes *hv2)
kono
parents: 67
diff changeset
150 {
kono
parents: 67
diff changeset
151 return (hv1->num == hv2->num
kono
parents: 67
diff changeset
152 && memcmp (hv1->classes, hv2->classes,
kono
parents: 67
diff changeset
153 sizeof (enum reg_class) * hv1->num) == 0);
kono
parents: 67
diff changeset
154 }
kono
parents: 67
diff changeset
155
kono
parents: 67
diff changeset
156 /* Delete cost classes info V from the hash table. */
kono
parents: 67
diff changeset
157 inline void
kono
parents: 67
diff changeset
158 cost_classes_hasher::remove (cost_classes *v)
kono
parents: 67
diff changeset
159 {
kono
parents: 67
diff changeset
160 ira_free (v);
kono
parents: 67
diff changeset
161 }
kono
parents: 67
diff changeset
162
kono
parents: 67
diff changeset
163 /* Hash table of unique cost classes. */
kono
parents: 67
diff changeset
164 static hash_table<cost_classes_hasher> *cost_classes_htab;
kono
parents: 67
diff changeset
165
kono
parents: 67
diff changeset
166 /* Map allocno class -> cost classes for pseudo of given allocno
kono
parents: 67
diff changeset
167 class. */
kono
parents: 67
diff changeset
168 static cost_classes_t cost_classes_aclass_cache[N_REG_CLASSES];
kono
parents: 67
diff changeset
169
kono
parents: 67
diff changeset
170 /* Map mode -> cost classes for pseudo of give mode. */
kono
parents: 67
diff changeset
171 static cost_classes_t cost_classes_mode_cache[MAX_MACHINE_MODE];
kono
parents: 67
diff changeset
172
kono
parents: 67
diff changeset
173 /* Cost classes that include all classes in ira_important_classes. */
kono
parents: 67
diff changeset
174 static cost_classes all_cost_classes;
kono
parents: 67
diff changeset
175
kono
parents: 67
diff changeset
176 /* Use the array of classes in CLASSES_PTR to fill out the rest of
kono
parents: 67
diff changeset
177 the structure. */
kono
parents: 67
diff changeset
178 static void
kono
parents: 67
diff changeset
179 complete_cost_classes (cost_classes_t classes_ptr)
kono
parents: 67
diff changeset
180 {
kono
parents: 67
diff changeset
181 for (int i = 0; i < N_REG_CLASSES; i++)
kono
parents: 67
diff changeset
182 classes_ptr->index[i] = -1;
kono
parents: 67
diff changeset
183 for (int i = 0; i < FIRST_PSEUDO_REGISTER; i++)
kono
parents: 67
diff changeset
184 classes_ptr->hard_regno_index[i] = -1;
kono
parents: 67
diff changeset
185 for (int i = 0; i < classes_ptr->num; i++)
kono
parents: 67
diff changeset
186 {
kono
parents: 67
diff changeset
187 enum reg_class cl = classes_ptr->classes[i];
kono
parents: 67
diff changeset
188 classes_ptr->index[cl] = i;
kono
parents: 67
diff changeset
189 for (int j = ira_class_hard_regs_num[cl] - 1; j >= 0; j--)
kono
parents: 67
diff changeset
190 {
kono
parents: 67
diff changeset
191 unsigned int hard_regno = ira_class_hard_regs[cl][j];
kono
parents: 67
diff changeset
192 if (classes_ptr->hard_regno_index[hard_regno] < 0)
kono
parents: 67
diff changeset
193 classes_ptr->hard_regno_index[hard_regno] = i;
kono
parents: 67
diff changeset
194 }
kono
parents: 67
diff changeset
195 }
kono
parents: 67
diff changeset
196 }
kono
parents: 67
diff changeset
197
kono
parents: 67
diff changeset
198 /* Initialize info about the cost classes for each pseudo. */
kono
parents: 67
diff changeset
199 static void
kono
parents: 67
diff changeset
200 initiate_regno_cost_classes (void)
kono
parents: 67
diff changeset
201 {
kono
parents: 67
diff changeset
202 int size = sizeof (cost_classes_t) * max_reg_num ();
kono
parents: 67
diff changeset
203
kono
parents: 67
diff changeset
204 regno_cost_classes = (cost_classes_t *) ira_allocate (size);
kono
parents: 67
diff changeset
205 memset (regno_cost_classes, 0, size);
kono
parents: 67
diff changeset
206 memset (cost_classes_aclass_cache, 0,
kono
parents: 67
diff changeset
207 sizeof (cost_classes_t) * N_REG_CLASSES);
kono
parents: 67
diff changeset
208 memset (cost_classes_mode_cache, 0,
kono
parents: 67
diff changeset
209 sizeof (cost_classes_t) * MAX_MACHINE_MODE);
kono
parents: 67
diff changeset
210 cost_classes_htab = new hash_table<cost_classes_hasher> (200);
kono
parents: 67
diff changeset
211 all_cost_classes.num = ira_important_classes_num;
kono
parents: 67
diff changeset
212 for (int i = 0; i < ira_important_classes_num; i++)
kono
parents: 67
diff changeset
213 all_cost_classes.classes[i] = ira_important_classes[i];
kono
parents: 67
diff changeset
214 complete_cost_classes (&all_cost_classes);
kono
parents: 67
diff changeset
215 }
kono
parents: 67
diff changeset
216
kono
parents: 67
diff changeset
217 /* Create new cost classes from cost classes FROM and set up members
kono
parents: 67
diff changeset
218 index and hard_regno_index. Return the new classes. The function
kono
parents: 67
diff changeset
219 implements some common code of two functions
kono
parents: 67
diff changeset
220 setup_regno_cost_classes_by_aclass and
kono
parents: 67
diff changeset
221 setup_regno_cost_classes_by_mode. */
kono
parents: 67
diff changeset
222 static cost_classes_t
kono
parents: 67
diff changeset
223 setup_cost_classes (cost_classes_t from)
kono
parents: 67
diff changeset
224 {
kono
parents: 67
diff changeset
225 cost_classes_t classes_ptr;
kono
parents: 67
diff changeset
226
kono
parents: 67
diff changeset
227 classes_ptr = (cost_classes_t) ira_allocate (sizeof (struct cost_classes));
kono
parents: 67
diff changeset
228 classes_ptr->num = from->num;
kono
parents: 67
diff changeset
229 for (int i = 0; i < from->num; i++)
kono
parents: 67
diff changeset
230 classes_ptr->classes[i] = from->classes[i];
kono
parents: 67
diff changeset
231 complete_cost_classes (classes_ptr);
kono
parents: 67
diff changeset
232 return classes_ptr;
kono
parents: 67
diff changeset
233 }
kono
parents: 67
diff changeset
234
kono
parents: 67
diff changeset
235 /* Return a version of FULL that only considers registers in REGS that are
kono
parents: 67
diff changeset
236 valid for mode MODE. Both FULL and the returned class are globally
kono
parents: 67
diff changeset
237 allocated. */
kono
parents: 67
diff changeset
238 static cost_classes_t
kono
parents: 67
diff changeset
239 restrict_cost_classes (cost_classes_t full, machine_mode mode,
kono
parents: 67
diff changeset
240 const HARD_REG_SET &regs)
kono
parents: 67
diff changeset
241 {
kono
parents: 67
diff changeset
242 static struct cost_classes narrow;
kono
parents: 67
diff changeset
243 int map[N_REG_CLASSES];
kono
parents: 67
diff changeset
244 narrow.num = 0;
kono
parents: 67
diff changeset
245 for (int i = 0; i < full->num; i++)
kono
parents: 67
diff changeset
246 {
kono
parents: 67
diff changeset
247 /* Assume that we'll drop the class. */
kono
parents: 67
diff changeset
248 map[i] = -1;
kono
parents: 67
diff changeset
249
kono
parents: 67
diff changeset
250 /* Ignore classes that are too small for the mode. */
kono
parents: 67
diff changeset
251 enum reg_class cl = full->classes[i];
kono
parents: 67
diff changeset
252 if (!contains_reg_of_mode[cl][mode])
kono
parents: 67
diff changeset
253 continue;
kono
parents: 67
diff changeset
254
kono
parents: 67
diff changeset
255 /* Calculate the set of registers in CL that belong to REGS and
kono
parents: 67
diff changeset
256 are valid for MODE. */
kono
parents: 67
diff changeset
257 HARD_REG_SET valid_for_cl;
kono
parents: 67
diff changeset
258 COPY_HARD_REG_SET (valid_for_cl, reg_class_contents[cl]);
kono
parents: 67
diff changeset
259 AND_HARD_REG_SET (valid_for_cl, regs);
kono
parents: 67
diff changeset
260 AND_COMPL_HARD_REG_SET (valid_for_cl,
kono
parents: 67
diff changeset
261 ira_prohibited_class_mode_regs[cl][mode]);
kono
parents: 67
diff changeset
262 AND_COMPL_HARD_REG_SET (valid_for_cl, ira_no_alloc_regs);
kono
parents: 67
diff changeset
263 if (hard_reg_set_empty_p (valid_for_cl))
kono
parents: 67
diff changeset
264 continue;
kono
parents: 67
diff changeset
265
kono
parents: 67
diff changeset
266 /* Don't use this class if the set of valid registers is a subset
kono
parents: 67
diff changeset
267 of an existing class. For example, suppose we have two classes
kono
parents: 67
diff changeset
268 GR_REGS and FR_REGS and a union class GR_AND_FR_REGS. Suppose
kono
parents: 67
diff changeset
269 that the mode changes allowed by FR_REGS are not as general as
kono
parents: 67
diff changeset
270 the mode changes allowed by GR_REGS.
kono
parents: 67
diff changeset
271
kono
parents: 67
diff changeset
272 In this situation, the mode changes for GR_AND_FR_REGS could
kono
parents: 67
diff changeset
273 either be seen as the union or the intersection of the mode
kono
parents: 67
diff changeset
274 changes allowed by the two subclasses. The justification for
kono
parents: 67
diff changeset
275 the union-based definition would be that, if you want a mode
kono
parents: 67
diff changeset
276 change that's only allowed by GR_REGS, you can pick a register
kono
parents: 67
diff changeset
277 from the GR_REGS subclass. The justification for the
kono
parents: 67
diff changeset
278 intersection-based definition would be that every register
kono
parents: 67
diff changeset
279 from the class would allow the mode change.
kono
parents: 67
diff changeset
280
kono
parents: 67
diff changeset
281 However, if we have a register that needs to be in GR_REGS,
kono
parents: 67
diff changeset
282 using GR_AND_FR_REGS with the intersection-based definition
kono
parents: 67
diff changeset
283 would be too pessimistic, since it would bring in restrictions
kono
parents: 67
diff changeset
284 that only apply to FR_REGS. Conversely, if we have a register
kono
parents: 67
diff changeset
285 that needs to be in FR_REGS, using GR_AND_FR_REGS with the
kono
parents: 67
diff changeset
286 union-based definition would lose the extra restrictions
kono
parents: 67
diff changeset
287 placed on FR_REGS. GR_AND_FR_REGS is therefore only useful
kono
parents: 67
diff changeset
288 for cases where GR_REGS and FP_REGS are both valid. */
kono
parents: 67
diff changeset
289 int pos;
kono
parents: 67
diff changeset
290 for (pos = 0; pos < narrow.num; ++pos)
kono
parents: 67
diff changeset
291 {
kono
parents: 67
diff changeset
292 enum reg_class cl2 = narrow.classes[pos];
kono
parents: 67
diff changeset
293 if (hard_reg_set_subset_p (valid_for_cl, reg_class_contents[cl2]))
kono
parents: 67
diff changeset
294 break;
kono
parents: 67
diff changeset
295 }
kono
parents: 67
diff changeset
296 map[i] = pos;
kono
parents: 67
diff changeset
297 if (pos == narrow.num)
kono
parents: 67
diff changeset
298 {
kono
parents: 67
diff changeset
299 /* If several classes are equivalent, prefer to use the one
kono
parents: 67
diff changeset
300 that was chosen as the allocno class. */
kono
parents: 67
diff changeset
301 enum reg_class cl2 = ira_allocno_class_translate[cl];
kono
parents: 67
diff changeset
302 if (ira_class_hard_regs_num[cl] == ira_class_hard_regs_num[cl2])
kono
parents: 67
diff changeset
303 cl = cl2;
kono
parents: 67
diff changeset
304 narrow.classes[narrow.num++] = cl;
kono
parents: 67
diff changeset
305 }
kono
parents: 67
diff changeset
306 }
kono
parents: 67
diff changeset
307 if (narrow.num == full->num)
kono
parents: 67
diff changeset
308 return full;
kono
parents: 67
diff changeset
309
kono
parents: 67
diff changeset
310 cost_classes **slot = cost_classes_htab->find_slot (&narrow, INSERT);
kono
parents: 67
diff changeset
311 if (*slot == NULL)
kono
parents: 67
diff changeset
312 {
kono
parents: 67
diff changeset
313 cost_classes_t classes = setup_cost_classes (&narrow);
kono
parents: 67
diff changeset
314 /* Map equivalent classes to the representative that we chose above. */
kono
parents: 67
diff changeset
315 for (int i = 0; i < ira_important_classes_num; i++)
kono
parents: 67
diff changeset
316 {
kono
parents: 67
diff changeset
317 enum reg_class cl = ira_important_classes[i];
kono
parents: 67
diff changeset
318 int index = full->index[cl];
kono
parents: 67
diff changeset
319 if (index >= 0)
kono
parents: 67
diff changeset
320 classes->index[cl] = map[index];
kono
parents: 67
diff changeset
321 }
kono
parents: 67
diff changeset
322 *slot = classes;
kono
parents: 67
diff changeset
323 }
kono
parents: 67
diff changeset
324 return *slot;
kono
parents: 67
diff changeset
325 }
kono
parents: 67
diff changeset
326
kono
parents: 67
diff changeset
327 /* Setup cost classes for pseudo REGNO whose allocno class is ACLASS.
kono
parents: 67
diff changeset
328 This function is used when we know an initial approximation of
kono
parents: 67
diff changeset
329 allocno class of the pseudo already, e.g. on the second iteration
kono
parents: 67
diff changeset
330 of class cost calculation or after class cost calculation in
kono
parents: 67
diff changeset
331 register-pressure sensitive insn scheduling or register-pressure
kono
parents: 67
diff changeset
332 sensitive loop-invariant motion. */
kono
parents: 67
diff changeset
333 static void
kono
parents: 67
diff changeset
334 setup_regno_cost_classes_by_aclass (int regno, enum reg_class aclass)
kono
parents: 67
diff changeset
335 {
kono
parents: 67
diff changeset
336 static struct cost_classes classes;
kono
parents: 67
diff changeset
337 cost_classes_t classes_ptr;
kono
parents: 67
diff changeset
338 enum reg_class cl;
kono
parents: 67
diff changeset
339 int i;
kono
parents: 67
diff changeset
340 cost_classes **slot;
kono
parents: 67
diff changeset
341 HARD_REG_SET temp, temp2;
kono
parents: 67
diff changeset
342 bool exclude_p;
kono
parents: 67
diff changeset
343
kono
parents: 67
diff changeset
344 if ((classes_ptr = cost_classes_aclass_cache[aclass]) == NULL)
kono
parents: 67
diff changeset
345 {
kono
parents: 67
diff changeset
346 COPY_HARD_REG_SET (temp, reg_class_contents[aclass]);
kono
parents: 67
diff changeset
347 AND_COMPL_HARD_REG_SET (temp, ira_no_alloc_regs);
kono
parents: 67
diff changeset
348 /* We exclude classes from consideration which are subsets of
kono
parents: 67
diff changeset
349 ACLASS only if ACLASS is an uniform class. */
kono
parents: 67
diff changeset
350 exclude_p = ira_uniform_class_p[aclass];
kono
parents: 67
diff changeset
351 classes.num = 0;
kono
parents: 67
diff changeset
352 for (i = 0; i < ira_important_classes_num; i++)
kono
parents: 67
diff changeset
353 {
kono
parents: 67
diff changeset
354 cl = ira_important_classes[i];
kono
parents: 67
diff changeset
355 if (exclude_p)
kono
parents: 67
diff changeset
356 {
kono
parents: 67
diff changeset
357 /* Exclude non-uniform classes which are subsets of
kono
parents: 67
diff changeset
358 ACLASS. */
kono
parents: 67
diff changeset
359 COPY_HARD_REG_SET (temp2, reg_class_contents[cl]);
kono
parents: 67
diff changeset
360 AND_COMPL_HARD_REG_SET (temp2, ira_no_alloc_regs);
kono
parents: 67
diff changeset
361 if (hard_reg_set_subset_p (temp2, temp) && cl != aclass)
kono
parents: 67
diff changeset
362 continue;
kono
parents: 67
diff changeset
363 }
kono
parents: 67
diff changeset
364 classes.classes[classes.num++] = cl;
kono
parents: 67
diff changeset
365 }
kono
parents: 67
diff changeset
366 slot = cost_classes_htab->find_slot (&classes, INSERT);
kono
parents: 67
diff changeset
367 if (*slot == NULL)
kono
parents: 67
diff changeset
368 {
kono
parents: 67
diff changeset
369 classes_ptr = setup_cost_classes (&classes);
kono
parents: 67
diff changeset
370 *slot = classes_ptr;
kono
parents: 67
diff changeset
371 }
kono
parents: 67
diff changeset
372 classes_ptr = cost_classes_aclass_cache[aclass] = (cost_classes_t) *slot;
kono
parents: 67
diff changeset
373 }
kono
parents: 67
diff changeset
374 if (regno_reg_rtx[regno] != NULL_RTX)
kono
parents: 67
diff changeset
375 {
kono
parents: 67
diff changeset
376 /* Restrict the classes to those that are valid for REGNO's mode
kono
parents: 67
diff changeset
377 (which might for example exclude singleton classes if the mode
kono
parents: 67
diff changeset
378 requires two registers). Also restrict the classes to those that
kono
parents: 67
diff changeset
379 are valid for subregs of REGNO. */
kono
parents: 67
diff changeset
380 const HARD_REG_SET *valid_regs = valid_mode_changes_for_regno (regno);
kono
parents: 67
diff changeset
381 if (!valid_regs)
kono
parents: 67
diff changeset
382 valid_regs = &reg_class_contents[ALL_REGS];
kono
parents: 67
diff changeset
383 classes_ptr = restrict_cost_classes (classes_ptr,
kono
parents: 67
diff changeset
384 PSEUDO_REGNO_MODE (regno),
kono
parents: 67
diff changeset
385 *valid_regs);
kono
parents: 67
diff changeset
386 }
kono
parents: 67
diff changeset
387 regno_cost_classes[regno] = classes_ptr;
kono
parents: 67
diff changeset
388 }
kono
parents: 67
diff changeset
389
kono
parents: 67
diff changeset
390 /* Setup cost classes for pseudo REGNO with MODE. Usage of MODE can
kono
parents: 67
diff changeset
391 decrease number of cost classes for the pseudo, if hard registers
kono
parents: 67
diff changeset
392 of some important classes can not hold a value of MODE. So the
kono
parents: 67
diff changeset
393 pseudo can not get hard register of some important classes and cost
kono
parents: 67
diff changeset
394 calculation for such important classes is only wasting CPU
kono
parents: 67
diff changeset
395 time. */
kono
parents: 67
diff changeset
396 static void
kono
parents: 67
diff changeset
397 setup_regno_cost_classes_by_mode (int regno, machine_mode mode)
kono
parents: 67
diff changeset
398 {
kono
parents: 67
diff changeset
399 if (const HARD_REG_SET *valid_regs = valid_mode_changes_for_regno (regno))
kono
parents: 67
diff changeset
400 regno_cost_classes[regno] = restrict_cost_classes (&all_cost_classes,
kono
parents: 67
diff changeset
401 mode, *valid_regs);
kono
parents: 67
diff changeset
402 else
kono
parents: 67
diff changeset
403 {
kono
parents: 67
diff changeset
404 if (cost_classes_mode_cache[mode] == NULL)
kono
parents: 67
diff changeset
405 cost_classes_mode_cache[mode]
kono
parents: 67
diff changeset
406 = restrict_cost_classes (&all_cost_classes, mode,
kono
parents: 67
diff changeset
407 reg_class_contents[ALL_REGS]);
kono
parents: 67
diff changeset
408 regno_cost_classes[regno] = cost_classes_mode_cache[mode];
kono
parents: 67
diff changeset
409 }
kono
parents: 67
diff changeset
410 }
kono
parents: 67
diff changeset
411
kono
parents: 67
diff changeset
412 /* Finalize info about the cost classes for each pseudo. */
kono
parents: 67
diff changeset
413 static void
kono
parents: 67
diff changeset
414 finish_regno_cost_classes (void)
kono
parents: 67
diff changeset
415 {
kono
parents: 67
diff changeset
416 ira_free (regno_cost_classes);
kono
parents: 67
diff changeset
417 delete cost_classes_htab;
kono
parents: 67
diff changeset
418 cost_classes_htab = NULL;
kono
parents: 67
diff changeset
419 }
kono
parents: 67
diff changeset
420
kono
parents: 67
diff changeset
421
kono
parents: 67
diff changeset
422
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 /* Compute the cost of loading X into (if TO_P is TRUE) or from (if
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 TO_P is FALSE) a register of class RCLASS in mode MODE. X must not
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 be a pseudo register. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426 static int
111
kono
parents: 67
diff changeset
427 copy_cost (rtx x, machine_mode mode, reg_class_t rclass, bool to_p,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 secondary_reload_info *prev_sri)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 secondary_reload_info sri;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
431 reg_class_t secondary_class = NO_REGS;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
432
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 /* If X is a SCRATCH, there is actually nothing to move since we are
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 assuming optimal allocation. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 if (GET_CODE (x) == SCRATCH)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
437
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 /* Get the class we will actually use for a reload. */
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
439 rclass = targetm.preferred_reload_class (x, rclass);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
440
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 /* If we need a secondary reload for an intermediate, the cost is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
442 that to load the input into the intermediate register, then to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 copy it. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 sri.prev_sri = prev_sri;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
445 sri.extra_cost = 0;
111
kono
parents: 67
diff changeset
446 /* PR 68770: Secondary reload might examine the t_icode field. */
kono
parents: 67
diff changeset
447 sri.t_icode = CODE_FOR_nothing;
kono
parents: 67
diff changeset
448
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
449 secondary_class = targetm.secondary_reload (to_p, x, rclass, mode, &sri);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
450
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
451 if (secondary_class != NO_REGS)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 {
111
kono
parents: 67
diff changeset
453 ira_init_register_move_cost_if_necessary (mode);
kono
parents: 67
diff changeset
454 return (ira_register_move_cost[mode][(int) secondary_class][(int) rclass]
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
455 + sri.extra_cost
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 + copy_cost (x, mode, secondary_class, to_p, &sri));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
457 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
458
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 /* For memory, use the memory move cost, for (hard) registers, use
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
460 the cost to move between the register classes, and use 2 for
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
461 everything else (constants). */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 if (MEM_P (x) || rclass == NO_REGS)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
463 return sri.extra_cost
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
464 + ira_memory_move_cost[mode][(int) rclass][to_p != 0];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
465 else if (REG_P (x))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 {
111
kono
parents: 67
diff changeset
467 reg_class_t x_class = REGNO_REG_CLASS (REGNO (x));
kono
parents: 67
diff changeset
468
kono
parents: 67
diff changeset
469 ira_init_register_move_cost_if_necessary (mode);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
470 return (sri.extra_cost
111
kono
parents: 67
diff changeset
471 + ira_register_move_cost[mode][(int) x_class][(int) rclass]);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
473 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
474 /* If this is a constant, we may eventually want to call rtx_cost
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 here. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
476 return sri.extra_cost + COSTS_N_INSNS (1);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
477 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
478
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
479
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
480
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
481 /* Record the cost of using memory or hard registers of various
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 classes for the operands in INSN.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
483
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 N_ALTS is the number of alternatives.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 N_OPS is the number of operands.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 OPS is an array of the operands.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 MODES are the modes of the operands, in case any are VOIDmode.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 CONSTRAINTS are the constraints to use for the operands. This array
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 is modified by this procedure.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
490
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 This procedure works alternative by alternative. For each
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 alternative we assume that we will be able to allocate all allocnos
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
493 to their ideal register class and calculate the cost of using that
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
494 alternative. Then we compute, for each operand that is a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
495 pseudo-register, the cost of having the allocno allocated to each
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 register class and using it in that alternative. To this cost is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
497 added the cost of the alternative.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
498
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
499 The cost of each class for this insn is its lowest cost among all
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 the alternatives. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 record_reg_classes (int n_alts, int n_ops, rtx *ops,
111
kono
parents: 67
diff changeset
503 machine_mode *modes, const char **constraints,
kono
parents: 67
diff changeset
504 rtx_insn *insn, enum reg_class *pref)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 int alt;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 int i, j, k;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 int insn_allows_mem[MAX_RECOG_OPERANDS];
111
kono
parents: 67
diff changeset
509 move_table *move_in_cost, *move_out_cost;
kono
parents: 67
diff changeset
510 short (*mem_cost)[2];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 for (i = 0; i < n_ops; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 insn_allows_mem[i] = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
514
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 /* Process each alternative, each time minimizing an operand's cost
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
516 with the cost for each operand in that alternative. */
111
kono
parents: 67
diff changeset
517 alternative_mask preferred = get_preferred_alternatives (insn);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 for (alt = 0; alt < n_alts; alt++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
520 enum reg_class classes[MAX_RECOG_OPERANDS];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 int allows_mem[MAX_RECOG_OPERANDS];
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
522 enum reg_class rclass;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 int alt_fail = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
524 int alt_cost = 0, op_cost_add;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
525
111
kono
parents: 67
diff changeset
526 if (!TEST_BIT (preferred, alt))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
527 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
528 for (i = 0; i < recog_data.n_operands; i++)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
529 constraints[i] = skip_alternative (constraints[i]);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
530
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
531 continue;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
532 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
533
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 for (i = 0; i < n_ops; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 unsigned char c;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 const char *p = constraints[i];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
538 rtx op = ops[i];
111
kono
parents: 67
diff changeset
539 machine_mode mode = modes[i];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 int allows_addr = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
541 int win = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
542
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
543 /* Initially show we know nothing about the register class. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 classes[i] = NO_REGS;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 allows_mem[i] = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
546
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 /* If this operand has no constraints at all, we can
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 conclude nothing about it since anything is valid. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 if (*p == 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
550 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
551 if (REG_P (op) && REGNO (op) >= FIRST_PSEUDO_REGISTER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
552 memset (this_op_costs[i], 0, struct_costs_size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
554 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
555
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 /* If this alternative is only relevant when this operand
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 matches a previous operand, we do different things
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 depending on whether this operand is a allocno-reg or not.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
559 We must process any modifiers for the operand before we
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 can make this test. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
561 while (*p == '%' || *p == '=' || *p == '+' || *p == '&')
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
562 p++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
563
111
kono
parents: 67
diff changeset
564 if (p[0] >= '0' && p[0] <= '0' + i)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
565 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 /* Copy class and whether memory is allowed from the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 matching alternative. Then perform any needed cost
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 computations and/or adjustments. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 j = p[0] - '0';
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
570 classes[i] = classes[j];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 allows_mem[i] = allows_mem[j];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
572 if (allows_mem[i])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
573 insn_allows_mem[i] = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
574
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
575 if (! REG_P (op) || REGNO (op) < FIRST_PSEUDO_REGISTER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
576 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
577 /* If this matches the other operand, we have no
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
578 added cost and we win. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
579 if (rtx_equal_p (ops[j], op))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 win = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
581 /* If we can put the other operand into a register,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
582 add to the cost of this alternative the cost to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
583 copy this operand to the register used for the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
584 other operand. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
585 else if (classes[j] != NO_REGS)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
586 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
587 alt_cost += copy_cost (op, mode, classes[j], 1, NULL);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 win = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
589 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
591 else if (! REG_P (ops[j])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 || REGNO (ops[j]) < FIRST_PSEUDO_REGISTER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
593 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 /* This op is an allocno but the one it matches is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
595 not. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
596
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 /* If we can't put the other operand into a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 register, this alternative can't be used. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
599
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 if (classes[j] == NO_REGS)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 alt_fail = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
602 /* Otherwise, add to the cost of this alternative
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
603 the cost to copy the other operand to the hard
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 register used for this operand. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
605 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
606 alt_cost += copy_cost (ops[j], mode, classes[j], 1, NULL);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
607 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
608 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
609 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
610 /* The costs of this operand are not the same as the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
611 other operand since move costs are not symmetric.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
612 Moreover, if we cannot tie them, this alternative
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
613 needs to do a copy, which is one insn. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
614 struct costs *pp = this_op_costs[i];
111
kono
parents: 67
diff changeset
615 int *pp_costs = pp->cost;
kono
parents: 67
diff changeset
616 cost_classes_t cost_classes_ptr
kono
parents: 67
diff changeset
617 = regno_cost_classes[REGNO (op)];
kono
parents: 67
diff changeset
618 enum reg_class *cost_classes = cost_classes_ptr->classes;
kono
parents: 67
diff changeset
619 bool in_p = recog_data.operand_type[i] != OP_OUT;
kono
parents: 67
diff changeset
620 bool out_p = recog_data.operand_type[i] != OP_IN;
kono
parents: 67
diff changeset
621 enum reg_class op_class = classes[i];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
622
111
kono
parents: 67
diff changeset
623 ira_init_register_move_cost_if_necessary (mode);
kono
parents: 67
diff changeset
624 if (! in_p)
kono
parents: 67
diff changeset
625 {
kono
parents: 67
diff changeset
626 ira_assert (out_p);
kono
parents: 67
diff changeset
627 if (op_class == NO_REGS)
kono
parents: 67
diff changeset
628 {
kono
parents: 67
diff changeset
629 mem_cost = ira_memory_move_cost[mode];
kono
parents: 67
diff changeset
630 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
631 {
kono
parents: 67
diff changeset
632 rclass = cost_classes[k];
kono
parents: 67
diff changeset
633 pp_costs[k] = mem_cost[rclass][0] * frequency;
kono
parents: 67
diff changeset
634 }
kono
parents: 67
diff changeset
635 }
kono
parents: 67
diff changeset
636 else
kono
parents: 67
diff changeset
637 {
kono
parents: 67
diff changeset
638 move_out_cost = ira_may_move_out_cost[mode];
kono
parents: 67
diff changeset
639 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
640 {
kono
parents: 67
diff changeset
641 rclass = cost_classes[k];
kono
parents: 67
diff changeset
642 pp_costs[k]
kono
parents: 67
diff changeset
643 = move_out_cost[op_class][rclass] * frequency;
kono
parents: 67
diff changeset
644 }
kono
parents: 67
diff changeset
645 }
kono
parents: 67
diff changeset
646 }
kono
parents: 67
diff changeset
647 else if (! out_p)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 {
111
kono
parents: 67
diff changeset
649 ira_assert (in_p);
kono
parents: 67
diff changeset
650 if (op_class == NO_REGS)
kono
parents: 67
diff changeset
651 {
kono
parents: 67
diff changeset
652 mem_cost = ira_memory_move_cost[mode];
kono
parents: 67
diff changeset
653 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
654 {
kono
parents: 67
diff changeset
655 rclass = cost_classes[k];
kono
parents: 67
diff changeset
656 pp_costs[k] = mem_cost[rclass][1] * frequency;
kono
parents: 67
diff changeset
657 }
kono
parents: 67
diff changeset
658 }
kono
parents: 67
diff changeset
659 else
kono
parents: 67
diff changeset
660 {
kono
parents: 67
diff changeset
661 move_in_cost = ira_may_move_in_cost[mode];
kono
parents: 67
diff changeset
662 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
663 {
kono
parents: 67
diff changeset
664 rclass = cost_classes[k];
kono
parents: 67
diff changeset
665 pp_costs[k]
kono
parents: 67
diff changeset
666 = move_in_cost[rclass][op_class] * frequency;
kono
parents: 67
diff changeset
667 }
kono
parents: 67
diff changeset
668 }
kono
parents: 67
diff changeset
669 }
kono
parents: 67
diff changeset
670 else
kono
parents: 67
diff changeset
671 {
kono
parents: 67
diff changeset
672 if (op_class == NO_REGS)
kono
parents: 67
diff changeset
673 {
kono
parents: 67
diff changeset
674 mem_cost = ira_memory_move_cost[mode];
kono
parents: 67
diff changeset
675 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
676 {
kono
parents: 67
diff changeset
677 rclass = cost_classes[k];
kono
parents: 67
diff changeset
678 pp_costs[k] = ((mem_cost[rclass][0]
kono
parents: 67
diff changeset
679 + mem_cost[rclass][1])
kono
parents: 67
diff changeset
680 * frequency);
kono
parents: 67
diff changeset
681 }
kono
parents: 67
diff changeset
682 }
kono
parents: 67
diff changeset
683 else
kono
parents: 67
diff changeset
684 {
kono
parents: 67
diff changeset
685 move_in_cost = ira_may_move_in_cost[mode];
kono
parents: 67
diff changeset
686 move_out_cost = ira_may_move_out_cost[mode];
kono
parents: 67
diff changeset
687 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
688 {
kono
parents: 67
diff changeset
689 rclass = cost_classes[k];
kono
parents: 67
diff changeset
690 pp_costs[k] = ((move_in_cost[rclass][op_class]
kono
parents: 67
diff changeset
691 + move_out_cost[op_class][rclass])
kono
parents: 67
diff changeset
692 * frequency);
kono
parents: 67
diff changeset
693 }
kono
parents: 67
diff changeset
694 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
695 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
696
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
697 /* If the alternative actually allows memory, make
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
698 things a bit cheaper since we won't need an extra
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
699 insn to load it. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
700 pp->mem_cost
111
kono
parents: 67
diff changeset
701 = ((out_p ? ira_memory_move_cost[mode][op_class][0] : 0)
kono
parents: 67
diff changeset
702 + (in_p ? ira_memory_move_cost[mode][op_class][1] : 0)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 - allows_mem[i]) * frequency;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704
111
kono
parents: 67
diff changeset
705 /* If we have assigned a class to this allocno in
kono
parents: 67
diff changeset
706 our first pass, add a cost to this alternative
kono
parents: 67
diff changeset
707 corresponding to what we would add if this
kono
parents: 67
diff changeset
708 allocno were not in the appropriate class. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
709 if (pref)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
710 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
711 enum reg_class pref_class = pref[COST_INDEX (REGNO (op))];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
712
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
713 if (pref_class == NO_REGS)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
714 alt_cost
111
kono
parents: 67
diff changeset
715 += ((out_p
kono
parents: 67
diff changeset
716 ? ira_memory_move_cost[mode][op_class][0] : 0)
kono
parents: 67
diff changeset
717 + (in_p
kono
parents: 67
diff changeset
718 ? ira_memory_move_cost[mode][op_class][1]
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
719 : 0));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 else if (ira_reg_class_intersect
111
kono
parents: 67
diff changeset
721 [pref_class][op_class] == NO_REGS)
kono
parents: 67
diff changeset
722 alt_cost
kono
parents: 67
diff changeset
723 += ira_register_move_cost[mode][pref_class][op_class];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
724 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
725 if (REGNO (ops[i]) != REGNO (ops[j])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
726 && ! find_reg_note (insn, REG_DEAD, op))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
727 alt_cost += 2;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
728
111
kono
parents: 67
diff changeset
729 p++;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
730 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
731 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
732
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
733 /* Scan all the constraint letters. See if the operand
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
734 matches any of the constraints. Collect the valid
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
735 register classes and see if this operand accepts
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
736 memory. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
737 while ((c = *p))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
738 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
739 switch (c)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
740 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
741 case '*':
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
742 /* Ignore the next letter for this pass. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
743 c = *++p;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
744 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
745
111
kono
parents: 67
diff changeset
746 case '^':
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
747 alt_cost += 2;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
748 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
749
111
kono
parents: 67
diff changeset
750 case '?':
kono
parents: 67
diff changeset
751 alt_cost += 2;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
752 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
753
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 case 'g':
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
755 if (MEM_P (op)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
756 || (CONSTANT_P (op)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
757 && (! flag_pic || LEGITIMATE_PIC_OPERAND_P (op))))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 win = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 insn_allows_mem[i] = allows_mem[i] = 1;
111
kono
parents: 67
diff changeset
760 classes[i] = ira_reg_class_subunion[classes[i]][GENERAL_REGS];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
762
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
763 default:
111
kono
parents: 67
diff changeset
764 enum constraint_num cn = lookup_constraint (p);
kono
parents: 67
diff changeset
765 enum reg_class cl;
kono
parents: 67
diff changeset
766 switch (get_constraint_type (cn))
kono
parents: 67
diff changeset
767 {
kono
parents: 67
diff changeset
768 case CT_REGISTER:
kono
parents: 67
diff changeset
769 cl = reg_class_for_constraint (cn);
kono
parents: 67
diff changeset
770 if (cl != NO_REGS)
kono
parents: 67
diff changeset
771 classes[i] = ira_reg_class_subunion[classes[i]][cl];
kono
parents: 67
diff changeset
772 break;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
773
111
kono
parents: 67
diff changeset
774 case CT_CONST_INT:
kono
parents: 67
diff changeset
775 if (CONST_INT_P (op)
kono
parents: 67
diff changeset
776 && insn_const_int_ok_for_constraint (INTVAL (op), cn))
kono
parents: 67
diff changeset
777 win = 1;
kono
parents: 67
diff changeset
778 break;
kono
parents: 67
diff changeset
779
kono
parents: 67
diff changeset
780 case CT_MEMORY:
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
781 /* Every MEM can be reloaded to fit. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
782 insn_allows_mem[i] = allows_mem[i] = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
783 if (MEM_P (op))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
784 win = 1;
111
kono
parents: 67
diff changeset
785 break;
kono
parents: 67
diff changeset
786
kono
parents: 67
diff changeset
787 case CT_SPECIAL_MEMORY:
kono
parents: 67
diff changeset
788 insn_allows_mem[i] = allows_mem[i] = 1;
kono
parents: 67
diff changeset
789 if (MEM_P (op) && constraint_satisfied_p (op, cn))
kono
parents: 67
diff changeset
790 win = 1;
kono
parents: 67
diff changeset
791 break;
kono
parents: 67
diff changeset
792
kono
parents: 67
diff changeset
793 case CT_ADDRESS:
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
794 /* Every address can be reloaded to fit. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
795 allows_addr = 1;
111
kono
parents: 67
diff changeset
796 if (address_operand (op, GET_MODE (op))
kono
parents: 67
diff changeset
797 || constraint_satisfied_p (op, cn))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
798 win = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
799 /* We know this operand is an address, so we
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
800 want it to be allocated to a hard register
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
801 that can be the base of an address,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
802 i.e. BASE_REG_CLASS. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
803 classes[i]
111
kono
parents: 67
diff changeset
804 = ira_reg_class_subunion[classes[i]]
kono
parents: 67
diff changeset
805 [base_reg_class (VOIDmode, ADDR_SPACE_GENERIC,
kono
parents: 67
diff changeset
806 ADDRESS, SCRATCH)];
kono
parents: 67
diff changeset
807 break;
kono
parents: 67
diff changeset
808
kono
parents: 67
diff changeset
809 case CT_FIXED_FORM:
kono
parents: 67
diff changeset
810 if (constraint_satisfied_p (op, cn))
kono
parents: 67
diff changeset
811 win = 1;
kono
parents: 67
diff changeset
812 break;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
813 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
814 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
815 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
816 p += CONSTRAINT_LEN (c, p);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
817 if (c == ',')
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
818 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
819 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
820
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
821 constraints[i] = p;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
822
111
kono
parents: 67
diff changeset
823 if (alt_fail)
kono
parents: 67
diff changeset
824 break;
kono
parents: 67
diff changeset
825
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
826 /* How we account for this operand now depends on whether it
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
827 is a pseudo register or not. If it is, we first check if
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
828 any register classes are valid. If not, we ignore this
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
829 alternative, since we want to assume that all allocnos get
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
830 allocated for register preferencing. If some register
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
831 class is valid, compute the costs of moving the allocno
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
832 into that class. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
833 if (REG_P (op) && REGNO (op) >= FIRST_PSEUDO_REGISTER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
834 {
111
kono
parents: 67
diff changeset
835 if (classes[i] == NO_REGS && ! allows_mem[i])
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
836 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
837 /* We must always fail if the operand is a REG, but
111
kono
parents: 67
diff changeset
838 we did not find a suitable class and memory is
kono
parents: 67
diff changeset
839 not allowed.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
840
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
841 Otherwise we may perform an uninitialized read
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
842 from this_op_costs after the `continue' statement
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
843 below. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
844 alt_fail = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
845 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
846 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
847 {
111
kono
parents: 67
diff changeset
848 unsigned int regno = REGNO (op);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
849 struct costs *pp = this_op_costs[i];
111
kono
parents: 67
diff changeset
850 int *pp_costs = pp->cost;
kono
parents: 67
diff changeset
851 cost_classes_t cost_classes_ptr = regno_cost_classes[regno];
kono
parents: 67
diff changeset
852 enum reg_class *cost_classes = cost_classes_ptr->classes;
kono
parents: 67
diff changeset
853 bool in_p = recog_data.operand_type[i] != OP_OUT;
kono
parents: 67
diff changeset
854 bool out_p = recog_data.operand_type[i] != OP_IN;
kono
parents: 67
diff changeset
855 enum reg_class op_class = classes[i];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
856
111
kono
parents: 67
diff changeset
857 ira_init_register_move_cost_if_necessary (mode);
kono
parents: 67
diff changeset
858 if (! in_p)
kono
parents: 67
diff changeset
859 {
kono
parents: 67
diff changeset
860 ira_assert (out_p);
kono
parents: 67
diff changeset
861 if (op_class == NO_REGS)
kono
parents: 67
diff changeset
862 {
kono
parents: 67
diff changeset
863 mem_cost = ira_memory_move_cost[mode];
kono
parents: 67
diff changeset
864 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
865 {
kono
parents: 67
diff changeset
866 rclass = cost_classes[k];
kono
parents: 67
diff changeset
867 pp_costs[k] = mem_cost[rclass][0] * frequency;
kono
parents: 67
diff changeset
868 }
kono
parents: 67
diff changeset
869 }
kono
parents: 67
diff changeset
870 else
kono
parents: 67
diff changeset
871 {
kono
parents: 67
diff changeset
872 move_out_cost = ira_may_move_out_cost[mode];
kono
parents: 67
diff changeset
873 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
874 {
kono
parents: 67
diff changeset
875 rclass = cost_classes[k];
kono
parents: 67
diff changeset
876 pp_costs[k]
kono
parents: 67
diff changeset
877 = move_out_cost[op_class][rclass] * frequency;
kono
parents: 67
diff changeset
878 }
kono
parents: 67
diff changeset
879 }
kono
parents: 67
diff changeset
880 }
kono
parents: 67
diff changeset
881 else if (! out_p)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
882 {
111
kono
parents: 67
diff changeset
883 ira_assert (in_p);
kono
parents: 67
diff changeset
884 if (op_class == NO_REGS)
kono
parents: 67
diff changeset
885 {
kono
parents: 67
diff changeset
886 mem_cost = ira_memory_move_cost[mode];
kono
parents: 67
diff changeset
887 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
888 {
kono
parents: 67
diff changeset
889 rclass = cost_classes[k];
kono
parents: 67
diff changeset
890 pp_costs[k] = mem_cost[rclass][1] * frequency;
kono
parents: 67
diff changeset
891 }
kono
parents: 67
diff changeset
892 }
kono
parents: 67
diff changeset
893 else
kono
parents: 67
diff changeset
894 {
kono
parents: 67
diff changeset
895 move_in_cost = ira_may_move_in_cost[mode];
kono
parents: 67
diff changeset
896 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
897 {
kono
parents: 67
diff changeset
898 rclass = cost_classes[k];
kono
parents: 67
diff changeset
899 pp_costs[k]
kono
parents: 67
diff changeset
900 = move_in_cost[rclass][op_class] * frequency;
kono
parents: 67
diff changeset
901 }
kono
parents: 67
diff changeset
902 }
kono
parents: 67
diff changeset
903 }
kono
parents: 67
diff changeset
904 else
kono
parents: 67
diff changeset
905 {
kono
parents: 67
diff changeset
906 if (op_class == NO_REGS)
kono
parents: 67
diff changeset
907 {
kono
parents: 67
diff changeset
908 mem_cost = ira_memory_move_cost[mode];
kono
parents: 67
diff changeset
909 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
910 {
kono
parents: 67
diff changeset
911 rclass = cost_classes[k];
kono
parents: 67
diff changeset
912 pp_costs[k] = ((mem_cost[rclass][0]
kono
parents: 67
diff changeset
913 + mem_cost[rclass][1])
kono
parents: 67
diff changeset
914 * frequency);
kono
parents: 67
diff changeset
915 }
kono
parents: 67
diff changeset
916 }
kono
parents: 67
diff changeset
917 else
kono
parents: 67
diff changeset
918 {
kono
parents: 67
diff changeset
919 move_in_cost = ira_may_move_in_cost[mode];
kono
parents: 67
diff changeset
920 move_out_cost = ira_may_move_out_cost[mode];
kono
parents: 67
diff changeset
921 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
922 {
kono
parents: 67
diff changeset
923 rclass = cost_classes[k];
kono
parents: 67
diff changeset
924 pp_costs[k] = ((move_in_cost[rclass][op_class]
kono
parents: 67
diff changeset
925 + move_out_cost[op_class][rclass])
kono
parents: 67
diff changeset
926 * frequency);
kono
parents: 67
diff changeset
927 }
kono
parents: 67
diff changeset
928 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
929 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
930
111
kono
parents: 67
diff changeset
931 if (op_class == NO_REGS)
kono
parents: 67
diff changeset
932 /* Although we don't need insn to reload from
kono
parents: 67
diff changeset
933 memory, still accessing memory is usually more
kono
parents: 67
diff changeset
934 expensive than a register. */
kono
parents: 67
diff changeset
935 pp->mem_cost = frequency;
kono
parents: 67
diff changeset
936 else
kono
parents: 67
diff changeset
937 /* If the alternative actually allows memory, make
kono
parents: 67
diff changeset
938 things a bit cheaper since we won't need an
kono
parents: 67
diff changeset
939 extra insn to load it. */
kono
parents: 67
diff changeset
940 pp->mem_cost
kono
parents: 67
diff changeset
941 = ((out_p ? ira_memory_move_cost[mode][op_class][0] : 0)
kono
parents: 67
diff changeset
942 + (in_p ? ira_memory_move_cost[mode][op_class][1] : 0)
kono
parents: 67
diff changeset
943 - allows_mem[i]) * frequency;
kono
parents: 67
diff changeset
944 /* If we have assigned a class to this allocno in
kono
parents: 67
diff changeset
945 our first pass, add a cost to this alternative
kono
parents: 67
diff changeset
946 corresponding to what we would add if this
kono
parents: 67
diff changeset
947 allocno were not in the appropriate class. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
948 if (pref)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
949 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
950 enum reg_class pref_class = pref[COST_INDEX (REGNO (op))];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
951
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
952 if (pref_class == NO_REGS)
111
kono
parents: 67
diff changeset
953 {
kono
parents: 67
diff changeset
954 if (op_class != NO_REGS)
kono
parents: 67
diff changeset
955 alt_cost
kono
parents: 67
diff changeset
956 += ((out_p
kono
parents: 67
diff changeset
957 ? ira_memory_move_cost[mode][op_class][0]
kono
parents: 67
diff changeset
958 : 0)
kono
parents: 67
diff changeset
959 + (in_p
kono
parents: 67
diff changeset
960 ? ira_memory_move_cost[mode][op_class][1]
kono
parents: 67
diff changeset
961 : 0));
kono
parents: 67
diff changeset
962 }
kono
parents: 67
diff changeset
963 else if (op_class == NO_REGS)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
964 alt_cost
111
kono
parents: 67
diff changeset
965 += ((out_p
kono
parents: 67
diff changeset
966 ? ira_memory_move_cost[mode][pref_class][1]
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
967 : 0)
111
kono
parents: 67
diff changeset
968 + (in_p
kono
parents: 67
diff changeset
969 ? ira_memory_move_cost[mode][pref_class][0]
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
970 : 0));
111
kono
parents: 67
diff changeset
971 else if (ira_reg_class_intersect[pref_class][op_class]
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
972 == NO_REGS)
111
kono
parents: 67
diff changeset
973 alt_cost += (ira_register_move_cost
kono
parents: 67
diff changeset
974 [mode][pref_class][op_class]);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
975 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
976 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
977 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
978
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
979 /* Otherwise, if this alternative wins, either because we
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
980 have already determined that or if we have a hard
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
981 register of the proper class, there is no cost for this
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
982 alternative. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
983 else if (win || (REG_P (op)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
984 && reg_fits_class_p (op, classes[i],
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
985 0, GET_MODE (op))))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
986 ;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
987
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
988 /* If registers are valid, the cost of this alternative
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
989 includes copying the object to and/or from a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
990 register. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
991 else if (classes[i] != NO_REGS)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
992 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
993 if (recog_data.operand_type[i] != OP_OUT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
994 alt_cost += copy_cost (op, mode, classes[i], 1, NULL);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
995
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
996 if (recog_data.operand_type[i] != OP_IN)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
997 alt_cost += copy_cost (op, mode, classes[i], 0, NULL);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
998 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
999 /* The only other way this alternative can be used is if
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1000 this is a constant that could be placed into memory. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1001 else if (CONSTANT_P (op) && (allows_addr || allows_mem[i]))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1002 alt_cost += ira_memory_move_cost[mode][classes[i]][1];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1003 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1004 alt_fail = 1;
111
kono
parents: 67
diff changeset
1005
kono
parents: 67
diff changeset
1006 if (alt_fail)
kono
parents: 67
diff changeset
1007 break;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1008 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1009
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1010 if (alt_fail)
111
kono
parents: 67
diff changeset
1011 {
kono
parents: 67
diff changeset
1012 /* The loop above might have exited early once the failure
kono
parents: 67
diff changeset
1013 was seen. Skip over the constraints for the remaining
kono
parents: 67
diff changeset
1014 operands. */
kono
parents: 67
diff changeset
1015 i += 1;
kono
parents: 67
diff changeset
1016 for (; i < n_ops; ++i)
kono
parents: 67
diff changeset
1017 constraints[i] = skip_alternative (constraints[i]);
kono
parents: 67
diff changeset
1018 continue;
kono
parents: 67
diff changeset
1019 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1020
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1021 op_cost_add = alt_cost * frequency;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1022 /* Finally, update the costs with the information we've
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1023 calculated about this alternative. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1024 for (i = 0; i < n_ops; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1025 if (REG_P (ops[i]) && REGNO (ops[i]) >= FIRST_PSEUDO_REGISTER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1026 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1027 struct costs *pp = op_costs[i], *qq = this_op_costs[i];
111
kono
parents: 67
diff changeset
1028 int *pp_costs = pp->cost, *qq_costs = qq->cost;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1029 int scale = 1 + (recog_data.operand_type[i] == OP_INOUT);
111
kono
parents: 67
diff changeset
1030 cost_classes_t cost_classes_ptr
kono
parents: 67
diff changeset
1031 = regno_cost_classes[REGNO (ops[i])];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1032
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1033 pp->mem_cost = MIN (pp->mem_cost,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1034 (qq->mem_cost + op_cost_add) * scale);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1035
111
kono
parents: 67
diff changeset
1036 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
1037 pp_costs[k]
kono
parents: 67
diff changeset
1038 = MIN (pp_costs[k], (qq_costs[k] + op_cost_add) * scale);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1039 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1040 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1041
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1042 if (allocno_p)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1043 for (i = 0; i < n_ops; i++)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1044 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1045 ira_allocno_t a;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1046 rtx op = ops[i];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1047
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1048 if (! REG_P (op) || REGNO (op) < FIRST_PSEUDO_REGISTER)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1049 continue;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1050 a = ira_curr_regno_allocno_map [REGNO (op)];
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1051 if (! ALLOCNO_BAD_SPILL_P (a) && insn_allows_mem[i] == 0)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1052 ALLOCNO_BAD_SPILL_P (a) = true;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1053 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1054
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1055 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1056
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1057
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1058
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1059 /* Wrapper around REGNO_OK_FOR_INDEX_P, to allow pseudo registers. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1060 static inline bool
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1061 ok_for_index_p_nonstrict (rtx reg)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1062 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1063 unsigned regno = REGNO (reg);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1064
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1065 return regno >= FIRST_PSEUDO_REGISTER || REGNO_OK_FOR_INDEX_P (regno);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1066 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1067
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1068 /* A version of regno_ok_for_base_p for use here, when all
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1069 pseudo-registers should count as OK. Arguments as for
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1070 regno_ok_for_base_p. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1071 static inline bool
111
kono
parents: 67
diff changeset
1072 ok_for_base_p_nonstrict (rtx reg, machine_mode mode, addr_space_t as,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1073 enum rtx_code outer_code, enum rtx_code index_code)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1074 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1075 unsigned regno = REGNO (reg);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1076
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1077 if (regno >= FIRST_PSEUDO_REGISTER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1078 return true;
111
kono
parents: 67
diff changeset
1079 return ok_for_base_p_1 (regno, mode, as, outer_code, index_code);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1080 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1081
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1082 /* Record the pseudo registers we must reload into hard registers in a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1083 subexpression of a memory address, X.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1084
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1085 If CONTEXT is 0, we are looking at the base part of an address,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1086 otherwise we are looking at the index part.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1087
111
kono
parents: 67
diff changeset
1088 MODE and AS are the mode and address space of the memory reference;
kono
parents: 67
diff changeset
1089 OUTER_CODE and INDEX_CODE give the context that the rtx appears in.
kono
parents: 67
diff changeset
1090 These four arguments are passed down to base_reg_class.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1091
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1092 SCALE is twice the amount to multiply the cost by (it is twice so
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1093 we can represent half-cost adjustments). */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1094 static void
111
kono
parents: 67
diff changeset
1095 record_address_regs (machine_mode mode, addr_space_t as, rtx x,
kono
parents: 67
diff changeset
1096 int context, enum rtx_code outer_code,
kono
parents: 67
diff changeset
1097 enum rtx_code index_code, int scale)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1098 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1099 enum rtx_code code = GET_CODE (x);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1100 enum reg_class rclass;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1101
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102 if (context == 1)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103 rclass = INDEX_REG_CLASS;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1104 else
111
kono
parents: 67
diff changeset
1105 rclass = base_reg_class (mode, as, outer_code, index_code);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1106
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1107 switch (code)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1108 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1109 case CONST_INT:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1110 case CONST:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1111 case CC0:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1112 case PC:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1113 case SYMBOL_REF:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1114 case LABEL_REF:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1115 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1116
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1117 case PLUS:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1118 /* When we have an address that is a sum, we must determine
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1119 whether registers are "base" or "index" regs. If there is a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1120 sum of two registers, we must choose one to be the "base".
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1121 Luckily, we can use the REG_POINTER to make a good choice
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1122 most of the time. We only need to do this on machines that
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1123 can have two registers in an address and where the base and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1124 index register classes are different.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1125
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1126 ??? This code used to set REGNO_POINTER_FLAG in some cases,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1127 but that seems bogus since it should only be set when we are
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1128 sure the register is being used as a pointer. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1129 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1130 rtx arg0 = XEXP (x, 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1131 rtx arg1 = XEXP (x, 1);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1132 enum rtx_code code0 = GET_CODE (arg0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1133 enum rtx_code code1 = GET_CODE (arg1);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1134
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1135 /* Look inside subregs. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1136 if (code0 == SUBREG)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1137 arg0 = SUBREG_REG (arg0), code0 = GET_CODE (arg0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1138 if (code1 == SUBREG)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1139 arg1 = SUBREG_REG (arg1), code1 = GET_CODE (arg1);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1140
111
kono
parents: 67
diff changeset
1141 /* If index registers do not appear, or coincide with base registers,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1142 just record registers in any non-constant operands. We
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1143 assume here, as well as in the tests below, that all
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1144 addresses are in canonical form. */
111
kono
parents: 67
diff changeset
1145 if (MAX_REGS_PER_ADDRESS == 1
kono
parents: 67
diff changeset
1146 || INDEX_REG_CLASS == base_reg_class (VOIDmode, as, PLUS, SCRATCH))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1147 {
111
kono
parents: 67
diff changeset
1148 record_address_regs (mode, as, arg0, context, PLUS, code1, scale);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1149 if (! CONSTANT_P (arg1))
111
kono
parents: 67
diff changeset
1150 record_address_regs (mode, as, arg1, context, PLUS, code0, scale);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1151 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1152
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1153 /* If the second operand is a constant integer, it doesn't
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1154 change what class the first operand must be. */
111
kono
parents: 67
diff changeset
1155 else if (CONST_SCALAR_INT_P (arg1))
kono
parents: 67
diff changeset
1156 record_address_regs (mode, as, arg0, context, PLUS, code1, scale);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1157 /* If the second operand is a symbolic constant, the first
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1158 operand must be an index register. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1159 else if (code1 == SYMBOL_REF || code1 == CONST || code1 == LABEL_REF)
111
kono
parents: 67
diff changeset
1160 record_address_regs (mode, as, arg0, 1, PLUS, code1, scale);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1161 /* If both operands are registers but one is already a hard
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1162 register of index or reg-base class, give the other the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1163 class that the hard register is not. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1164 else if (code0 == REG && code1 == REG
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1165 && REGNO (arg0) < FIRST_PSEUDO_REGISTER
111
kono
parents: 67
diff changeset
1166 && (ok_for_base_p_nonstrict (arg0, mode, as, PLUS, REG)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1167 || ok_for_index_p_nonstrict (arg0)))
111
kono
parents: 67
diff changeset
1168 record_address_regs (mode, as, arg1,
kono
parents: 67
diff changeset
1169 ok_for_base_p_nonstrict (arg0, mode, as,
kono
parents: 67
diff changeset
1170 PLUS, REG) ? 1 : 0,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1171 PLUS, REG, scale);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1172 else if (code0 == REG && code1 == REG
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1173 && REGNO (arg1) < FIRST_PSEUDO_REGISTER
111
kono
parents: 67
diff changeset
1174 && (ok_for_base_p_nonstrict (arg1, mode, as, PLUS, REG)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1175 || ok_for_index_p_nonstrict (arg1)))
111
kono
parents: 67
diff changeset
1176 record_address_regs (mode, as, arg0,
kono
parents: 67
diff changeset
1177 ok_for_base_p_nonstrict (arg1, mode, as,
kono
parents: 67
diff changeset
1178 PLUS, REG) ? 1 : 0,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1179 PLUS, REG, scale);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1180 /* If one operand is known to be a pointer, it must be the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1181 base with the other operand the index. Likewise if the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1182 other operand is a MULT. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1183 else if ((code0 == REG && REG_POINTER (arg0)) || code1 == MULT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1184 {
111
kono
parents: 67
diff changeset
1185 record_address_regs (mode, as, arg0, 0, PLUS, code1, scale);
kono
parents: 67
diff changeset
1186 record_address_regs (mode, as, arg1, 1, PLUS, code0, scale);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1187 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1188 else if ((code1 == REG && REG_POINTER (arg1)) || code0 == MULT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1189 {
111
kono
parents: 67
diff changeset
1190 record_address_regs (mode, as, arg0, 1, PLUS, code1, scale);
kono
parents: 67
diff changeset
1191 record_address_regs (mode, as, arg1, 0, PLUS, code0, scale);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1192 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1193 /* Otherwise, count equal chances that each might be a base or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1194 index register. This case should be rare. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1195 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1196 {
111
kono
parents: 67
diff changeset
1197 record_address_regs (mode, as, arg0, 0, PLUS, code1, scale / 2);
kono
parents: 67
diff changeset
1198 record_address_regs (mode, as, arg0, 1, PLUS, code1, scale / 2);
kono
parents: 67
diff changeset
1199 record_address_regs (mode, as, arg1, 0, PLUS, code0, scale / 2);
kono
parents: 67
diff changeset
1200 record_address_regs (mode, as, arg1, 1, PLUS, code0, scale / 2);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1201 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1202 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1203 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1204
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1205 /* Double the importance of an allocno that is incremented or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1206 decremented, since it would take two extra insns if it ends
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1207 up in the wrong place. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1208 case POST_MODIFY:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1209 case PRE_MODIFY:
111
kono
parents: 67
diff changeset
1210 record_address_regs (mode, as, XEXP (x, 0), 0, code,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1211 GET_CODE (XEXP (XEXP (x, 1), 1)), 2 * scale);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1212 if (REG_P (XEXP (XEXP (x, 1), 1)))
111
kono
parents: 67
diff changeset
1213 record_address_regs (mode, as, XEXP (XEXP (x, 1), 1), 1, code, REG,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1214 2 * scale);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1215 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1216
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1217 case POST_INC:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1218 case PRE_INC:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1219 case POST_DEC:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1220 case PRE_DEC:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1221 /* Double the importance of an allocno that is incremented or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1222 decremented, since it would take two extra insns if it ends
111
kono
parents: 67
diff changeset
1223 up in the wrong place. */
kono
parents: 67
diff changeset
1224 record_address_regs (mode, as, XEXP (x, 0), 0, code, SCRATCH, 2 * scale);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1225 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1226
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1227 case REG:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1228 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1229 struct costs *pp;
111
kono
parents: 67
diff changeset
1230 int *pp_costs;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1231 enum reg_class i;
111
kono
parents: 67
diff changeset
1232 int k, regno, add_cost;
kono
parents: 67
diff changeset
1233 cost_classes_t cost_classes_ptr;
kono
parents: 67
diff changeset
1234 enum reg_class *cost_classes;
kono
parents: 67
diff changeset
1235 move_table *move_in_cost;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1236
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1237 if (REGNO (x) < FIRST_PSEUDO_REGISTER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1238 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1239
111
kono
parents: 67
diff changeset
1240 regno = REGNO (x);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1241 if (allocno_p)
111
kono
parents: 67
diff changeset
1242 ALLOCNO_BAD_SPILL_P (ira_curr_regno_allocno_map[regno]) = true;
kono
parents: 67
diff changeset
1243 pp = COSTS (costs, COST_INDEX (regno));
kono
parents: 67
diff changeset
1244 add_cost = (ira_memory_move_cost[Pmode][rclass][1] * scale) / 2;
kono
parents: 67
diff changeset
1245 if (INT_MAX - add_cost < pp->mem_cost)
kono
parents: 67
diff changeset
1246 pp->mem_cost = INT_MAX;
kono
parents: 67
diff changeset
1247 else
kono
parents: 67
diff changeset
1248 pp->mem_cost += add_cost;
kono
parents: 67
diff changeset
1249 cost_classes_ptr = regno_cost_classes[regno];
kono
parents: 67
diff changeset
1250 cost_classes = cost_classes_ptr->classes;
kono
parents: 67
diff changeset
1251 pp_costs = pp->cost;
kono
parents: 67
diff changeset
1252 ira_init_register_move_cost_if_necessary (Pmode);
kono
parents: 67
diff changeset
1253 move_in_cost = ira_may_move_in_cost[Pmode];
kono
parents: 67
diff changeset
1254 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1255 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1256 i = cost_classes[k];
111
kono
parents: 67
diff changeset
1257 add_cost = (move_in_cost[i][rclass] * scale) / 2;
kono
parents: 67
diff changeset
1258 if (INT_MAX - add_cost < pp_costs[k])
kono
parents: 67
diff changeset
1259 pp_costs[k] = INT_MAX;
kono
parents: 67
diff changeset
1260 else
kono
parents: 67
diff changeset
1261 pp_costs[k] += add_cost;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1262 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1263 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1264 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1265
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1266 default:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1267 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1268 const char *fmt = GET_RTX_FORMAT (code);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1269 int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1270 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1271 if (fmt[i] == 'e')
111
kono
parents: 67
diff changeset
1272 record_address_regs (mode, as, XEXP (x, i), context, code, SCRATCH,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1273 scale);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1274 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1275 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1276 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1277
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1278
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1279
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1280 /* Calculate the costs of insn operands. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1281 static void
111
kono
parents: 67
diff changeset
1282 record_operand_costs (rtx_insn *insn, enum reg_class *pref)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1283 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1284 const char *constraints[MAX_RECOG_OPERANDS];
111
kono
parents: 67
diff changeset
1285 machine_mode modes[MAX_RECOG_OPERANDS];
kono
parents: 67
diff changeset
1286 rtx ops[MAX_RECOG_OPERANDS];
kono
parents: 67
diff changeset
1287 rtx set;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1288 int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1289
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1290 for (i = 0; i < recog_data.n_operands; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1291 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1292 constraints[i] = recog_data.constraints[i];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1293 modes[i] = recog_data.operand_mode[i];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1294 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1295
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1296 /* If we get here, we are set up to record the costs of all the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1297 operands for this insn. Start by initializing the costs. Then
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1298 handle any address registers. Finally record the desired classes
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1299 for any allocnos, doing it twice if some pair of operands are
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1300 commutative. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1301 for (i = 0; i < recog_data.n_operands; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1302 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1303 memcpy (op_costs[i], init_cost, struct_costs_size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1304
111
kono
parents: 67
diff changeset
1305 ops[i] = recog_data.operand[i];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1306 if (GET_CODE (recog_data.operand[i]) == SUBREG)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1307 recog_data.operand[i] = SUBREG_REG (recog_data.operand[i]);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1308
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1309 if (MEM_P (recog_data.operand[i]))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1310 record_address_regs (GET_MODE (recog_data.operand[i]),
111
kono
parents: 67
diff changeset
1311 MEM_ADDR_SPACE (recog_data.operand[i]),
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1312 XEXP (recog_data.operand[i], 0),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1313 0, MEM, SCRATCH, frequency * 2);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1314 else if (constraints[i][0] == 'p'
111
kono
parents: 67
diff changeset
1315 || (insn_extra_address_constraint
kono
parents: 67
diff changeset
1316 (lookup_constraint (constraints[i]))))
kono
parents: 67
diff changeset
1317 record_address_regs (VOIDmode, ADDR_SPACE_GENERIC,
kono
parents: 67
diff changeset
1318 recog_data.operand[i], 0, ADDRESS, SCRATCH,
kono
parents: 67
diff changeset
1319 frequency * 2);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1320 }
111
kono
parents: 67
diff changeset
1321
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1322 /* Check for commutative in a separate loop so everything will have
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1323 been initialized. We must do this even if one operand is a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1324 constant--see addsi3 in m68k.md. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1325 for (i = 0; i < (int) recog_data.n_operands - 1; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1326 if (constraints[i][0] == '%')
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1327 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1328 const char *xconstraints[MAX_RECOG_OPERANDS];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1329 int j;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1330
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1331 /* Handle commutative operands by swapping the constraints.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1332 We assume the modes are the same. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1333 for (j = 0; j < recog_data.n_operands; j++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1334 xconstraints[j] = constraints[j];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1335
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1336 xconstraints[i] = constraints[i+1];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1337 xconstraints[i+1] = constraints[i];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1338 record_reg_classes (recog_data.n_alternatives, recog_data.n_operands,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1339 recog_data.operand, modes,
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1340 xconstraints, insn, pref);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1341 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1342 record_reg_classes (recog_data.n_alternatives, recog_data.n_operands,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1343 recog_data.operand, modes,
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1344 constraints, insn, pref);
111
kono
parents: 67
diff changeset
1345
kono
parents: 67
diff changeset
1346 /* If this insn is a single set copying operand 1 to operand 0 and
kono
parents: 67
diff changeset
1347 one operand is an allocno with the other a hard reg or an allocno
kono
parents: 67
diff changeset
1348 that prefers a hard register that is in its own register class
kono
parents: 67
diff changeset
1349 then we may want to adjust the cost of that register class to -1.
kono
parents: 67
diff changeset
1350
kono
parents: 67
diff changeset
1351 Avoid the adjustment if the source does not die to avoid
kono
parents: 67
diff changeset
1352 stressing of register allocator by preferencing two colliding
kono
parents: 67
diff changeset
1353 registers into single class.
kono
parents: 67
diff changeset
1354
kono
parents: 67
diff changeset
1355 Also avoid the adjustment if a copy between hard registers of the
kono
parents: 67
diff changeset
1356 class is expensive (ten times the cost of a default copy is
kono
parents: 67
diff changeset
1357 considered arbitrarily expensive). This avoids losing when the
kono
parents: 67
diff changeset
1358 preferred class is very expensive as the source of a copy
kono
parents: 67
diff changeset
1359 instruction. */
kono
parents: 67
diff changeset
1360 if ((set = single_set (insn)) != NULL_RTX
kono
parents: 67
diff changeset
1361 /* In rare cases the single set insn might have less 2 operands
kono
parents: 67
diff changeset
1362 as the source can be a fixed special reg. */
kono
parents: 67
diff changeset
1363 && recog_data.n_operands > 1
kono
parents: 67
diff changeset
1364 && ops[0] == SET_DEST (set) && ops[1] == SET_SRC (set))
kono
parents: 67
diff changeset
1365 {
kono
parents: 67
diff changeset
1366 int regno, other_regno;
kono
parents: 67
diff changeset
1367 rtx dest = SET_DEST (set);
kono
parents: 67
diff changeset
1368 rtx src = SET_SRC (set);
kono
parents: 67
diff changeset
1369
kono
parents: 67
diff changeset
1370 if (GET_CODE (dest) == SUBREG
kono
parents: 67
diff changeset
1371 && (GET_MODE_SIZE (GET_MODE (dest))
kono
parents: 67
diff changeset
1372 == GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest)))))
kono
parents: 67
diff changeset
1373 dest = SUBREG_REG (dest);
kono
parents: 67
diff changeset
1374 if (GET_CODE (src) == SUBREG
kono
parents: 67
diff changeset
1375 && (GET_MODE_SIZE (GET_MODE (src))
kono
parents: 67
diff changeset
1376 == GET_MODE_SIZE (GET_MODE (SUBREG_REG (src)))))
kono
parents: 67
diff changeset
1377 src = SUBREG_REG (src);
kono
parents: 67
diff changeset
1378 if (REG_P (src) && REG_P (dest)
kono
parents: 67
diff changeset
1379 && find_regno_note (insn, REG_DEAD, REGNO (src))
kono
parents: 67
diff changeset
1380 && (((regno = REGNO (src)) >= FIRST_PSEUDO_REGISTER
kono
parents: 67
diff changeset
1381 && (other_regno = REGNO (dest)) < FIRST_PSEUDO_REGISTER)
kono
parents: 67
diff changeset
1382 || ((regno = REGNO (dest)) >= FIRST_PSEUDO_REGISTER
kono
parents: 67
diff changeset
1383 && (other_regno = REGNO (src)) < FIRST_PSEUDO_REGISTER)))
kono
parents: 67
diff changeset
1384 {
kono
parents: 67
diff changeset
1385 machine_mode mode = GET_MODE (src);
kono
parents: 67
diff changeset
1386 cost_classes_t cost_classes_ptr = regno_cost_classes[regno];
kono
parents: 67
diff changeset
1387 enum reg_class *cost_classes = cost_classes_ptr->classes;
kono
parents: 67
diff changeset
1388 reg_class_t rclass;
kono
parents: 67
diff changeset
1389 int k;
kono
parents: 67
diff changeset
1390
kono
parents: 67
diff changeset
1391 i = regno == (int) REGNO (src) ? 1 : 0;
kono
parents: 67
diff changeset
1392 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
1393 {
kono
parents: 67
diff changeset
1394 rclass = cost_classes[k];
kono
parents: 67
diff changeset
1395 if (TEST_HARD_REG_BIT (reg_class_contents[rclass], other_regno)
kono
parents: 67
diff changeset
1396 && (reg_class_size[(int) rclass]
kono
parents: 67
diff changeset
1397 == ira_reg_class_max_nregs [(int) rclass][(int) mode]))
kono
parents: 67
diff changeset
1398 {
kono
parents: 67
diff changeset
1399 if (reg_class_size[rclass] == 1)
kono
parents: 67
diff changeset
1400 op_costs[i]->cost[k] = -frequency;
kono
parents: 67
diff changeset
1401 else if (in_hard_reg_set_p (reg_class_contents[rclass],
kono
parents: 67
diff changeset
1402 mode, other_regno))
kono
parents: 67
diff changeset
1403 op_costs[i]->cost[k] = -frequency;
kono
parents: 67
diff changeset
1404 }
kono
parents: 67
diff changeset
1405 }
kono
parents: 67
diff changeset
1406 }
kono
parents: 67
diff changeset
1407 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1408 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1409
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1410
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1411
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1412 /* Process one insn INSN. Scan it and record each time it would save
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1413 code to put a certain allocnos in a certain class. Return the last
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1414 insn processed, so that the scan can be continued from there. */
111
kono
parents: 67
diff changeset
1415 static rtx_insn *
kono
parents: 67
diff changeset
1416 scan_one_insn (rtx_insn *insn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1417 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1418 enum rtx_code pat_code;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1419 rtx set, note;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1420 int i, k;
111
kono
parents: 67
diff changeset
1421 bool counted_mem;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1422
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1423 if (!NONDEBUG_INSN_P (insn))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1424 return insn;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1425
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1426 pat_code = GET_CODE (PATTERN (insn));
111
kono
parents: 67
diff changeset
1427 if (pat_code == ASM_INPUT)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1428 return insn;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1429
111
kono
parents: 67
diff changeset
1430 /* If INSN is a USE/CLOBBER of a pseudo in a mode M then go ahead
kono
parents: 67
diff changeset
1431 and initialize the register move costs of mode M.
kono
parents: 67
diff changeset
1432
kono
parents: 67
diff changeset
1433 The pseudo may be related to another pseudo via a copy (implicit or
kono
parents: 67
diff changeset
1434 explicit) and if there are no mode M uses/sets of the original
kono
parents: 67
diff changeset
1435 pseudo, then we may leave the register move costs uninitialized for
kono
parents: 67
diff changeset
1436 mode M. */
kono
parents: 67
diff changeset
1437 if (pat_code == USE || pat_code == CLOBBER)
kono
parents: 67
diff changeset
1438 {
kono
parents: 67
diff changeset
1439 rtx x = XEXP (PATTERN (insn), 0);
kono
parents: 67
diff changeset
1440 if (GET_CODE (x) == REG
kono
parents: 67
diff changeset
1441 && REGNO (x) >= FIRST_PSEUDO_REGISTER
kono
parents: 67
diff changeset
1442 && have_regs_of_mode[GET_MODE (x)])
kono
parents: 67
diff changeset
1443 ira_init_register_move_cost_if_necessary (GET_MODE (x));
kono
parents: 67
diff changeset
1444 return insn;
kono
parents: 67
diff changeset
1445 }
kono
parents: 67
diff changeset
1446
kono
parents: 67
diff changeset
1447 counted_mem = false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1448 set = single_set (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1449 extract_insn (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1450
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1451 /* If this insn loads a parameter from its stack slot, then it
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1452 represents a savings, rather than a cost, if the parameter is
111
kono
parents: 67
diff changeset
1453 stored in memory. Record this fact.
kono
parents: 67
diff changeset
1454
kono
parents: 67
diff changeset
1455 Similarly if we're loading other constants from memory (constant
kono
parents: 67
diff changeset
1456 pool, TOC references, small data areas, etc) and this is the only
kono
parents: 67
diff changeset
1457 assignment to the destination pseudo.
kono
parents: 67
diff changeset
1458
kono
parents: 67
diff changeset
1459 Don't do this if SET_SRC (set) isn't a general operand, if it is
kono
parents: 67
diff changeset
1460 a memory requiring special instructions to load it, decreasing
kono
parents: 67
diff changeset
1461 mem_cost might result in it being loaded using the specialized
kono
parents: 67
diff changeset
1462 instruction into a register, then stored into stack and loaded
kono
parents: 67
diff changeset
1463 again from the stack. See PR52208.
kono
parents: 67
diff changeset
1464
kono
parents: 67
diff changeset
1465 Don't do this if SET_SRC (set) has side effect. See PR56124. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1466 if (set != 0 && REG_P (SET_DEST (set)) && MEM_P (SET_SRC (set))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1467 && (note = find_reg_note (insn, REG_EQUIV, NULL_RTX)) != NULL_RTX
111
kono
parents: 67
diff changeset
1468 && ((MEM_P (XEXP (note, 0))
kono
parents: 67
diff changeset
1469 && !side_effects_p (SET_SRC (set)))
kono
parents: 67
diff changeset
1470 || (CONSTANT_P (XEXP (note, 0))
kono
parents: 67
diff changeset
1471 && targetm.legitimate_constant_p (GET_MODE (SET_DEST (set)),
kono
parents: 67
diff changeset
1472 XEXP (note, 0))
kono
parents: 67
diff changeset
1473 && REG_N_SETS (REGNO (SET_DEST (set))) == 1))
kono
parents: 67
diff changeset
1474 && general_operand (SET_SRC (set), GET_MODE (SET_SRC (set)))
kono
parents: 67
diff changeset
1475 /* LRA does not use equiv with a symbol for PIC code. */
kono
parents: 67
diff changeset
1476 && (! ira_use_lra_p || ! pic_offset_table_rtx
kono
parents: 67
diff changeset
1477 || ! contains_symbol_ref_p (XEXP (note, 0))))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1478 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1479 enum reg_class cl = GENERAL_REGS;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1480 rtx reg = SET_DEST (set);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1481 int num = COST_INDEX (REGNO (reg));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1482
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1483 COSTS (costs, num)->mem_cost
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1484 -= ira_memory_move_cost[GET_MODE (reg)][cl][1] * frequency;
111
kono
parents: 67
diff changeset
1485 record_address_regs (GET_MODE (SET_SRC (set)),
kono
parents: 67
diff changeset
1486 MEM_ADDR_SPACE (SET_SRC (set)),
kono
parents: 67
diff changeset
1487 XEXP (SET_SRC (set), 0), 0, MEM, SCRATCH,
kono
parents: 67
diff changeset
1488 frequency * 2);
kono
parents: 67
diff changeset
1489 counted_mem = true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1490 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1491
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1492 record_operand_costs (insn, pref);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1493
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1494 /* Now add the cost for each operand to the total costs for its
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1495 allocno. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1496 for (i = 0; i < recog_data.n_operands; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1497 if (REG_P (recog_data.operand[i])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1498 && REGNO (recog_data.operand[i]) >= FIRST_PSEUDO_REGISTER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1499 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1500 int regno = REGNO (recog_data.operand[i]);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1501 struct costs *p = COSTS (costs, COST_INDEX (regno));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1502 struct costs *q = op_costs[i];
111
kono
parents: 67
diff changeset
1503 int *p_costs = p->cost, *q_costs = q->cost;
kono
parents: 67
diff changeset
1504 cost_classes_t cost_classes_ptr = regno_cost_classes[regno];
kono
parents: 67
diff changeset
1505 int add_cost;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1506
111
kono
parents: 67
diff changeset
1507 /* If the already accounted for the memory "cost" above, don't
kono
parents: 67
diff changeset
1508 do so again. */
kono
parents: 67
diff changeset
1509 if (!counted_mem)
kono
parents: 67
diff changeset
1510 {
kono
parents: 67
diff changeset
1511 add_cost = q->mem_cost;
kono
parents: 67
diff changeset
1512 if (add_cost > 0 && INT_MAX - add_cost < p->mem_cost)
kono
parents: 67
diff changeset
1513 p->mem_cost = INT_MAX;
kono
parents: 67
diff changeset
1514 else
kono
parents: 67
diff changeset
1515 p->mem_cost += add_cost;
kono
parents: 67
diff changeset
1516 }
kono
parents: 67
diff changeset
1517 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
1518 {
kono
parents: 67
diff changeset
1519 add_cost = q_costs[k];
kono
parents: 67
diff changeset
1520 if (add_cost > 0 && INT_MAX - add_cost < p_costs[k])
kono
parents: 67
diff changeset
1521 p_costs[k] = INT_MAX;
kono
parents: 67
diff changeset
1522 else
kono
parents: 67
diff changeset
1523 p_costs[k] += add_cost;
kono
parents: 67
diff changeset
1524 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1525 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1526
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1527 return insn;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1528 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1529
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1530
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1531
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1532 /* Print allocnos costs to file F. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1533 static void
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1534 print_allocno_costs (FILE *f)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1535 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1536 int k;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1537 ira_allocno_t a;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1538 ira_allocno_iterator ai;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1539
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1540 ira_assert (allocno_p);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1541 fprintf (f, "\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1542 FOR_EACH_ALLOCNO (a, ai)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1543 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1544 int i, rclass;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1545 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1546 int regno = ALLOCNO_REGNO (a);
111
kono
parents: 67
diff changeset
1547 cost_classes_t cost_classes_ptr = regno_cost_classes[regno];
kono
parents: 67
diff changeset
1548 enum reg_class *cost_classes = cost_classes_ptr->classes;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1549
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1550 i = ALLOCNO_NUM (a);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1551 fprintf (f, " a%d(r%d,", i, regno);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1552 if ((bb = ALLOCNO_LOOP_TREE_NODE (a)->bb) != NULL)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1553 fprintf (f, "b%d", bb->index);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1554 else
111
kono
parents: 67
diff changeset
1555 fprintf (f, "l%d", ALLOCNO_LOOP_TREE_NODE (a)->loop_num);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1556 fprintf (f, ") costs:");
111
kono
parents: 67
diff changeset
1557 for (k = 0; k < cost_classes_ptr->num; k++)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1558 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1559 rclass = cost_classes[k];
111
kono
parents: 67
diff changeset
1560 fprintf (f, " %s:%d", reg_class_names[rclass],
kono
parents: 67
diff changeset
1561 COSTS (costs, i)->cost[k]);
kono
parents: 67
diff changeset
1562 if (flag_ira_region == IRA_REGION_ALL
kono
parents: 67
diff changeset
1563 || flag_ira_region == IRA_REGION_MIXED)
kono
parents: 67
diff changeset
1564 fprintf (f, ",%d", COSTS (total_allocno_costs, i)->cost[k]);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1565 }
111
kono
parents: 67
diff changeset
1566 fprintf (f, " MEM:%i", COSTS (costs, i)->mem_cost);
kono
parents: 67
diff changeset
1567 if (flag_ira_region == IRA_REGION_ALL
kono
parents: 67
diff changeset
1568 || flag_ira_region == IRA_REGION_MIXED)
kono
parents: 67
diff changeset
1569 fprintf (f, ",%d", COSTS (total_allocno_costs, i)->mem_cost);
kono
parents: 67
diff changeset
1570 fprintf (f, "\n");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1571 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1572 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1573
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1574 /* Print pseudo costs to file F. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1575 static void
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1576 print_pseudo_costs (FILE *f)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1577 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1578 int regno, k;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1579 int rclass;
111
kono
parents: 67
diff changeset
1580 cost_classes_t cost_classes_ptr;
kono
parents: 67
diff changeset
1581 enum reg_class *cost_classes;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1582
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1583 ira_assert (! allocno_p);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1584 fprintf (f, "\n");
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1585 for (regno = max_reg_num () - 1; regno >= FIRST_PSEUDO_REGISTER; regno--)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1586 {
111
kono
parents: 67
diff changeset
1587 if (REG_N_REFS (regno) <= 0)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1588 continue;
111
kono
parents: 67
diff changeset
1589 cost_classes_ptr = regno_cost_classes[regno];
kono
parents: 67
diff changeset
1590 cost_classes = cost_classes_ptr->classes;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1591 fprintf (f, " r%d costs:", regno);
111
kono
parents: 67
diff changeset
1592 for (k = 0; k < cost_classes_ptr->num; k++)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1593 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1594 rclass = cost_classes[k];
111
kono
parents: 67
diff changeset
1595 fprintf (f, " %s:%d", reg_class_names[rclass],
kono
parents: 67
diff changeset
1596 COSTS (costs, regno)->cost[k]);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1597 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1598 fprintf (f, " MEM:%i\n", COSTS (costs, regno)->mem_cost);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1599 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1600 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1601
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1602 /* Traverse the BB represented by LOOP_TREE_NODE to update the allocno
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1603 costs. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1604 static void
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1605 process_bb_for_costs (basic_block bb)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1606 {
111
kono
parents: 67
diff changeset
1607 rtx_insn *insn;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1608
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1609 frequency = REG_FREQ_FROM_BB (bb);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1610 if (frequency == 0)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1611 frequency = 1;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1612 FOR_BB_INSNS (bb, insn)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1613 insn = scan_one_insn (insn);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1614 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1615
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1616 /* Traverse the BB represented by LOOP_TREE_NODE to update the allocno
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1617 costs. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1618 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1619 process_bb_node_for_costs (ira_loop_tree_node_t loop_tree_node)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1620 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1621 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1622
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1623 bb = loop_tree_node->bb;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1624 if (bb != NULL)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1625 process_bb_for_costs (bb);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1626 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1627
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1628 /* Find costs of register classes and memory for allocnos or pseudos
111
kono
parents: 67
diff changeset
1629 and their best costs. Set up preferred, alternative and allocno
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1630 classes for pseudos. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1631 static void
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1632 find_costs_and_classes (FILE *dump_file)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1633 {
111
kono
parents: 67
diff changeset
1634 int i, k, start, max_cost_classes_num;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1635 int pass;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1636 basic_block bb;
111
kono
parents: 67
diff changeset
1637 enum reg_class *regno_best_class, new_class;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1638
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1639 init_recog ();
111
kono
parents: 67
diff changeset
1640 regno_best_class
kono
parents: 67
diff changeset
1641 = (enum reg_class *) ira_allocate (max_reg_num ()
kono
parents: 67
diff changeset
1642 * sizeof (enum reg_class));
kono
parents: 67
diff changeset
1643 for (i = max_reg_num () - 1; i >= FIRST_PSEUDO_REGISTER; i--)
kono
parents: 67
diff changeset
1644 regno_best_class[i] = NO_REGS;
kono
parents: 67
diff changeset
1645 if (!resize_reg_info () && allocno_p
kono
parents: 67
diff changeset
1646 && pseudo_classes_defined_p && flag_expensive_optimizations)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1647 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1648 ira_allocno_t a;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1649 ira_allocno_iterator ai;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1650
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1651 pref = pref_buffer;
111
kono
parents: 67
diff changeset
1652 max_cost_classes_num = 1;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1653 FOR_EACH_ALLOCNO (a, ai)
111
kono
parents: 67
diff changeset
1654 {
kono
parents: 67
diff changeset
1655 pref[ALLOCNO_NUM (a)] = reg_preferred_class (ALLOCNO_REGNO (a));
kono
parents: 67
diff changeset
1656 setup_regno_cost_classes_by_aclass
kono
parents: 67
diff changeset
1657 (ALLOCNO_REGNO (a), pref[ALLOCNO_NUM (a)]);
kono
parents: 67
diff changeset
1658 max_cost_classes_num
kono
parents: 67
diff changeset
1659 = MAX (max_cost_classes_num,
kono
parents: 67
diff changeset
1660 regno_cost_classes[ALLOCNO_REGNO (a)]->num);
kono
parents: 67
diff changeset
1661 }
kono
parents: 67
diff changeset
1662 start = 1;
kono
parents: 67
diff changeset
1663 }
kono
parents: 67
diff changeset
1664 else
kono
parents: 67
diff changeset
1665 {
kono
parents: 67
diff changeset
1666 pref = NULL;
kono
parents: 67
diff changeset
1667 max_cost_classes_num = ira_important_classes_num;
kono
parents: 67
diff changeset
1668 for (i = max_reg_num () - 1; i >= FIRST_PSEUDO_REGISTER; i--)
kono
parents: 67
diff changeset
1669 if (regno_reg_rtx[i] != NULL_RTX)
kono
parents: 67
diff changeset
1670 setup_regno_cost_classes_by_mode (i, PSEUDO_REGNO_MODE (i));
kono
parents: 67
diff changeset
1671 else
kono
parents: 67
diff changeset
1672 setup_regno_cost_classes_by_aclass (i, ALL_REGS);
kono
parents: 67
diff changeset
1673 start = 0;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1674 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1675 if (allocno_p)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1676 /* Clear the flag for the next compiled function. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1677 pseudo_classes_defined_p = false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1678 /* Normally we scan the insns once and determine the best class to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1679 use for each allocno. However, if -fexpensive-optimizations are
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1680 on, we do so twice, the second time using the tentative best
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1681 classes to guide the selection. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1682 for (pass = start; pass <= flag_expensive_optimizations; pass++)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1683 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1684 if ((!allocno_p || internal_flag_ira_verbose > 0) && dump_file)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1685 fprintf (dump_file,
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1686 "\nPass %i for finding pseudo/allocno costs\n\n", pass);
111
kono
parents: 67
diff changeset
1687
kono
parents: 67
diff changeset
1688 if (pass != start)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1689 {
111
kono
parents: 67
diff changeset
1690 max_cost_classes_num = 1;
kono
parents: 67
diff changeset
1691 for (i = max_reg_num () - 1; i >= FIRST_PSEUDO_REGISTER; i--)
kono
parents: 67
diff changeset
1692 {
kono
parents: 67
diff changeset
1693 setup_regno_cost_classes_by_aclass (i, regno_best_class[i]);
kono
parents: 67
diff changeset
1694 max_cost_classes_num
kono
parents: 67
diff changeset
1695 = MAX (max_cost_classes_num, regno_cost_classes[i]->num);
kono
parents: 67
diff changeset
1696 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1697 }
111
kono
parents: 67
diff changeset
1698
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1699 struct_costs_size
111
kono
parents: 67
diff changeset
1700 = sizeof (struct costs) + sizeof (int) * (max_cost_classes_num - 1);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1701 /* Zero out our accumulation of the cost of each class for each
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1702 allocno. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1703 memset (costs, 0, cost_elements_num * struct_costs_size);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1704
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1705 if (allocno_p)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1706 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1707 /* Scan the instructions and record each time it would save code
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1708 to put a certain allocno in a certain class. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1709 ira_traverse_loop_tree (true, ira_loop_tree_root,
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1710 process_bb_node_for_costs, NULL);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1711
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1712 memcpy (total_allocno_costs, costs,
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1713 max_struct_costs_size * ira_allocnos_num);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1714 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1715 else
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1716 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1717 basic_block bb;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1718
111
kono
parents: 67
diff changeset
1719 FOR_EACH_BB_FN (bb, cfun)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1720 process_bb_for_costs (bb);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1721 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1722
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1723 if (pass == 0)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1724 pref = pref_buffer;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1725
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1726 /* Now for each allocno look at how desirable each class is and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1727 find which class is preferred. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1728 for (i = max_reg_num () - 1; i >= FIRST_PSEUDO_REGISTER; i--)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1729 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1730 ira_allocno_t a, parent_a;
111
kono
parents: 67
diff changeset
1731 int rclass, a_num, parent_a_num, add_cost;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1732 ira_loop_tree_node_t parent;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1733 int best_cost, allocno_cost;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1734 enum reg_class best, alt_class;
111
kono
parents: 67
diff changeset
1735 cost_classes_t cost_classes_ptr = regno_cost_classes[i];
kono
parents: 67
diff changeset
1736 enum reg_class *cost_classes;
kono
parents: 67
diff changeset
1737 int *i_costs = temp_costs->cost;
kono
parents: 67
diff changeset
1738 int i_mem_cost;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1739 int equiv_savings = regno_equiv_gains[i];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1740
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1741 if (! allocno_p)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1742 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1743 if (regno_reg_rtx[i] == NULL_RTX)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1744 continue;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1745 memcpy (temp_costs, COSTS (costs, i), struct_costs_size);
111
kono
parents: 67
diff changeset
1746 i_mem_cost = temp_costs->mem_cost;
kono
parents: 67
diff changeset
1747 cost_classes = cost_classes_ptr->classes;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1748 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1749 else
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1750 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1751 if (ira_regno_allocno_map[i] == NULL)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1752 continue;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1753 memset (temp_costs, 0, struct_costs_size);
111
kono
parents: 67
diff changeset
1754 i_mem_cost = 0;
kono
parents: 67
diff changeset
1755 cost_classes = cost_classes_ptr->classes;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1756 /* Find cost of all allocnos with the same regno. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1757 for (a = ira_regno_allocno_map[i];
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1758 a != NULL;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1759 a = ALLOCNO_NEXT_REGNO_ALLOCNO (a))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1760 {
111
kono
parents: 67
diff changeset
1761 int *a_costs, *p_costs;
kono
parents: 67
diff changeset
1762
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1763 a_num = ALLOCNO_NUM (a);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1764 if ((flag_ira_region == IRA_REGION_ALL
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1765 || flag_ira_region == IRA_REGION_MIXED)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1766 && (parent = ALLOCNO_LOOP_TREE_NODE (a)->parent) != NULL
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1767 && (parent_a = parent->regno_allocno_map[i]) != NULL
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1768 /* There are no caps yet. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1769 && bitmap_bit_p (ALLOCNO_LOOP_TREE_NODE
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1770 (a)->border_allocnos,
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1771 ALLOCNO_NUM (a)))
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1772 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1773 /* Propagate costs to upper levels in the region
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1774 tree. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1775 parent_a_num = ALLOCNO_NUM (parent_a);
111
kono
parents: 67
diff changeset
1776 a_costs = COSTS (total_allocno_costs, a_num)->cost;
kono
parents: 67
diff changeset
1777 p_costs = COSTS (total_allocno_costs, parent_a_num)->cost;
kono
parents: 67
diff changeset
1778 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
1779 {
kono
parents: 67
diff changeset
1780 add_cost = a_costs[k];
kono
parents: 67
diff changeset
1781 if (add_cost > 0 && INT_MAX - add_cost < p_costs[k])
kono
parents: 67
diff changeset
1782 p_costs[k] = INT_MAX;
kono
parents: 67
diff changeset
1783 else
kono
parents: 67
diff changeset
1784 p_costs[k] += add_cost;
kono
parents: 67
diff changeset
1785 }
kono
parents: 67
diff changeset
1786 add_cost = COSTS (total_allocno_costs, a_num)->mem_cost;
kono
parents: 67
diff changeset
1787 if (add_cost > 0
kono
parents: 67
diff changeset
1788 && (INT_MAX - add_cost
kono
parents: 67
diff changeset
1789 < COSTS (total_allocno_costs,
kono
parents: 67
diff changeset
1790 parent_a_num)->mem_cost))
kono
parents: 67
diff changeset
1791 COSTS (total_allocno_costs, parent_a_num)->mem_cost
kono
parents: 67
diff changeset
1792 = INT_MAX;
kono
parents: 67
diff changeset
1793 else
kono
parents: 67
diff changeset
1794 COSTS (total_allocno_costs, parent_a_num)->mem_cost
kono
parents: 67
diff changeset
1795 += add_cost;
kono
parents: 67
diff changeset
1796
kono
parents: 67
diff changeset
1797 if (i >= first_moveable_pseudo && i < last_moveable_pseudo)
kono
parents: 67
diff changeset
1798 COSTS (total_allocno_costs, parent_a_num)->mem_cost = 0;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1799 }
111
kono
parents: 67
diff changeset
1800 a_costs = COSTS (costs, a_num)->cost;
kono
parents: 67
diff changeset
1801 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
1802 {
kono
parents: 67
diff changeset
1803 add_cost = a_costs[k];
kono
parents: 67
diff changeset
1804 if (add_cost > 0 && INT_MAX - add_cost < i_costs[k])
kono
parents: 67
diff changeset
1805 i_costs[k] = INT_MAX;
kono
parents: 67
diff changeset
1806 else
kono
parents: 67
diff changeset
1807 i_costs[k] += add_cost;
kono
parents: 67
diff changeset
1808 }
kono
parents: 67
diff changeset
1809 add_cost = COSTS (costs, a_num)->mem_cost;
kono
parents: 67
diff changeset
1810 if (add_cost > 0 && INT_MAX - add_cost < i_mem_cost)
kono
parents: 67
diff changeset
1811 i_mem_cost = INT_MAX;
kono
parents: 67
diff changeset
1812 else
kono
parents: 67
diff changeset
1813 i_mem_cost += add_cost;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1814 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1815 }
111
kono
parents: 67
diff changeset
1816 if (i >= first_moveable_pseudo && i < last_moveable_pseudo)
kono
parents: 67
diff changeset
1817 i_mem_cost = 0;
kono
parents: 67
diff changeset
1818 else if (equiv_savings < 0)
kono
parents: 67
diff changeset
1819 i_mem_cost = -equiv_savings;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1820 else if (equiv_savings > 0)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1821 {
111
kono
parents: 67
diff changeset
1822 i_mem_cost = 0;
kono
parents: 67
diff changeset
1823 for (k = cost_classes_ptr->num - 1; k >= 0; k--)
kono
parents: 67
diff changeset
1824 i_costs[k] += equiv_savings;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1825 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1826
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1827 best_cost = (1 << (HOST_BITS_PER_INT - 2)) - 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1828 best = ALL_REGS;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1829 alt_class = NO_REGS;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1830 /* Find best common class for all allocnos with the same
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1831 regno. */
111
kono
parents: 67
diff changeset
1832 for (k = 0; k < cost_classes_ptr->num; k++)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1833 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1834 rclass = cost_classes[k];
111
kono
parents: 67
diff changeset
1835 if (i_costs[k] < best_cost)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1836 {
111
kono
parents: 67
diff changeset
1837 best_cost = i_costs[k];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1838 best = (enum reg_class) rclass;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1839 }
111
kono
parents: 67
diff changeset
1840 else if (i_costs[k] == best_cost)
kono
parents: 67
diff changeset
1841 best = ira_reg_class_subunion[best][rclass];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1842 if (pass == flag_expensive_optimizations
111
kono
parents: 67
diff changeset
1843 /* We still prefer registers to memory even at this
kono
parents: 67
diff changeset
1844 stage if their costs are the same. We will make
kono
parents: 67
diff changeset
1845 a final decision during assigning hard registers
kono
parents: 67
diff changeset
1846 when we have all info including more accurate
kono
parents: 67
diff changeset
1847 costs which might be affected by assigning hard
kono
parents: 67
diff changeset
1848 registers to other pseudos because the pseudos
kono
parents: 67
diff changeset
1849 involved in moves can be coalesced. */
kono
parents: 67
diff changeset
1850 && i_costs[k] <= i_mem_cost
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1851 && (reg_class_size[reg_class_subunion[alt_class][rclass]]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1852 > reg_class_size[alt_class]))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1853 alt_class = reg_class_subunion[alt_class][rclass];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1854 }
111
kono
parents: 67
diff changeset
1855 alt_class = ira_allocno_class_translate[alt_class];
kono
parents: 67
diff changeset
1856 if (best_cost > i_mem_cost
kono
parents: 67
diff changeset
1857 && ! non_spilled_static_chain_regno_p (i))
kono
parents: 67
diff changeset
1858 regno_aclass[i] = NO_REGS;
kono
parents: 67
diff changeset
1859 else if (!optimize && !targetm.class_likely_spilled_p (best))
kono
parents: 67
diff changeset
1860 /* Registers in the alternative class are likely to need
kono
parents: 67
diff changeset
1861 longer or slower sequences than registers in the best class.
kono
parents: 67
diff changeset
1862 When optimizing we make some effort to use the best class
kono
parents: 67
diff changeset
1863 over the alternative class where possible, but at -O0 we
kono
parents: 67
diff changeset
1864 effectively give the alternative class equal weight.
kono
parents: 67
diff changeset
1865 We then run the risk of using slower alternative registers
kono
parents: 67
diff changeset
1866 when plenty of registers from the best class are still free.
kono
parents: 67
diff changeset
1867 This is especially true because live ranges tend to be very
kono
parents: 67
diff changeset
1868 short in -O0 code and so register pressure tends to be low.
kono
parents: 67
diff changeset
1869
kono
parents: 67
diff changeset
1870 Avoid that by ignoring the alternative class if the best
kono
parents: 67
diff changeset
1871 class has plenty of registers.
kono
parents: 67
diff changeset
1872
kono
parents: 67
diff changeset
1873 The union class arrays give important classes and only
kono
parents: 67
diff changeset
1874 part of it are allocno classes. So translate them into
kono
parents: 67
diff changeset
1875 allocno classes. */
kono
parents: 67
diff changeset
1876 regno_aclass[i] = ira_allocno_class_translate[best];
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1877 else
111
kono
parents: 67
diff changeset
1878 {
kono
parents: 67
diff changeset
1879 /* Make the common class the biggest class of best and
kono
parents: 67
diff changeset
1880 alt_class. Translate the common class into an
kono
parents: 67
diff changeset
1881 allocno class too. */
kono
parents: 67
diff changeset
1882 regno_aclass[i] = (ira_allocno_class_translate
kono
parents: 67
diff changeset
1883 [ira_reg_class_superunion[best][alt_class]]);
kono
parents: 67
diff changeset
1884 ira_assert (regno_aclass[i] != NO_REGS
kono
parents: 67
diff changeset
1885 && ira_reg_allocno_class_p[regno_aclass[i]]);
kono
parents: 67
diff changeset
1886 }
kono
parents: 67
diff changeset
1887 if ((new_class
kono
parents: 67
diff changeset
1888 = (reg_class) (targetm.ira_change_pseudo_allocno_class
kono
parents: 67
diff changeset
1889 (i, regno_aclass[i], best))) != regno_aclass[i])
kono
parents: 67
diff changeset
1890 {
kono
parents: 67
diff changeset
1891 regno_aclass[i] = new_class;
kono
parents: 67
diff changeset
1892 if (hard_reg_set_subset_p (reg_class_contents[new_class],
kono
parents: 67
diff changeset
1893 reg_class_contents[best]))
kono
parents: 67
diff changeset
1894 best = new_class;
kono
parents: 67
diff changeset
1895 if (hard_reg_set_subset_p (reg_class_contents[new_class],
kono
parents: 67
diff changeset
1896 reg_class_contents[alt_class]))
kono
parents: 67
diff changeset
1897 alt_class = new_class;
kono
parents: 67
diff changeset
1898 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1899 if (pass == flag_expensive_optimizations)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1900 {
111
kono
parents: 67
diff changeset
1901 if (best_cost > i_mem_cost
kono
parents: 67
diff changeset
1902 /* Do not assign NO_REGS to static chain pointer
kono
parents: 67
diff changeset
1903 pseudo when non-local goto is used. */
kono
parents: 67
diff changeset
1904 && ! non_spilled_static_chain_regno_p (i))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1905 best = alt_class = NO_REGS;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1906 else if (best == alt_class)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1907 alt_class = NO_REGS;
111
kono
parents: 67
diff changeset
1908 setup_reg_classes (i, best, alt_class, regno_aclass[i]);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1909 if ((!allocno_p || internal_flag_ira_verbose > 2)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1910 && dump_file != NULL)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1911 fprintf (dump_file,
111
kono
parents: 67
diff changeset
1912 " r%d: preferred %s, alternative %s, allocno %s\n",
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1913 i, reg_class_names[best], reg_class_names[alt_class],
111
kono
parents: 67
diff changeset
1914 reg_class_names[regno_aclass[i]]);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1915 }
111
kono
parents: 67
diff changeset
1916 regno_best_class[i] = best;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1917 if (! allocno_p)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1918 {
111
kono
parents: 67
diff changeset
1919 pref[i] = (best_cost > i_mem_cost
kono
parents: 67
diff changeset
1920 && ! non_spilled_static_chain_regno_p (i)
kono
parents: 67
diff changeset
1921 ? NO_REGS : best);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1922 continue;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1923 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1924 for (a = ira_regno_allocno_map[i];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1925 a != NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1926 a = ALLOCNO_NEXT_REGNO_ALLOCNO (a))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1927 {
111
kono
parents: 67
diff changeset
1928 enum reg_class aclass = regno_aclass[i];
kono
parents: 67
diff changeset
1929 int a_num = ALLOCNO_NUM (a);
kono
parents: 67
diff changeset
1930 int *total_a_costs = COSTS (total_allocno_costs, a_num)->cost;
kono
parents: 67
diff changeset
1931 int *a_costs = COSTS (costs, a_num)->cost;
kono
parents: 67
diff changeset
1932
kono
parents: 67
diff changeset
1933 if (aclass == NO_REGS)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1934 best = NO_REGS;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1935 else
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1936 {
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1937 /* Finding best class which is subset of the common
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1938 class. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1939 best_cost = (1 << (HOST_BITS_PER_INT - 2)) - 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1940 allocno_cost = best_cost;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1941 best = ALL_REGS;
111
kono
parents: 67
diff changeset
1942 for (k = 0; k < cost_classes_ptr->num; k++)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1943 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1944 rclass = cost_classes[k];
111
kono
parents: 67
diff changeset
1945 if (! ira_class_subset_p[rclass][aclass])
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1946 continue;
111
kono
parents: 67
diff changeset
1947 if (total_a_costs[k] < best_cost)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1948 {
111
kono
parents: 67
diff changeset
1949 best_cost = total_a_costs[k];
kono
parents: 67
diff changeset
1950 allocno_cost = a_costs[k];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1951 best = (enum reg_class) rclass;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1952 }
111
kono
parents: 67
diff changeset
1953 else if (total_a_costs[k] == best_cost)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1954 {
111
kono
parents: 67
diff changeset
1955 best = ira_reg_class_subunion[best][rclass];
kono
parents: 67
diff changeset
1956 allocno_cost = MAX (allocno_cost, a_costs[k]);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1957 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1958 }
111
kono
parents: 67
diff changeset
1959 ALLOCNO_CLASS_COST (a) = allocno_cost;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1960 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1961 if (internal_flag_ira_verbose > 2 && dump_file != NULL
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1962 && (pass == 0 || pref[a_num] != best))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1963 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1964 fprintf (dump_file, " a%d (r%d,", a_num, i);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1965 if ((bb = ALLOCNO_LOOP_TREE_NODE (a)->bb) != NULL)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1966 fprintf (dump_file, "b%d", bb->index);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1967 else
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1968 fprintf (dump_file, "l%d",
111
kono
parents: 67
diff changeset
1969 ALLOCNO_LOOP_TREE_NODE (a)->loop_num);
kono
parents: 67
diff changeset
1970 fprintf (dump_file, ") best %s, allocno %s\n",
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1971 reg_class_names[best],
111
kono
parents: 67
diff changeset
1972 reg_class_names[aclass]);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1973 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1974 pref[a_num] = best;
111
kono
parents: 67
diff changeset
1975 if (pass == flag_expensive_optimizations && best != aclass
kono
parents: 67
diff changeset
1976 && ira_class_hard_regs_num[best] > 0
kono
parents: 67
diff changeset
1977 && (ira_reg_class_max_nregs[best][ALLOCNO_MODE (a)]
kono
parents: 67
diff changeset
1978 >= ira_class_hard_regs_num[best]))
kono
parents: 67
diff changeset
1979 {
kono
parents: 67
diff changeset
1980 int ind = cost_classes_ptr->index[aclass];
kono
parents: 67
diff changeset
1981
kono
parents: 67
diff changeset
1982 ira_assert (ind >= 0);
kono
parents: 67
diff changeset
1983 ira_init_register_move_cost_if_necessary (ALLOCNO_MODE (a));
kono
parents: 67
diff changeset
1984 ira_add_allocno_pref (a, ira_class_hard_regs[best][0],
kono
parents: 67
diff changeset
1985 (a_costs[ind] - ALLOCNO_CLASS_COST (a))
kono
parents: 67
diff changeset
1986 / (ira_register_move_cost
kono
parents: 67
diff changeset
1987 [ALLOCNO_MODE (a)][best][aclass]));
kono
parents: 67
diff changeset
1988 for (k = 0; k < cost_classes_ptr->num; k++)
kono
parents: 67
diff changeset
1989 if (ira_class_subset_p[cost_classes[k]][best])
kono
parents: 67
diff changeset
1990 a_costs[k] = a_costs[ind];
kono
parents: 67
diff changeset
1991 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1992 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1993 }
111
kono
parents: 67
diff changeset
1994
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1995 if (internal_flag_ira_verbose > 4 && dump_file)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1996 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1997 if (allocno_p)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1998 print_allocno_costs (dump_file);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
1999 else
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2000 print_pseudo_costs (dump_file);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2001 fprintf (dump_file,"\n");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2002 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2003 }
111
kono
parents: 67
diff changeset
2004 ira_free (regno_best_class);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2005 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2006
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2007
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2008
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2009 /* Process moves involving hard regs to modify allocno hard register
111
kono
parents: 67
diff changeset
2010 costs. We can do this only after determining allocno class. If a
kono
parents: 67
diff changeset
2011 hard register forms a register class, then moves with the hard
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2012 register are already taken into account in class costs for the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2013 allocno. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2014 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2015 process_bb_node_for_hard_reg_moves (ira_loop_tree_node_t loop_tree_node)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2016 {
111
kono
parents: 67
diff changeset
2017 int i, freq, src_regno, dst_regno, hard_regno, a_regno;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2018 bool to_p;
111
kono
parents: 67
diff changeset
2019 ira_allocno_t a, curr_a;
kono
parents: 67
diff changeset
2020 ira_loop_tree_node_t curr_loop_tree_node;
kono
parents: 67
diff changeset
2021 enum reg_class rclass;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2022 basic_block bb;
111
kono
parents: 67
diff changeset
2023 rtx_insn *insn;
kono
parents: 67
diff changeset
2024 rtx set, src, dst;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2025
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2026 bb = loop_tree_node->bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2027 if (bb == NULL)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2028 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2029 freq = REG_FREQ_FROM_BB (bb);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2030 if (freq == 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2031 freq = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2032 FOR_BB_INSNS (bb, insn)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2033 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2034 if (!NONDEBUG_INSN_P (insn))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2035 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2036 set = single_set (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2037 if (set == NULL_RTX)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2038 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2039 dst = SET_DEST (set);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2040 src = SET_SRC (set);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2041 if (! REG_P (dst) || ! REG_P (src))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2042 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2043 dst_regno = REGNO (dst);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2044 src_regno = REGNO (src);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2045 if (dst_regno >= FIRST_PSEUDO_REGISTER
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2046 && src_regno < FIRST_PSEUDO_REGISTER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2047 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2048 hard_regno = src_regno;
111
kono
parents: 67
diff changeset
2049 a = ira_curr_regno_allocno_map[dst_regno];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2050 to_p = true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2051 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2052 else if (src_regno >= FIRST_PSEUDO_REGISTER
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2053 && dst_regno < FIRST_PSEUDO_REGISTER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2054 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2055 hard_regno = dst_regno;
111
kono
parents: 67
diff changeset
2056 a = ira_curr_regno_allocno_map[src_regno];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2057 to_p = false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2058 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2059 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2060 continue;
111
kono
parents: 67
diff changeset
2061 rclass = ALLOCNO_CLASS (a);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2062 if (! TEST_HARD_REG_BIT (reg_class_contents[rclass], hard_regno))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2063 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2064 i = ira_class_hard_reg_index[rclass][hard_regno];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2065 if (i < 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2066 continue;
111
kono
parents: 67
diff changeset
2067 a_regno = ALLOCNO_REGNO (a);
kono
parents: 67
diff changeset
2068 for (curr_loop_tree_node = ALLOCNO_LOOP_TREE_NODE (a);
kono
parents: 67
diff changeset
2069 curr_loop_tree_node != NULL;
kono
parents: 67
diff changeset
2070 curr_loop_tree_node = curr_loop_tree_node->parent)
kono
parents: 67
diff changeset
2071 if ((curr_a = curr_loop_tree_node->regno_allocno_map[a_regno]) != NULL)
kono
parents: 67
diff changeset
2072 ira_add_allocno_pref (curr_a, hard_regno, freq);
kono
parents: 67
diff changeset
2073 {
kono
parents: 67
diff changeset
2074 int cost;
kono
parents: 67
diff changeset
2075 enum reg_class hard_reg_class;
kono
parents: 67
diff changeset
2076 machine_mode mode;
kono
parents: 67
diff changeset
2077
kono
parents: 67
diff changeset
2078 mode = ALLOCNO_MODE (a);
kono
parents: 67
diff changeset
2079 hard_reg_class = REGNO_REG_CLASS (hard_regno);
kono
parents: 67
diff changeset
2080 ira_init_register_move_cost_if_necessary (mode);
kono
parents: 67
diff changeset
2081 cost = (to_p ? ira_register_move_cost[mode][hard_reg_class][rclass]
kono
parents: 67
diff changeset
2082 : ira_register_move_cost[mode][rclass][hard_reg_class]) * freq;
kono
parents: 67
diff changeset
2083 ira_allocate_and_set_costs (&ALLOCNO_HARD_REG_COSTS (a), rclass,
kono
parents: 67
diff changeset
2084 ALLOCNO_CLASS_COST (a));
kono
parents: 67
diff changeset
2085 ira_allocate_and_set_costs (&ALLOCNO_CONFLICT_HARD_REG_COSTS (a),
kono
parents: 67
diff changeset
2086 rclass, 0);
kono
parents: 67
diff changeset
2087 ALLOCNO_HARD_REG_COSTS (a)[i] -= cost;
kono
parents: 67
diff changeset
2088 ALLOCNO_CONFLICT_HARD_REG_COSTS (a)[i] -= cost;
kono
parents: 67
diff changeset
2089 ALLOCNO_CLASS_COST (a) = MIN (ALLOCNO_CLASS_COST (a),
kono
parents: 67
diff changeset
2090 ALLOCNO_HARD_REG_COSTS (a)[i]);
kono
parents: 67
diff changeset
2091 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2092 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2093 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2094
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2095 /* After we find hard register and memory costs for allocnos, define
111
kono
parents: 67
diff changeset
2096 its class and modify hard register cost because insns moving
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2097 allocno to/from hard registers. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2098 static void
111
kono
parents: 67
diff changeset
2099 setup_allocno_class_and_costs (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2100 {
111
kono
parents: 67
diff changeset
2101 int i, j, n, regno, hard_regno, num;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2102 int *reg_costs;
111
kono
parents: 67
diff changeset
2103 enum reg_class aclass, rclass;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2104 ira_allocno_t a;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2105 ira_allocno_iterator ai;
111
kono
parents: 67
diff changeset
2106 cost_classes_t cost_classes_ptr;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2107
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2108 ira_assert (allocno_p);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2109 FOR_EACH_ALLOCNO (a, ai)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2110 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2111 i = ALLOCNO_NUM (a);
111
kono
parents: 67
diff changeset
2112 regno = ALLOCNO_REGNO (a);
kono
parents: 67
diff changeset
2113 aclass = regno_aclass[regno];
kono
parents: 67
diff changeset
2114 cost_classes_ptr = regno_cost_classes[regno];
kono
parents: 67
diff changeset
2115 ira_assert (pref[i] == NO_REGS || aclass != NO_REGS);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2116 ALLOCNO_MEMORY_COST (a) = COSTS (costs, i)->mem_cost;
111
kono
parents: 67
diff changeset
2117 ira_set_allocno_class (a, aclass);
kono
parents: 67
diff changeset
2118 if (aclass == NO_REGS)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2119 continue;
111
kono
parents: 67
diff changeset
2120 if (optimize && ALLOCNO_CLASS (a) != pref[i])
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2121 {
111
kono
parents: 67
diff changeset
2122 n = ira_class_hard_regs_num[aclass];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2123 ALLOCNO_HARD_REG_COSTS (a)
111
kono
parents: 67
diff changeset
2124 = reg_costs = ira_allocate_cost_vector (aclass);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2125 for (j = n - 1; j >= 0; j--)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2126 {
111
kono
parents: 67
diff changeset
2127 hard_regno = ira_class_hard_regs[aclass][j];
kono
parents: 67
diff changeset
2128 if (TEST_HARD_REG_BIT (reg_class_contents[pref[i]], hard_regno))
kono
parents: 67
diff changeset
2129 reg_costs[j] = ALLOCNO_CLASS_COST (a);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2130 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2131 {
111
kono
parents: 67
diff changeset
2132 rclass = REGNO_REG_CLASS (hard_regno);
kono
parents: 67
diff changeset
2133 num = cost_classes_ptr->index[rclass];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2134 if (num < 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2135 {
111
kono
parents: 67
diff changeset
2136 num = cost_classes_ptr->hard_regno_index[hard_regno];
kono
parents: 67
diff changeset
2137 ira_assert (num >= 0);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2138 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2139 reg_costs[j] = COSTS (costs, i)->cost[num];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2140 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2141 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2142 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2143 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2144 if (optimize)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2145 ira_traverse_loop_tree (true, ira_loop_tree_root,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2146 process_bb_node_for_hard_reg_moves, NULL);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2147 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2148
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2149
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2150
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2151 /* Function called once during compiler work. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2152 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2153 ira_init_costs_once (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2154 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2155 int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2156
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2157 init_cost = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2158 for (i = 0; i < MAX_RECOG_OPERANDS; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2159 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2160 op_costs[i] = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2161 this_op_costs[i] = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2162 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2163 temp_costs = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2164 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2165
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2166 /* Free allocated temporary cost vectors. */
111
kono
parents: 67
diff changeset
2167 void
kono
parents: 67
diff changeset
2168 target_ira_int::free_ira_costs ()
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2169 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2170 int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2171
111
kono
parents: 67
diff changeset
2172 free (x_init_cost);
kono
parents: 67
diff changeset
2173 x_init_cost = NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2174 for (i = 0; i < MAX_RECOG_OPERANDS; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2175 {
111
kono
parents: 67
diff changeset
2176 free (x_op_costs[i]);
kono
parents: 67
diff changeset
2177 free (x_this_op_costs[i]);
kono
parents: 67
diff changeset
2178 x_op_costs[i] = x_this_op_costs[i] = NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2179 }
111
kono
parents: 67
diff changeset
2180 free (x_temp_costs);
kono
parents: 67
diff changeset
2181 x_temp_costs = NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2182 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2183
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2184 /* This is called each time register related information is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2185 changed. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2186 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2187 ira_init_costs (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2188 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2189 int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2190
111
kono
parents: 67
diff changeset
2191 this_target_ira_int->free_ira_costs ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2192 max_struct_costs_size
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2193 = sizeof (struct costs) + sizeof (int) * (ira_important_classes_num - 1);
111
kono
parents: 67
diff changeset
2194 /* Don't use ira_allocate because vectors live through several IRA
kono
parents: 67
diff changeset
2195 calls. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2196 init_cost = (struct costs *) xmalloc (max_struct_costs_size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2197 init_cost->mem_cost = 1000000;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2198 for (i = 0; i < ira_important_classes_num; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2199 init_cost->cost[i] = 1000000;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2200 for (i = 0; i < MAX_RECOG_OPERANDS; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2201 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2202 op_costs[i] = (struct costs *) xmalloc (max_struct_costs_size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2203 this_op_costs[i] = (struct costs *) xmalloc (max_struct_costs_size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2204 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2205 temp_costs = (struct costs *) xmalloc (max_struct_costs_size);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2206 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2207
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2208
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2209
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2210 /* Common initialization function for ira_costs and
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2211 ira_set_pseudo_classes. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2212 static void
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2213 init_costs (void)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2214 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2215 init_subregs_of_mode ();
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2216 costs = (struct costs *) ira_allocate (max_struct_costs_size
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2217 * cost_elements_num);
111
kono
parents: 67
diff changeset
2218 pref_buffer = (enum reg_class *) ira_allocate (sizeof (enum reg_class)
kono
parents: 67
diff changeset
2219 * cost_elements_num);
kono
parents: 67
diff changeset
2220 regno_aclass = (enum reg_class *) ira_allocate (sizeof (enum reg_class)
kono
parents: 67
diff changeset
2221 * max_reg_num ());
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2222 regno_equiv_gains = (int *) ira_allocate (sizeof (int) * max_reg_num ());
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2223 memset (regno_equiv_gains, 0, sizeof (int) * max_reg_num ());
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2224 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2225
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2226 /* Common finalization function for ira_costs and
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2227 ira_set_pseudo_classes. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2228 static void
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2229 finish_costs (void)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2230 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2231 finish_subregs_of_mode ();
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2232 ira_free (regno_equiv_gains);
111
kono
parents: 67
diff changeset
2233 ira_free (regno_aclass);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2234 ira_free (pref_buffer);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2235 ira_free (costs);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2236 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2237
111
kono
parents: 67
diff changeset
2238 /* Entry function which defines register class, memory and hard
kono
parents: 67
diff changeset
2239 register costs for each allocno. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2240 void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2241 ira_costs (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2242 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2243 allocno_p = true;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2244 cost_elements_num = ira_allocnos_num;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2245 init_costs ();
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2246 total_allocno_costs = (struct costs *) ira_allocate (max_struct_costs_size
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2247 * ira_allocnos_num);
111
kono
parents: 67
diff changeset
2248 initiate_regno_cost_classes ();
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2249 calculate_elim_costs_all_insns ();
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2250 find_costs_and_classes (ira_dump_file);
111
kono
parents: 67
diff changeset
2251 setup_allocno_class_and_costs ();
kono
parents: 67
diff changeset
2252 finish_regno_cost_classes ();
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2253 finish_costs ();
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2254 ira_free (total_allocno_costs);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2255 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2256
111
kono
parents: 67
diff changeset
2257 /* Entry function which defines classes for pseudos.
kono
parents: 67
diff changeset
2258 Set pseudo_classes_defined_p only if DEFINE_PSEUDO_CLASSES is true. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2259 void
111
kono
parents: 67
diff changeset
2260 ira_set_pseudo_classes (bool define_pseudo_classes, FILE *dump_file)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2261 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2262 allocno_p = false;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2263 internal_flag_ira_verbose = flag_ira_verbose;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2264 cost_elements_num = max_reg_num ();
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2265 init_costs ();
111
kono
parents: 67
diff changeset
2266 initiate_regno_cost_classes ();
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2267 find_costs_and_classes (dump_file);
111
kono
parents: 67
diff changeset
2268 finish_regno_cost_classes ();
kono
parents: 67
diff changeset
2269 if (define_pseudo_classes)
kono
parents: 67
diff changeset
2270 pseudo_classes_defined_p = true;
kono
parents: 67
diff changeset
2271
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
2272 finish_costs ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2273 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2274
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2275
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2276
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2277 /* Change hard register costs for allocnos which lives through
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2278 function calls. This is called only when we found all intersected
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2279 calls during building allocno live ranges. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2280 void
111
kono
parents: 67
diff changeset
2281 ira_tune_allocno_costs (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2282 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2283 int j, n, regno;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2284 int cost, min_cost, *reg_costs;
111
kono
parents: 67
diff changeset
2285 enum reg_class aclass, rclass;
kono
parents: 67
diff changeset
2286 machine_mode mode;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2287 ira_allocno_t a;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2288 ira_allocno_iterator ai;
111
kono
parents: 67
diff changeset
2289 ira_allocno_object_iterator oi;
kono
parents: 67
diff changeset
2290 ira_object_t obj;
kono
parents: 67
diff changeset
2291 bool skip_p;
kono
parents: 67
diff changeset
2292 HARD_REG_SET *crossed_calls_clobber_regs;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2293
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2294 FOR_EACH_ALLOCNO (a, ai)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2295 {
111
kono
parents: 67
diff changeset
2296 aclass = ALLOCNO_CLASS (a);
kono
parents: 67
diff changeset
2297 if (aclass == NO_REGS)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2298 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2299 mode = ALLOCNO_MODE (a);
111
kono
parents: 67
diff changeset
2300 n = ira_class_hard_regs_num[aclass];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2301 min_cost = INT_MAX;
111
kono
parents: 67
diff changeset
2302 if (ALLOCNO_CALLS_CROSSED_NUM (a)
kono
parents: 67
diff changeset
2303 != ALLOCNO_CHEAP_CALLS_CROSSED_NUM (a))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2304 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2305 ira_allocate_and_set_costs
111
kono
parents: 67
diff changeset
2306 (&ALLOCNO_HARD_REG_COSTS (a), aclass,
kono
parents: 67
diff changeset
2307 ALLOCNO_CLASS_COST (a));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2308 reg_costs = ALLOCNO_HARD_REG_COSTS (a);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2309 for (j = n - 1; j >= 0; j--)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2310 {
111
kono
parents: 67
diff changeset
2311 regno = ira_class_hard_regs[aclass][j];
kono
parents: 67
diff changeset
2312 skip_p = false;
kono
parents: 67
diff changeset
2313 FOR_EACH_ALLOCNO_OBJECT (a, obj, oi)
kono
parents: 67
diff changeset
2314 {
kono
parents: 67
diff changeset
2315 if (ira_hard_reg_set_intersection_p (regno, mode,
kono
parents: 67
diff changeset
2316 OBJECT_CONFLICT_HARD_REGS
kono
parents: 67
diff changeset
2317 (obj)))
kono
parents: 67
diff changeset
2318 {
kono
parents: 67
diff changeset
2319 skip_p = true;
kono
parents: 67
diff changeset
2320 break;
kono
parents: 67
diff changeset
2321 }
kono
parents: 67
diff changeset
2322 }
kono
parents: 67
diff changeset
2323 if (skip_p)
kono
parents: 67
diff changeset
2324 continue;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2325 rclass = REGNO_REG_CLASS (regno);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2326 cost = 0;
111
kono
parents: 67
diff changeset
2327 crossed_calls_clobber_regs
kono
parents: 67
diff changeset
2328 = &(ALLOCNO_CROSSED_CALLS_CLOBBERED_REGS (a));
kono
parents: 67
diff changeset
2329 if (ira_hard_reg_set_intersection_p (regno, mode,
kono
parents: 67
diff changeset
2330 *crossed_calls_clobber_regs)
kono
parents: 67
diff changeset
2331 && (ira_hard_reg_set_intersection_p (regno, mode,
kono
parents: 67
diff changeset
2332 call_used_reg_set)
kono
parents: 67
diff changeset
2333 || targetm.hard_regno_call_part_clobbered (regno,
kono
parents: 67
diff changeset
2334 mode)))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2335 cost += (ALLOCNO_CALL_FREQ (a)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2336 * (ira_memory_move_cost[mode][rclass][0]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2337 + ira_memory_move_cost[mode][rclass][1]));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2338 #ifdef IRA_HARD_REGNO_ADD_COST_MULTIPLIER
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2339 cost += ((ira_memory_move_cost[mode][rclass][0]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2340 + ira_memory_move_cost[mode][rclass][1])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2341 * ALLOCNO_FREQ (a)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2342 * IRA_HARD_REGNO_ADD_COST_MULTIPLIER (regno) / 2);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2343 #endif
111
kono
parents: 67
diff changeset
2344 if (INT_MAX - cost < reg_costs[j])
kono
parents: 67
diff changeset
2345 reg_costs[j] = INT_MAX;
kono
parents: 67
diff changeset
2346 else
kono
parents: 67
diff changeset
2347 reg_costs[j] += cost;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2348 if (min_cost > reg_costs[j])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2349 min_cost = reg_costs[j];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2350 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2351 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2352 if (min_cost != INT_MAX)
111
kono
parents: 67
diff changeset
2353 ALLOCNO_CLASS_COST (a) = min_cost;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2354
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2355 /* Some targets allow pseudos to be allocated to unaligned sequences
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2356 of hard registers. However, selecting an unaligned sequence can
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2357 unnecessarily restrict later allocations. So increase the cost of
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2358 unaligned hard regs to encourage the use of aligned hard regs. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2359 {
111
kono
parents: 67
diff changeset
2360 const int nregs = ira_reg_class_max_nregs[aclass][ALLOCNO_MODE (a)];
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2361
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2362 if (nregs > 1)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2363 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2364 ira_allocate_and_set_costs
111
kono
parents: 67
diff changeset
2365 (&ALLOCNO_HARD_REG_COSTS (a), aclass, ALLOCNO_CLASS_COST (a));
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2366 reg_costs = ALLOCNO_HARD_REG_COSTS (a);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2367 for (j = n - 1; j >= 0; j--)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2368 {
111
kono
parents: 67
diff changeset
2369 regno = ira_non_ordered_class_hard_regs[aclass][j];
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2370 if ((regno % nregs) != 0)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2371 {
111
kono
parents: 67
diff changeset
2372 int index = ira_class_hard_reg_index[aclass][regno];
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2373 ira_assert (index != -1);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2374 reg_costs[index] += ALLOCNO_FREQ (a);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2375 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2376 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2377 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2378 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2379 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2380 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2381
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2382 /* Add COST to the estimated gain for eliminating REGNO with its
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2383 equivalence. If COST is zero, record that no such elimination is
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2384 possible. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2385
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2386 void
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2387 ira_adjust_equiv_reg_cost (unsigned regno, int cost)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2388 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2389 if (cost == 0)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2390 regno_equiv_gains[regno] = 0;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2391 else
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2392 regno_equiv_gains[regno] += cost;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2393 }
111
kono
parents: 67
diff changeset
2394
kono
parents: 67
diff changeset
2395 void
kono
parents: 67
diff changeset
2396 ira_costs_c_finalize (void)
kono
parents: 67
diff changeset
2397 {
kono
parents: 67
diff changeset
2398 this_target_ira_int->free_ira_costs ();
kono
parents: 67
diff changeset
2399 }