]>
Commit | Line | Data |
---|---|---|
7ee2468b | 1 | /* Definitions for the shared dumpfile. |
85ec4feb | 2 | Copyright (C) 2004-2018 Free Software Foundation, Inc. |
7ee2468b SB |
3 | |
4 | This file is part of GCC. | |
5 | ||
6 | GCC is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 3, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GCC is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GCC; see the file COPYING3. If not see | |
18 | <http://www.gnu.org/licenses/>. */ | |
19 | ||
20 | ||
21 | #ifndef GCC_DUMPFILE_H | |
22 | #define GCC_DUMPFILE_H 1 | |
23 | ||
4f5b9c80 | 24 | #include "profile-count.h" |
78c60e3d | 25 | |
7ee2468b | 26 | /* Different tree dump places. When you add new tree dump places, |
2b4e6bf1 | 27 | extend the DUMP_FILES array in dumpfile.c. */ |
7ee2468b SB |
28 | enum tree_dump_index |
29 | { | |
30 | TDI_none, /* No dump */ | |
0e0a19c5 NS |
31 | TDI_cgraph, /* dump function call graph. */ |
32 | TDI_inheritance, /* dump type inheritance graph. */ | |
0bdad123 | 33 | TDI_clones, /* dump IPA cloning decisions. */ |
7ee2468b | 34 | TDI_original, /* dump each function before optimizing it */ |
363dc72c | 35 | TDI_gimple, /* dump each function after gimplifying it */ |
7ee2468b | 36 | TDI_nested, /* dump each function after unnesting it */ |
b4da704c | 37 | TDI_lto_stream_out, /* dump information about lto streaming */ |
a529e0a6 NS |
38 | |
39 | TDI_lang_all, /* enable all the language dumps. */ | |
0e0a19c5 NS |
40 | TDI_tree_all, /* enable all the GENERIC/GIMPLE dumps. */ |
41 | TDI_rtl_all, /* enable all the RTL dumps. */ | |
42 | TDI_ipa_all, /* enable all the IPA dumps. */ | |
7ee2468b SB |
43 | |
44 | TDI_end | |
45 | }; | |
46 | ||
8264c84d ML |
47 | /* Enum used to distinguish dump files to types. */ |
48 | ||
49 | enum dump_kind | |
50 | { | |
51 | DK_none, | |
52 | DK_lang, | |
53 | DK_tree, | |
54 | DK_rtl, | |
286c97f3 | 55 | DK_ipa |
8264c84d ML |
56 | }; |
57 | ||
78c60e3d SS |
58 | /* Bit masks to control dumping. Not all values are applicable to all |
59 | dumps. Add new ones at the end. When you define new values, extend | |
2b4e6bf1 SS |
60 | the DUMP_OPTIONS array in dumpfile.c. The TDF_* flags coexist with |
61 | MSG_* flags (for -fopt-info) and the bit values must be chosen to | |
62 | allow that. */ | |
4af78ef8 DM |
63 | enum dump_flag |
64 | { | |
65 | /* Value of TDF_NONE is used just for bits filtered by TDF_KIND_MASK. */ | |
66 | TDF_NONE = 0, | |
67 | ||
68 | /* Dump node addresses. */ | |
69 | TDF_ADDRESS = (1 << 0), | |
70 | ||
71 | /* Don't go wild following links. */ | |
72 | TDF_SLIM = (1 << 1), | |
73 | ||
74 | /* Don't unparse the function. */ | |
75 | TDF_RAW = (1 << 2), | |
76 | ||
77 | /* Show more detailed info about each pass. */ | |
78 | TDF_DETAILS = (1 << 3), | |
79 | ||
80 | /* Dump various statistics about each pass. */ | |
81 | TDF_STATS = (1 << 4), | |
82 | ||
83 | /* Display basic block boundaries. */ | |
84 | TDF_BLOCKS = (1 << 5), | |
85 | ||
86 | /* Display virtual operands. */ | |
87 | TDF_VOPS = (1 << 6), | |
88 | ||
89 | /* Display statement line numbers. */ | |
90 | TDF_LINENO = (1 << 7), | |
91 | ||
92 | /* Display decl UIDs. */ | |
93 | TDF_UID = (1 << 8), | |
94 | ||
95 | /* Address of stmt. */ | |
96 | TDF_STMTADDR = (1 << 9), | |
97 | ||
98 | /* A graph dump is being emitted. */ | |
99 | TDF_GRAPH = (1 << 10), | |
100 | ||
101 | /* Display memory symbols in expr. | |
102 | Implies TDF_VOPS. */ | |
103 | TDF_MEMSYMS = (1 << 11), | |
104 | ||
105 | /* A flag to only print the RHS of a gimple stmt. */ | |
106 | TDF_RHS_ONLY = (1 << 12), | |
107 | ||
108 | /* Display asm names of decls. */ | |
109 | TDF_ASMNAME = (1 << 13), | |
110 | ||
111 | /* Display EH region number holding this gimple statement. */ | |
112 | TDF_EH = (1 << 14), | |
113 | ||
114 | /* Omit UIDs from dumps. */ | |
115 | TDF_NOUID = (1 << 15), | |
116 | ||
117 | /* Display alias information. */ | |
118 | TDF_ALIAS = (1 << 16), | |
119 | ||
120 | /* Enumerate locals by uid. */ | |
121 | TDF_ENUMERATE_LOCALS = (1 << 17), | |
122 | ||
123 | /* Dump cselib details. */ | |
124 | TDF_CSELIB = (1 << 18), | |
125 | ||
126 | /* Dump SCEV details. */ | |
127 | TDF_SCEV = (1 << 19), | |
128 | ||
129 | /* Dump in GIMPLE FE syntax */ | |
130 | TDF_GIMPLE = (1 << 20), | |
131 | ||
132 | /* Dump folding details. */ | |
133 | TDF_FOLDING = (1 << 21), | |
134 | ||
135 | /* -fopt-info optimized sources. */ | |
136 | MSG_OPTIMIZED_LOCATIONS = (1 << 22), | |
137 | ||
138 | /* Missed opportunities. */ | |
139 | MSG_MISSED_OPTIMIZATION = (1 << 23), | |
140 | ||
141 | /* General optimization info. */ | |
142 | MSG_NOTE = (1 << 24), | |
143 | ||
144 | MSG_ALL = (MSG_OPTIMIZED_LOCATIONS | |
145 | | MSG_MISSED_OPTIMIZATION | |
146 | | MSG_NOTE), | |
147 | ||
148 | /* Dumping for -fcompare-debug. */ | |
de6c8d7f ML |
149 | TDF_COMPARE_DEBUG = (1 << 25), |
150 | ||
151 | /* All values. */ | |
152 | TDF_ALL_VALUES = (1 << 26) - 1 | |
4af78ef8 DM |
153 | }; |
154 | ||
155 | /* Dump flags type. */ | |
156 | ||
157 | typedef enum dump_flag dump_flags_t; | |
158 | ||
159 | static inline dump_flags_t | |
160 | operator| (dump_flags_t lhs, dump_flags_t rhs) | |
161 | { | |
162 | return (dump_flags_t)((int)lhs | (int)rhs); | |
163 | } | |
164 | ||
165 | static inline dump_flags_t | |
166 | operator& (dump_flags_t lhs, dump_flags_t rhs) | |
167 | { | |
168 | return (dump_flags_t)((int)lhs & (int)rhs); | |
169 | } | |
170 | ||
171 | static inline dump_flags_t | |
172 | operator~ (dump_flags_t flags) | |
173 | { | |
174 | return (dump_flags_t)~((int)flags); | |
175 | } | |
176 | ||
177 | static inline dump_flags_t & | |
178 | operator|= (dump_flags_t &lhs, dump_flags_t rhs) | |
179 | { | |
180 | lhs = (dump_flags_t)((int)lhs | (int)rhs); | |
181 | return lhs; | |
182 | } | |
183 | ||
184 | static inline dump_flags_t & | |
185 | operator&= (dump_flags_t &lhs, dump_flags_t rhs) | |
186 | { | |
187 | lhs = (dump_flags_t)((int)lhs & (int)rhs); | |
188 | return lhs; | |
189 | } | |
1a817418 | 190 | |
2b4e6bf1 SS |
191 | /* Flags to control high-level -fopt-info dumps. Usually these flags |
192 | define a group of passes. An optimization pass can be part of | |
193 | multiple groups. */ | |
2b4e6bf1 | 194 | |
4af78ef8 DM |
195 | enum optgroup_flag |
196 | { | |
197 | OPTGROUP_NONE = 0, | |
198 | ||
199 | /* IPA optimization passes */ | |
200 | OPTGROUP_IPA = (1 << 1), | |
201 | ||
202 | /* Loop optimization passes */ | |
203 | OPTGROUP_LOOP = (1 << 2), | |
204 | ||
205 | /* Inlining passes */ | |
206 | OPTGROUP_INLINE = (1 << 3), | |
1a817418 | 207 | |
4af78ef8 DM |
208 | /* OMP (Offloading and Multi Processing) transformations */ |
209 | OPTGROUP_OMP = (1 << 4), | |
210 | ||
211 | /* Vectorization passes */ | |
212 | OPTGROUP_VEC = (1 << 5), | |
213 | ||
214 | /* All other passes */ | |
215 | OPTGROUP_OTHER = (1 << 6), | |
216 | ||
217 | OPTGROUP_ALL = (OPTGROUP_IPA | OPTGROUP_LOOP | OPTGROUP_INLINE | |
218 | | OPTGROUP_OMP | OPTGROUP_VEC | OPTGROUP_OTHER) | |
219 | }; | |
220 | ||
221 | typedef enum optgroup_flag optgroup_flags_t; | |
222 | ||
223 | static inline optgroup_flags_t | |
224 | operator| (optgroup_flags_t lhs, optgroup_flags_t rhs) | |
225 | { | |
226 | return (optgroup_flags_t)((int)lhs | (int)rhs); | |
227 | } | |
228 | ||
229 | static inline optgroup_flags_t & | |
230 | operator|= (optgroup_flags_t &lhs, optgroup_flags_t rhs) | |
231 | { | |
232 | lhs = (optgroup_flags_t)((int)lhs | (int)rhs); | |
233 | return lhs; | |
234 | } | |
1a817418 | 235 | |
78c60e3d SS |
236 | /* Define a tree dump switch. */ |
237 | struct dump_file_info | |
238 | { | |
8264c84d ML |
239 | /* Suffix to give output file. */ |
240 | const char *suffix; | |
241 | /* Command line dump switch. */ | |
242 | const char *swtch; | |
243 | /* Command line glob. */ | |
244 | const char *glob; | |
245 | /* Filename for the pass-specific stream. */ | |
246 | const char *pfilename; | |
247 | /* Filename for the -fopt-info stream. */ | |
248 | const char *alt_filename; | |
249 | /* Pass-specific dump stream. */ | |
250 | FILE *pstream; | |
251 | /* -fopt-info stream. */ | |
252 | FILE *alt_stream; | |
253 | /* Dump kind. */ | |
254 | dump_kind dkind; | |
255 | /* Dump flags. */ | |
256 | dump_flags_t pflags; | |
257 | /* A pass flags for -fopt-info. */ | |
4af78ef8 | 258 | dump_flags_t alt_flags; |
8264c84d | 259 | /* Flags for -fopt-info given by a user. */ |
4af78ef8 | 260 | optgroup_flags_t optgroup_flags; |
8264c84d ML |
261 | /* State of pass-specific stream. */ |
262 | int pstate; | |
263 | /* State of the -fopt-info stream. */ | |
264 | int alt_state; | |
265 | /* Dump file number. */ | |
266 | int num; | |
267 | /* Fields "suffix", "swtch", "glob" can be const strings, | |
268 | or can be dynamically allocated, needing free. */ | |
269 | bool owns_strings; | |
270 | /* When a given dump file is being initialized, this flag is set to true | |
271 | if the corresponding TDF_graph dump file has also been initialized. */ | |
272 | bool graph_dump_initialized; | |
78c60e3d | 273 | }; |
7ee2468b | 274 | |
4f5b9c80 DM |
275 | /* A class for describing where in the user's source that a dump message |
276 | relates to, with various constructors for convenience. | |
277 | In particular, this lets us associate dump messages | |
278 | with hotness information (e.g. from PGO), allowing them to | |
279 | be prioritized by code hotness. */ | |
280 | ||
281 | class dump_user_location_t | |
282 | { | |
283 | public: | |
284 | /* Default constructor, analogous to UNKNOWN_LOCATION. */ | |
285 | dump_user_location_t () : m_count (), m_loc (UNKNOWN_LOCATION) {} | |
286 | ||
287 | /* Construct from a gimple statement (using its location and hotness). */ | |
288 | dump_user_location_t (gimple *stmt); | |
289 | ||
290 | /* Construct from an RTL instruction (using its location and hotness). */ | |
291 | dump_user_location_t (rtx_insn *insn); | |
292 | ||
293 | /* Construct from a location_t. This one is deprecated (since it doesn't | |
294 | capture hotness information); it thus needs to be spelled out. */ | |
295 | static dump_user_location_t | |
296 | from_location_t (location_t loc) | |
297 | { | |
298 | return dump_user_location_t (profile_count (), loc); | |
299 | } | |
300 | ||
301 | /* Construct from a function declaration. This one requires spelling out | |
302 | to avoid accidentally constructing from other kinds of tree. */ | |
303 | static dump_user_location_t | |
304 | from_function_decl (tree fndecl); | |
305 | ||
306 | profile_count get_count () const { return m_count; } | |
307 | location_t get_location_t () const { return m_loc; } | |
308 | ||
309 | private: | |
310 | /* Private ctor from count and location, for use by from_location_t. */ | |
311 | dump_user_location_t (profile_count count, location_t loc) | |
312 | : m_count (count), m_loc (loc) | |
313 | {} | |
314 | ||
315 | profile_count m_count; | |
316 | location_t m_loc; | |
317 | }; | |
318 | ||
319 | /* A class for identifying where in the compiler's own source | |
320 | (or a plugin) that a dump message is being emitted from. */ | |
321 | ||
322 | struct dump_impl_location_t | |
323 | { | |
324 | dump_impl_location_t ( | |
325 | #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) | |
326 | const char *file = __builtin_FILE (), | |
327 | int line = __builtin_LINE (), | |
328 | const char *function = __builtin_FUNCTION () | |
329 | #else | |
330 | const char *file = __FILE__, | |
331 | int line = __LINE__, | |
332 | const char *function = NULL | |
333 | #endif | |
334 | ) | |
335 | : m_file (file), m_line (line), m_function (function) | |
336 | {} | |
337 | ||
338 | const char *m_file; | |
339 | int m_line; | |
340 | const char *m_function; | |
341 | }; | |
342 | ||
343 | /* A bundle of information for describing the location of a dump message: | |
344 | (a) the source location and hotness within the user's code, together with | |
345 | (b) the source location within the compiler/plugin. | |
346 | ||
347 | The constructors use default parameters so that (b) gets sets up | |
348 | automatically. | |
349 | ||
350 | The upshot is that you can pass in e.g. a gimple * to dump_printf_loc, | |
351 | and the dump call will automatically record where in GCC's source | |
352 | code the dump was emitted from. */ | |
353 | ||
354 | class dump_location_t | |
355 | { | |
356 | public: | |
357 | /* Default constructor, analogous to UNKNOWN_LOCATION. */ | |
358 | dump_location_t (const dump_impl_location_t &impl_location | |
359 | = dump_impl_location_t ()) | |
360 | : m_user_location (dump_user_location_t ()), | |
361 | m_impl_location (impl_location) | |
362 | { | |
363 | } | |
364 | ||
365 | /* Construct from a gimple statement (using its location and hotness). */ | |
366 | dump_location_t (gimple *stmt, | |
367 | const dump_impl_location_t &impl_location | |
368 | = dump_impl_location_t ()) | |
369 | : m_user_location (dump_user_location_t (stmt)), | |
370 | m_impl_location (impl_location) | |
371 | { | |
372 | } | |
373 | ||
374 | /* Construct from an RTL instruction (using its location and hotness). */ | |
375 | dump_location_t (rtx_insn *insn, | |
376 | const dump_impl_location_t &impl_location | |
377 | = dump_impl_location_t ()) | |
378 | : m_user_location (dump_user_location_t (insn)), | |
379 | m_impl_location (impl_location) | |
380 | { | |
381 | } | |
382 | ||
383 | /* Construct from a dump_user_location_t. */ | |
384 | dump_location_t (const dump_user_location_t &user_location, | |
385 | const dump_impl_location_t &impl_location | |
386 | = dump_impl_location_t ()) | |
387 | : m_user_location (user_location), | |
388 | m_impl_location (impl_location) | |
389 | { | |
390 | } | |
391 | ||
392 | /* Construct from a location_t. This one is deprecated (since it doesn't | |
393 | capture hotness information), and thus requires spelling out. */ | |
394 | static dump_location_t | |
395 | from_location_t (location_t loc, | |
396 | const dump_impl_location_t &impl_location | |
397 | = dump_impl_location_t ()) | |
398 | { | |
399 | return dump_location_t (dump_user_location_t::from_location_t (loc), | |
400 | impl_location); | |
401 | } | |
402 | ||
403 | const dump_user_location_t & | |
404 | get_user_location () const { return m_user_location; } | |
405 | ||
406 | const dump_impl_location_t & | |
407 | get_impl_location () const { return m_impl_location; } | |
408 | ||
409 | location_t get_location_t () const | |
410 | { | |
411 | return m_user_location.get_location_t (); | |
412 | } | |
413 | ||
414 | profile_count get_count () const { return m_user_location.get_count (); } | |
415 | ||
416 | private: | |
417 | dump_user_location_t m_user_location; | |
418 | dump_impl_location_t m_impl_location; | |
419 | }; | |
420 | ||
78c60e3d | 421 | /* In dumpfile.c */ |
75fdb07e | 422 | extern FILE *dump_begin (int, dump_flags_t *, int part=-1); |
7ee2468b | 423 | extern void dump_end (int, FILE *); |
78c60e3d | 424 | extern int opt_info_switch_p (const char *); |
7ee2468b | 425 | extern const char *dump_flag_name (int); |
4a4412b9 | 426 | extern const kv_pair<optgroup_flags_t> optgroup_options[]; |
4df3629e DM |
427 | |
428 | /* Global variables used to communicate with passes. */ | |
429 | extern FILE *dump_file; | |
430 | extern dump_flags_t dump_flags; | |
431 | extern const char *dump_file_name; | |
432 | ||
433 | extern bool dumps_are_enabled; | |
434 | ||
435 | extern void set_dump_file (FILE *new_dump_file); | |
436 | ||
437 | /* Return true if any of the dumps is enabled, false otherwise. */ | |
438 | static inline bool | |
439 | dump_enabled_p (void) | |
440 | { | |
441 | return dumps_are_enabled; | |
442 | } | |
443 | ||
444 | /* The following API calls (which *don't* take a "FILE *") | |
b84e3bde DM |
445 | write the output to zero or more locations. |
446 | ||
447 | Some destinations are written to immediately as dump_* calls | |
448 | are made; for others, the output is consolidated into an "optinfo" | |
449 | instance (with its own metadata), and only emitted once the optinfo | |
450 | is complete. | |
451 | ||
452 | The destinations are: | |
453 | ||
454 | (a) the "immediate" destinations: | |
455 | (a.1) the active dump_file, if any | |
456 | (a.2) the -fopt-info destination, if any | |
457 | (b) the "optinfo" destinations, if any: | |
458 | (b.1) as optimization records | |
459 | ||
460 | dump_* (MSG_*) --> dumpfile.c --> items --> (a.1) dump_file | |
461 | | `-> (a.2) alt_dump_file | |
462 | | | |
463 | `--> (b) optinfo | |
464 | `---> optinfo destinations | |
465 | (b.1) optimization records | |
4df3629e DM |
466 | |
467 | For optinfos, the dump_*_loc mark the beginning of an optinfo | |
468 | instance: all subsequent dump_* calls are consolidated into | |
469 | that optinfo, until the next dump_*_loc call (or a change in | |
470 | dump scope, or a call to dumpfile_ensure_any_optinfo_are_flushed). | |
471 | ||
472 | A group of dump_* calls should be guarded by: | |
473 | ||
474 | if (dump_enabled_p ()) | |
475 | ||
476 | to minimize the work done for the common case where dumps | |
477 | are disabled. */ | |
478 | ||
1a817418 | 479 | extern void dump_printf (dump_flags_t, const char *, ...) ATTRIBUTE_PRINTF_2; |
4f5b9c80 DM |
480 | extern void dump_printf_loc (dump_flags_t, const dump_location_t &, |
481 | const char *, ...) ATTRIBUTE_PRINTF_3; | |
c24e924f | 482 | extern void dump_function (int phase, tree fn); |
4af78ef8 | 483 | extern void dump_basic_block (dump_flags_t, basic_block, int); |
d7259673 DM |
484 | extern void dump_generic_expr_loc (dump_flags_t, const dump_location_t &, |
485 | dump_flags_t, tree); | |
1a817418 | 486 | extern void dump_generic_expr (dump_flags_t, dump_flags_t, tree); |
4f5b9c80 DM |
487 | extern void dump_gimple_stmt_loc (dump_flags_t, const dump_location_t &, |
488 | dump_flags_t, gimple *, int); | |
1a817418 | 489 | extern void dump_gimple_stmt (dump_flags_t, dump_flags_t, gimple *, int); |
30f502ed RB |
490 | extern void dump_gimple_expr_loc (dump_flags_t, const dump_location_t &, |
491 | dump_flags_t, gimple *, int); | |
492 | extern void dump_gimple_expr (dump_flags_t, dump_flags_t, gimple *, int); | |
4df3629e | 493 | extern void dump_symtab_node (dump_flags_t, symtab_node *); |
78c60e3d | 494 | |
dc3f3805 | 495 | template<unsigned int N, typename C> |
4af78ef8 | 496 | void dump_dec (dump_flags_t, const poly_int<N, C> &); |
370c2ebe RS |
497 | extern void dump_dec (dump_flags_t, const poly_wide_int &, signop); |
498 | extern void dump_hex (dump_flags_t, const poly_wide_int &); | |
dc3f3805 | 499 | |
4df3629e | 500 | extern void dumpfile_ensure_any_optinfo_are_flushed (); |
73fbfcad | 501 | |
6475e077 DM |
502 | /* Managing nested scopes, so that dumps can express the call chain |
503 | leading to a dump message. */ | |
504 | ||
505 | extern unsigned int get_dump_scope_depth (); | |
506 | extern void dump_begin_scope (const char *name, const dump_location_t &loc); | |
507 | extern void dump_end_scope (); | |
508 | ||
509 | /* Implementation detail of the AUTO_DUMP_SCOPE macro below. | |
510 | ||
511 | A RAII-style class intended to make it easy to emit dump | |
512 | information about entering and exiting a collection of nested | |
513 | function calls. */ | |
514 | ||
515 | class auto_dump_scope | |
516 | { | |
517 | public: | |
518 | auto_dump_scope (const char *name, dump_location_t loc) | |
519 | { | |
520 | if (dump_enabled_p ()) | |
521 | dump_begin_scope (name, loc); | |
522 | } | |
523 | ~auto_dump_scope () | |
524 | { | |
525 | if (dump_enabled_p ()) | |
526 | dump_end_scope (); | |
527 | } | |
528 | }; | |
529 | ||
530 | /* A macro for calling: | |
531 | dump_begin_scope (NAME, LOC); | |
532 | via an RAII object, thus printing "=== MSG ===\n" to the dumpfile etc, | |
533 | and then calling | |
534 | dump_end_scope (); | |
535 | once the object goes out of scope, thus capturing the nesting of | |
536 | the scopes. */ | |
537 | ||
538 | #define AUTO_DUMP_SCOPE(NAME, LOC) \ | |
539 | auto_dump_scope scope (NAME, LOC) | |
540 | ||
4df3629e DM |
541 | extern void dump_function (int phase, tree fn); |
542 | extern void print_combine_total_stats (void); | |
543 | extern bool enable_rtl_dump_file (void); | |
544 | ||
545 | /* In tree-dump.c */ | |
546 | extern void dump_node (const_tree, dump_flags_t, FILE *); | |
547 | ||
548 | /* In combine.c */ | |
549 | extern void dump_combine_total_stats (FILE *); | |
550 | /* In cfghooks.c */ | |
551 | extern void dump_bb (FILE *, basic_block, int, dump_flags_t); | |
552 | ||
47e0da37 DM |
553 | namespace gcc { |
554 | ||
4df3629e DM |
555 | /* A class for managing all of the various dump files used by the |
556 | optimization passes. */ | |
557 | ||
47e0da37 DM |
558 | class dump_manager |
559 | { | |
560 | public: | |
561 | ||
562 | dump_manager (); | |
10fdd6e9 | 563 | ~dump_manager (); |
47e0da37 | 564 | |
10fdd6e9 DM |
565 | /* Register a dumpfile. |
566 | ||
567 | TAKE_OWNERSHIP determines whether callee takes ownership of strings | |
568 | SUFFIX, SWTCH, and GLOB. */ | |
47e0da37 DM |
569 | unsigned int |
570 | dump_register (const char *suffix, const char *swtch, const char *glob, | |
4af78ef8 DM |
571 | dump_kind dkind, optgroup_flags_t optgroup_flags, |
572 | bool take_ownership); | |
47e0da37 | 573 | |
363dc72c JJ |
574 | /* Allow languages and middle-end to register their dumps before the |
575 | optimization passes. */ | |
576 | void | |
577 | register_dumps (); | |
578 | ||
47e0da37 DM |
579 | /* Return the dump_file_info for the given phase. */ |
580 | struct dump_file_info * | |
581 | get_dump_file_info (int phase) const; | |
582 | ||
799505ae DM |
583 | struct dump_file_info * |
584 | get_dump_file_info_by_switch (const char *swtch) const; | |
585 | ||
47e0da37 DM |
586 | /* Return the name of the dump file for the given phase. |
587 | If the dump is not enabled, returns NULL. */ | |
588 | char * | |
75fdb07e | 589 | get_dump_file_name (int phase, int part = -1) const; |
47e0da37 | 590 | |
799505ae | 591 | char * |
75fdb07e | 592 | get_dump_file_name (struct dump_file_info *dfi, int part = -1) const; |
799505ae | 593 | |
47e0da37 DM |
594 | int |
595 | dump_switch_p (const char *arg); | |
596 | ||
597 | /* Start a dump for PHASE. Store user-supplied dump flags in | |
598 | *FLAG_PTR. Return the number of streams opened. Set globals | |
599 | DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and | |
600 | set dump_flags appropriately for both pass dump stream and | |
601 | -fopt-info stream. */ | |
602 | int | |
1a817418 | 603 | dump_start (int phase, dump_flags_t *flag_ptr); |
47e0da37 DM |
604 | |
605 | /* Finish a tree dump for PHASE and close associated dump streams. Also | |
606 | reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */ | |
607 | void | |
608 | dump_finish (int phase); | |
609 | ||
610 | FILE * | |
75fdb07e | 611 | dump_begin (int phase, dump_flags_t *flag_ptr, int part); |
47e0da37 DM |
612 | |
613 | /* Returns nonzero if tree dump PHASE has been initialized. */ | |
614 | int | |
615 | dump_initialized_p (int phase) const; | |
616 | ||
617 | /* Returns the switch name of PHASE. */ | |
618 | const char * | |
619 | dump_flag_name (int phase) const; | |
620 | ||
621 | private: | |
622 | ||
623 | int | |
624 | dump_phase_enabled_p (int phase) const; | |
625 | ||
626 | int | |
627 | dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob); | |
628 | ||
629 | int | |
8264c84d | 630 | dump_enable_all (dump_kind dkind, dump_flags_t flags, const char *filename); |
47e0da37 DM |
631 | |
632 | int | |
4af78ef8 | 633 | opt_info_enable_passes (optgroup_flags_t optgroup_flags, dump_flags_t flags, |
1a817418 | 634 | const char *filename); |
47e0da37 DM |
635 | |
636 | private: | |
637 | ||
638 | /* Dynamically registered dump files and switches. */ | |
639 | int m_next_dump; | |
640 | struct dump_file_info *m_extra_dump_files; | |
641 | size_t m_extra_dump_files_in_use; | |
642 | size_t m_extra_dump_files_alloced; | |
643 | ||
644 | /* Grant access to dump_enable_all. */ | |
645 | friend bool ::enable_rtl_dump_file (void); | |
646 | ||
647 | /* Grant access to opt_info_enable_passes. */ | |
648 | friend int ::opt_info_switch_p (const char *arg); | |
649 | ||
650 | }; // class dump_manager | |
651 | ||
652 | } // namespace gcc | |
653 | ||
7ee2468b | 654 | #endif /* GCC_DUMPFILE_H */ |