1 /* Definitions for the shared dumpfile.
2 Copyright (C) 2004-2017 Free Software Foundation, Inc.
4 This file is part of GCC.
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)
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.
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/>. */
21 #ifndef GCC_DUMPFILE_H
22 #define GCC_DUMPFILE_H 1
25 /* Different tree dump places. When you add new tree dump places,
26 extend the DUMP_FILES array in dumpfile.c. */
29 TDI_none
, /* No dump */
30 TDI_cgraph
, /* dump function call graph. */
31 TDI_inheritance
, /* dump type inheritance graph. */
32 TDI_clones
, /* dump IPA cloning decisions. */
33 TDI_tu
, /* dump the whole translation unit. */
34 TDI_class
, /* dump class hierarchy. */
35 TDI_original
, /* dump each function before optimizing it */
36 TDI_generic
, /* dump each function after genericizing it */
37 TDI_nested
, /* dump each function after unnesting it */
39 TDI_lang_all
, /* enable all the language dumps. */
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. */
47 /* Enum used to distinguish dump files to types. */
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
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
63 #define TDF_ADDRESS (1 << 3) /* dump node addresses */
64 #define TDF_SLIM (1 << 4) /* don't go wild following links */
65 #define TDF_RAW (1 << 5) /* don't unparse the function */
66 #define TDF_DETAILS (1 << 6) /* show more detailed info about
68 #define TDF_STATS (1 << 7) /* dump various statistics about
70 #define TDF_BLOCKS (1 << 8) /* display basic block boundaries */
71 #define TDF_VOPS (1 << 9) /* display virtual operands */
72 #define TDF_LINENO (1 << 10) /* display statement line numbers */
73 #define TDF_UID (1 << 11) /* display decl UIDs */
75 #define TDF_STMTADDR (1 << 12) /* Address of stmt. */
77 #define TDF_GRAPH (1 << 13) /* a graph dump is being emitted */
78 #define TDF_MEMSYMS (1 << 14) /* display memory symbols in expr.
81 #define TDF_DIAGNOSTIC (1 << 15) /* A dump to be put in a diagnostic
83 #define TDF_VERBOSE (1 << 16) /* A dump that uses the full tree
84 dumper to print stmts. */
85 #define TDF_RHS_ONLY (1 << 17) /* a flag to only print the RHS of
87 #define TDF_ASMNAME (1 << 18) /* display asm names of decls */
88 #define TDF_EH (1 << 19) /* display EH region number
89 holding this gimple statement. */
90 #define TDF_NOUID (1 << 20) /* omit UIDs from dumps. */
91 #define TDF_ALIAS (1 << 21) /* display alias information */
92 #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid. */
93 #define TDF_CSELIB (1 << 23) /* Dump cselib details. */
94 #define TDF_SCEV (1 << 24) /* Dump SCEV details. */
95 #define TDF_COMMENT (1 << 25) /* Dump lines with prefix ";;" */
96 #define TDF_GIMPLE (1 << 26) /* Dump in GIMPLE FE syntax */
97 #define MSG_OPTIMIZED_LOCATIONS (1 << 27) /* -fopt-info optimized sources */
98 #define MSG_MISSED_OPTIMIZATION (1 << 28) /* missed opportunities */
99 #define MSG_NOTE (1 << 29) /* general optimization info */
100 #define MSG_ALL (MSG_OPTIMIZED_LOCATIONS | MSG_MISSED_OPTIMIZATION \
104 /* Value of TDF_NONE is used just for bits filtered by TDF_KIND_MASK. */
108 /* Flags to control high-level -fopt-info dumps. Usually these flags
109 define a group of passes. An optimization pass can be part of
111 #define OPTGROUP_NONE (0)
112 #define OPTGROUP_IPA (1 << 1) /* IPA optimization passes */
113 #define OPTGROUP_LOOP (1 << 2) /* Loop optimization passes */
114 #define OPTGROUP_INLINE (1 << 3) /* Inlining passes */
115 #define OPTGROUP_OMP (1 << 4) /* OMP (Offloading and Multi
116 Processing) transformations */
117 #define OPTGROUP_VEC (1 << 5) /* Vectorization passes */
118 #define OPTGROUP_OTHER (1 << 6) /* All other passes */
119 #define OPTGROUP_ALL (OPTGROUP_IPA | OPTGROUP_LOOP | OPTGROUP_INLINE \
120 | OPTGROUP_OMP | OPTGROUP_VEC | OPTGROUP_OTHER)
122 /* Dump flags type. */
124 typedef uint64_t dump_flags_t
;
126 /* Define a tree dump switch. */
127 struct dump_file_info
130 CONSTEXPR
dump_file_info ();
133 dump_file_info (const char *_suffix
, const char *_swtch
, dump_kind _dkind
,
136 /* Suffix to give output file. */
138 /* Command line dump switch. */
140 /* Command line glob. */
142 /* Filename for the pass-specific stream. */
143 const char *pfilename
;
144 /* Filename for the -fopt-info stream. */
145 const char *alt_filename
;
146 /* Pass-specific dump stream. */
148 /* -fopt-info stream. */
154 /* A pass flags for -fopt-info. */
156 /* Flags for -fopt-info given by a user. */
158 /* State of pass-specific stream. */
160 /* State of the -fopt-info stream. */
162 /* Dump file number. */
164 /* Fields "suffix", "swtch", "glob" can be const strings,
165 or can be dynamically allocated, needing free. */
167 /* When a given dump file is being initialized, this flag is set to true
168 if the corresponding TDF_graph dump file has also been initialized. */
169 bool graph_dump_initialized
;
173 extern FILE *dump_begin (int, dump_flags_t
*);
174 extern void dump_end (int, FILE *);
175 extern int opt_info_switch_p (const char *);
176 extern const char *dump_flag_name (int);
177 extern void dump_printf (dump_flags_t
, const char *, ...) ATTRIBUTE_PRINTF_2
;
178 extern void dump_printf_loc (dump_flags_t
, source_location
,
179 const char *, ...) ATTRIBUTE_PRINTF_3
;
180 extern void dump_function (int phase
, tree fn
);
181 extern void dump_basic_block (int, basic_block
, int);
182 extern void dump_generic_expr_loc (int, source_location
, int, tree
);
183 extern void dump_generic_expr (dump_flags_t
, dump_flags_t
, tree
);
184 extern void dump_gimple_stmt_loc (dump_flags_t
, source_location
, dump_flags_t
,
186 extern void dump_gimple_stmt (dump_flags_t
, dump_flags_t
, gimple
*, int);
187 extern void print_combine_total_stats (void);
188 extern bool enable_rtl_dump_file (void);
191 extern void dump_node (const_tree
, dump_flags_t
, FILE *);
194 extern void dump_combine_total_stats (FILE *);
196 extern void dump_bb (FILE *, basic_block
, int, dump_flags_t
);
198 /* Global variables used to communicate with passes. */
199 extern FILE *dump_file
;
200 extern FILE *alt_dump_file
;
201 extern dump_flags_t dump_flags
;
202 extern const char *dump_file_name
;
204 /* Return true if any of the dumps is enabled, false otherwise. */
206 dump_enabled_p (void)
208 return (dump_file
|| alt_dump_file
);
220 /* Register a dumpfile.
222 TAKE_OWNERSHIP determines whether callee takes ownership of strings
223 SUFFIX, SWTCH, and GLOB. */
225 dump_register (const char *suffix
, const char *swtch
, const char *glob
,
226 dump_kind dkind
, int optgroup_flags
, bool take_ownership
);
228 /* Return the dump_file_info for the given phase. */
229 struct dump_file_info
*
230 get_dump_file_info (int phase
) const;
232 struct dump_file_info
*
233 get_dump_file_info_by_switch (const char *swtch
) const;
235 /* Return the name of the dump file for the given phase.
236 If the dump is not enabled, returns NULL. */
238 get_dump_file_name (int phase
) const;
241 get_dump_file_name (struct dump_file_info
*dfi
) const;
244 dump_switch_p (const char *arg
);
246 /* Start a dump for PHASE. Store user-supplied dump flags in
247 *FLAG_PTR. Return the number of streams opened. Set globals
248 DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
249 set dump_flags appropriately for both pass dump stream and
250 -fopt-info stream. */
252 dump_start (int phase
, dump_flags_t
*flag_ptr
);
254 /* Finish a tree dump for PHASE and close associated dump streams. Also
255 reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
257 dump_finish (int phase
);
260 dump_begin (int phase
, dump_flags_t
*flag_ptr
);
262 /* Returns nonzero if tree dump PHASE has been initialized. */
264 dump_initialized_p (int phase
) const;
266 /* Returns the switch name of PHASE. */
268 dump_flag_name (int phase
) const;
273 dump_phase_enabled_p (int phase
) const;
276 dump_switch_p_1 (const char *arg
, struct dump_file_info
*dfi
, bool doglob
);
279 dump_enable_all (dump_kind dkind
, dump_flags_t flags
, const char *filename
);
282 opt_info_enable_passes (int optgroup_flags
, dump_flags_t flags
,
283 const char *filename
);
287 /* Dynamically registered dump files and switches. */
289 struct dump_file_info
*m_extra_dump_files
;
290 size_t m_extra_dump_files_in_use
;
291 size_t m_extra_dump_files_alloced
;
293 /* Grant access to dump_enable_all. */
294 friend bool ::enable_rtl_dump_file (void);
296 /* Grant access to opt_info_enable_passes. */
297 friend int ::opt_info_switch_p (const char *arg
);
299 }; // class dump_manager
303 #endif /* GCC_DUMPFILE_H */