annotate gcc/mode-switching.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
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 /* CPU mode switching
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 1998-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 This file is part of GCC.
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 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
7 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
8 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
9 version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 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
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 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
14 for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 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
17 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 #include "config.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #include "coretypes.h"
111
kono
parents: 67
diff changeset
23 #include "backend.h"
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
24 #include "target.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 #include "rtl.h"
111
kono
parents: 67
diff changeset
26 #include "cfghooks.h"
kono
parents: 67
diff changeset
27 #include "df.h"
kono
parents: 67
diff changeset
28 #include "memmodel.h"
kono
parents: 67
diff changeset
29 #include "tm_p.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 #include "regs.h"
111
kono
parents: 67
diff changeset
31 #include "emit-rtl.h"
kono
parents: 67
diff changeset
32 #include "cfgrtl.h"
kono
parents: 67
diff changeset
33 #include "cfganal.h"
kono
parents: 67
diff changeset
34 #include "lcm.h"
kono
parents: 67
diff changeset
35 #include "cfgcleanup.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 #include "tree-pass.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 /* We want target macros for the mode switching code to be able to refer
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 to instruction attribute values. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 #include "insn-attr.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 #ifdef OPTIMIZE_MODE_SWITCHING
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 /* The algorithm for setting the modes consists of scanning the insn list
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 and finding all the insns which require a specific mode. Each insn gets
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 a unique struct seginfo element. These structures are inserted into a list
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 for each basic block. For each entity, there is an array of bb_info over
111
kono
parents: 67
diff changeset
48 the flow graph basic blocks (local var 'bb_info'), which contains a list
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 of all insns within that basic block, in the order they are encountered.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 For each entity, any basic block WITHOUT any insns requiring a specific
111
kono
parents: 67
diff changeset
52 mode are given a single entry without a mode (each basic block in the
kono
parents: 67
diff changeset
53 flow graph must have at least one entry in the segment table).
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 The LCM algorithm is then run over the flow graph to determine where to
111
kono
parents: 67
diff changeset
56 place the sets to the highest-priority mode with respect to the first
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 insn in any one block. Any adjustments required to the transparency
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 vectors are made, then the next iteration starts for the next-lower
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 priority mode, till for each entity all modes are exhausted.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60
111
kono
parents: 67
diff changeset
61 More details can be found in the code of optimize_mode_switching. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 /* This structure contains the information for each insn which requires
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 either single or double mode to be set.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 MODE is the mode this insn must be executed in.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 INSN_PTR is the insn to be executed (may be the note that marks the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 beginning of a basic block).
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 BBNUM is the flow graph basic block this insn occurs in.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 NEXT is the next insn in the same basic block. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 struct seginfo
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 int mode;
111
kono
parents: 67
diff changeset
73 rtx_insn *insn_ptr;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 int bbnum;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 struct seginfo *next;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 HARD_REG_SET regs_live;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 struct bb_info
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 struct seginfo *seginfo;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 int computing;
111
kono
parents: 67
diff changeset
83 int mode_out;
kono
parents: 67
diff changeset
84 int mode_in;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86
111
kono
parents: 67
diff changeset
87 static struct seginfo * new_seginfo (int, rtx_insn *, int, HARD_REG_SET);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 static void add_seginfo (struct bb_info *, struct seginfo *);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 static void reg_dies (rtx, HARD_REG_SET *);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 static void reg_becomes_live (rtx, const_rtx, void *);
111
kono
parents: 67
diff changeset
91
kono
parents: 67
diff changeset
92 /* Clear ode I from entity J in bitmap B. */
kono
parents: 67
diff changeset
93 #define clear_mode_bit(b, j, i) \
kono
parents: 67
diff changeset
94 bitmap_clear_bit (b, (j * max_num_modes) + i)
kono
parents: 67
diff changeset
95
kono
parents: 67
diff changeset
96 /* Test mode I from entity J in bitmap B. */
kono
parents: 67
diff changeset
97 #define mode_bit_p(b, j, i) \
kono
parents: 67
diff changeset
98 bitmap_bit_p (b, (j * max_num_modes) + i)
kono
parents: 67
diff changeset
99
kono
parents: 67
diff changeset
100 /* Set mode I from entity J in bitmal B. */
kono
parents: 67
diff changeset
101 #define set_mode_bit(b, j, i) \
kono
parents: 67
diff changeset
102 bitmap_set_bit (b, (j * max_num_modes) + i)
kono
parents: 67
diff changeset
103
kono
parents: 67
diff changeset
104 /* Emit modes segments from EDGE_LIST associated with entity E.
kono
parents: 67
diff changeset
105 INFO gives mode availability for each mode. */
kono
parents: 67
diff changeset
106
kono
parents: 67
diff changeset
107 static bool
kono
parents: 67
diff changeset
108 commit_mode_sets (struct edge_list *edge_list, int e, struct bb_info *info)
kono
parents: 67
diff changeset
109 {
kono
parents: 67
diff changeset
110 bool need_commit = false;
kono
parents: 67
diff changeset
111
kono
parents: 67
diff changeset
112 for (int ed = NUM_EDGES (edge_list) - 1; ed >= 0; ed--)
kono
parents: 67
diff changeset
113 {
kono
parents: 67
diff changeset
114 edge eg = INDEX_EDGE (edge_list, ed);
kono
parents: 67
diff changeset
115 int mode;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116
111
kono
parents: 67
diff changeset
117 if ((mode = (int)(intptr_t)(eg->aux)) != -1)
kono
parents: 67
diff changeset
118 {
kono
parents: 67
diff changeset
119 HARD_REG_SET live_at_edge;
kono
parents: 67
diff changeset
120 basic_block src_bb = eg->src;
kono
parents: 67
diff changeset
121 int cur_mode = info[src_bb->index].mode_out;
kono
parents: 67
diff changeset
122 rtx_insn *mode_set;
kono
parents: 67
diff changeset
123
kono
parents: 67
diff changeset
124 REG_SET_TO_HARD_REG_SET (live_at_edge, df_get_live_out (src_bb));
kono
parents: 67
diff changeset
125
kono
parents: 67
diff changeset
126 rtl_profile_for_edge (eg);
kono
parents: 67
diff changeset
127 start_sequence ();
kono
parents: 67
diff changeset
128
kono
parents: 67
diff changeset
129 targetm.mode_switching.emit (e, mode, cur_mode, live_at_edge);
kono
parents: 67
diff changeset
130
kono
parents: 67
diff changeset
131 mode_set = get_insns ();
kono
parents: 67
diff changeset
132 end_sequence ();
kono
parents: 67
diff changeset
133 default_rtl_profile ();
kono
parents: 67
diff changeset
134
kono
parents: 67
diff changeset
135 /* Do not bother to insert empty sequence. */
kono
parents: 67
diff changeset
136 if (mode_set == NULL)
kono
parents: 67
diff changeset
137 continue;
kono
parents: 67
diff changeset
138
kono
parents: 67
diff changeset
139 /* We should not get an abnormal edge here. */
kono
parents: 67
diff changeset
140 gcc_assert (! (eg->flags & EDGE_ABNORMAL));
kono
parents: 67
diff changeset
141
kono
parents: 67
diff changeset
142 need_commit = true;
kono
parents: 67
diff changeset
143 insert_insn_on_edge (mode_set, eg);
kono
parents: 67
diff changeset
144 }
kono
parents: 67
diff changeset
145 }
kono
parents: 67
diff changeset
146
kono
parents: 67
diff changeset
147 return need_commit;
kono
parents: 67
diff changeset
148 }
kono
parents: 67
diff changeset
149
kono
parents: 67
diff changeset
150 /* Allocate a new BBINFO structure, initialized with the MODE, INSN,
kono
parents: 67
diff changeset
151 and basic block BB parameters.
kono
parents: 67
diff changeset
152 INSN may not be a NOTE_INSN_BASIC_BLOCK, unless it is an empty
kono
parents: 67
diff changeset
153 basic block; that allows us later to insert instructions in a FIFO-like
kono
parents: 67
diff changeset
154 manner. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 static struct seginfo *
111
kono
parents: 67
diff changeset
157 new_seginfo (int mode, rtx_insn *insn, int bb, HARD_REG_SET regs_live)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 struct seginfo *ptr;
111
kono
parents: 67
diff changeset
160
kono
parents: 67
diff changeset
161 gcc_assert (!NOTE_INSN_BASIC_BLOCK_P (insn)
kono
parents: 67
diff changeset
162 || insn == BB_END (NOTE_BASIC_BLOCK (insn)));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 ptr = XNEW (struct seginfo);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 ptr->mode = mode;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 ptr->insn_ptr = insn;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 ptr->bbnum = bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 ptr->next = NULL;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
168 ptr->regs_live = regs_live;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 return ptr;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 /* Add a seginfo element to the end of a list.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 HEAD is a pointer to the list beginning.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 INFO is the structure to be linked in. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 add_seginfo (struct bb_info *head, struct seginfo *info)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 struct seginfo *ptr;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 if (head->seginfo == NULL)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 head->seginfo = info;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 ptr = head->seginfo;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 while (ptr->next != NULL)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 ptr = ptr->next;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 ptr->next = info;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 /* Record in LIVE that register REG died. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 reg_dies (rtx reg, HARD_REG_SET *live)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 int regno;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 if (!REG_P (reg))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 regno = REGNO (reg);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 if (regno < FIRST_PSEUDO_REGISTER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 remove_from_hard_reg_set (live, GET_MODE (reg), regno);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 /* Record in LIVE that register REG became live.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 This is called via note_stores. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 reg_becomes_live (rtx reg, const_rtx setter ATTRIBUTE_UNUSED, void *live)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 int regno;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 if (GET_CODE (reg) == SUBREG)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 reg = SUBREG_REG (reg);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 if (!REG_P (reg))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 regno = REGNO (reg);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 if (regno < FIRST_PSEUDO_REGISTER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 add_to_hard_reg_set ((HARD_REG_SET *) live, GET_MODE (reg), regno);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 /* Split the fallthrough edge to the exit block, so that we can note
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 that there NORMAL_MODE is required. Return the new block if it's
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 inserted before the exit block. Otherwise return null. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 static basic_block
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 create_pre_exit (int n_entities, int *entity_map, const int *num_modes)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 edge eg;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 edge_iterator ei;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 basic_block pre_exit;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 /* The only non-call predecessor at this stage is a block with a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 fallthrough edge; there can be at most one, but there could be
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 none at all, e.g. when exit is called. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 pre_exit = 0;
111
kono
parents: 67
diff changeset
241 FOR_EACH_EDGE (eg, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 if (eg->flags & EDGE_FALLTHRU)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 basic_block src_bb = eg->src;
111
kono
parents: 67
diff changeset
245 rtx_insn *last_insn;
kono
parents: 67
diff changeset
246 rtx ret_reg;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 gcc_assert (!pre_exit);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 /* If this function returns a value at the end, we have to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 insert the final mode switch before the return value copy
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
251 to its hard register.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
252
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
253 x86 targets use mode-switching infrastructure to
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
254 conditionally insert vzeroupper instruction at the exit
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
255 from the function where there is no need to switch the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
256 mode before the return value copy. The vzeroupper insertion
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
257 pass runs after reload, so use !reload_completed as a stand-in
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
258 for x86 to skip the search for the return value copy insn.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
259
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
260 N.b.: the code below assumes that the return copy insn
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
261 immediately precedes its corresponding use insn. This
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
262 assumption does not hold after reload, since sched1 pass
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
263 can schedule the return copy insn away from its
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
264 corresponding use insn. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
265 if (!reload_completed
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
266 && EDGE_COUNT (EXIT_BLOCK_PTR_FOR_FN (cfun)->preds) == 1
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 && NONJUMP_INSN_P ((last_insn = BB_END (src_bb)))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 && GET_CODE (PATTERN (last_insn)) == USE
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 && GET_CODE ((ret_reg = XEXP (PATTERN (last_insn), 0))) == REG)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 int ret_start = REGNO (ret_reg);
111
kono
parents: 67
diff changeset
272 int nregs = REG_NREGS (ret_reg);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 int ret_end = ret_start + nregs;
111
kono
parents: 67
diff changeset
274 bool short_block = false;
kono
parents: 67
diff changeset
275 bool multi_reg_return = false;
kono
parents: 67
diff changeset
276 bool forced_late_switch = false;
kono
parents: 67
diff changeset
277 rtx_insn *before_return_copy;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 do
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 {
111
kono
parents: 67
diff changeset
281 rtx_insn *return_copy = PREV_INSN (last_insn);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 rtx return_copy_pat, copy_reg;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 int copy_start, copy_num;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 int j;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285
111
kono
parents: 67
diff changeset
286 if (NONDEBUG_INSN_P (return_copy))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 /* When using SJLJ exceptions, the call to the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 unregister function is inserted between the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 clobber of the return value and the copy.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 We do not want to split the block before this
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 or any other call; if we have not found the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 copy yet, the copy must have been deleted. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 if (CALL_P (return_copy))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 {
111
kono
parents: 67
diff changeset
296 short_block = true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 return_copy_pat = PATTERN (return_copy);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 switch (GET_CODE (return_copy_pat))
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 case USE:
111
kono
parents: 67
diff changeset
303 /* Skip USEs of multiple return registers.
kono
parents: 67
diff changeset
304 __builtin_apply pattern is also handled here. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 if (GET_CODE (XEXP (return_copy_pat, 0)) == REG
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
306 && (targetm.calls.function_value_regno_p
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 (REGNO (XEXP (return_copy_pat, 0)))))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 {
111
kono
parents: 67
diff changeset
309 multi_reg_return = true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 last_insn = return_copy;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
314
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 case ASM_OPERANDS:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 /* Skip barrier insns. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 if (!MEM_VOLATILE_P (return_copy_pat))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 break;
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 /* Fall through. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
321
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 case ASM_INPUT:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 case UNSPEC_VOLATILE:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 last_insn = return_copy;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 continue;
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 default:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 }
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 /* If the return register is not (in its entirety)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 likely spilled, the return copy might be
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 partially or completely optimized away. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 return_copy_pat = single_set (return_copy);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 if (!return_copy_pat)
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 return_copy_pat = PATTERN (return_copy);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 if (GET_CODE (return_copy_pat) != CLOBBER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 else if (!optimize)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 /* This might be (clobber (reg [<result>]))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 when not optimizing. Then check if
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 the previous insn is the clobber for
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 the return register. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
346 copy_reg = SET_DEST (return_copy_pat);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 if (GET_CODE (copy_reg) == REG
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 && !HARD_REGISTER_NUM_P (REGNO (copy_reg)))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 if (INSN_P (PREV_INSN (return_copy)))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 return_copy = PREV_INSN (return_copy);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 return_copy_pat = PATTERN (return_copy);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 if (GET_CODE (return_copy_pat) != CLOBBER)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 copy_reg = SET_DEST (return_copy_pat);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 if (GET_CODE (copy_reg) == REG)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 copy_start = REGNO (copy_reg);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 else if (GET_CODE (copy_reg) == SUBREG
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 && GET_CODE (SUBREG_REG (copy_reg)) == REG)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 copy_start = REGNO (SUBREG_REG (copy_reg));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 else
111
kono
parents: 67
diff changeset
367 {
kono
parents: 67
diff changeset
368 /* When control reaches end of non-void function,
kono
parents: 67
diff changeset
369 there are no return copy insns at all. This
kono
parents: 67
diff changeset
370 avoids an ice on that invalid function. */
kono
parents: 67
diff changeset
371 if (ret_start + nregs == ret_end)
kono
parents: 67
diff changeset
372 short_block = true;
kono
parents: 67
diff changeset
373 break;
kono
parents: 67
diff changeset
374 }
kono
parents: 67
diff changeset
375 if (!targetm.calls.function_value_regno_p (copy_start))
kono
parents: 67
diff changeset
376 copy_num = 0;
kono
parents: 67
diff changeset
377 else
kono
parents: 67
diff changeset
378 copy_num = hard_regno_nregs (copy_start,
kono
parents: 67
diff changeset
379 GET_MODE (copy_reg));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
380
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 /* If the return register is not likely spilled, - as is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 the case for floating point on SH4 - then it might
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 be set by an arithmetic operation that needs a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 different mode than the exit block. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 for (j = n_entities - 1; j >= 0; j--)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 int e = entity_map[j];
111
kono
parents: 67
diff changeset
388 int mode =
kono
parents: 67
diff changeset
389 targetm.mode_switching.needed (e, return_copy);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
390
111
kono
parents: 67
diff changeset
391 if (mode != num_modes[e]
kono
parents: 67
diff changeset
392 && mode != targetm.mode_switching.exit (e))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
395 if (j >= 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 {
111
kono
parents: 67
diff changeset
397 /* __builtin_return emits a sequence of loads to all
kono
parents: 67
diff changeset
398 return registers. One of them might require
kono
parents: 67
diff changeset
399 another mode than MODE_EXIT, even if it is
kono
parents: 67
diff changeset
400 unrelated to the return value, so we want to put
kono
parents: 67
diff changeset
401 the final mode switch after it. */
kono
parents: 67
diff changeset
402 if (multi_reg_return
kono
parents: 67
diff changeset
403 && targetm.calls.function_value_regno_p
kono
parents: 67
diff changeset
404 (copy_start))
kono
parents: 67
diff changeset
405 forced_late_switch = true;
kono
parents: 67
diff changeset
406
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 /* For the SH4, floating point loads depend on fpscr,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 thus we might need to put the final mode switch
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 after the return value copy. That is still OK,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 because a floating point return value does not
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 conflict with address reloads. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 if (copy_start >= ret_start
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 && copy_start + copy_num <= ret_end
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 && OBJECT_P (SET_SRC (return_copy_pat)))
111
kono
parents: 67
diff changeset
415 forced_late_switch = true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 }
111
kono
parents: 67
diff changeset
418 if (copy_num == 0)
kono
parents: 67
diff changeset
419 {
kono
parents: 67
diff changeset
420 last_insn = return_copy;
kono
parents: 67
diff changeset
421 continue;
kono
parents: 67
diff changeset
422 }
0
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 if (copy_start >= ret_start
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 && copy_start + copy_num <= ret_end)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426 nregs -= copy_num;
111
kono
parents: 67
diff changeset
427 else if (!multi_reg_return
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
428 || !targetm.calls.function_value_regno_p
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
429 (copy_start))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 last_insn = return_copy;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 /* ??? Exception handling can lead to the return value
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 copy being already separated from the return value use,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 as in unwind-dw2.c .
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 Similarly, conditionally returning without a value,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 and conditionally using builtin_return can lead to an
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 isolated use. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 if (return_copy == BB_HEAD (src_bb))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
440 {
111
kono
parents: 67
diff changeset
441 short_block = true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
442 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 last_insn = return_copy;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
445 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
446 while (nregs);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
447
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
448 /* If we didn't see a full return value copy, verify that there
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
449 is a plausible reason for this. If some, but not all of the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
450 return register is likely spilled, we can expect that there
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
451 is a copy for the likely spilled part. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 gcc_assert (!nregs
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
453 || forced_late_switch
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
454 || short_block
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
455 || !(targetm.class_likely_spilled_p
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 (REGNO_REG_CLASS (ret_start)))
111
kono
parents: 67
diff changeset
457 || nregs != REG_NREGS (ret_reg)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
458 /* For multi-hard-register floating point
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 values, sometimes the likely-spilled part
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
460 is ordinarily copied first, then the other
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
461 part is set with an arithmetic operation.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 This doesn't actually cause reload
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
463 failures, so let it pass. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 || (GET_MODE_CLASS (GET_MODE (ret_reg)) != MODE_INT
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
465 && nregs != 1));
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
466
111
kono
parents: 67
diff changeset
467 if (!NOTE_INSN_BASIC_BLOCK_P (last_insn))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 before_return_copy
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 = emit_note_before (NOTE_INSN_DELETED, last_insn);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
471 /* Instructions preceding LAST_INSN in the same block might
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 require a different mode than MODE_EXIT, so if we might
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
473 have such instructions, keep them in a separate block
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
474 from pre_exit. */
111
kono
parents: 67
diff changeset
475 src_bb = split_block (src_bb,
kono
parents: 67
diff changeset
476 PREV_INSN (before_return_copy))->dest;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
477 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
478 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
479 before_return_copy = last_insn;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
480 pre_exit = split_block (src_bb, before_return_copy)->src;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
481 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 pre_exit = split_edge (eg);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
487
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 return pre_exit;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
490
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 /* Find all insns that need a particular mode setting, and insert the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 necessary mode switches. Return true if we did work. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
493
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
494 static int
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
495 optimize_mode_switching (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
497 int e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
498 basic_block bb;
111
kono
parents: 67
diff changeset
499 bool need_commit = false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 static const int num_modes[] = NUM_MODES_FOR_MODE_SWITCHING;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 #define N_ENTITIES ARRAY_SIZE (num_modes)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 int entity_map[N_ENTITIES];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 struct bb_info *bb_info[N_ENTITIES];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
504 int i, j;
111
kono
parents: 67
diff changeset
505 int n_entities = 0;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 int max_num_modes = 0;
111
kono
parents: 67
diff changeset
507 bool emitted ATTRIBUTE_UNUSED = false;
kono
parents: 67
diff changeset
508 basic_block post_entry = 0;
kono
parents: 67
diff changeset
509 basic_block pre_exit = 0;
kono
parents: 67
diff changeset
510 struct edge_list *edge_list = 0;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511
111
kono
parents: 67
diff changeset
512 /* These bitmaps are used for the LCM algorithm. */
kono
parents: 67
diff changeset
513 sbitmap *kill, *del, *insert, *antic, *transp, *comp;
kono
parents: 67
diff changeset
514 sbitmap *avin, *avout;
kono
parents: 67
diff changeset
515
kono
parents: 67
diff changeset
516 for (e = N_ENTITIES - 1; e >= 0; e--)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 if (OPTIMIZE_MODE_SWITCHING (e))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 int entry_exit_extra = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
520
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 /* Create the list of segments within each basic block.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
522 If NORMAL_MODE is defined, allow for two extra
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 blocks split from the entry and exit block. */
111
kono
parents: 67
diff changeset
524 if (targetm.mode_switching.entry && targetm.mode_switching.exit)
kono
parents: 67
diff changeset
525 entry_exit_extra = 3;
kono
parents: 67
diff changeset
526
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
527 bb_info[n_entities]
111
kono
parents: 67
diff changeset
528 = XCNEWVEC (struct bb_info,
kono
parents: 67
diff changeset
529 last_basic_block_for_fn (cfun) + entry_exit_extra);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 entity_map[n_entities++] = e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 if (num_modes[e] > max_num_modes)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 max_num_modes = num_modes[e];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
534
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 if (! n_entities)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
537
111
kono
parents: 67
diff changeset
538 /* Make sure if MODE_ENTRY is defined MODE_EXIT is defined. */
kono
parents: 67
diff changeset
539 gcc_assert ((targetm.mode_switching.entry && targetm.mode_switching.exit)
kono
parents: 67
diff changeset
540 || (!targetm.mode_switching.entry
kono
parents: 67
diff changeset
541 && !targetm.mode_switching.exit));
kono
parents: 67
diff changeset
542
kono
parents: 67
diff changeset
543 if (targetm.mode_switching.entry && targetm.mode_switching.exit)
kono
parents: 67
diff changeset
544 {
kono
parents: 67
diff changeset
545 /* Split the edge from the entry block, so that we can note that
kono
parents: 67
diff changeset
546 there NORMAL_MODE is supplied. */
kono
parents: 67
diff changeset
547 post_entry = split_edge (single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
kono
parents: 67
diff changeset
548 pre_exit = create_pre_exit (n_entities, entity_map, num_modes);
kono
parents: 67
diff changeset
549 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
550
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
551 df_analyze ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
552
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 /* Create the bitmap vectors. */
111
kono
parents: 67
diff changeset
554 antic = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
kono
parents: 67
diff changeset
555 n_entities * max_num_modes);
kono
parents: 67
diff changeset
556 transp = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
kono
parents: 67
diff changeset
557 n_entities * max_num_modes);
kono
parents: 67
diff changeset
558 comp = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
kono
parents: 67
diff changeset
559 n_entities * max_num_modes);
kono
parents: 67
diff changeset
560 avin = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
kono
parents: 67
diff changeset
561 n_entities * max_num_modes);
kono
parents: 67
diff changeset
562 avout = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
kono
parents: 67
diff changeset
563 n_entities * max_num_modes);
kono
parents: 67
diff changeset
564 kill = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
kono
parents: 67
diff changeset
565 n_entities * max_num_modes);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
566
111
kono
parents: 67
diff changeset
567 bitmap_vector_ones (transp, last_basic_block_for_fn (cfun));
kono
parents: 67
diff changeset
568 bitmap_vector_clear (antic, last_basic_block_for_fn (cfun));
kono
parents: 67
diff changeset
569 bitmap_vector_clear (comp, last_basic_block_for_fn (cfun));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
570
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 for (j = n_entities - 1; j >= 0; j--)
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 int e = entity_map[j];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
574 int no_mode = num_modes[e];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
575 struct bb_info *info = bb_info[j];
111
kono
parents: 67
diff changeset
576 rtx_insn *insn;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
577
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
578 /* Determine what the first use (if any) need for a mode of entity E is.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
579 This will be the mode that is anticipatable for this block.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 Also compute the initial transparency settings. */
111
kono
parents: 67
diff changeset
581 FOR_EACH_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
582 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
583 struct seginfo *ptr;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
584 int last_mode = no_mode;
111
kono
parents: 67
diff changeset
585 bool any_set_required = false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
586 HARD_REG_SET live_now;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
587
111
kono
parents: 67
diff changeset
588 info[bb->index].mode_out = info[bb->index].mode_in = no_mode;
kono
parents: 67
diff changeset
589
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 REG_SET_TO_HARD_REG_SET (live_now, df_get_live_in (bb));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
591
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 /* Pretend the mode is clobbered across abnormal edges. */
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 edge_iterator ei;
111
kono
parents: 67
diff changeset
595 edge eg;
kono
parents: 67
diff changeset
596 FOR_EACH_EDGE (eg, ei, bb->preds)
kono
parents: 67
diff changeset
597 if (eg->flags & EDGE_COMPLEX)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 break;
111
kono
parents: 67
diff changeset
599 if (eg)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 {
111
kono
parents: 67
diff changeset
601 rtx_insn *ins_pos = BB_HEAD (bb);
kono
parents: 67
diff changeset
602 if (LABEL_P (ins_pos))
kono
parents: 67
diff changeset
603 ins_pos = NEXT_INSN (ins_pos);
kono
parents: 67
diff changeset
604 gcc_assert (NOTE_INSN_BASIC_BLOCK_P (ins_pos));
kono
parents: 67
diff changeset
605 if (ins_pos != BB_END (bb))
kono
parents: 67
diff changeset
606 ins_pos = NEXT_INSN (ins_pos);
kono
parents: 67
diff changeset
607 ptr = new_seginfo (no_mode, ins_pos, bb->index, live_now);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
608 add_seginfo (info + bb->index, ptr);
111
kono
parents: 67
diff changeset
609 for (i = 0; i < no_mode; i++)
kono
parents: 67
diff changeset
610 clear_mode_bit (transp[bb->index], j, i);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
611 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
612 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
613
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
614 FOR_BB_INSNS (bb, insn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
615 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
616 if (INSN_P (insn))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
617 {
111
kono
parents: 67
diff changeset
618 int mode = targetm.mode_switching.needed (e, insn);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
619 rtx link;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
620
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
621 if (mode != no_mode && mode != last_mode)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
622 {
111
kono
parents: 67
diff changeset
623 any_set_required = true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
624 last_mode = mode;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
625 ptr = new_seginfo (mode, insn, bb->index, live_now);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
626 add_seginfo (info + bb->index, ptr);
111
kono
parents: 67
diff changeset
627 for (i = 0; i < no_mode; i++)
kono
parents: 67
diff changeset
628 clear_mode_bit (transp[bb->index], j, i);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
629 }
111
kono
parents: 67
diff changeset
630
kono
parents: 67
diff changeset
631 if (targetm.mode_switching.after)
kono
parents: 67
diff changeset
632 last_mode = targetm.mode_switching.after (e, last_mode,
kono
parents: 67
diff changeset
633 insn);
kono
parents: 67
diff changeset
634
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
635 /* Update LIVE_NOW. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
636 for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
637 if (REG_NOTE_KIND (link) == REG_DEAD)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 reg_dies (XEXP (link, 0), &live_now);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
639
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
640 note_stores (insn, reg_becomes_live, &live_now);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
641 for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
642 if (REG_NOTE_KIND (link) == REG_UNUSED)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
643 reg_dies (XEXP (link, 0), &live_now);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
644 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
646
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
647 info[bb->index].computing = last_mode;
111
kono
parents: 67
diff changeset
648 /* Check for blocks without ANY mode requirements.
kono
parents: 67
diff changeset
649 N.B. because of MODE_AFTER, last_mode might still
kono
parents: 67
diff changeset
650 be different from no_mode, in which case we need to
kono
parents: 67
diff changeset
651 mark the block as nontransparent. */
kono
parents: 67
diff changeset
652 if (!any_set_required)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 ptr = new_seginfo (no_mode, BB_END (bb), bb->index, live_now);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
655 add_seginfo (info + bb->index, ptr);
111
kono
parents: 67
diff changeset
656 if (last_mode != no_mode)
kono
parents: 67
diff changeset
657 for (i = 0; i < no_mode; i++)
kono
parents: 67
diff changeset
658 clear_mode_bit (transp[bb->index], j, i);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
659 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
660 }
111
kono
parents: 67
diff changeset
661 if (targetm.mode_switching.entry && targetm.mode_switching.exit)
kono
parents: 67
diff changeset
662 {
kono
parents: 67
diff changeset
663 int mode = targetm.mode_switching.entry (e);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
664
111
kono
parents: 67
diff changeset
665 info[post_entry->index].mode_out =
kono
parents: 67
diff changeset
666 info[post_entry->index].mode_in = no_mode;
kono
parents: 67
diff changeset
667 if (pre_exit)
kono
parents: 67
diff changeset
668 {
kono
parents: 67
diff changeset
669 info[pre_exit->index].mode_out =
kono
parents: 67
diff changeset
670 info[pre_exit->index].mode_in = no_mode;
kono
parents: 67
diff changeset
671 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
672
111
kono
parents: 67
diff changeset
673 if (mode != no_mode)
kono
parents: 67
diff changeset
674 {
kono
parents: 67
diff changeset
675 bb = post_entry;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
676
111
kono
parents: 67
diff changeset
677 /* By always making this nontransparent, we save
kono
parents: 67
diff changeset
678 an extra check in make_preds_opaque. We also
kono
parents: 67
diff changeset
679 need this to avoid confusing pre_edge_lcm when
kono
parents: 67
diff changeset
680 antic is cleared but transp and comp are set. */
kono
parents: 67
diff changeset
681 for (i = 0; i < no_mode; i++)
kono
parents: 67
diff changeset
682 clear_mode_bit (transp[bb->index], j, i);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
683
111
kono
parents: 67
diff changeset
684 /* Insert a fake computing definition of MODE into entry
kono
parents: 67
diff changeset
685 blocks which compute no mode. This represents the mode on
kono
parents: 67
diff changeset
686 entry. */
kono
parents: 67
diff changeset
687 info[bb->index].computing = mode;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
688
111
kono
parents: 67
diff changeset
689 if (pre_exit)
kono
parents: 67
diff changeset
690 info[pre_exit->index].seginfo->mode =
kono
parents: 67
diff changeset
691 targetm.mode_switching.exit (e);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
692 }
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
111
kono
parents: 67
diff changeset
695 /* Set the anticipatable and computing arrays. */
kono
parents: 67
diff changeset
696 for (i = 0; i < no_mode; i++)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
697 {
111
kono
parents: 67
diff changeset
698 int m = targetm.mode_switching.priority (entity_map[j], i);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
699
111
kono
parents: 67
diff changeset
700 FOR_EACH_BB_FN (bb, cfun)
kono
parents: 67
diff changeset
701 {
kono
parents: 67
diff changeset
702 if (info[bb->index].seginfo->mode == m)
kono
parents: 67
diff changeset
703 set_mode_bit (antic[bb->index], j, m);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704
111
kono
parents: 67
diff changeset
705 if (info[bb->index].computing == m)
kono
parents: 67
diff changeset
706 set_mode_bit (comp[bb->index], j, m);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
707 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
708 }
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 /* Calculate the optimal locations for the
kono
parents: 67
diff changeset
712 placement mode switches to modes with priority I. */
kono
parents: 67
diff changeset
713
kono
parents: 67
diff changeset
714 FOR_EACH_BB_FN (bb, cfun)
kono
parents: 67
diff changeset
715 bitmap_not (kill[bb->index], transp[bb->index]);
kono
parents: 67
diff changeset
716
kono
parents: 67
diff changeset
717 edge_list = pre_edge_lcm_avs (n_entities * max_num_modes, transp, comp, antic,
kono
parents: 67
diff changeset
718 kill, avin, avout, &insert, &del);
kono
parents: 67
diff changeset
719
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 for (j = n_entities - 1; j >= 0; j--)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
721 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
722 int no_mode = num_modes[entity_map[j]];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
723
111
kono
parents: 67
diff changeset
724 /* Insert all mode sets that have been inserted by lcm. */
kono
parents: 67
diff changeset
725
kono
parents: 67
diff changeset
726 for (int ed = NUM_EDGES (edge_list) - 1; ed >= 0; ed--)
kono
parents: 67
diff changeset
727 {
kono
parents: 67
diff changeset
728 edge eg = INDEX_EDGE (edge_list, ed);
kono
parents: 67
diff changeset
729
kono
parents: 67
diff changeset
730 eg->aux = (void *)(intptr_t)-1;
kono
parents: 67
diff changeset
731
kono
parents: 67
diff changeset
732 for (i = 0; i < no_mode; i++)
kono
parents: 67
diff changeset
733 {
kono
parents: 67
diff changeset
734 int m = targetm.mode_switching.priority (entity_map[j], i);
kono
parents: 67
diff changeset
735 if (mode_bit_p (insert[ed], j, m))
kono
parents: 67
diff changeset
736 {
kono
parents: 67
diff changeset
737 eg->aux = (void *)(intptr_t)m;
kono
parents: 67
diff changeset
738 break;
kono
parents: 67
diff changeset
739 }
kono
parents: 67
diff changeset
740 }
kono
parents: 67
diff changeset
741 }
kono
parents: 67
diff changeset
742
kono
parents: 67
diff changeset
743 FOR_EACH_BB_FN (bb, cfun)
kono
parents: 67
diff changeset
744 {
kono
parents: 67
diff changeset
745 struct bb_info *info = bb_info[j];
kono
parents: 67
diff changeset
746 int last_mode = no_mode;
kono
parents: 67
diff changeset
747
kono
parents: 67
diff changeset
748 /* intialize mode in availability for bb. */
kono
parents: 67
diff changeset
749 for (i = 0; i < no_mode; i++)
kono
parents: 67
diff changeset
750 if (mode_bit_p (avout[bb->index], j, i))
kono
parents: 67
diff changeset
751 {
kono
parents: 67
diff changeset
752 if (last_mode == no_mode)
kono
parents: 67
diff changeset
753 last_mode = i;
kono
parents: 67
diff changeset
754 if (last_mode != i)
kono
parents: 67
diff changeset
755 {
kono
parents: 67
diff changeset
756 last_mode = no_mode;
kono
parents: 67
diff changeset
757 break;
kono
parents: 67
diff changeset
758 }
kono
parents: 67
diff changeset
759 }
kono
parents: 67
diff changeset
760 info[bb->index].mode_out = last_mode;
kono
parents: 67
diff changeset
761
kono
parents: 67
diff changeset
762 /* intialize mode out availability for bb. */
kono
parents: 67
diff changeset
763 last_mode = no_mode;
kono
parents: 67
diff changeset
764 for (i = 0; i < no_mode; i++)
kono
parents: 67
diff changeset
765 if (mode_bit_p (avin[bb->index], j, i))
kono
parents: 67
diff changeset
766 {
kono
parents: 67
diff changeset
767 if (last_mode == no_mode)
kono
parents: 67
diff changeset
768 last_mode = i;
kono
parents: 67
diff changeset
769 if (last_mode != i)
kono
parents: 67
diff changeset
770 {
kono
parents: 67
diff changeset
771 last_mode = no_mode;
kono
parents: 67
diff changeset
772 break;
kono
parents: 67
diff changeset
773 }
kono
parents: 67
diff changeset
774 }
kono
parents: 67
diff changeset
775 info[bb->index].mode_in = last_mode;
kono
parents: 67
diff changeset
776
kono
parents: 67
diff changeset
777 for (i = 0; i < no_mode; i++)
kono
parents: 67
diff changeset
778 if (mode_bit_p (del[bb->index], j, i))
kono
parents: 67
diff changeset
779 info[bb->index].seginfo->mode = no_mode;
kono
parents: 67
diff changeset
780 }
kono
parents: 67
diff changeset
781
kono
parents: 67
diff changeset
782 /* Now output the remaining mode sets in all the segments. */
kono
parents: 67
diff changeset
783
kono
parents: 67
diff changeset
784 /* In case there was no mode inserted. the mode information on the edge
kono
parents: 67
diff changeset
785 might not be complete.
kono
parents: 67
diff changeset
786 Update mode info on edges and commit pending mode sets. */
kono
parents: 67
diff changeset
787 need_commit |= commit_mode_sets (edge_list, entity_map[j], bb_info[j]);
kono
parents: 67
diff changeset
788
kono
parents: 67
diff changeset
789 /* Reset modes for next entity. */
kono
parents: 67
diff changeset
790 clear_aux_for_edges ();
kono
parents: 67
diff changeset
791
kono
parents: 67
diff changeset
792 FOR_EACH_BB_FN (bb, cfun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
793 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
794 struct seginfo *ptr, *next;
111
kono
parents: 67
diff changeset
795 int cur_mode = bb_info[j][bb->index].mode_in;
kono
parents: 67
diff changeset
796
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
797 for (ptr = bb_info[j][bb->index].seginfo; ptr; ptr = next)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
798 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
799 next = ptr->next;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
800 if (ptr->mode != no_mode)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
801 {
111
kono
parents: 67
diff changeset
802 rtx_insn *mode_set;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
803
111
kono
parents: 67
diff changeset
804 rtl_profile_for_bb (bb);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
805 start_sequence ();
111
kono
parents: 67
diff changeset
806
kono
parents: 67
diff changeset
807 targetm.mode_switching.emit (entity_map[j], ptr->mode,
kono
parents: 67
diff changeset
808 cur_mode, ptr->regs_live);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
809 mode_set = get_insns ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
810 end_sequence ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
811
111
kono
parents: 67
diff changeset
812 /* modes kill each other inside a basic block. */
kono
parents: 67
diff changeset
813 cur_mode = ptr->mode;
kono
parents: 67
diff changeset
814
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
815 /* Insert MODE_SET only if it is nonempty. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
816 if (mode_set != NULL_RTX)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
817 {
111
kono
parents: 67
diff changeset
818 emitted = true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
819 if (NOTE_INSN_BASIC_BLOCK_P (ptr->insn_ptr))
111
kono
parents: 67
diff changeset
820 /* We need to emit the insns in a FIFO-like manner,
kono
parents: 67
diff changeset
821 i.e. the first to be emitted at our insertion
kono
parents: 67
diff changeset
822 point ends up first in the instruction steam.
kono
parents: 67
diff changeset
823 Because we made sure that NOTE_INSN_BASIC_BLOCK is
kono
parents: 67
diff changeset
824 only used for initially empty basic blocks, we
kono
parents: 67
diff changeset
825 can achieve this by appending at the end of
kono
parents: 67
diff changeset
826 the block. */
kono
parents: 67
diff changeset
827 emit_insn_after
kono
parents: 67
diff changeset
828 (mode_set, BB_END (NOTE_BASIC_BLOCK (ptr->insn_ptr)));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
829 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
830 emit_insn_before (mode_set, ptr->insn_ptr);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
831 }
111
kono
parents: 67
diff changeset
832
kono
parents: 67
diff changeset
833 default_rtl_profile ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
834 }
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 free (ptr);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
837 }
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
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
840 free (bb_info[j]);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
841 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
842
111
kono
parents: 67
diff changeset
843 free_edge_list (edge_list);
kono
parents: 67
diff changeset
844
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
845 /* Finished. Free up all the things we've allocated. */
111
kono
parents: 67
diff changeset
846 sbitmap_vector_free (del);
kono
parents: 67
diff changeset
847 sbitmap_vector_free (insert);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
848 sbitmap_vector_free (kill);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
849 sbitmap_vector_free (antic);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
850 sbitmap_vector_free (transp);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
851 sbitmap_vector_free (comp);
111
kono
parents: 67
diff changeset
852 sbitmap_vector_free (avin);
kono
parents: 67
diff changeset
853 sbitmap_vector_free (avout);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
854
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
855 if (need_commit)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 commit_edge_insertions ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
857
111
kono
parents: 67
diff changeset
858 if (targetm.mode_switching.entry && targetm.mode_switching.exit)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
859 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
860 free_dominance_info (CDI_DOMINATORS);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
861 cleanup_cfg (CLEANUP_NO_INSN_DEL);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
862 }
111
kono
parents: 67
diff changeset
863 else if (!need_commit && !emitted)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
864 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
865
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 return 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
867 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
868
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
869 #endif /* OPTIMIZE_MODE_SWITCHING */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
870
111
kono
parents: 67
diff changeset
871 namespace {
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
872
111
kono
parents: 67
diff changeset
873 const pass_data pass_data_mode_switching =
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
874 {
111
kono
parents: 67
diff changeset
875 RTL_PASS, /* type */
kono
parents: 67
diff changeset
876 "mode_sw", /* name */
kono
parents: 67
diff changeset
877 OPTGROUP_NONE, /* optinfo_flags */
kono
parents: 67
diff changeset
878 TV_MODE_SWITCH, /* tv_id */
kono
parents: 67
diff changeset
879 0, /* properties_required */
kono
parents: 67
diff changeset
880 0, /* properties_provided */
kono
parents: 67
diff changeset
881 0, /* properties_destroyed */
kono
parents: 67
diff changeset
882 0, /* todo_flags_start */
kono
parents: 67
diff changeset
883 TODO_df_finish, /* todo_flags_finish */
kono
parents: 67
diff changeset
884 };
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
885
111
kono
parents: 67
diff changeset
886 class pass_mode_switching : public rtl_opt_pass
kono
parents: 67
diff changeset
887 {
kono
parents: 67
diff changeset
888 public:
kono
parents: 67
diff changeset
889 pass_mode_switching (gcc::context *ctxt)
kono
parents: 67
diff changeset
890 : rtl_opt_pass (pass_data_mode_switching, ctxt)
kono
parents: 67
diff changeset
891 {}
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
892
111
kono
parents: 67
diff changeset
893 /* opt_pass methods: */
kono
parents: 67
diff changeset
894 /* The epiphany backend creates a second instance of this pass, so we need
kono
parents: 67
diff changeset
895 a clone method. */
kono
parents: 67
diff changeset
896 opt_pass * clone () { return new pass_mode_switching (m_ctxt); }
kono
parents: 67
diff changeset
897 virtual bool gate (function *)
kono
parents: 67
diff changeset
898 {
kono
parents: 67
diff changeset
899 #ifdef OPTIMIZE_MODE_SWITCHING
kono
parents: 67
diff changeset
900 return true;
kono
parents: 67
diff changeset
901 #else
kono
parents: 67
diff changeset
902 return false;
kono
parents: 67
diff changeset
903 #endif
kono
parents: 67
diff changeset
904 }
kono
parents: 67
diff changeset
905
kono
parents: 67
diff changeset
906 virtual unsigned int execute (function *)
kono
parents: 67
diff changeset
907 {
kono
parents: 67
diff changeset
908 #ifdef OPTIMIZE_MODE_SWITCHING
kono
parents: 67
diff changeset
909 optimize_mode_switching ();
kono
parents: 67
diff changeset
910 #endif /* OPTIMIZE_MODE_SWITCHING */
kono
parents: 67
diff changeset
911 return 0;
kono
parents: 67
diff changeset
912 }
kono
parents: 67
diff changeset
913
kono
parents: 67
diff changeset
914 }; // class pass_mode_switching
kono
parents: 67
diff changeset
915
kono
parents: 67
diff changeset
916 } // anon namespace
kono
parents: 67
diff changeset
917
kono
parents: 67
diff changeset
918 rtl_opt_pass *
kono
parents: 67
diff changeset
919 make_pass_mode_switching (gcc::context *ctxt)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
920 {
111
kono
parents: 67
diff changeset
921 return new pass_mode_switching (ctxt);
kono
parents: 67
diff changeset
922 }