annotate gcc/web.c @ 127:4c56639505ff

fix function.c and add CbC-example Makefile
author mir3636
date Wed, 11 Apr 2018 18:46:58 +0900
parents 04ced10e8804
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 /* Web construction code for GNU compiler.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 Contributed by Jan Hubicka.
111
kono
parents: 67
diff changeset
3 Copyright (C) 2001-2017 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 /* Simple optimization pass that splits independent uses of each pseudo,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 increasing effectiveness of other optimizations. The optimization can
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 serve as an example of use for the dataflow module.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 We don't split registers with REG_USERVAR set unless -fmessy-debugging
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 is specified, because debugging information about such split variables
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 is almost unusable.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 TODO
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 - We may use profile information and ignore infrequent use for the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 purpose of web unifying, inserting the compensation code later to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 implement full induction variable expansion for loops (currently
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 we expand only if the induction variable is dead afterward, which
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 is often the case). */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 #include "config.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 #include "coretypes.h"
111
kono
parents: 67
diff changeset
39 #include "backend.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 #include "rtl.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 #include "df.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
42 #include "insn-config.h"
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
43 #include "recog.h"
111
kono
parents: 67
diff changeset
44
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 #include "tree-pass.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 /* Find the root of unionfind tree (the representative of set). */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49
111
kono
parents: 67
diff changeset
50 web_entry_base *
kono
parents: 67
diff changeset
51 web_entry_base::unionfind_root ()
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 {
111
kono
parents: 67
diff changeset
53 web_entry_base *element = this, *element1 = this, *element2;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54
111
kono
parents: 67
diff changeset
55 while (element->pred ())
kono
parents: 67
diff changeset
56 element = element->pred ();
kono
parents: 67
diff changeset
57 while (element1->pred ())
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 {
111
kono
parents: 67
diff changeset
59 element2 = element1->pred ();
kono
parents: 67
diff changeset
60 element1->set_pred (element);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 element1 = element2;
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 return element;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
66 /* Union sets.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 Return true if FIRST and SECOND points to the same web entry structure and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 nothing is done. Otherwise, return false. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 bool
111
kono
parents: 67
diff changeset
71 unionfind_union (web_entry_base *first, web_entry_base *second)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 {
111
kono
parents: 67
diff changeset
73 first = first->unionfind_root ();
kono
parents: 67
diff changeset
74 second = second->unionfind_root ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 if (first == second)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 return true;
111
kono
parents: 67
diff changeset
77 second->set_pred (first);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80
111
kono
parents: 67
diff changeset
81 class web_entry : public web_entry_base
kono
parents: 67
diff changeset
82 {
kono
parents: 67
diff changeset
83 private:
kono
parents: 67
diff changeset
84 rtx reg_pvt;
kono
parents: 67
diff changeset
85
kono
parents: 67
diff changeset
86 public:
kono
parents: 67
diff changeset
87 rtx reg () { return reg_pvt; }
kono
parents: 67
diff changeset
88 void set_reg (rtx r) { reg_pvt = r; }
kono
parents: 67
diff changeset
89 };
kono
parents: 67
diff changeset
90
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
91 /* For INSN, union all defs and uses that are linked by match_dup.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
92 FUN is the function that does the union. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
93
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
94 static void
111
kono
parents: 67
diff changeset
95 union_match_dups (rtx_insn *insn, web_entry *def_entry, web_entry *use_entry,
kono
parents: 67
diff changeset
96 bool (*fun) (web_entry_base *, web_entry_base *))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
97 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
98 struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
111
kono
parents: 67
diff changeset
99 df_ref use_link = DF_INSN_INFO_USES (insn_info);
kono
parents: 67
diff changeset
100 df_ref def_link = DF_INSN_INFO_DEFS (insn_info);
kono
parents: 67
diff changeset
101 struct web_entry *dup_entry;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
102 int i;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
103
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
104 extract_insn (insn);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
105
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
106 for (i = 0; i < recog_data.n_dups; i++)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
107 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
108 int op = recog_data.dup_num[i];
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
109 enum op_type type = recog_data.operand_type[op];
111
kono
parents: 67
diff changeset
110 df_ref ref, dupref;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
111 struct web_entry *entry;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
112
111
kono
parents: 67
diff changeset
113 dup_entry = use_entry;
kono
parents: 67
diff changeset
114 for (dupref = use_link; dupref; dupref = DF_REF_NEXT_LOC (dupref))
kono
parents: 67
diff changeset
115 if (DF_REF_LOC (dupref) == recog_data.dup_loc[i])
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
116 break;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
117
111
kono
parents: 67
diff changeset
118 if (dupref == NULL && type == OP_INOUT)
kono
parents: 67
diff changeset
119 {
kono
parents: 67
diff changeset
120 dup_entry = def_entry;
kono
parents: 67
diff changeset
121 for (dupref = def_link; dupref; dupref = DF_REF_NEXT_LOC (dupref))
kono
parents: 67
diff changeset
122 if (DF_REF_LOC (dupref) == recog_data.dup_loc[i])
kono
parents: 67
diff changeset
123 break;
kono
parents: 67
diff changeset
124 }
kono
parents: 67
diff changeset
125 /* ??? *DUPREF can still be zero, because when an operand matches
kono
parents: 67
diff changeset
126 a memory, DF_REF_LOC (use_link[n]) points to the register part
kono
parents: 67
diff changeset
127 of the address, whereas recog_data.dup_loc[m] points to the
kono
parents: 67
diff changeset
128 entire memory ref, thus we fail to find the duplicate entry,
kono
parents: 67
diff changeset
129 even though it is there.
kono
parents: 67
diff changeset
130 Example: i686-pc-linux-gnu gcc.c-torture/compile/950607-1.c
kono
parents: 67
diff changeset
131 -O3 -fomit-frame-pointer -funroll-loops */
kono
parents: 67
diff changeset
132 if (dupref == NULL
kono
parents: 67
diff changeset
133 || DF_REF_REGNO (dupref) < FIRST_PSEUDO_REGISTER)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
134 continue;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
135
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
136 ref = type == OP_IN ? use_link : def_link;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
137 entry = type == OP_IN ? use_entry : def_entry;
111
kono
parents: 67
diff changeset
138 for (; ref; ref = DF_REF_NEXT_LOC (ref))
kono
parents: 67
diff changeset
139 {
kono
parents: 67
diff changeset
140 rtx *l = DF_REF_LOC (ref);
kono
parents: 67
diff changeset
141 if (l == recog_data.operand_loc[op])
kono
parents: 67
diff changeset
142 break;
kono
parents: 67
diff changeset
143 if (l && DF_REF_REAL_LOC (ref) == recog_data.operand_loc[op])
kono
parents: 67
diff changeset
144 break;
kono
parents: 67
diff changeset
145 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
146
111
kono
parents: 67
diff changeset
147 if (!ref && type == OP_INOUT)
kono
parents: 67
diff changeset
148 {
kono
parents: 67
diff changeset
149 entry = use_entry;
kono
parents: 67
diff changeset
150 for (ref = use_link; ref; ref = DF_REF_NEXT_LOC (ref))
kono
parents: 67
diff changeset
151 {
kono
parents: 67
diff changeset
152 rtx *l = DF_REF_LOC (ref);
kono
parents: 67
diff changeset
153 if (l == recog_data.operand_loc[op])
kono
parents: 67
diff changeset
154 break;
kono
parents: 67
diff changeset
155 if (l && DF_REF_REAL_LOC (ref) == recog_data.operand_loc[op])
kono
parents: 67
diff changeset
156 break;
kono
parents: 67
diff changeset
157 }
kono
parents: 67
diff changeset
158 }
kono
parents: 67
diff changeset
159
kono
parents: 67
diff changeset
160 gcc_assert (ref);
kono
parents: 67
diff changeset
161 (*fun) (dup_entry + DF_REF_ID (dupref), entry + DF_REF_ID (ref));
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
162 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
163 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
164
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 /* For each use, all possible defs reaching it must come in the same
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 register, union them.
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
167 FUN is the function that does the union.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
168
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
169 In USED, we keep the DF_REF_ID of the first uninitialized uses of a
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
170 register, so that all uninitialized uses of the register can be
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
171 combined into a single web. We actually offset it by 2, because
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
172 the values 0 and 1 are reserved for use by entry_register. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 void
111
kono
parents: 67
diff changeset
175 union_defs (df_ref use, web_entry *def_entry,
kono
parents: 67
diff changeset
176 unsigned int *used, web_entry *use_entry,
kono
parents: 67
diff changeset
177 bool (*fun) (web_entry_base *, web_entry_base *))
0
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 df_insn_info *insn_info = DF_REF_INSN_INFO (use);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 struct df_link *link = DF_REF_CHAIN (use);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 rtx set;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 if (insn_info)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 {
111
kono
parents: 67
diff changeset
185 df_ref eq_use;
kono
parents: 67
diff changeset
186
kono
parents: 67
diff changeset
187 set = single_set (insn_info->insn);
kono
parents: 67
diff changeset
188 FOR_EACH_INSN_INFO_EQ_USE (eq_use, insn_info)
kono
parents: 67
diff changeset
189 if (use != eq_use
kono
parents: 67
diff changeset
190 && DF_REF_REAL_REG (use) == DF_REF_REAL_REG (eq_use))
kono
parents: 67
diff changeset
191 (*fun) (use_entry + DF_REF_ID (use), use_entry + DF_REF_ID (eq_use));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 else
111
kono
parents: 67
diff changeset
194 set = NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
196 /* Union all occurrences of the same register in reg notes. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 /* Recognize trivial noop moves and attempt to keep them as noop. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 if (set
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 && SET_SRC (set) == DF_REF_REG (use)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 && SET_SRC (set) == SET_DEST (set))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 {
111
kono
parents: 67
diff changeset
204 df_ref def;
kono
parents: 67
diff changeset
205
kono
parents: 67
diff changeset
206 FOR_EACH_INSN_INFO_DEF (def, insn_info)
kono
parents: 67
diff changeset
207 if (DF_REF_REAL_REG (use) == DF_REF_REAL_REG (def))
kono
parents: 67
diff changeset
208 (*fun) (use_entry + DF_REF_ID (use), def_entry + DF_REF_ID (def));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
210
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
211 /* UD chains of uninitialized REGs are empty. Keeping all uses of
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
212 the same uninitialized REG in a single web is not necessary for
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
213 correctness, since the uses are undefined, but it's wasteful to
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
214 allocate one register or slot for each reference. Furthermore,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
215 creating new pseudos for uninitialized references in debug insns
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
216 (see PR 42631) causes -fcompare-debug failures. We record the
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
217 number of the first uninitialized reference we found, and merge
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
218 with it any other uninitialized references to the same
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
219 register. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
220 if (!link)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
221 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
222 int regno = REGNO (DF_REF_REAL_REG (use));
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
223 if (used[regno])
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
224 (*fun) (use_entry + DF_REF_ID (use), use_entry + used[regno] - 2);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
225 else
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
226 used[regno] = DF_REF_ID (use) + 2;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
227 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
228
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 while (link)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 (*fun) (use_entry + DF_REF_ID (use),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 def_entry + DF_REF_ID (link->ref));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 link = link->next;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 /* A READ_WRITE use requires the corresponding def to be in the same
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 register. Find it and union. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 if (DF_REF_FLAGS (use) & DF_REF_READ_WRITE)
111
kono
parents: 67
diff changeset
239 if (insn_info)
kono
parents: 67
diff changeset
240 {
kono
parents: 67
diff changeset
241 df_ref def;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242
111
kono
parents: 67
diff changeset
243 FOR_EACH_INSN_INFO_DEF (def, insn_info)
kono
parents: 67
diff changeset
244 if (DF_REF_REAL_REG (use) == DF_REF_REAL_REG (def))
kono
parents: 67
diff changeset
245 (*fun) (use_entry + DF_REF_ID (use), def_entry + DF_REF_ID (def));
kono
parents: 67
diff changeset
246 }
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
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 /* Find the corresponding register for the given entry. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 static rtx
111
kono
parents: 67
diff changeset
252 entry_register (web_entry *entry, df_ref ref, unsigned int *used)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 {
111
kono
parents: 67
diff changeset
254 web_entry *root;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 rtx reg, newreg;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 /* Find the corresponding web and see if it has been visited. */
111
kono
parents: 67
diff changeset
258 root = (web_entry *)entry->unionfind_root ();
kono
parents: 67
diff changeset
259 if (root->reg ())
kono
parents: 67
diff changeset
260 return root->reg ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 /* We are seeing this web for the first time, do the assignment. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 reg = DF_REF_REAL_REG (ref);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
265 /* In case the original register is already assigned, generate new
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
266 one. Since we use USED to merge uninitialized refs into a single
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
267 web, we might found an element to be nonzero without our having
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
268 used it. Test for 1, because union_defs saves it for our use,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
269 and there won't be any use for the other values when we get to
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
270 this point. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
271 if (used[REGNO (reg)] != 1)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 newreg = reg, used[REGNO (reg)] = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 newreg = gen_reg_rtx (GET_MODE (reg));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 REG_USERVAR_P (newreg) = REG_USERVAR_P (reg);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 REG_POINTER (newreg) = REG_POINTER (reg);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 REG_ATTRS (newreg) = REG_ATTRS (reg);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 if (dump_file)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 fprintf (dump_file, "Web oldreg=%i newreg=%i\n", REGNO (reg),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 REGNO (newreg));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283
111
kono
parents: 67
diff changeset
284 root->set_reg (newreg);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 return newreg;
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
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 /* Replace the reference by REG. */
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 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 replace_ref (df_ref ref, rtx reg)
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 rtx oldreg = DF_REF_REAL_REG (ref);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 rtx *loc = DF_REF_REAL_LOC (ref);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 unsigned int uid = DF_REF_INSN_UID (ref);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 if (oldreg == reg)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 return;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 if (dump_file)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 fprintf (dump_file, "Updating insn %i (%i->%i)\n",
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
301 uid, REGNO (oldreg), REGNO (reg));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 *loc = reg;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 df_insn_rescan (DF_REF_INSN (ref));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306
111
kono
parents: 67
diff changeset
307 namespace {
kono
parents: 67
diff changeset
308
kono
parents: 67
diff changeset
309 const pass_data pass_data_web =
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 {
111
kono
parents: 67
diff changeset
311 RTL_PASS, /* type */
kono
parents: 67
diff changeset
312 "web", /* name */
kono
parents: 67
diff changeset
313 OPTGROUP_NONE, /* optinfo_flags */
kono
parents: 67
diff changeset
314 TV_WEB, /* tv_id */
kono
parents: 67
diff changeset
315 0, /* properties_required */
kono
parents: 67
diff changeset
316 0, /* properties_provided */
kono
parents: 67
diff changeset
317 0, /* properties_destroyed */
kono
parents: 67
diff changeset
318 0, /* todo_flags_start */
kono
parents: 67
diff changeset
319 TODO_df_finish, /* todo_flags_finish */
kono
parents: 67
diff changeset
320 };
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
321
111
kono
parents: 67
diff changeset
322 class pass_web : public rtl_opt_pass
kono
parents: 67
diff changeset
323 {
kono
parents: 67
diff changeset
324 public:
kono
parents: 67
diff changeset
325 pass_web (gcc::context *ctxt)
kono
parents: 67
diff changeset
326 : rtl_opt_pass (pass_data_web, ctxt)
kono
parents: 67
diff changeset
327 {}
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328
111
kono
parents: 67
diff changeset
329 /* opt_pass methods: */
kono
parents: 67
diff changeset
330 virtual bool gate (function *) { return (optimize > 0 && flag_web); }
kono
parents: 67
diff changeset
331 virtual unsigned int execute (function *);
kono
parents: 67
diff changeset
332
kono
parents: 67
diff changeset
333 }; // class pass_web
kono
parents: 67
diff changeset
334
kono
parents: 67
diff changeset
335 unsigned int
kono
parents: 67
diff changeset
336 pass_web::execute (function *fun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 {
111
kono
parents: 67
diff changeset
338 web_entry *def_entry;
kono
parents: 67
diff changeset
339 web_entry *use_entry;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 unsigned int max = max_reg_num ();
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
341 unsigned int *used;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 basic_block bb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 unsigned int uses_num = 0;
111
kono
parents: 67
diff changeset
344 rtx_insn *insn;
0
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 df_set_flags (DF_NO_HARD_REGS + DF_EQ_NOTES);
111
kono
parents: 67
diff changeset
347 df_set_flags (DF_RD_PRUNE_DEAD_DEFS);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 df_chain_add_problem (DF_UD_CHAIN);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 df_analyze ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 df_set_flags (DF_DEFER_INSN_RESCAN);
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 /* Assign ids to the uses. */
111
kono
parents: 67
diff changeset
353 FOR_ALL_BB_FN (bb, fun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 FOR_BB_INSNS (bb, insn)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 {
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
356 if (NONDEBUG_INSN_P (insn))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 {
111
kono
parents: 67
diff changeset
358 struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
kono
parents: 67
diff changeset
359 df_ref use;
kono
parents: 67
diff changeset
360 FOR_EACH_INSN_INFO_USE (use, insn_info)
kono
parents: 67
diff changeset
361 if (DF_REF_REGNO (use) >= FIRST_PSEUDO_REGISTER)
kono
parents: 67
diff changeset
362 DF_REF_ID (use) = uses_num++;
kono
parents: 67
diff changeset
363 FOR_EACH_INSN_INFO_EQ_USE (use, insn_info)
kono
parents: 67
diff changeset
364 if (DF_REF_REGNO (use) >= FIRST_PSEUDO_REGISTER)
kono
parents: 67
diff changeset
365 DF_REF_ID (use) = uses_num++;
0
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 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
369 /* Record the number of uses and defs at the beginning of the optimization. */
111
kono
parents: 67
diff changeset
370 def_entry = XCNEWVEC (web_entry, DF_DEFS_TABLE_SIZE ());
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
371 used = XCNEWVEC (unsigned, max);
111
kono
parents: 67
diff changeset
372 use_entry = XCNEWVEC (web_entry, uses_num);
0
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 /* Produce the web. */
111
kono
parents: 67
diff changeset
375 FOR_ALL_BB_FN (bb, fun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 FOR_BB_INSNS (bb, insn)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
377 if (NONDEBUG_INSN_P (insn))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 {
111
kono
parents: 67
diff changeset
379 struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
kono
parents: 67
diff changeset
380 df_ref use;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
381 union_match_dups (insn, def_entry, use_entry, unionfind_union);
111
kono
parents: 67
diff changeset
382 FOR_EACH_INSN_INFO_USE (use, insn_info)
kono
parents: 67
diff changeset
383 if (DF_REF_REGNO (use) >= FIRST_PSEUDO_REGISTER)
kono
parents: 67
diff changeset
384 union_defs (use, def_entry, used, use_entry, unionfind_union);
kono
parents: 67
diff changeset
385 FOR_EACH_INSN_INFO_EQ_USE (use, insn_info)
kono
parents: 67
diff changeset
386 if (DF_REF_REGNO (use) >= FIRST_PSEUDO_REGISTER)
kono
parents: 67
diff changeset
387 union_defs (use, def_entry, used, use_entry, unionfind_union);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 }
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 /* Update the instruction stream, allocating new registers for split pseudos
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 in progress. */
111
kono
parents: 67
diff changeset
392 FOR_ALL_BB_FN (bb, fun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 FOR_BB_INSNS (bb, insn)
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
394 if (NONDEBUG_INSN_P (insn)
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
395 /* Ignore naked clobber. For example, reg 134 in the second insn
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
396 of the following sequence will not be replaced.
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
397
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
398 (insn (clobber (reg:SI 134)))
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
399
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
400 (insn (set (reg:SI 0 r0) (reg:SI 134)))
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
401
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
402 Thus the later passes can optimize them away. */
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
403 && GET_CODE (PATTERN (insn)) != CLOBBER)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 {
111
kono
parents: 67
diff changeset
405 struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
kono
parents: 67
diff changeset
406 df_ref def, use;
kono
parents: 67
diff changeset
407 FOR_EACH_INSN_INFO_USE (use, insn_info)
kono
parents: 67
diff changeset
408 if (DF_REF_REGNO (use) >= FIRST_PSEUDO_REGISTER)
kono
parents: 67
diff changeset
409 replace_ref (use, entry_register (use_entry + DF_REF_ID (use),
kono
parents: 67
diff changeset
410 use, used));
kono
parents: 67
diff changeset
411 FOR_EACH_INSN_INFO_EQ_USE (use, insn_info)
kono
parents: 67
diff changeset
412 if (DF_REF_REGNO (use) >= FIRST_PSEUDO_REGISTER)
kono
parents: 67
diff changeset
413 replace_ref (use, entry_register (use_entry + DF_REF_ID (use),
kono
parents: 67
diff changeset
414 use, used));
kono
parents: 67
diff changeset
415 FOR_EACH_INSN_INFO_DEF (def, insn_info)
kono
parents: 67
diff changeset
416 if (DF_REF_REGNO (def) >= FIRST_PSEUDO_REGISTER)
kono
parents: 67
diff changeset
417 replace_ref (def, entry_register (def_entry + DF_REF_ID (def),
kono
parents: 67
diff changeset
418 def, used));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
419 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
420
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 free (def_entry);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 free (use_entry);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 free (used);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426
111
kono
parents: 67
diff changeset
427 } // anon namespace
kono
parents: 67
diff changeset
428
kono
parents: 67
diff changeset
429 rtl_opt_pass *
kono
parents: 67
diff changeset
430 make_pass_web (gcc::context *ctxt)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 {
111
kono
parents: 67
diff changeset
432 return new pass_web (ctxt);
kono
parents: 67
diff changeset
433 }