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