annotate gcc/lower-subreg.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Decompose multiword subregs.
111
kono
parents: 67
diff changeset
2 Copyright (C) 2007-2017 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Richard Henderson <rth@redhat.com>
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 Ian Lance Taylor <iant@google.com>
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 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
9 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
10 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
11 version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 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
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 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
16 for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 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
19 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #include "config.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #include "coretypes.h"
111
kono
parents: 67
diff changeset
25 #include "backend.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 "cfghooks.h"
kono
parents: 67
diff changeset
29 #include "df.h"
kono
parents: 67
diff changeset
30 #include "memmodel.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 #include "tm_p.h"
111
kono
parents: 67
diff changeset
32 #include "expmed.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 #include "insn-config.h"
111
kono
parents: 67
diff changeset
34 #include "emit-rtl.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 #include "recog.h"
111
kono
parents: 67
diff changeset
36 #include "cfgrtl.h"
kono
parents: 67
diff changeset
37 #include "cfgbuild.h"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
38 #include "dce.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 #include "expr.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 #include "tree-pass.h"
111
kono
parents: 67
diff changeset
41 #include "lower-subreg.h"
kono
parents: 67
diff changeset
42 #include "rtl-iter.h"
kono
parents: 67
diff changeset
43 #include "target.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 /* Decompose multi-word pseudo-registers into individual
111
kono
parents: 67
diff changeset
47 pseudo-registers when possible and profitable. This is possible
kono
parents: 67
diff changeset
48 when all the uses of a multi-word register are via SUBREG, or are
kono
parents: 67
diff changeset
49 copies of the register to another location. Breaking apart the
kono
parents: 67
diff changeset
50 register permits more CSE and permits better register allocation.
kono
parents: 67
diff changeset
51 This is profitable if the machine does not have move instructions
kono
parents: 67
diff changeset
52 to do this.
kono
parents: 67
diff changeset
53
kono
parents: 67
diff changeset
54 This pass only splits moves with modes that are wider than
kono
parents: 67
diff changeset
55 word_mode and ASHIFTs, LSHIFTRTs, ASHIFTRTs and ZERO_EXTENDs with
kono
parents: 67
diff changeset
56 integer modes that are twice the width of word_mode. The latter
kono
parents: 67
diff changeset
57 could be generalized if there was a need to do this, but the trend in
kono
parents: 67
diff changeset
58 architectures is to not need this.
kono
parents: 67
diff changeset
59
kono
parents: 67
diff changeset
60 There are two useful preprocessor defines for use by maintainers:
kono
parents: 67
diff changeset
61
kono
parents: 67
diff changeset
62 #define LOG_COSTS 1
kono
parents: 67
diff changeset
63
kono
parents: 67
diff changeset
64 if you wish to see the actual cost estimates that are being used
kono
parents: 67
diff changeset
65 for each mode wider than word mode and the cost estimates for zero
kono
parents: 67
diff changeset
66 extension and the shifts. This can be useful when port maintainers
kono
parents: 67
diff changeset
67 are tuning insn rtx costs.
kono
parents: 67
diff changeset
68
kono
parents: 67
diff changeset
69 #define FORCE_LOWERING 1
kono
parents: 67
diff changeset
70
kono
parents: 67
diff changeset
71 if you wish to test the pass with all the transformation forced on.
kono
parents: 67
diff changeset
72 This can be useful for finding bugs in the transformations. */
kono
parents: 67
diff changeset
73
kono
parents: 67
diff changeset
74 #define LOG_COSTS 0
kono
parents: 67
diff changeset
75 #define FORCE_LOWERING 0
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 /* Bit N in this bitmap is set if regno N is used in a context in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 which we can decompose it. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 static bitmap decomposable_context;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 /* Bit N in this bitmap is set if regno N is used in a context in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 which it can not be decomposed. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 static bitmap non_decomposable_context;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
85 /* Bit N in this bitmap is set if regno N is used in a subreg
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
86 which changes the mode but not the size. This typically happens
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
87 when the register accessed as a floating-point value; we want to
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
88 avoid generating accesses to its subwords in integer modes. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
89 static bitmap subreg_context;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
90
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 /* Bit N in the bitmap in element M of this array is set if there is a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 copy from reg M to reg N. */
111
kono
parents: 67
diff changeset
93 static vec<bitmap> reg_copy_graph;
kono
parents: 67
diff changeset
94
kono
parents: 67
diff changeset
95 struct target_lower_subreg default_target_lower_subreg;
kono
parents: 67
diff changeset
96 #if SWITCHABLE_TARGET
kono
parents: 67
diff changeset
97 struct target_lower_subreg *this_target_lower_subreg
kono
parents: 67
diff changeset
98 = &default_target_lower_subreg;
kono
parents: 67
diff changeset
99 #endif
kono
parents: 67
diff changeset
100
kono
parents: 67
diff changeset
101 #define twice_word_mode \
kono
parents: 67
diff changeset
102 this_target_lower_subreg->x_twice_word_mode
kono
parents: 67
diff changeset
103 #define choices \
kono
parents: 67
diff changeset
104 this_target_lower_subreg->x_choices
kono
parents: 67
diff changeset
105
kono
parents: 67
diff changeset
106 /* RTXes used while computing costs. */
kono
parents: 67
diff changeset
107 struct cost_rtxes {
kono
parents: 67
diff changeset
108 /* Source and target registers. */
kono
parents: 67
diff changeset
109 rtx source;
kono
parents: 67
diff changeset
110 rtx target;
kono
parents: 67
diff changeset
111
kono
parents: 67
diff changeset
112 /* A twice_word_mode ZERO_EXTEND of SOURCE. */
kono
parents: 67
diff changeset
113 rtx zext;
kono
parents: 67
diff changeset
114
kono
parents: 67
diff changeset
115 /* A shift of SOURCE. */
kono
parents: 67
diff changeset
116 rtx shift;
kono
parents: 67
diff changeset
117
kono
parents: 67
diff changeset
118 /* A SET of TARGET. */
kono
parents: 67
diff changeset
119 rtx set;
kono
parents: 67
diff changeset
120 };
kono
parents: 67
diff changeset
121
kono
parents: 67
diff changeset
122 /* Return the cost of a CODE shift in mode MODE by OP1 bits, using the
kono
parents: 67
diff changeset
123 rtxes in RTXES. SPEED_P selects between the speed and size cost. */
kono
parents: 67
diff changeset
124
kono
parents: 67
diff changeset
125 static int
kono
parents: 67
diff changeset
126 shift_cost (bool speed_p, struct cost_rtxes *rtxes, enum rtx_code code,
kono
parents: 67
diff changeset
127 machine_mode mode, int op1)
kono
parents: 67
diff changeset
128 {
kono
parents: 67
diff changeset
129 PUT_CODE (rtxes->shift, code);
kono
parents: 67
diff changeset
130 PUT_MODE (rtxes->shift, mode);
kono
parents: 67
diff changeset
131 PUT_MODE (rtxes->source, mode);
kono
parents: 67
diff changeset
132 XEXP (rtxes->shift, 1) = GEN_INT (op1);
kono
parents: 67
diff changeset
133 return set_src_cost (rtxes->shift, mode, speed_p);
kono
parents: 67
diff changeset
134 }
kono
parents: 67
diff changeset
135
kono
parents: 67
diff changeset
136 /* For each X in the range [0, BITS_PER_WORD), set SPLITTING[X]
kono
parents: 67
diff changeset
137 to true if it is profitable to split a double-word CODE shift
kono
parents: 67
diff changeset
138 of X + BITS_PER_WORD bits. SPEED_P says whether we are testing
kono
parents: 67
diff changeset
139 for speed or size profitability.
kono
parents: 67
diff changeset
140
kono
parents: 67
diff changeset
141 Use the rtxes in RTXES to calculate costs. WORD_MOVE_ZERO_COST is
kono
parents: 67
diff changeset
142 the cost of moving zero into a word-mode register. WORD_MOVE_COST
kono
parents: 67
diff changeset
143 is the cost of moving between word registers. */
kono
parents: 67
diff changeset
144
kono
parents: 67
diff changeset
145 static void
kono
parents: 67
diff changeset
146 compute_splitting_shift (bool speed_p, struct cost_rtxes *rtxes,
kono
parents: 67
diff changeset
147 bool *splitting, enum rtx_code code,
kono
parents: 67
diff changeset
148 int word_move_zero_cost, int word_move_cost)
kono
parents: 67
diff changeset
149 {
kono
parents: 67
diff changeset
150 int wide_cost, narrow_cost, upper_cost, i;
kono
parents: 67
diff changeset
151
kono
parents: 67
diff changeset
152 for (i = 0; i < BITS_PER_WORD; i++)
kono
parents: 67
diff changeset
153 {
kono
parents: 67
diff changeset
154 wide_cost = shift_cost (speed_p, rtxes, code, twice_word_mode,
kono
parents: 67
diff changeset
155 i + BITS_PER_WORD);
kono
parents: 67
diff changeset
156 if (i == 0)
kono
parents: 67
diff changeset
157 narrow_cost = word_move_cost;
kono
parents: 67
diff changeset
158 else
kono
parents: 67
diff changeset
159 narrow_cost = shift_cost (speed_p, rtxes, code, word_mode, i);
kono
parents: 67
diff changeset
160
kono
parents: 67
diff changeset
161 if (code != ASHIFTRT)
kono
parents: 67
diff changeset
162 upper_cost = word_move_zero_cost;
kono
parents: 67
diff changeset
163 else if (i == BITS_PER_WORD - 1)
kono
parents: 67
diff changeset
164 upper_cost = word_move_cost;
kono
parents: 67
diff changeset
165 else
kono
parents: 67
diff changeset
166 upper_cost = shift_cost (speed_p, rtxes, code, word_mode,
kono
parents: 67
diff changeset
167 BITS_PER_WORD - 1);
kono
parents: 67
diff changeset
168
kono
parents: 67
diff changeset
169 if (LOG_COSTS)
kono
parents: 67
diff changeset
170 fprintf (stderr, "%s %s by %d: original cost %d, split cost %d + %d\n",
kono
parents: 67
diff changeset
171 GET_MODE_NAME (twice_word_mode), GET_RTX_NAME (code),
kono
parents: 67
diff changeset
172 i + BITS_PER_WORD, wide_cost, narrow_cost, upper_cost);
kono
parents: 67
diff changeset
173
kono
parents: 67
diff changeset
174 if (FORCE_LOWERING || wide_cost >= narrow_cost + upper_cost)
kono
parents: 67
diff changeset
175 splitting[i] = true;
kono
parents: 67
diff changeset
176 }
kono
parents: 67
diff changeset
177 }
kono
parents: 67
diff changeset
178
kono
parents: 67
diff changeset
179 /* Compute what we should do when optimizing for speed or size; SPEED_P
kono
parents: 67
diff changeset
180 selects which. Use RTXES for computing costs. */
kono
parents: 67
diff changeset
181
kono
parents: 67
diff changeset
182 static void
kono
parents: 67
diff changeset
183 compute_costs (bool speed_p, struct cost_rtxes *rtxes)
kono
parents: 67
diff changeset
184 {
kono
parents: 67
diff changeset
185 unsigned int i;
kono
parents: 67
diff changeset
186 int word_move_zero_cost, word_move_cost;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187
111
kono
parents: 67
diff changeset
188 PUT_MODE (rtxes->target, word_mode);
kono
parents: 67
diff changeset
189 SET_SRC (rtxes->set) = CONST0_RTX (word_mode);
kono
parents: 67
diff changeset
190 word_move_zero_cost = set_rtx_cost (rtxes->set, speed_p);
kono
parents: 67
diff changeset
191
kono
parents: 67
diff changeset
192 SET_SRC (rtxes->set) = rtxes->source;
kono
parents: 67
diff changeset
193 word_move_cost = set_rtx_cost (rtxes->set, speed_p);
kono
parents: 67
diff changeset
194
kono
parents: 67
diff changeset
195 if (LOG_COSTS)
kono
parents: 67
diff changeset
196 fprintf (stderr, "%s move: from zero cost %d, from reg cost %d\n",
kono
parents: 67
diff changeset
197 GET_MODE_NAME (word_mode), word_move_zero_cost, word_move_cost);
kono
parents: 67
diff changeset
198
kono
parents: 67
diff changeset
199 for (i = 0; i < MAX_MACHINE_MODE; i++)
kono
parents: 67
diff changeset
200 {
kono
parents: 67
diff changeset
201 machine_mode mode = (machine_mode) i;
kono
parents: 67
diff changeset
202 int factor = GET_MODE_SIZE (mode) / UNITS_PER_WORD;
kono
parents: 67
diff changeset
203 if (factor > 1)
kono
parents: 67
diff changeset
204 {
kono
parents: 67
diff changeset
205 int mode_move_cost;
kono
parents: 67
diff changeset
206
kono
parents: 67
diff changeset
207 PUT_MODE (rtxes->target, mode);
kono
parents: 67
diff changeset
208 PUT_MODE (rtxes->source, mode);
kono
parents: 67
diff changeset
209 mode_move_cost = set_rtx_cost (rtxes->set, speed_p);
kono
parents: 67
diff changeset
210
kono
parents: 67
diff changeset
211 if (LOG_COSTS)
kono
parents: 67
diff changeset
212 fprintf (stderr, "%s move: original cost %d, split cost %d * %d\n",
kono
parents: 67
diff changeset
213 GET_MODE_NAME (mode), mode_move_cost,
kono
parents: 67
diff changeset
214 word_move_cost, factor);
kono
parents: 67
diff changeset
215
kono
parents: 67
diff changeset
216 if (FORCE_LOWERING || mode_move_cost >= word_move_cost * factor)
kono
parents: 67
diff changeset
217 {
kono
parents: 67
diff changeset
218 choices[speed_p].move_modes_to_split[i] = true;
kono
parents: 67
diff changeset
219 choices[speed_p].something_to_do = true;
kono
parents: 67
diff changeset
220 }
kono
parents: 67
diff changeset
221 }
kono
parents: 67
diff changeset
222 }
kono
parents: 67
diff changeset
223
kono
parents: 67
diff changeset
224 /* For the moves and shifts, the only case that is checked is one
kono
parents: 67
diff changeset
225 where the mode of the target is an integer mode twice the width
kono
parents: 67
diff changeset
226 of the word_mode.
kono
parents: 67
diff changeset
227
kono
parents: 67
diff changeset
228 If it is not profitable to split a double word move then do not
kono
parents: 67
diff changeset
229 even consider the shifts or the zero extension. */
kono
parents: 67
diff changeset
230 if (choices[speed_p].move_modes_to_split[(int) twice_word_mode])
kono
parents: 67
diff changeset
231 {
kono
parents: 67
diff changeset
232 int zext_cost;
kono
parents: 67
diff changeset
233
kono
parents: 67
diff changeset
234 /* The only case here to check to see if moving the upper part with a
kono
parents: 67
diff changeset
235 zero is cheaper than doing the zext itself. */
kono
parents: 67
diff changeset
236 PUT_MODE (rtxes->source, word_mode);
kono
parents: 67
diff changeset
237 zext_cost = set_src_cost (rtxes->zext, twice_word_mode, speed_p);
kono
parents: 67
diff changeset
238
kono
parents: 67
diff changeset
239 if (LOG_COSTS)
kono
parents: 67
diff changeset
240 fprintf (stderr, "%s %s: original cost %d, split cost %d + %d\n",
kono
parents: 67
diff changeset
241 GET_MODE_NAME (twice_word_mode), GET_RTX_NAME (ZERO_EXTEND),
kono
parents: 67
diff changeset
242 zext_cost, word_move_cost, word_move_zero_cost);
kono
parents: 67
diff changeset
243
kono
parents: 67
diff changeset
244 if (FORCE_LOWERING || zext_cost >= word_move_cost + word_move_zero_cost)
kono
parents: 67
diff changeset
245 choices[speed_p].splitting_zext = true;
kono
parents: 67
diff changeset
246
kono
parents: 67
diff changeset
247 compute_splitting_shift (speed_p, rtxes,
kono
parents: 67
diff changeset
248 choices[speed_p].splitting_ashift, ASHIFT,
kono
parents: 67
diff changeset
249 word_move_zero_cost, word_move_cost);
kono
parents: 67
diff changeset
250 compute_splitting_shift (speed_p, rtxes,
kono
parents: 67
diff changeset
251 choices[speed_p].splitting_lshiftrt, LSHIFTRT,
kono
parents: 67
diff changeset
252 word_move_zero_cost, word_move_cost);
kono
parents: 67
diff changeset
253 compute_splitting_shift (speed_p, rtxes,
kono
parents: 67
diff changeset
254 choices[speed_p].splitting_ashiftrt, ASHIFTRT,
kono
parents: 67
diff changeset
255 word_move_zero_cost, word_move_cost);
kono
parents: 67
diff changeset
256 }
kono
parents: 67
diff changeset
257 }
kono
parents: 67
diff changeset
258
kono
parents: 67
diff changeset
259 /* Do one-per-target initialisation. This involves determining
kono
parents: 67
diff changeset
260 which operations on the machine are profitable. If none are found,
kono
parents: 67
diff changeset
261 then the pass just returns when called. */
kono
parents: 67
diff changeset
262
kono
parents: 67
diff changeset
263 void
kono
parents: 67
diff changeset
264 init_lower_subreg (void)
kono
parents: 67
diff changeset
265 {
kono
parents: 67
diff changeset
266 struct cost_rtxes rtxes;
kono
parents: 67
diff changeset
267
kono
parents: 67
diff changeset
268 memset (this_target_lower_subreg, 0, sizeof (*this_target_lower_subreg));
kono
parents: 67
diff changeset
269
kono
parents: 67
diff changeset
270 twice_word_mode = GET_MODE_2XWIDER_MODE (word_mode).require ();
kono
parents: 67
diff changeset
271
kono
parents: 67
diff changeset
272 rtxes.target = gen_rtx_REG (word_mode, LAST_VIRTUAL_REGISTER + 1);
kono
parents: 67
diff changeset
273 rtxes.source = gen_rtx_REG (word_mode, LAST_VIRTUAL_REGISTER + 2);
kono
parents: 67
diff changeset
274 rtxes.set = gen_rtx_SET (rtxes.target, rtxes.source);
kono
parents: 67
diff changeset
275 rtxes.zext = gen_rtx_ZERO_EXTEND (twice_word_mode, rtxes.source);
kono
parents: 67
diff changeset
276 rtxes.shift = gen_rtx_ASHIFT (twice_word_mode, rtxes.source, const0_rtx);
kono
parents: 67
diff changeset
277
kono
parents: 67
diff changeset
278 if (LOG_COSTS)
kono
parents: 67
diff changeset
279 fprintf (stderr, "\nSize costs\n==========\n\n");
kono
parents: 67
diff changeset
280 compute_costs (false, &rtxes);
kono
parents: 67
diff changeset
281
kono
parents: 67
diff changeset
282 if (LOG_COSTS)
kono
parents: 67
diff changeset
283 fprintf (stderr, "\nSpeed costs\n===========\n\n");
kono
parents: 67
diff changeset
284 compute_costs (true, &rtxes);
kono
parents: 67
diff changeset
285 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 static bool
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 simple_move_operand (rtx x)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 if (GET_CODE (x) == SUBREG)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 x = SUBREG_REG (x);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 if (!OBJECT_P (x))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 if (GET_CODE (x) == LABEL_REF
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 || GET_CODE (x) == SYMBOL_REF
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 || GET_CODE (x) == HIGH
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 || GET_CODE (x) == CONST)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 if (MEM_P (x)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 && (MEM_VOLATILE_P (x)
111
kono
parents: 67
diff changeset
304 || mode_dependent_address_p (XEXP (x, 0), MEM_ADDR_SPACE (x))))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309
111
kono
parents: 67
diff changeset
310 /* If INSN is a single set between two objects that we want to split,
kono
parents: 67
diff changeset
311 return the single set. SPEED_P says whether we are optimizing
kono
parents: 67
diff changeset
312 INSN for speed or size.
kono
parents: 67
diff changeset
313
kono
parents: 67
diff changeset
314 INSN should have been passed to recog and extract_insn before this
kono
parents: 67
diff changeset
315 is called. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
316
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 static rtx
111
kono
parents: 67
diff changeset
318 simple_move (rtx_insn *insn, bool speed_p)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 rtx x;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
321 rtx set;
111
kono
parents: 67
diff changeset
322 machine_mode mode;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
323
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 if (recog_data.n_operands != 2)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 return NULL_RTX;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
326
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 set = single_set (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 if (!set)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 return NULL_RTX;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
330
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 x = SET_DEST (set);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 if (x != recog_data.operand[0] && x != recog_data.operand[1])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 return NULL_RTX;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 if (!simple_move_operand (x))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 return NULL_RTX;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
336
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 x = SET_SRC (set);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 if (x != recog_data.operand[0] && x != recog_data.operand[1])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 return NULL_RTX;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 /* For the src we can handle ASM_OPERANDS, and it is beneficial for
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 things like x86 rdtsc which returns a DImode value. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 if (GET_CODE (x) != ASM_OPERANDS
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 && !simple_move_operand (x))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 return NULL_RTX;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
345
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
346 /* We try to decompose in integer modes, to avoid generating
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 inefficient code copying between integer and floating point
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 registers. That means that we can't decompose if this is a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 non-integer mode for which there is no integer mode of the same
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 size. */
111
kono
parents: 67
diff changeset
351 mode = GET_MODE (SET_DEST (set));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 if (!SCALAR_INT_MODE_P (mode)
111
kono
parents: 67
diff changeset
353 && !int_mode_for_size (GET_MODE_BITSIZE (mode), 0).exists ())
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 return NULL_RTX;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 /* Reject PARTIAL_INT modes. They are used for processor specific
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 purposes and it's probably best not to tamper with them. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 if (GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 return NULL_RTX;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
360
111
kono
parents: 67
diff changeset
361 if (!choices[speed_p].move_modes_to_split[(int) mode])
kono
parents: 67
diff changeset
362 return NULL_RTX;
kono
parents: 67
diff changeset
363
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 return set;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 /* If SET is a copy from one multi-word pseudo-register to another,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 record that in reg_copy_graph. Return whether it is such a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
369 copy. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
370
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 static bool
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 find_pseudo_copy (rtx set)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 rtx dest = SET_DEST (set);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 rtx src = SET_SRC (set);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 unsigned int rd, rs;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 bitmap b;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
378
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 if (!REG_P (dest) || !REG_P (src))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
381
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 rd = REGNO (dest);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 rs = REGNO (src);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 if (HARD_REGISTER_NUM_P (rd) || HARD_REGISTER_NUM_P (rs))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
386
111
kono
parents: 67
diff changeset
387 b = reg_copy_graph[rs];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 if (b == NULL)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 b = BITMAP_ALLOC (NULL);
111
kono
parents: 67
diff changeset
391 reg_copy_graph[rs] = b;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
393
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 bitmap_set_bit (b, rd);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
395
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
398
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
399 /* Look through the registers in DECOMPOSABLE_CONTEXT. For each case
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 where they are copied to another register, add the register to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 which they are copied to DECOMPOSABLE_CONTEXT. Use
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 NON_DECOMPOSABLE_CONTEXT to limit this--we don't bother to track
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 copies of registers which are in NON_DECOMPOSABLE_CONTEXT. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
404
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 propagate_pseudo_copies (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 {
111
kono
parents: 67
diff changeset
408 auto_bitmap queue, propagate;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
409
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 bitmap_copy (queue, decomposable_context);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 do
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 bitmap_iterator iter;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 unsigned int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
415
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 bitmap_clear (propagate);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 EXECUTE_IF_SET_IN_BITMAP (queue, 0, i, iter)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
419 {
111
kono
parents: 67
diff changeset
420 bitmap b = reg_copy_graph[i];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 if (b)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 bitmap_ior_and_compl_into (propagate, b, non_decomposable_context);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
424
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 bitmap_and_compl (queue, propagate, decomposable_context);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426 bitmap_ior_into (decomposable_context, propagate);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
427 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 while (!bitmap_empty_p (queue));
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
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 /* A pointer to one of these values is passed to
111
kono
parents: 67
diff changeset
432 find_decomposable_subregs. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
433
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 enum classify_move_insn
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 /* Not a simple move from one location to another. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 NOT_SIMPLE_MOVE,
111
kono
parents: 67
diff changeset
438 /* A simple move we want to decompose. */
kono
parents: 67
diff changeset
439 DECOMPOSABLE_SIMPLE_MOVE,
kono
parents: 67
diff changeset
440 /* Any other simple move. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 SIMPLE_MOVE
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
442 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
443
111
kono
parents: 67
diff changeset
444 /* If we find a SUBREG in *LOC which we could use to decompose a
kono
parents: 67
diff changeset
445 pseudo-register, set a bit in DECOMPOSABLE_CONTEXT. If we find an
kono
parents: 67
diff changeset
446 unadorned register which is not a simple pseudo-register copy,
kono
parents: 67
diff changeset
447 DATA will point at the type of move, and we set a bit in
kono
parents: 67
diff changeset
448 DECOMPOSABLE_CONTEXT or NON_DECOMPOSABLE_CONTEXT as appropriate. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
449
111
kono
parents: 67
diff changeset
450 static void
kono
parents: 67
diff changeset
451 find_decomposable_subregs (rtx *loc, enum classify_move_insn *pcmi)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 {
111
kono
parents: 67
diff changeset
453 subrtx_var_iterator::array_type array;
kono
parents: 67
diff changeset
454 FOR_EACH_SUBRTX_VAR (iter, array, *loc, NONCONST)
kono
parents: 67
diff changeset
455 {
kono
parents: 67
diff changeset
456 rtx x = *iter;
kono
parents: 67
diff changeset
457 if (GET_CODE (x) == SUBREG)
kono
parents: 67
diff changeset
458 {
kono
parents: 67
diff changeset
459 rtx inner = SUBREG_REG (x);
kono
parents: 67
diff changeset
460 unsigned int regno, outer_size, inner_size, outer_words, inner_words;
kono
parents: 67
diff changeset
461
kono
parents: 67
diff changeset
462 if (!REG_P (inner))
kono
parents: 67
diff changeset
463 continue;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
464
111
kono
parents: 67
diff changeset
465 regno = REGNO (inner);
kono
parents: 67
diff changeset
466 if (HARD_REGISTER_NUM_P (regno))
kono
parents: 67
diff changeset
467 {
kono
parents: 67
diff changeset
468 iter.skip_subrtxes ();
kono
parents: 67
diff changeset
469 continue;
kono
parents: 67
diff changeset
470 }
kono
parents: 67
diff changeset
471
kono
parents: 67
diff changeset
472 outer_size = GET_MODE_SIZE (GET_MODE (x));
kono
parents: 67
diff changeset
473 inner_size = GET_MODE_SIZE (GET_MODE (inner));
kono
parents: 67
diff changeset
474 outer_words = (outer_size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
kono
parents: 67
diff changeset
475 inner_words = (inner_size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
476
111
kono
parents: 67
diff changeset
477 /* We only try to decompose single word subregs of multi-word
kono
parents: 67
diff changeset
478 registers. When we find one, we return -1 to avoid iterating
kono
parents: 67
diff changeset
479 over the inner register.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
480
111
kono
parents: 67
diff changeset
481 ??? This doesn't allow, e.g., DImode subregs of TImode values
kono
parents: 67
diff changeset
482 on 32-bit targets. We would need to record the way the
kono
parents: 67
diff changeset
483 pseudo-register was used, and only decompose if all the uses
kono
parents: 67
diff changeset
484 were the same number and size of pieces. Hopefully this
kono
parents: 67
diff changeset
485 doesn't happen much. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486
111
kono
parents: 67
diff changeset
487 if (outer_words == 1 && inner_words > 1)
kono
parents: 67
diff changeset
488 {
kono
parents: 67
diff changeset
489 bitmap_set_bit (decomposable_context, regno);
kono
parents: 67
diff changeset
490 iter.skip_subrtxes ();
kono
parents: 67
diff changeset
491 continue;
kono
parents: 67
diff changeset
492 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
493
111
kono
parents: 67
diff changeset
494 /* If this is a cast from one mode to another, where the modes
kono
parents: 67
diff changeset
495 have the same size, and they are not tieable, then mark this
kono
parents: 67
diff changeset
496 register as non-decomposable. If we decompose it we are
kono
parents: 67
diff changeset
497 likely to mess up whatever the backend is trying to do. */
kono
parents: 67
diff changeset
498 if (outer_words > 1
kono
parents: 67
diff changeset
499 && outer_size == inner_size
kono
parents: 67
diff changeset
500 && !targetm.modes_tieable_p (GET_MODE (x), GET_MODE (inner)))
kono
parents: 67
diff changeset
501 {
kono
parents: 67
diff changeset
502 bitmap_set_bit (non_decomposable_context, regno);
kono
parents: 67
diff changeset
503 bitmap_set_bit (subreg_context, regno);
kono
parents: 67
diff changeset
504 iter.skip_subrtxes ();
kono
parents: 67
diff changeset
505 continue;
kono
parents: 67
diff changeset
506 }
kono
parents: 67
diff changeset
507 }
kono
parents: 67
diff changeset
508 else if (REG_P (x))
kono
parents: 67
diff changeset
509 {
kono
parents: 67
diff changeset
510 unsigned int regno;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511
111
kono
parents: 67
diff changeset
512 /* We will see an outer SUBREG before we see the inner REG, so
kono
parents: 67
diff changeset
513 when we see a plain REG here it means a direct reference to
kono
parents: 67
diff changeset
514 the register.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
515
111
kono
parents: 67
diff changeset
516 If this is not a simple copy from one location to another,
kono
parents: 67
diff changeset
517 then we can not decompose this register. If this is a simple
kono
parents: 67
diff changeset
518 copy we want to decompose, and the mode is right,
kono
parents: 67
diff changeset
519 then we mark the register as decomposable.
kono
parents: 67
diff changeset
520 Otherwise we don't say anything about this register --
kono
parents: 67
diff changeset
521 it could be decomposed, but whether that would be
kono
parents: 67
diff changeset
522 profitable depends upon how it is used elsewhere.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
523
111
kono
parents: 67
diff changeset
524 We only set bits in the bitmap for multi-word
kono
parents: 67
diff changeset
525 pseudo-registers, since those are the only ones we care about
kono
parents: 67
diff changeset
526 and it keeps the size of the bitmaps down. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
527
111
kono
parents: 67
diff changeset
528 regno = REGNO (x);
kono
parents: 67
diff changeset
529 if (!HARD_REGISTER_NUM_P (regno)
kono
parents: 67
diff changeset
530 && GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD)
kono
parents: 67
diff changeset
531 {
kono
parents: 67
diff changeset
532 switch (*pcmi)
kono
parents: 67
diff changeset
533 {
kono
parents: 67
diff changeset
534 case NOT_SIMPLE_MOVE:
kono
parents: 67
diff changeset
535 bitmap_set_bit (non_decomposable_context, regno);
kono
parents: 67
diff changeset
536 break;
kono
parents: 67
diff changeset
537 case DECOMPOSABLE_SIMPLE_MOVE:
kono
parents: 67
diff changeset
538 if (targetm.modes_tieable_p (GET_MODE (x), word_mode))
kono
parents: 67
diff changeset
539 bitmap_set_bit (decomposable_context, regno);
kono
parents: 67
diff changeset
540 break;
kono
parents: 67
diff changeset
541 case SIMPLE_MOVE:
kono
parents: 67
diff changeset
542 break;
kono
parents: 67
diff changeset
543 default:
kono
parents: 67
diff changeset
544 gcc_unreachable ();
kono
parents: 67
diff changeset
545 }
kono
parents: 67
diff changeset
546 }
kono
parents: 67
diff changeset
547 }
kono
parents: 67
diff changeset
548 else if (MEM_P (x))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 {
111
kono
parents: 67
diff changeset
550 enum classify_move_insn cmi_mem = NOT_SIMPLE_MOVE;
kono
parents: 67
diff changeset
551
kono
parents: 67
diff changeset
552 /* Any registers used in a MEM do not participate in a
kono
parents: 67
diff changeset
553 SIMPLE_MOVE or DECOMPOSABLE_SIMPLE_MOVE. Do our own recursion
kono
parents: 67
diff changeset
554 here, and return -1 to block the parent's recursion. */
kono
parents: 67
diff changeset
555 find_decomposable_subregs (&XEXP (x, 0), &cmi_mem);
kono
parents: 67
diff changeset
556 iter.skip_subrtxes ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
559 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
560
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
561 /* Decompose REGNO into word-sized components. We smash the REG node
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
562 in place. This ensures that (1) something goes wrong quickly if we
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 fail to make some replacement, and (2) the debug information inside
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
564 the symbol table is automatically kept up to date. */
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 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 decompose_register (unsigned int regno)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 rtx reg;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
570 unsigned int words, i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 rtvec v;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
572
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
573 reg = regno_reg_rtx[regno];
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 regno_reg_rtx[regno] = NULL_RTX;
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 words = GET_MODE_SIZE (GET_MODE (reg));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
578 words = (words + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
579
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 v = rtvec_alloc (words);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
581 for (i = 0; i < words; ++i)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
582 RTVEC_ELT (v, i) = gen_reg_rtx_offset (reg, word_mode, i * UNITS_PER_WORD);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
583
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
584 PUT_CODE (reg, CONCATN);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
585 XVEC (reg, 0) = v;
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 if (dump_file)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
589 fprintf (dump_file, "; Splitting reg %u ->", regno);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 for (i = 0; i < words; ++i)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
591 fprintf (dump_file, " %u", REGNO (XVECEXP (reg, 0, i)));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 fputc ('\n', dump_file);
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 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
595
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 /* Get a SUBREG of a CONCATN. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
597
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 static rtx
111
kono
parents: 67
diff changeset
599 simplify_subreg_concatn (machine_mode outermode, rtx op,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 unsigned int byte)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
602 unsigned int inner_size;
111
kono
parents: 67
diff changeset
603 machine_mode innermode, partmode;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 rtx part;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
605 unsigned int final_offset;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
606
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
607 gcc_assert (GET_CODE (op) == CONCATN);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
608 gcc_assert (byte % GET_MODE_SIZE (outermode) == 0);
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 innermode = GET_MODE (op);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
611 gcc_assert (byte < GET_MODE_SIZE (innermode));
111
kono
parents: 67
diff changeset
612 if (GET_MODE_SIZE (outermode) > GET_MODE_SIZE (innermode))
kono
parents: 67
diff changeset
613 return NULL_RTX;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
614
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
615 inner_size = GET_MODE_SIZE (innermode) / XVECLEN (op, 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
616 part = XVECEXP (op, 0, byte / inner_size);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
617 partmode = GET_MODE (part);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
618
111
kono
parents: 67
diff changeset
619 final_offset = byte % inner_size;
kono
parents: 67
diff changeset
620 if (final_offset + GET_MODE_SIZE (outermode) > inner_size)
kono
parents: 67
diff changeset
621 return NULL_RTX;
kono
parents: 67
diff changeset
622
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
623 /* VECTOR_CSTs in debug expressions are expanded into CONCATN instead of
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
624 regular CONST_VECTORs. They have vector or integer modes, depending
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
625 on the capabilities of the target. Cope with them. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
626 if (partmode == VOIDmode && VECTOR_MODE_P (innermode))
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
627 partmode = GET_MODE_INNER (innermode);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
628 else if (partmode == VOIDmode)
111
kono
parents: 67
diff changeset
629 partmode = mode_for_size (inner_size * BITS_PER_UNIT,
kono
parents: 67
diff changeset
630 GET_MODE_CLASS (innermode), 0).require ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
631
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
632 return simplify_gen_subreg (outermode, part, partmode, final_offset);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
633 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
634
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
635 /* Wrapper around simplify_gen_subreg which handles CONCATN. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
636
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
637 static rtx
111
kono
parents: 67
diff changeset
638 simplify_gen_subreg_concatn (machine_mode outermode, rtx op,
kono
parents: 67
diff changeset
639 machine_mode innermode, unsigned int byte)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
640 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
641 rtx ret;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
642
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
643 /* We have to handle generating a SUBREG of a SUBREG of a CONCATN.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
644 If OP is a SUBREG of a CONCATN, then it must be a simple mode
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 change with the same size and offset 0, or it must extract a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
646 part. We shouldn't see anything else here. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
647 if (GET_CODE (op) == SUBREG && GET_CODE (SUBREG_REG (op)) == CONCATN)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
649 rtx op2;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
650
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
651 if ((GET_MODE_SIZE (GET_MODE (op))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
652 == GET_MODE_SIZE (GET_MODE (SUBREG_REG (op))))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 && SUBREG_BYTE (op) == 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 return simplify_gen_subreg_concatn (outermode, SUBREG_REG (op),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
655 GET_MODE (SUBREG_REG (op)), byte);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
656
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
657 op2 = simplify_subreg_concatn (GET_MODE (op), SUBREG_REG (op),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
658 SUBREG_BYTE (op));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
659 if (op2 == NULL_RTX)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
660 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
661 /* We don't handle paradoxical subregs here. */
111
kono
parents: 67
diff changeset
662 gcc_assert (!paradoxical_subreg_p (outermode, GET_MODE (op)));
kono
parents: 67
diff changeset
663 gcc_assert (!paradoxical_subreg_p (op));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 op2 = simplify_subreg_concatn (outermode, SUBREG_REG (op),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
665 byte + SUBREG_BYTE (op));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
666 gcc_assert (op2 != NULL_RTX);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
667 return op2;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
668 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
669
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
670 op = op2;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
671 gcc_assert (op != NULL_RTX);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
672 gcc_assert (innermode == GET_MODE (op));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
673 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
674
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
675 if (GET_CODE (op) == CONCATN)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
676 return simplify_subreg_concatn (outermode, op, byte);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
677
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
678 ret = simplify_gen_subreg (outermode, op, innermode, byte);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
679
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
680 /* If we see an insn like (set (reg:DI) (subreg:DI (reg:SI) 0)) then
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
681 resolve_simple_move will ask for the high part of the paradoxical
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
682 subreg, which does not have a value. Just return a zero. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
683 if (ret == NULL_RTX
111
kono
parents: 67
diff changeset
684 && paradoxical_subreg_p (op))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
685 return CONST0_RTX (outermode);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
686
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
687 gcc_assert (ret != NULL_RTX);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
688 return ret;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
689 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
690
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
691 /* Return whether we should resolve X into the registers into which it
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
692 was decomposed. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
693
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
694 static bool
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
695 resolve_reg_p (rtx x)
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 return GET_CODE (x) == CONCATN;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
698 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
699
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
700 /* Return whether X is a SUBREG of a register which we need to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
701 resolve. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
702
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 static bool
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704 resolve_subreg_p (rtx x)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
706 if (GET_CODE (x) != SUBREG)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
707 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
708 return resolve_reg_p (SUBREG_REG (x));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
709 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
710
111
kono
parents: 67
diff changeset
711 /* Look for SUBREGs in *LOC which need to be decomposed. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
712
111
kono
parents: 67
diff changeset
713 static bool
kono
parents: 67
diff changeset
714 resolve_subreg_use (rtx *loc, rtx insn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
715 {
111
kono
parents: 67
diff changeset
716 subrtx_ptr_iterator::array_type array;
kono
parents: 67
diff changeset
717 FOR_EACH_SUBRTX_PTR (iter, array, loc, NONCONST)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
718 {
111
kono
parents: 67
diff changeset
719 rtx *loc = *iter;
kono
parents: 67
diff changeset
720 rtx x = *loc;
kono
parents: 67
diff changeset
721 if (resolve_subreg_p (x))
kono
parents: 67
diff changeset
722 {
kono
parents: 67
diff changeset
723 x = simplify_subreg_concatn (GET_MODE (x), SUBREG_REG (x),
kono
parents: 67
diff changeset
724 SUBREG_BYTE (x));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
725
111
kono
parents: 67
diff changeset
726 /* It is possible for a note to contain a reference which we can
kono
parents: 67
diff changeset
727 decompose. In this case, return 1 to the caller to indicate
kono
parents: 67
diff changeset
728 that the note must be removed. */
kono
parents: 67
diff changeset
729 if (!x)
kono
parents: 67
diff changeset
730 {
kono
parents: 67
diff changeset
731 gcc_assert (!insn);
kono
parents: 67
diff changeset
732 return true;
kono
parents: 67
diff changeset
733 }
kono
parents: 67
diff changeset
734
kono
parents: 67
diff changeset
735 validate_change (insn, loc, x, 1);
kono
parents: 67
diff changeset
736 iter.skip_subrtxes ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
737 }
111
kono
parents: 67
diff changeset
738 else if (resolve_reg_p (x))
kono
parents: 67
diff changeset
739 /* Return 1 to the caller to indicate that we found a direct
kono
parents: 67
diff changeset
740 reference to a register which is being decomposed. This can
kono
parents: 67
diff changeset
741 happen inside notes, multiword shift or zero-extend
kono
parents: 67
diff changeset
742 instructions. */
kono
parents: 67
diff changeset
743 return true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
744 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
745
111
kono
parents: 67
diff changeset
746 return false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
747 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
748
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
749 /* Resolve any decomposed registers which appear in register notes on
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
750 INSN. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
751
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
752 static void
111
kono
parents: 67
diff changeset
753 resolve_reg_notes (rtx_insn *insn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
755 rtx *pnote, note;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
756
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
757 note = find_reg_equal_equiv_note (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 if (note)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
760 int old_count = num_validated_changes ();
111
kono
parents: 67
diff changeset
761 if (resolve_subreg_use (&XEXP (note, 0), NULL_RTX))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
762 remove_note (insn, note);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
763 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
764 if (old_count != num_validated_changes ())
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
765 df_notes_rescan (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
766 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
767
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
768 pnote = &REG_NOTES (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
769 while (*pnote != NULL_RTX)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
770 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
771 bool del = false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
772
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
773 note = *pnote;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
774 switch (REG_NOTE_KIND (note))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
775 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
776 case REG_DEAD:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
777 case REG_UNUSED:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
778 if (resolve_reg_p (XEXP (note, 0)))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
779 del = true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
780 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
781
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
782 default:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
783 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
784 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
785
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
786 if (del)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
787 *pnote = XEXP (note, 1);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
788 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
789 pnote = &XEXP (note, 1);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
790 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
791 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
792
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
793 /* Return whether X can be decomposed into subwords. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
794
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
795 static bool
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
796 can_decompose_p (rtx x)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
797 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
798 if (REG_P (x))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
799 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
800 unsigned int regno = REGNO (x);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
801
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
802 if (HARD_REGISTER_NUM_P (regno))
111
kono
parents: 67
diff changeset
803 {
kono
parents: 67
diff changeset
804 unsigned int byte, num_bytes;
kono
parents: 67
diff changeset
805
kono
parents: 67
diff changeset
806 num_bytes = GET_MODE_SIZE (GET_MODE (x));
kono
parents: 67
diff changeset
807 for (byte = 0; byte < num_bytes; byte += UNITS_PER_WORD)
kono
parents: 67
diff changeset
808 if (simplify_subreg_regno (regno, GET_MODE (x), byte, word_mode) < 0)
kono
parents: 67
diff changeset
809 return false;
kono
parents: 67
diff changeset
810 return true;
kono
parents: 67
diff changeset
811 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
812 else
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
813 return !bitmap_bit_p (subreg_context, regno);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
814 }
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 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
817 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
818
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
819 /* Decompose the registers used in a simple move SET within INSN. If
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
820 we don't change anything, return INSN, otherwise return the start
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
821 of the sequence of moves. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
822
111
kono
parents: 67
diff changeset
823 static rtx_insn *
kono
parents: 67
diff changeset
824 resolve_simple_move (rtx set, rtx_insn *insn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
825 {
111
kono
parents: 67
diff changeset
826 rtx src, dest, real_dest;
kono
parents: 67
diff changeset
827 rtx_insn *insns;
kono
parents: 67
diff changeset
828 machine_mode orig_mode, dest_mode;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
829 unsigned int words;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
830 bool pushing;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
831
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
832 src = SET_SRC (set);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
833 dest = SET_DEST (set);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
834 orig_mode = GET_MODE (dest);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
835
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
836 words = (GET_MODE_SIZE (orig_mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
111
kono
parents: 67
diff changeset
837 gcc_assert (words > 1);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
838
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
839 start_sequence ();
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 /* We have to handle copying from a SUBREG of a decomposed reg where
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
842 the SUBREG is larger than word size. Rather than assume that we
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
843 can take a word_mode SUBREG of the destination, we copy to a new
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
844 register and then copy that to the destination. */
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 real_dest = NULL_RTX;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
847
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
848 if (GET_CODE (src) == SUBREG
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
849 && resolve_reg_p (SUBREG_REG (src))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
850 && (SUBREG_BYTE (src) != 0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
851 || (GET_MODE_SIZE (orig_mode)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
852 != GET_MODE_SIZE (GET_MODE (SUBREG_REG (src))))))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
853 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
854 real_dest = dest;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
855 dest = gen_reg_rtx (orig_mode);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 if (REG_P (real_dest))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 REG_ATTRS (dest) = REG_ATTRS (real_dest);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
858 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
859
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
860 /* Similarly if we are copying to a SUBREG of a decomposed reg where
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
861 the SUBREG is larger than word size. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
862
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
863 if (GET_CODE (dest) == SUBREG
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
864 && resolve_reg_p (SUBREG_REG (dest))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
865 && (SUBREG_BYTE (dest) != 0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 || (GET_MODE_SIZE (orig_mode)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
867 != GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest))))))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
868 {
111
kono
parents: 67
diff changeset
869 rtx reg, smove;
kono
parents: 67
diff changeset
870 rtx_insn *minsn;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
871
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
872 reg = gen_reg_rtx (orig_mode);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
873 minsn = emit_move_insn (reg, src);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
874 smove = single_set (minsn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
875 gcc_assert (smove != NULL_RTX);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
876 resolve_simple_move (smove, minsn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
877 src = reg;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
878 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
879
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
880 /* If we didn't have any big SUBREGS of decomposed registers, and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
881 neither side of the move is a register we are decomposing, then
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
882 we don't have to do anything here. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
883
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
884 if (src == SET_SRC (set)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
885 && dest == SET_DEST (set)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
886 && !resolve_reg_p (src)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
887 && !resolve_subreg_p (src)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
888 && !resolve_reg_p (dest)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
889 && !resolve_subreg_p (dest))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
890 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
891 end_sequence ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
892 return insn;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
893 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
894
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
895 /* It's possible for the code to use a subreg of a decomposed
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
896 register while forming an address. We need to handle that before
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
897 passing the address to emit_move_insn. We pass NULL_RTX as the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
898 insn parameter to resolve_subreg_use because we can not validate
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
899 the insn yet. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
900 if (MEM_P (src) || MEM_P (dest))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
901 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
902 int acg;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
903
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
904 if (MEM_P (src))
111
kono
parents: 67
diff changeset
905 resolve_subreg_use (&XEXP (src, 0), NULL_RTX);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
906 if (MEM_P (dest))
111
kono
parents: 67
diff changeset
907 resolve_subreg_use (&XEXP (dest, 0), NULL_RTX);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
908 acg = apply_change_group ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
909 gcc_assert (acg);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
910 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
911
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
912 /* If SRC is a register which we can't decompose, or has side
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
913 effects, we need to move via a temporary register. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
914
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
915 if (!can_decompose_p (src)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
916 || side_effects_p (src)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
917 || GET_CODE (src) == ASM_OPERANDS)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
918 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
919 rtx reg;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
920
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
921 reg = gen_reg_rtx (orig_mode);
111
kono
parents: 67
diff changeset
922
kono
parents: 67
diff changeset
923 if (AUTO_INC_DEC)
kono
parents: 67
diff changeset
924 {
kono
parents: 67
diff changeset
925 rtx_insn *move = emit_move_insn (reg, src);
kono
parents: 67
diff changeset
926 if (MEM_P (src))
kono
parents: 67
diff changeset
927 {
kono
parents: 67
diff changeset
928 rtx note = find_reg_note (insn, REG_INC, NULL_RTX);
kono
parents: 67
diff changeset
929 if (note)
kono
parents: 67
diff changeset
930 add_reg_note (move, REG_INC, XEXP (note, 0));
kono
parents: 67
diff changeset
931 }
kono
parents: 67
diff changeset
932 }
kono
parents: 67
diff changeset
933 else
kono
parents: 67
diff changeset
934 emit_move_insn (reg, src);
kono
parents: 67
diff changeset
935
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
936 src = reg;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
937 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
938
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
939 /* If DEST is a register which we can't decompose, or has side
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
940 effects, we need to first move to a temporary register. We
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
941 handle the common case of pushing an operand directly. We also
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
942 go through a temporary register if it holds a floating point
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
943 value. This gives us better code on systems which can't move
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
944 data easily between integer and floating point registers. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
945
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
946 dest_mode = orig_mode;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
947 pushing = push_operand (dest, dest_mode);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
948 if (!can_decompose_p (dest)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
949 || (side_effects_p (dest) && !pushing)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
950 || (!SCALAR_INT_MODE_P (dest_mode)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
951 && !resolve_reg_p (dest)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
952 && !resolve_subreg_p (dest)))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
953 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
954 if (real_dest == NULL_RTX)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
955 real_dest = dest;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
956 if (!SCALAR_INT_MODE_P (dest_mode))
111
kono
parents: 67
diff changeset
957 dest_mode = int_mode_for_mode (dest_mode).require ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
958 dest = gen_reg_rtx (dest_mode);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
959 if (REG_P (real_dest))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
960 REG_ATTRS (dest) = REG_ATTRS (real_dest);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
961 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
962
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
963 if (pushing)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
964 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
965 unsigned int i, j, jinc;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
966
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
967 gcc_assert (GET_MODE_SIZE (orig_mode) % UNITS_PER_WORD == 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
968 gcc_assert (GET_CODE (XEXP (dest, 0)) != PRE_MODIFY);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
969 gcc_assert (GET_CODE (XEXP (dest, 0)) != POST_MODIFY);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
970
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
971 if (WORDS_BIG_ENDIAN == STACK_GROWS_DOWNWARD)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
972 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
973 j = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
974 jinc = 1;
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 else
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 j = words - 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
979 jinc = -1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
980 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
981
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
982 for (i = 0; i < words; ++i, j += jinc)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
983 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
984 rtx temp;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
985
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
986 temp = copy_rtx (XEXP (dest, 0));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
987 temp = adjust_automodify_address_nv (dest, word_mode, temp,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
988 j * UNITS_PER_WORD);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
989 emit_move_insn (temp,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
990 simplify_gen_subreg_concatn (word_mode, src,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
991 orig_mode,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
992 j * UNITS_PER_WORD));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
993 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
994 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
995 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
996 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
997 unsigned int i;
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 if (REG_P (dest) && !HARD_REGISTER_NUM_P (REGNO (dest)))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1000 emit_clobber (dest);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1001
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1002 for (i = 0; i < words; ++i)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1003 emit_move_insn (simplify_gen_subreg_concatn (word_mode, dest,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1004 dest_mode,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1005 i * UNITS_PER_WORD),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1006 simplify_gen_subreg_concatn (word_mode, src,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1007 orig_mode,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1008 i * UNITS_PER_WORD));
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
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1011 if (real_dest != NULL_RTX)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1012 {
111
kono
parents: 67
diff changeset
1013 rtx mdest, smove;
kono
parents: 67
diff changeset
1014 rtx_insn *minsn;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1015
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1016 if (dest_mode == orig_mode)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1017 mdest = dest;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1018 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1019 mdest = simplify_gen_subreg (orig_mode, dest, GET_MODE (dest), 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1020 minsn = emit_move_insn (real_dest, mdest);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1021
111
kono
parents: 67
diff changeset
1022 if (AUTO_INC_DEC && MEM_P (real_dest)
kono
parents: 67
diff changeset
1023 && !(resolve_reg_p (real_dest) || resolve_subreg_p (real_dest)))
kono
parents: 67
diff changeset
1024 {
kono
parents: 67
diff changeset
1025 rtx note = find_reg_note (insn, REG_INC, NULL_RTX);
kono
parents: 67
diff changeset
1026 if (note)
kono
parents: 67
diff changeset
1027 add_reg_note (minsn, REG_INC, XEXP (note, 0));
kono
parents: 67
diff changeset
1028 }
kono
parents: 67
diff changeset
1029
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1030 smove = single_set (minsn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1031 gcc_assert (smove != NULL_RTX);
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 resolve_simple_move (smove, minsn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1034 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1035
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1036 insns = get_insns ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1037 end_sequence ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1038
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1039 copy_reg_eh_region_note_forward (insn, insns, NULL_RTX);
0
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 emit_insn_before (insns, insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1042
111
kono
parents: 67
diff changeset
1043 /* If we get here via self-recursion, then INSN is not yet in the insns
kono
parents: 67
diff changeset
1044 chain and delete_insn will fail. We only want to remove INSN from the
kono
parents: 67
diff changeset
1045 current sequence. See PR56738. */
kono
parents: 67
diff changeset
1046 if (in_sequence_p ())
kono
parents: 67
diff changeset
1047 remove_insn (insn);
kono
parents: 67
diff changeset
1048 else
kono
parents: 67
diff changeset
1049 delete_insn (insn);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1050
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1051 return insns;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1052 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1053
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1054 /* Change a CLOBBER of a decomposed register into a CLOBBER of the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1055 component registers. Return whether we changed something. */
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 static bool
111
kono
parents: 67
diff changeset
1058 resolve_clobber (rtx pat, rtx_insn *insn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1059 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1060 rtx reg;
111
kono
parents: 67
diff changeset
1061 machine_mode orig_mode;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1062 unsigned int words, i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1063 int ret;
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 reg = XEXP (pat, 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1066 if (!resolve_reg_p (reg) && !resolve_subreg_p (reg))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1067 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1068
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1069 orig_mode = GET_MODE (reg);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1070 words = GET_MODE_SIZE (orig_mode);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1071 words = (words + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1072
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1073 ret = validate_change (NULL_RTX, &XEXP (pat, 0),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1074 simplify_gen_subreg_concatn (word_mode, reg,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1075 orig_mode, 0),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1076 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1077 df_insn_rescan (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1078 gcc_assert (ret != 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1079
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1080 for (i = words - 1; i > 0; --i)
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 rtx x;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1083
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1084 x = simplify_gen_subreg_concatn (word_mode, reg, orig_mode,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1085 i * UNITS_PER_WORD);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1086 x = gen_rtx_CLOBBER (VOIDmode, x);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1087 emit_insn_after (x, insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1088 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1089
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1090 resolve_reg_notes (insn);
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 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1093 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1094
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1095 /* A USE of a decomposed register is no longer meaningful. Return
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1096 whether we changed something. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1097
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1098 static bool
111
kono
parents: 67
diff changeset
1099 resolve_use (rtx pat, rtx_insn *insn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1100 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1101 if (resolve_reg_p (XEXP (pat, 0)) || resolve_subreg_p (XEXP (pat, 0)))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103 delete_insn (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1104 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1105 }
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 resolve_reg_notes (insn);
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 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1110 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1111
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1112 /* A VAR_LOCATION can be simplified. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1113
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1114 static void
111
kono
parents: 67
diff changeset
1115 resolve_debug (rtx_insn *insn)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1116 {
111
kono
parents: 67
diff changeset
1117 subrtx_ptr_iterator::array_type array;
kono
parents: 67
diff changeset
1118 FOR_EACH_SUBRTX_PTR (iter, array, &PATTERN (insn), NONCONST)
kono
parents: 67
diff changeset
1119 {
kono
parents: 67
diff changeset
1120 rtx *loc = *iter;
kono
parents: 67
diff changeset
1121 rtx x = *loc;
kono
parents: 67
diff changeset
1122 if (resolve_subreg_p (x))
kono
parents: 67
diff changeset
1123 {
kono
parents: 67
diff changeset
1124 x = simplify_subreg_concatn (GET_MODE (x), SUBREG_REG (x),
kono
parents: 67
diff changeset
1125 SUBREG_BYTE (x));
kono
parents: 67
diff changeset
1126
kono
parents: 67
diff changeset
1127 if (x)
kono
parents: 67
diff changeset
1128 *loc = x;
kono
parents: 67
diff changeset
1129 else
kono
parents: 67
diff changeset
1130 x = copy_rtx (*loc);
kono
parents: 67
diff changeset
1131 }
kono
parents: 67
diff changeset
1132 if (resolve_reg_p (x))
kono
parents: 67
diff changeset
1133 *loc = copy_rtx (x);
kono
parents: 67
diff changeset
1134 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1135
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1136 df_insn_rescan (insn);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1137
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1138 resolve_reg_notes (insn);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1139 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1140
111
kono
parents: 67
diff changeset
1141 /* Check if INSN is a decomposable multiword-shift or zero-extend and
kono
parents: 67
diff changeset
1142 set the decomposable_context bitmap accordingly. SPEED_P is true
kono
parents: 67
diff changeset
1143 if we are optimizing INSN for speed rather than size. Return true
kono
parents: 67
diff changeset
1144 if INSN is decomposable. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1145
111
kono
parents: 67
diff changeset
1146 static bool
kono
parents: 67
diff changeset
1147 find_decomposable_shift_zext (rtx_insn *insn, bool speed_p)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1148 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1149 rtx set;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1150 rtx op;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1151 rtx op_operand;
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 set = single_set (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1154 if (!set)
111
kono
parents: 67
diff changeset
1155 return false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1156
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1157 op = SET_SRC (set);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1158 if (GET_CODE (op) != ASHIFT
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1159 && GET_CODE (op) != LSHIFTRT
111
kono
parents: 67
diff changeset
1160 && GET_CODE (op) != ASHIFTRT
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1161 && GET_CODE (op) != ZERO_EXTEND)
111
kono
parents: 67
diff changeset
1162 return false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1163
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1164 op_operand = XEXP (op, 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1165 if (!REG_P (SET_DEST (set)) || !REG_P (op_operand)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1166 || HARD_REGISTER_NUM_P (REGNO (SET_DEST (set)))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1167 || HARD_REGISTER_NUM_P (REGNO (op_operand))
111
kono
parents: 67
diff changeset
1168 || GET_MODE (op) != twice_word_mode)
kono
parents: 67
diff changeset
1169 return false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1170
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1171 if (GET_CODE (op) == ZERO_EXTEND)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1172 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1173 if (GET_MODE (op_operand) != word_mode
111
kono
parents: 67
diff changeset
1174 || !choices[speed_p].splitting_zext)
kono
parents: 67
diff changeset
1175 return false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1176 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1177 else /* left or right shift */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1178 {
111
kono
parents: 67
diff changeset
1179 bool *splitting = (GET_CODE (op) == ASHIFT
kono
parents: 67
diff changeset
1180 ? choices[speed_p].splitting_ashift
kono
parents: 67
diff changeset
1181 : GET_CODE (op) == ASHIFTRT
kono
parents: 67
diff changeset
1182 ? choices[speed_p].splitting_ashiftrt
kono
parents: 67
diff changeset
1183 : choices[speed_p].splitting_lshiftrt);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1184 if (!CONST_INT_P (XEXP (op, 1))
111
kono
parents: 67
diff changeset
1185 || !IN_RANGE (INTVAL (XEXP (op, 1)), BITS_PER_WORD,
kono
parents: 67
diff changeset
1186 2 * BITS_PER_WORD - 1)
kono
parents: 67
diff changeset
1187 || !splitting[INTVAL (XEXP (op, 1)) - BITS_PER_WORD])
kono
parents: 67
diff changeset
1188 return false;
kono
parents: 67
diff changeset
1189
kono
parents: 67
diff changeset
1190 bitmap_set_bit (decomposable_context, REGNO (op_operand));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1191 }
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 bitmap_set_bit (decomposable_context, REGNO (SET_DEST (set)));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1194
111
kono
parents: 67
diff changeset
1195 return true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1196 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1197
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1198 /* Decompose a more than word wide shift (in INSN) of a multiword
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1199 pseudo or a multiword zero-extend of a wordmode pseudo into a move
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1200 and 'set to zero' insn. Return a pointer to the new insn when a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1201 replacement was done. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1202
111
kono
parents: 67
diff changeset
1203 static rtx_insn *
kono
parents: 67
diff changeset
1204 resolve_shift_zext (rtx_insn *insn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1205 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1206 rtx set;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1207 rtx op;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1208 rtx op_operand;
111
kono
parents: 67
diff changeset
1209 rtx_insn *insns;
kono
parents: 67
diff changeset
1210 rtx src_reg, dest_reg, dest_upper, upper_src = NULL_RTX;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1211 int src_reg_num, dest_reg_num, offset1, offset2, src_offset;
111
kono
parents: 67
diff changeset
1212 scalar_int_mode inner_mode;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1213
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1214 set = single_set (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1215 if (!set)
111
kono
parents: 67
diff changeset
1216 return NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1217
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1218 op = SET_SRC (set);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1219 if (GET_CODE (op) != ASHIFT
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1220 && GET_CODE (op) != LSHIFTRT
111
kono
parents: 67
diff changeset
1221 && GET_CODE (op) != ASHIFTRT
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1222 && GET_CODE (op) != ZERO_EXTEND)
111
kono
parents: 67
diff changeset
1223 return NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1224
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1225 op_operand = XEXP (op, 0);
111
kono
parents: 67
diff changeset
1226 if (!is_a <scalar_int_mode> (GET_MODE (op_operand), &inner_mode))
kono
parents: 67
diff changeset
1227 return NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1228
111
kono
parents: 67
diff changeset
1229 /* We can tear this operation apart only if the regs were already
kono
parents: 67
diff changeset
1230 torn apart. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1231 if (!resolve_reg_p (SET_DEST (set)) && !resolve_reg_p (op_operand))
111
kono
parents: 67
diff changeset
1232 return NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1233
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1234 /* src_reg_num is the number of the word mode register which we
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1235 are operating on. For a left shift and a zero_extend on little
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1236 endian machines this is register 0. */
111
kono
parents: 67
diff changeset
1237 src_reg_num = (GET_CODE (op) == LSHIFTRT || GET_CODE (op) == ASHIFTRT)
kono
parents: 67
diff changeset
1238 ? 1 : 0;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1239
111
kono
parents: 67
diff changeset
1240 if (WORDS_BIG_ENDIAN && GET_MODE_SIZE (inner_mode) > UNITS_PER_WORD)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1241 src_reg_num = 1 - src_reg_num;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1242
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1243 if (GET_CODE (op) == ZERO_EXTEND)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1244 dest_reg_num = WORDS_BIG_ENDIAN ? 1 : 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1245 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1246 dest_reg_num = 1 - src_reg_num;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1247
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1248 offset1 = UNITS_PER_WORD * dest_reg_num;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1249 offset2 = UNITS_PER_WORD * (1 - dest_reg_num);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1250 src_offset = UNITS_PER_WORD * src_reg_num;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1251
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1252 start_sequence ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1253
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1254 dest_reg = simplify_gen_subreg_concatn (word_mode, SET_DEST (set),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1255 GET_MODE (SET_DEST (set)),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1256 offset1);
111
kono
parents: 67
diff changeset
1257 dest_upper = simplify_gen_subreg_concatn (word_mode, SET_DEST (set),
kono
parents: 67
diff changeset
1258 GET_MODE (SET_DEST (set)),
kono
parents: 67
diff changeset
1259 offset2);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1260 src_reg = simplify_gen_subreg_concatn (word_mode, op_operand,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1261 GET_MODE (op_operand),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1262 src_offset);
111
kono
parents: 67
diff changeset
1263 if (GET_CODE (op) == ASHIFTRT
kono
parents: 67
diff changeset
1264 && INTVAL (XEXP (op, 1)) != 2 * BITS_PER_WORD - 1)
kono
parents: 67
diff changeset
1265 upper_src = expand_shift (RSHIFT_EXPR, word_mode, copy_rtx (src_reg),
kono
parents: 67
diff changeset
1266 BITS_PER_WORD - 1, NULL_RTX, 0);
kono
parents: 67
diff changeset
1267
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1268 if (GET_CODE (op) != ZERO_EXTEND)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1269 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1270 int shift_count = INTVAL (XEXP (op, 1));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1271 if (shift_count > BITS_PER_WORD)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1272 src_reg = expand_shift (GET_CODE (op) == ASHIFT ?
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1273 LSHIFT_EXPR : RSHIFT_EXPR,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1274 word_mode, src_reg,
111
kono
parents: 67
diff changeset
1275 shift_count - BITS_PER_WORD,
kono
parents: 67
diff changeset
1276 dest_reg, GET_CODE (op) != ASHIFTRT);
0
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 if (dest_reg != src_reg)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1280 emit_move_insn (dest_reg, src_reg);
111
kono
parents: 67
diff changeset
1281 if (GET_CODE (op) != ASHIFTRT)
kono
parents: 67
diff changeset
1282 emit_move_insn (dest_upper, CONST0_RTX (word_mode));
kono
parents: 67
diff changeset
1283 else if (INTVAL (XEXP (op, 1)) == 2 * BITS_PER_WORD - 1)
kono
parents: 67
diff changeset
1284 emit_move_insn (dest_upper, copy_rtx (src_reg));
kono
parents: 67
diff changeset
1285 else
kono
parents: 67
diff changeset
1286 emit_move_insn (dest_upper, upper_src);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1287 insns = get_insns ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1288
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1289 end_sequence ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1290
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1291 emit_insn_before (insns, insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1292
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1293 if (dump_file)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1294 {
111
kono
parents: 67
diff changeset
1295 rtx_insn *in;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1296 fprintf (dump_file, "; Replacing insn: %d with insns: ", INSN_UID (insn));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1297 for (in = insns; in != insn; in = NEXT_INSN (in))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1298 fprintf (dump_file, "%d ", INSN_UID (in));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1299 fprintf (dump_file, "\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1300 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1301
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1302 delete_insn (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1303 return insns;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1304 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1305
111
kono
parents: 67
diff changeset
1306 /* Print to dump_file a description of what we're doing with shift code CODE.
kono
parents: 67
diff changeset
1307 SPLITTING[X] is true if we are splitting shifts by X + BITS_PER_WORD. */
kono
parents: 67
diff changeset
1308
kono
parents: 67
diff changeset
1309 static void
kono
parents: 67
diff changeset
1310 dump_shift_choices (enum rtx_code code, bool *splitting)
kono
parents: 67
diff changeset
1311 {
kono
parents: 67
diff changeset
1312 int i;
kono
parents: 67
diff changeset
1313 const char *sep;
kono
parents: 67
diff changeset
1314
kono
parents: 67
diff changeset
1315 fprintf (dump_file,
kono
parents: 67
diff changeset
1316 " Splitting mode %s for %s lowering with shift amounts = ",
kono
parents: 67
diff changeset
1317 GET_MODE_NAME (twice_word_mode), GET_RTX_NAME (code));
kono
parents: 67
diff changeset
1318 sep = "";
kono
parents: 67
diff changeset
1319 for (i = 0; i < BITS_PER_WORD; i++)
kono
parents: 67
diff changeset
1320 if (splitting[i])
kono
parents: 67
diff changeset
1321 {
kono
parents: 67
diff changeset
1322 fprintf (dump_file, "%s%d", sep, i + BITS_PER_WORD);
kono
parents: 67
diff changeset
1323 sep = ",";
kono
parents: 67
diff changeset
1324 }
kono
parents: 67
diff changeset
1325 fprintf (dump_file, "\n");
kono
parents: 67
diff changeset
1326 }
kono
parents: 67
diff changeset
1327
kono
parents: 67
diff changeset
1328 /* Print to dump_file a description of what we're doing when optimizing
kono
parents: 67
diff changeset
1329 for speed or size; SPEED_P says which. DESCRIPTION is a description
kono
parents: 67
diff changeset
1330 of the SPEED_P choice. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1331
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1332 static void
111
kono
parents: 67
diff changeset
1333 dump_choices (bool speed_p, const char *description)
kono
parents: 67
diff changeset
1334 {
kono
parents: 67
diff changeset
1335 unsigned int i;
kono
parents: 67
diff changeset
1336
kono
parents: 67
diff changeset
1337 fprintf (dump_file, "Choices when optimizing for %s:\n", description);
kono
parents: 67
diff changeset
1338
kono
parents: 67
diff changeset
1339 for (i = 0; i < MAX_MACHINE_MODE; i++)
kono
parents: 67
diff changeset
1340 if (GET_MODE_SIZE ((machine_mode) i) > UNITS_PER_WORD)
kono
parents: 67
diff changeset
1341 fprintf (dump_file, " %s mode %s for copy lowering.\n",
kono
parents: 67
diff changeset
1342 choices[speed_p].move_modes_to_split[i]
kono
parents: 67
diff changeset
1343 ? "Splitting"
kono
parents: 67
diff changeset
1344 : "Skipping",
kono
parents: 67
diff changeset
1345 GET_MODE_NAME ((machine_mode) i));
kono
parents: 67
diff changeset
1346
kono
parents: 67
diff changeset
1347 fprintf (dump_file, " %s mode %s for zero_extend lowering.\n",
kono
parents: 67
diff changeset
1348 choices[speed_p].splitting_zext ? "Splitting" : "Skipping",
kono
parents: 67
diff changeset
1349 GET_MODE_NAME (twice_word_mode));
kono
parents: 67
diff changeset
1350
kono
parents: 67
diff changeset
1351 dump_shift_choices (ASHIFT, choices[speed_p].splitting_ashift);
kono
parents: 67
diff changeset
1352 dump_shift_choices (LSHIFTRT, choices[speed_p].splitting_lshiftrt);
kono
parents: 67
diff changeset
1353 dump_shift_choices (ASHIFTRT, choices[speed_p].splitting_ashiftrt);
kono
parents: 67
diff changeset
1354 fprintf (dump_file, "\n");
kono
parents: 67
diff changeset
1355 }
kono
parents: 67
diff changeset
1356
kono
parents: 67
diff changeset
1357 /* Look for registers which are always accessed via word-sized SUBREGs
kono
parents: 67
diff changeset
1358 or -if DECOMPOSE_COPIES is true- via copies. Decompose these
kono
parents: 67
diff changeset
1359 registers into several word-sized pseudo-registers. */
kono
parents: 67
diff changeset
1360
kono
parents: 67
diff changeset
1361 static void
kono
parents: 67
diff changeset
1362 decompose_multiword_subregs (bool decompose_copies)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1363 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1364 unsigned int max;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1365 basic_block bb;
111
kono
parents: 67
diff changeset
1366 bool speed_p;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1367
111
kono
parents: 67
diff changeset
1368 if (dump_file)
kono
parents: 67
diff changeset
1369 {
kono
parents: 67
diff changeset
1370 dump_choices (false, "size");
kono
parents: 67
diff changeset
1371 dump_choices (true, "speed");
kono
parents: 67
diff changeset
1372 }
kono
parents: 67
diff changeset
1373
kono
parents: 67
diff changeset
1374 /* Check if this target even has any modes to consider lowering. */
kono
parents: 67
diff changeset
1375 if (!choices[false].something_to_do && !choices[true].something_to_do)
kono
parents: 67
diff changeset
1376 {
kono
parents: 67
diff changeset
1377 if (dump_file)
kono
parents: 67
diff changeset
1378 fprintf (dump_file, "Nothing to do!\n");
kono
parents: 67
diff changeset
1379 return;
kono
parents: 67
diff changeset
1380 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1381
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1382 max = max_reg_num ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1383
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1384 /* First see if there are any multi-word pseudo-registers. If there
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1385 aren't, there is nothing we can do. This should speed up this
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1386 pass in the normal case, since it should be faster than scanning
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1387 all the insns. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1388 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1389 unsigned int i;
111
kono
parents: 67
diff changeset
1390 bool useful_modes_seen = false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1391
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1392 for (i = FIRST_PSEUDO_REGISTER; i < max; ++i)
111
kono
parents: 67
diff changeset
1393 if (regno_reg_rtx[i] != NULL)
kono
parents: 67
diff changeset
1394 {
kono
parents: 67
diff changeset
1395 machine_mode mode = GET_MODE (regno_reg_rtx[i]);
kono
parents: 67
diff changeset
1396 if (choices[false].move_modes_to_split[(int) mode]
kono
parents: 67
diff changeset
1397 || choices[true].move_modes_to_split[(int) mode])
kono
parents: 67
diff changeset
1398 {
kono
parents: 67
diff changeset
1399 useful_modes_seen = true;
kono
parents: 67
diff changeset
1400 break;
kono
parents: 67
diff changeset
1401 }
kono
parents: 67
diff changeset
1402 }
kono
parents: 67
diff changeset
1403
kono
parents: 67
diff changeset
1404 if (!useful_modes_seen)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1405 {
111
kono
parents: 67
diff changeset
1406 if (dump_file)
kono
parents: 67
diff changeset
1407 fprintf (dump_file, "Nothing to lower in this function.\n");
kono
parents: 67
diff changeset
1408 return;
0
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
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1412 if (df)
111
kono
parents: 67
diff changeset
1413 {
kono
parents: 67
diff changeset
1414 df_set_flags (DF_DEFER_INSN_RESCAN);
kono
parents: 67
diff changeset
1415 run_word_dce ();
kono
parents: 67
diff changeset
1416 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1417
111
kono
parents: 67
diff changeset
1418 /* FIXME: It may be possible to change this code to look for each
kono
parents: 67
diff changeset
1419 multi-word pseudo-register and to find each insn which sets or
kono
parents: 67
diff changeset
1420 uses that register. That should be faster than scanning all the
kono
parents: 67
diff changeset
1421 insns. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1422
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1423 decomposable_context = BITMAP_ALLOC (NULL);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1424 non_decomposable_context = BITMAP_ALLOC (NULL);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1425 subreg_context = BITMAP_ALLOC (NULL);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1426
111
kono
parents: 67
diff changeset
1427 reg_copy_graph.create (max);
kono
parents: 67
diff changeset
1428 reg_copy_graph.safe_grow_cleared (max);
kono
parents: 67
diff changeset
1429 memset (reg_copy_graph.address (), 0, sizeof (bitmap) * max);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1430
111
kono
parents: 67
diff changeset
1431 speed_p = optimize_function_for_speed_p (cfun);
kono
parents: 67
diff changeset
1432 FOR_EACH_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1433 {
111
kono
parents: 67
diff changeset
1434 rtx_insn *insn;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1435
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1436 FOR_BB_INSNS (bb, insn)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1437 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1438 rtx set;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1439 enum classify_move_insn cmi;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1440 int i, n;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1441
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1442 if (!INSN_P (insn)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1443 || GET_CODE (PATTERN (insn)) == CLOBBER
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1444 || GET_CODE (PATTERN (insn)) == USE)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1445 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1446
111
kono
parents: 67
diff changeset
1447 recog_memoized (insn);
kono
parents: 67
diff changeset
1448
kono
parents: 67
diff changeset
1449 if (find_decomposable_shift_zext (insn, speed_p))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1450 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1451
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1452 extract_insn (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1453
111
kono
parents: 67
diff changeset
1454 set = simple_move (insn, speed_p);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1455
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1456 if (!set)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1457 cmi = NOT_SIMPLE_MOVE;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1458 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1459 {
111
kono
parents: 67
diff changeset
1460 /* We mark pseudo-to-pseudo copies as decomposable during the
kono
parents: 67
diff changeset
1461 second pass only. The first pass is so early that there is
kono
parents: 67
diff changeset
1462 good chance such moves will be optimized away completely by
kono
parents: 67
diff changeset
1463 subsequent optimizations anyway.
kono
parents: 67
diff changeset
1464
kono
parents: 67
diff changeset
1465 However, we call find_pseudo_copy even during the first pass
kono
parents: 67
diff changeset
1466 so as to properly set up the reg_copy_graph. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1467 if (find_pseudo_copy (set))
111
kono
parents: 67
diff changeset
1468 cmi = decompose_copies? DECOMPOSABLE_SIMPLE_MOVE : SIMPLE_MOVE;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1469 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1470 cmi = SIMPLE_MOVE;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1471 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1472
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1473 n = recog_data.n_operands;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1474 for (i = 0; i < n; ++i)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1475 {
111
kono
parents: 67
diff changeset
1476 find_decomposable_subregs (&recog_data.operand[i], &cmi);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1477
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1478 /* We handle ASM_OPERANDS as a special case to support
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1479 things like x86 rdtsc which returns a DImode value.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1480 We can decompose the output, which will certainly be
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1481 operand 0, but not the inputs. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1482
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1483 if (cmi == SIMPLE_MOVE
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1484 && GET_CODE (SET_SRC (set)) == ASM_OPERANDS)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1485 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1486 gcc_assert (i == 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1487 cmi = NOT_SIMPLE_MOVE;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1488 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1489 }
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 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1492
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1493 bitmap_and_compl_into (decomposable_context, non_decomposable_context);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1494 if (!bitmap_empty_p (decomposable_context))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1495 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1496 unsigned int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1497 sbitmap_iterator sbi;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1498 bitmap_iterator iter;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1499 unsigned int regno;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1500
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1501 propagate_pseudo_copies ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1502
111
kono
parents: 67
diff changeset
1503 auto_sbitmap sub_blocks (last_basic_block_for_fn (cfun));
kono
parents: 67
diff changeset
1504 bitmap_clear (sub_blocks);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1505
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1506 EXECUTE_IF_SET_IN_BITMAP (decomposable_context, 0, regno, iter)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1507 decompose_register (regno);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1508
111
kono
parents: 67
diff changeset
1509 FOR_EACH_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1510 {
111
kono
parents: 67
diff changeset
1511 rtx_insn *insn;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1512
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1513 FOR_BB_INSNS (bb, insn)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1514 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1515 rtx pat;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1516
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1517 if (!INSN_P (insn))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1518 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1519
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1520 pat = PATTERN (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1521 if (GET_CODE (pat) == CLOBBER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1522 resolve_clobber (pat, insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1523 else if (GET_CODE (pat) == USE)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1524 resolve_use (pat, insn);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1525 else if (DEBUG_INSN_P (insn))
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1526 resolve_debug (insn);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1527 else
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 rtx set;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1530 int i;
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 recog_memoized (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1533 extract_insn (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1534
111
kono
parents: 67
diff changeset
1535 set = simple_move (insn, speed_p);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1536 if (set)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1537 {
111
kono
parents: 67
diff changeset
1538 rtx_insn *orig_insn = insn;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1539 bool cfi = control_flow_insn_p (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1540
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1541 /* We can end up splitting loads to multi-word pseudos
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1542 into separate loads to machine word size pseudos.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1543 When this happens, we first had one load that can
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1544 throw, and after resolve_simple_move we'll have a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1545 bunch of loads (at least two). All those loads may
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1546 trap if we can have non-call exceptions, so they
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1547 all will end the current basic block. We split the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1548 block after the outer loop over all insns, but we
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1549 make sure here that we will be able to split the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1550 basic block and still produce the correct control
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1551 flow graph for it. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1552 gcc_assert (!cfi
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1553 || (cfun->can_throw_non_call_exceptions
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1554 && can_throw_internal (insn)));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1555
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1556 insn = resolve_simple_move (set, insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1557 if (insn != orig_insn)
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 recog_memoized (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1560 extract_insn (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1561
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1562 if (cfi)
111
kono
parents: 67
diff changeset
1563 bitmap_set_bit (sub_blocks, bb->index);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1564 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1565 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1566 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1567 {
111
kono
parents: 67
diff changeset
1568 rtx_insn *decomposed_shift;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1569
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1570 decomposed_shift = resolve_shift_zext (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1571 if (decomposed_shift != NULL_RTX)
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 insn = decomposed_shift;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1574 recog_memoized (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1575 extract_insn (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1576 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1577 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1578
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1579 for (i = recog_data.n_operands - 1; i >= 0; --i)
111
kono
parents: 67
diff changeset
1580 resolve_subreg_use (recog_data.operand_loc[i], insn);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1581
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1582 resolve_reg_notes (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1583
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1584 if (num_validated_changes () > 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1585 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1586 for (i = recog_data.n_dups - 1; i >= 0; --i)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1587 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1588 rtx *pl = recog_data.dup_loc[i];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1589 int dup_num = recog_data.dup_num[i];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1590 rtx *px = recog_data.operand_loc[dup_num];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1591
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1592 validate_unshare_change (insn, pl, *px, 1);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1593 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1594
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1595 i = apply_change_group ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1596 gcc_assert (i);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1597 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1598 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1599 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1600 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1601
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1602 /* If we had insns to split that caused control flow insns in the middle
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1603 of a basic block, split those blocks now. Note that we only handle
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1604 the case where splitting a load has caused multiple possibly trapping
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1605 loads to appear. */
111
kono
parents: 67
diff changeset
1606 EXECUTE_IF_SET_IN_BITMAP (sub_blocks, 0, i, sbi)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1607 {
111
kono
parents: 67
diff changeset
1608 rtx_insn *insn, *end;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1609 edge fallthru;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1610
111
kono
parents: 67
diff changeset
1611 bb = BASIC_BLOCK_FOR_FN (cfun, i);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1612 insn = BB_HEAD (bb);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1613 end = BB_END (bb);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1614
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1615 while (insn != end)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1616 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1617 if (control_flow_insn_p (insn))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1618 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1619 /* Split the block after insn. There will be a fallthru
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1620 edge, which is OK so we keep it. We have to create the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1621 exception edges ourselves. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1622 fallthru = split_block (bb, insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1623 rtl_make_eh_edge (NULL, bb, BB_END (bb));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1624 bb = fallthru->dest;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1625 insn = BB_HEAD (bb);
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 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1628 insn = NEXT_INSN (insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1629 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1630 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1631 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1632
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1633 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1634 unsigned int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1635 bitmap b;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1636
111
kono
parents: 67
diff changeset
1637 FOR_EACH_VEC_ELT (reg_copy_graph, i, b)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1638 if (b)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1639 BITMAP_FREE (b);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1640 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1641
111
kono
parents: 67
diff changeset
1642 reg_copy_graph.release ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1643
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1644 BITMAP_FREE (decomposable_context);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1645 BITMAP_FREE (non_decomposable_context);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1646 BITMAP_FREE (subreg_context);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1647 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1648
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1649 /* Implement first lower subreg pass. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1650
111
kono
parents: 67
diff changeset
1651 namespace {
kono
parents: 67
diff changeset
1652
kono
parents: 67
diff changeset
1653 const pass_data pass_data_lower_subreg =
kono
parents: 67
diff changeset
1654 {
kono
parents: 67
diff changeset
1655 RTL_PASS, /* type */
kono
parents: 67
diff changeset
1656 "subreg1", /* name */
kono
parents: 67
diff changeset
1657 OPTGROUP_NONE, /* optinfo_flags */
kono
parents: 67
diff changeset
1658 TV_LOWER_SUBREG, /* tv_id */
kono
parents: 67
diff changeset
1659 0, /* properties_required */
kono
parents: 67
diff changeset
1660 0, /* properties_provided */
kono
parents: 67
diff changeset
1661 0, /* properties_destroyed */
kono
parents: 67
diff changeset
1662 0, /* todo_flags_start */
kono
parents: 67
diff changeset
1663 0, /* todo_flags_finish */
kono
parents: 67
diff changeset
1664 };
kono
parents: 67
diff changeset
1665
kono
parents: 67
diff changeset
1666 class pass_lower_subreg : public rtl_opt_pass
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1667 {
111
kono
parents: 67
diff changeset
1668 public:
kono
parents: 67
diff changeset
1669 pass_lower_subreg (gcc::context *ctxt)
kono
parents: 67
diff changeset
1670 : rtl_opt_pass (pass_data_lower_subreg, ctxt)
kono
parents: 67
diff changeset
1671 {}
kono
parents: 67
diff changeset
1672
kono
parents: 67
diff changeset
1673 /* opt_pass methods: */
kono
parents: 67
diff changeset
1674 virtual bool gate (function *) { return flag_split_wide_types != 0; }
kono
parents: 67
diff changeset
1675 virtual unsigned int execute (function *)
kono
parents: 67
diff changeset
1676 {
kono
parents: 67
diff changeset
1677 decompose_multiword_subregs (false);
kono
parents: 67
diff changeset
1678 return 0;
kono
parents: 67
diff changeset
1679 }
kono
parents: 67
diff changeset
1680
kono
parents: 67
diff changeset
1681 }; // class pass_lower_subreg
kono
parents: 67
diff changeset
1682
kono
parents: 67
diff changeset
1683 } // anon namespace
kono
parents: 67
diff changeset
1684
kono
parents: 67
diff changeset
1685 rtl_opt_pass *
kono
parents: 67
diff changeset
1686 make_pass_lower_subreg (gcc::context *ctxt)
kono
parents: 67
diff changeset
1687 {
kono
parents: 67
diff changeset
1688 return new pass_lower_subreg (ctxt);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1689 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1690
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1691 /* Implement second lower subreg pass. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1692
111
kono
parents: 67
diff changeset
1693 namespace {
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1694
111
kono
parents: 67
diff changeset
1695 const pass_data pass_data_lower_subreg2 =
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1696 {
111
kono
parents: 67
diff changeset
1697 RTL_PASS, /* type */
kono
parents: 67
diff changeset
1698 "subreg2", /* name */
kono
parents: 67
diff changeset
1699 OPTGROUP_NONE, /* optinfo_flags */
kono
parents: 67
diff changeset
1700 TV_LOWER_SUBREG, /* tv_id */
kono
parents: 67
diff changeset
1701 0, /* properties_required */
kono
parents: 67
diff changeset
1702 0, /* properties_provided */
kono
parents: 67
diff changeset
1703 0, /* properties_destroyed */
kono
parents: 67
diff changeset
1704 0, /* todo_flags_start */
kono
parents: 67
diff changeset
1705 TODO_df_finish, /* todo_flags_finish */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1706 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1707
111
kono
parents: 67
diff changeset
1708 class pass_lower_subreg2 : public rtl_opt_pass
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1709 {
111
kono
parents: 67
diff changeset
1710 public:
kono
parents: 67
diff changeset
1711 pass_lower_subreg2 (gcc::context *ctxt)
kono
parents: 67
diff changeset
1712 : rtl_opt_pass (pass_data_lower_subreg2, ctxt)
kono
parents: 67
diff changeset
1713 {}
kono
parents: 67
diff changeset
1714
kono
parents: 67
diff changeset
1715 /* opt_pass methods: */
kono
parents: 67
diff changeset
1716 virtual bool gate (function *) { return flag_split_wide_types != 0; }
kono
parents: 67
diff changeset
1717 virtual unsigned int execute (function *)
kono
parents: 67
diff changeset
1718 {
kono
parents: 67
diff changeset
1719 decompose_multiword_subregs (true);
kono
parents: 67
diff changeset
1720 return 0;
kono
parents: 67
diff changeset
1721 }
kono
parents: 67
diff changeset
1722
kono
parents: 67
diff changeset
1723 }; // class pass_lower_subreg2
kono
parents: 67
diff changeset
1724
kono
parents: 67
diff changeset
1725 } // anon namespace
kono
parents: 67
diff changeset
1726
kono
parents: 67
diff changeset
1727 rtl_opt_pass *
kono
parents: 67
diff changeset
1728 make_pass_lower_subreg2 (gcc::context *ctxt)
kono
parents: 67
diff changeset
1729 {
kono
parents: 67
diff changeset
1730 return new pass_lower_subreg2 (ctxt);
kono
parents: 67
diff changeset
1731 }