annotate gcc/dumpfile.h @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
kono
parents:
diff changeset
1 /* Definitions for the shared dumpfile.
kono
parents:
diff changeset
2 Copyright (C) 2004-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This file is part of GCC.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
8 the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
9 any later version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful,
kono
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
14 GNU General Public License for more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 #ifndef GCC_DUMPFILE_H
kono
parents:
diff changeset
22 #define GCC_DUMPFILE_H 1
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 /* Different tree dump places. When you add new tree dump places,
kono
parents:
diff changeset
26 extend the DUMP_FILES array in dumpfile.c. */
kono
parents:
diff changeset
27 enum tree_dump_index
kono
parents:
diff changeset
28 {
kono
parents:
diff changeset
29 TDI_none, /* No dump */
kono
parents:
diff changeset
30 TDI_cgraph, /* dump function call graph. */
kono
parents:
diff changeset
31 TDI_inheritance, /* dump type inheritance graph. */
kono
parents:
diff changeset
32 TDI_clones, /* dump IPA cloning decisions. */
kono
parents:
diff changeset
33 TDI_original, /* dump each function before optimizing it */
kono
parents:
diff changeset
34 TDI_gimple, /* dump each function after gimplifying it */
kono
parents:
diff changeset
35 TDI_nested, /* dump each function after unnesting it */
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 TDI_lang_all, /* enable all the language dumps. */
kono
parents:
diff changeset
38 TDI_tree_all, /* enable all the GENERIC/GIMPLE dumps. */
kono
parents:
diff changeset
39 TDI_rtl_all, /* enable all the RTL dumps. */
kono
parents:
diff changeset
40 TDI_ipa_all, /* enable all the IPA dumps. */
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 TDI_end
kono
parents:
diff changeset
43 };
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 /* Enum used to distinguish dump files to types. */
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 enum dump_kind
kono
parents:
diff changeset
48 {
kono
parents:
diff changeset
49 DK_none,
kono
parents:
diff changeset
50 DK_lang,
kono
parents:
diff changeset
51 DK_tree,
kono
parents:
diff changeset
52 DK_rtl,
kono
parents:
diff changeset
53 DK_ipa
kono
parents:
diff changeset
54 };
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 /* Bit masks to control dumping. Not all values are applicable to all
kono
parents:
diff changeset
57 dumps. Add new ones at the end. When you define new values, extend
kono
parents:
diff changeset
58 the DUMP_OPTIONS array in dumpfile.c. The TDF_* flags coexist with
kono
parents:
diff changeset
59 MSG_* flags (for -fopt-info) and the bit values must be chosen to
kono
parents:
diff changeset
60 allow that. */
kono
parents:
diff changeset
61 #define TDF_ADDRESS (1 << 0) /* dump node addresses */
kono
parents:
diff changeset
62 #define TDF_SLIM (1 << 1) /* don't go wild following links */
kono
parents:
diff changeset
63 #define TDF_RAW (1 << 2) /* don't unparse the function */
kono
parents:
diff changeset
64 #define TDF_DETAILS (1 << 3) /* show more detailed info about
kono
parents:
diff changeset
65 each pass */
kono
parents:
diff changeset
66 #define TDF_STATS (1 << 4) /* dump various statistics about
kono
parents:
diff changeset
67 each pass */
kono
parents:
diff changeset
68 #define TDF_BLOCKS (1 << 5) /* display basic block boundaries */
kono
parents:
diff changeset
69 #define TDF_VOPS (1 << 6) /* display virtual operands */
kono
parents:
diff changeset
70 #define TDF_LINENO (1 << 7) /* display statement line numbers */
kono
parents:
diff changeset
71 #define TDF_UID (1 << 8) /* display decl UIDs */
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 #define TDF_STMTADDR (1 << 9) /* Address of stmt. */
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 #define TDF_GRAPH (1 << 10) /* a graph dump is being emitted */
kono
parents:
diff changeset
76 #define TDF_MEMSYMS (1 << 11) /* display memory symbols in expr.
kono
parents:
diff changeset
77 Implies TDF_VOPS. */
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 #define TDF_RHS_ONLY (1 << 12) /* a flag to only print the RHS of
kono
parents:
diff changeset
80 a gimple stmt. */
kono
parents:
diff changeset
81 #define TDF_ASMNAME (1 << 13) /* display asm names of decls */
kono
parents:
diff changeset
82 #define TDF_EH (1 << 14) /* display EH region number
kono
parents:
diff changeset
83 holding this gimple statement. */
kono
parents:
diff changeset
84 #define TDF_NOUID (1 << 15) /* omit UIDs from dumps. */
kono
parents:
diff changeset
85 #define TDF_ALIAS (1 << 16) /* display alias information */
kono
parents:
diff changeset
86 #define TDF_ENUMERATE_LOCALS (1 << 17) /* Enumerate locals by uid. */
kono
parents:
diff changeset
87 #define TDF_CSELIB (1 << 18) /* Dump cselib details. */
kono
parents:
diff changeset
88 #define TDF_SCEV (1 << 19) /* Dump SCEV details. */
kono
parents:
diff changeset
89 #define TDF_GIMPLE (1 << 20) /* Dump in GIMPLE FE syntax */
kono
parents:
diff changeset
90 #define TDF_FOLDING (1 << 21) /* Dump folding details. */
kono
parents:
diff changeset
91 #define MSG_OPTIMIZED_LOCATIONS (1 << 22) /* -fopt-info optimized sources */
kono
parents:
diff changeset
92 #define MSG_MISSED_OPTIMIZATION (1 << 23) /* missed opportunities */
kono
parents:
diff changeset
93 #define MSG_NOTE (1 << 24) /* general optimization info */
kono
parents:
diff changeset
94 #define MSG_ALL (MSG_OPTIMIZED_LOCATIONS | MSG_MISSED_OPTIMIZATION \
kono
parents:
diff changeset
95 | MSG_NOTE)
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 /* Value of TDF_NONE is used just for bits filtered by TDF_KIND_MASK. */
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 #define TDF_NONE 0
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 /* Flags to control high-level -fopt-info dumps. Usually these flags
kono
parents:
diff changeset
103 define a group of passes. An optimization pass can be part of
kono
parents:
diff changeset
104 multiple groups. */
kono
parents:
diff changeset
105 #define OPTGROUP_NONE (0)
kono
parents:
diff changeset
106 #define OPTGROUP_IPA (1 << 1) /* IPA optimization passes */
kono
parents:
diff changeset
107 #define OPTGROUP_LOOP (1 << 2) /* Loop optimization passes */
kono
parents:
diff changeset
108 #define OPTGROUP_INLINE (1 << 3) /* Inlining passes */
kono
parents:
diff changeset
109 #define OPTGROUP_OMP (1 << 4) /* OMP (Offloading and Multi
kono
parents:
diff changeset
110 Processing) transformations */
kono
parents:
diff changeset
111 #define OPTGROUP_VEC (1 << 5) /* Vectorization passes */
kono
parents:
diff changeset
112 #define OPTGROUP_OTHER (1 << 6) /* All other passes */
kono
parents:
diff changeset
113 #define OPTGROUP_ALL (OPTGROUP_IPA | OPTGROUP_LOOP | OPTGROUP_INLINE \
kono
parents:
diff changeset
114 | OPTGROUP_OMP | OPTGROUP_VEC | OPTGROUP_OTHER)
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 /* Dump flags type. */
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 typedef uint64_t dump_flags_t;
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 /* Define a tree dump switch. */
kono
parents:
diff changeset
121 struct dump_file_info
kono
parents:
diff changeset
122 {
kono
parents:
diff changeset
123 /* Suffix to give output file. */
kono
parents:
diff changeset
124 const char *suffix;
kono
parents:
diff changeset
125 /* Command line dump switch. */
kono
parents:
diff changeset
126 const char *swtch;
kono
parents:
diff changeset
127 /* Command line glob. */
kono
parents:
diff changeset
128 const char *glob;
kono
parents:
diff changeset
129 /* Filename for the pass-specific stream. */
kono
parents:
diff changeset
130 const char *pfilename;
kono
parents:
diff changeset
131 /* Filename for the -fopt-info stream. */
kono
parents:
diff changeset
132 const char *alt_filename;
kono
parents:
diff changeset
133 /* Pass-specific dump stream. */
kono
parents:
diff changeset
134 FILE *pstream;
kono
parents:
diff changeset
135 /* -fopt-info stream. */
kono
parents:
diff changeset
136 FILE *alt_stream;
kono
parents:
diff changeset
137 /* Dump kind. */
kono
parents:
diff changeset
138 dump_kind dkind;
kono
parents:
diff changeset
139 /* Dump flags. */
kono
parents:
diff changeset
140 dump_flags_t pflags;
kono
parents:
diff changeset
141 /* A pass flags for -fopt-info. */
kono
parents:
diff changeset
142 int alt_flags;
kono
parents:
diff changeset
143 /* Flags for -fopt-info given by a user. */
kono
parents:
diff changeset
144 int optgroup_flags;
kono
parents:
diff changeset
145 /* State of pass-specific stream. */
kono
parents:
diff changeset
146 int pstate;
kono
parents:
diff changeset
147 /* State of the -fopt-info stream. */
kono
parents:
diff changeset
148 int alt_state;
kono
parents:
diff changeset
149 /* Dump file number. */
kono
parents:
diff changeset
150 int num;
kono
parents:
diff changeset
151 /* Fields "suffix", "swtch", "glob" can be const strings,
kono
parents:
diff changeset
152 or can be dynamically allocated, needing free. */
kono
parents:
diff changeset
153 bool owns_strings;
kono
parents:
diff changeset
154 /* When a given dump file is being initialized, this flag is set to true
kono
parents:
diff changeset
155 if the corresponding TDF_graph dump file has also been initialized. */
kono
parents:
diff changeset
156 bool graph_dump_initialized;
kono
parents:
diff changeset
157 };
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 /* In dumpfile.c */
kono
parents:
diff changeset
160 extern FILE *dump_begin (int, dump_flags_t *);
kono
parents:
diff changeset
161 extern void dump_end (int, FILE *);
kono
parents:
diff changeset
162 extern int opt_info_switch_p (const char *);
kono
parents:
diff changeset
163 extern const char *dump_flag_name (int);
kono
parents:
diff changeset
164 extern void dump_printf (dump_flags_t, const char *, ...) ATTRIBUTE_PRINTF_2;
kono
parents:
diff changeset
165 extern void dump_printf_loc (dump_flags_t, source_location,
kono
parents:
diff changeset
166 const char *, ...) ATTRIBUTE_PRINTF_3;
kono
parents:
diff changeset
167 extern void dump_function (int phase, tree fn);
kono
parents:
diff changeset
168 extern void dump_basic_block (int, basic_block, int);
kono
parents:
diff changeset
169 extern void dump_generic_expr_loc (int, source_location, int, tree);
kono
parents:
diff changeset
170 extern void dump_generic_expr (dump_flags_t, dump_flags_t, tree);
kono
parents:
diff changeset
171 extern void dump_gimple_stmt_loc (dump_flags_t, source_location, dump_flags_t,
kono
parents:
diff changeset
172 gimple *, int);
kono
parents:
diff changeset
173 extern void dump_gimple_stmt (dump_flags_t, dump_flags_t, gimple *, int);
kono
parents:
diff changeset
174 extern void print_combine_total_stats (void);
kono
parents:
diff changeset
175 extern bool enable_rtl_dump_file (void);
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 /* In tree-dump.c */
kono
parents:
diff changeset
178 extern void dump_node (const_tree, dump_flags_t, FILE *);
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 /* In combine.c */
kono
parents:
diff changeset
181 extern void dump_combine_total_stats (FILE *);
kono
parents:
diff changeset
182 /* In cfghooks.c */
kono
parents:
diff changeset
183 extern void dump_bb (FILE *, basic_block, int, dump_flags_t);
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 /* Global variables used to communicate with passes. */
kono
parents:
diff changeset
186 extern FILE *dump_file;
kono
parents:
diff changeset
187 extern FILE *alt_dump_file;
kono
parents:
diff changeset
188 extern dump_flags_t dump_flags;
kono
parents:
diff changeset
189 extern const char *dump_file_name;
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 /* Return true if any of the dumps is enabled, false otherwise. */
kono
parents:
diff changeset
192 static inline bool
kono
parents:
diff changeset
193 dump_enabled_p (void)
kono
parents:
diff changeset
194 {
kono
parents:
diff changeset
195 return (dump_file || alt_dump_file);
kono
parents:
diff changeset
196 }
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 namespace gcc {
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 class dump_manager
kono
parents:
diff changeset
201 {
kono
parents:
diff changeset
202 public:
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 dump_manager ();
kono
parents:
diff changeset
205 ~dump_manager ();
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 /* Register a dumpfile.
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 TAKE_OWNERSHIP determines whether callee takes ownership of strings
kono
parents:
diff changeset
210 SUFFIX, SWTCH, and GLOB. */
kono
parents:
diff changeset
211 unsigned int
kono
parents:
diff changeset
212 dump_register (const char *suffix, const char *swtch, const char *glob,
kono
parents:
diff changeset
213 dump_kind dkind, int optgroup_flags, bool take_ownership);
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 /* Allow languages and middle-end to register their dumps before the
kono
parents:
diff changeset
216 optimization passes. */
kono
parents:
diff changeset
217 void
kono
parents:
diff changeset
218 register_dumps ();
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 /* Return the dump_file_info for the given phase. */
kono
parents:
diff changeset
221 struct dump_file_info *
kono
parents:
diff changeset
222 get_dump_file_info (int phase) const;
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 struct dump_file_info *
kono
parents:
diff changeset
225 get_dump_file_info_by_switch (const char *swtch) const;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 /* Return the name of the dump file for the given phase.
kono
parents:
diff changeset
228 If the dump is not enabled, returns NULL. */
kono
parents:
diff changeset
229 char *
kono
parents:
diff changeset
230 get_dump_file_name (int phase) const;
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 char *
kono
parents:
diff changeset
233 get_dump_file_name (struct dump_file_info *dfi) const;
kono
parents:
diff changeset
234
kono
parents:
diff changeset
235 int
kono
parents:
diff changeset
236 dump_switch_p (const char *arg);
kono
parents:
diff changeset
237
kono
parents:
diff changeset
238 /* Start a dump for PHASE. Store user-supplied dump flags in
kono
parents:
diff changeset
239 *FLAG_PTR. Return the number of streams opened. Set globals
kono
parents:
diff changeset
240 DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
kono
parents:
diff changeset
241 set dump_flags appropriately for both pass dump stream and
kono
parents:
diff changeset
242 -fopt-info stream. */
kono
parents:
diff changeset
243 int
kono
parents:
diff changeset
244 dump_start (int phase, dump_flags_t *flag_ptr);
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 /* Finish a tree dump for PHASE and close associated dump streams. Also
kono
parents:
diff changeset
247 reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
kono
parents:
diff changeset
248 void
kono
parents:
diff changeset
249 dump_finish (int phase);
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 FILE *
kono
parents:
diff changeset
252 dump_begin (int phase, dump_flags_t *flag_ptr);
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 /* Returns nonzero if tree dump PHASE has been initialized. */
kono
parents:
diff changeset
255 int
kono
parents:
diff changeset
256 dump_initialized_p (int phase) const;
kono
parents:
diff changeset
257
kono
parents:
diff changeset
258 /* Returns the switch name of PHASE. */
kono
parents:
diff changeset
259 const char *
kono
parents:
diff changeset
260 dump_flag_name (int phase) const;
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 private:
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 int
kono
parents:
diff changeset
265 dump_phase_enabled_p (int phase) const;
kono
parents:
diff changeset
266
kono
parents:
diff changeset
267 int
kono
parents:
diff changeset
268 dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob);
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 int
kono
parents:
diff changeset
271 dump_enable_all (dump_kind dkind, dump_flags_t flags, const char *filename);
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 int
kono
parents:
diff changeset
274 opt_info_enable_passes (int optgroup_flags, dump_flags_t flags,
kono
parents:
diff changeset
275 const char *filename);
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 private:
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 /* Dynamically registered dump files and switches. */
kono
parents:
diff changeset
280 int m_next_dump;
kono
parents:
diff changeset
281 struct dump_file_info *m_extra_dump_files;
kono
parents:
diff changeset
282 size_t m_extra_dump_files_in_use;
kono
parents:
diff changeset
283 size_t m_extra_dump_files_alloced;
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285 /* Grant access to dump_enable_all. */
kono
parents:
diff changeset
286 friend bool ::enable_rtl_dump_file (void);
kono
parents:
diff changeset
287
kono
parents:
diff changeset
288 /* Grant access to opt_info_enable_passes. */
kono
parents:
diff changeset
289 friend int ::opt_info_switch_p (const char *arg);
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291 }; // class dump_manager
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 } // namespace gcc
kono
parents:
diff changeset
294
kono
parents:
diff changeset
295 #endif /* GCC_DUMPFILE_H */