PR c++/86171 - ICE with recursive alias instantiation.
[official-gcc.git] / gcc / dumpfile.h
blobf6ad670f0e430eff10de54bf55531251718a9e54
1 /* Definitions for the shared dumpfile.
2 Copyright (C) 2004-2018 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)
9 any later version.
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. */
27 enum tree_dump_index
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_original, /* dump each function before optimizing it */
34 TDI_gimple, /* dump each function after gimplifying it */
35 TDI_nested, /* dump each function after unnesting it */
36 TDI_lto_stream_out, /* dump information about lto streaming */
38 TDI_lang_all, /* enable all the language dumps. */
39 TDI_tree_all, /* enable all the GENERIC/GIMPLE dumps. */
40 TDI_rtl_all, /* enable all the RTL dumps. */
41 TDI_ipa_all, /* enable all the IPA dumps. */
43 TDI_end
46 /* Enum used to distinguish dump files to types. */
48 enum dump_kind
50 DK_none,
51 DK_lang,
52 DK_tree,
53 DK_rtl,
54 DK_ipa
57 /* Bit masks to control dumping. Not all values are applicable to all
58 dumps. Add new ones at the end. When you define new values, extend
59 the DUMP_OPTIONS array in dumpfile.c. The TDF_* flags coexist with
60 MSG_* flags (for -fopt-info) and the bit values must be chosen to
61 allow that. */
62 enum dump_flag
64 /* Value of TDF_NONE is used just for bits filtered by TDF_KIND_MASK. */
65 TDF_NONE = 0,
67 /* Dump node addresses. */
68 TDF_ADDRESS = (1 << 0),
70 /* Don't go wild following links. */
71 TDF_SLIM = (1 << 1),
73 /* Don't unparse the function. */
74 TDF_RAW = (1 << 2),
76 /* Show more detailed info about each pass. */
77 TDF_DETAILS = (1 << 3),
79 /* Dump various statistics about each pass. */
80 TDF_STATS = (1 << 4),
82 /* Display basic block boundaries. */
83 TDF_BLOCKS = (1 << 5),
85 /* Display virtual operands. */
86 TDF_VOPS = (1 << 6),
88 /* Display statement line numbers. */
89 TDF_LINENO = (1 << 7),
91 /* Display decl UIDs. */
92 TDF_UID = (1 << 8),
94 /* Address of stmt. */
95 TDF_STMTADDR = (1 << 9),
97 /* A graph dump is being emitted. */
98 TDF_GRAPH = (1 << 10),
100 /* Display memory symbols in expr.
101 Implies TDF_VOPS. */
102 TDF_MEMSYMS = (1 << 11),
104 /* A flag to only print the RHS of a gimple stmt. */
105 TDF_RHS_ONLY = (1 << 12),
107 /* Display asm names of decls. */
108 TDF_ASMNAME = (1 << 13),
110 /* Display EH region number holding this gimple statement. */
111 TDF_EH = (1 << 14),
113 /* Omit UIDs from dumps. */
114 TDF_NOUID = (1 << 15),
116 /* Display alias information. */
117 TDF_ALIAS = (1 << 16),
119 /* Enumerate locals by uid. */
120 TDF_ENUMERATE_LOCALS = (1 << 17),
122 /* Dump cselib details. */
123 TDF_CSELIB = (1 << 18),
125 /* Dump SCEV details. */
126 TDF_SCEV = (1 << 19),
128 /* Dump in GIMPLE FE syntax */
129 TDF_GIMPLE = (1 << 20),
131 /* Dump folding details. */
132 TDF_FOLDING = (1 << 21),
134 /* -fopt-info optimized sources. */
135 MSG_OPTIMIZED_LOCATIONS = (1 << 22),
137 /* Missed opportunities. */
138 MSG_MISSED_OPTIMIZATION = (1 << 23),
140 /* General optimization info. */
141 MSG_NOTE = (1 << 24),
143 MSG_ALL = (MSG_OPTIMIZED_LOCATIONS
144 | MSG_MISSED_OPTIMIZATION
145 | MSG_NOTE),
147 /* Dumping for -fcompare-debug. */
148 TDF_COMPARE_DEBUG = (1 << 25)
151 /* Dump flags type. */
153 typedef enum dump_flag dump_flags_t;
155 static inline dump_flags_t
156 operator| (dump_flags_t lhs, dump_flags_t rhs)
158 return (dump_flags_t)((int)lhs | (int)rhs);
161 static inline dump_flags_t
162 operator& (dump_flags_t lhs, dump_flags_t rhs)
164 return (dump_flags_t)((int)lhs & (int)rhs);
167 static inline dump_flags_t
168 operator~ (dump_flags_t flags)
170 return (dump_flags_t)~((int)flags);
173 static inline dump_flags_t &
174 operator|= (dump_flags_t &lhs, dump_flags_t rhs)
176 lhs = (dump_flags_t)((int)lhs | (int)rhs);
177 return lhs;
180 static inline dump_flags_t &
181 operator&= (dump_flags_t &lhs, dump_flags_t rhs)
183 lhs = (dump_flags_t)((int)lhs & (int)rhs);
184 return lhs;
187 /* Flags to control high-level -fopt-info dumps. Usually these flags
188 define a group of passes. An optimization pass can be part of
189 multiple groups. */
191 enum optgroup_flag
193 OPTGROUP_NONE = 0,
195 /* IPA optimization passes */
196 OPTGROUP_IPA = (1 << 1),
198 /* Loop optimization passes */
199 OPTGROUP_LOOP = (1 << 2),
201 /* Inlining passes */
202 OPTGROUP_INLINE = (1 << 3),
204 /* OMP (Offloading and Multi Processing) transformations */
205 OPTGROUP_OMP = (1 << 4),
207 /* Vectorization passes */
208 OPTGROUP_VEC = (1 << 5),
210 /* All other passes */
211 OPTGROUP_OTHER = (1 << 6),
213 OPTGROUP_ALL = (OPTGROUP_IPA | OPTGROUP_LOOP | OPTGROUP_INLINE
214 | OPTGROUP_OMP | OPTGROUP_VEC | OPTGROUP_OTHER)
217 typedef enum optgroup_flag optgroup_flags_t;
219 static inline optgroup_flags_t
220 operator| (optgroup_flags_t lhs, optgroup_flags_t rhs)
222 return (optgroup_flags_t)((int)lhs | (int)rhs);
225 static inline optgroup_flags_t &
226 operator|= (optgroup_flags_t &lhs, optgroup_flags_t rhs)
228 lhs = (optgroup_flags_t)((int)lhs | (int)rhs);
229 return lhs;
232 /* Define a tree dump switch. */
233 struct dump_file_info
235 /* Suffix to give output file. */
236 const char *suffix;
237 /* Command line dump switch. */
238 const char *swtch;
239 /* Command line glob. */
240 const char *glob;
241 /* Filename for the pass-specific stream. */
242 const char *pfilename;
243 /* Filename for the -fopt-info stream. */
244 const char *alt_filename;
245 /* Pass-specific dump stream. */
246 FILE *pstream;
247 /* -fopt-info stream. */
248 FILE *alt_stream;
249 /* Dump kind. */
250 dump_kind dkind;
251 /* Dump flags. */
252 dump_flags_t pflags;
253 /* A pass flags for -fopt-info. */
254 dump_flags_t alt_flags;
255 /* Flags for -fopt-info given by a user. */
256 optgroup_flags_t optgroup_flags;
257 /* State of pass-specific stream. */
258 int pstate;
259 /* State of the -fopt-info stream. */
260 int alt_state;
261 /* Dump file number. */
262 int num;
263 /* Fields "suffix", "swtch", "glob" can be const strings,
264 or can be dynamically allocated, needing free. */
265 bool owns_strings;
266 /* When a given dump file is being initialized, this flag is set to true
267 if the corresponding TDF_graph dump file has also been initialized. */
268 bool graph_dump_initialized;
271 /* In dumpfile.c */
272 extern FILE *dump_begin (int, dump_flags_t *);
273 extern void dump_end (int, FILE *);
274 extern int opt_info_switch_p (const char *);
275 extern const char *dump_flag_name (int);
276 extern void dump_printf (dump_flags_t, const char *, ...) ATTRIBUTE_PRINTF_2;
277 extern void dump_printf_loc (dump_flags_t, source_location,
278 const char *, ...) ATTRIBUTE_PRINTF_3;
279 extern void dump_function (int phase, tree fn);
280 extern void dump_basic_block (dump_flags_t, basic_block, int);
281 extern void dump_generic_expr_loc (dump_flags_t, source_location, dump_flags_t, tree);
282 extern void dump_generic_expr (dump_flags_t, dump_flags_t, tree);
283 extern void dump_gimple_stmt_loc (dump_flags_t, source_location, dump_flags_t,
284 gimple *, int);
285 extern void dump_gimple_stmt (dump_flags_t, dump_flags_t, gimple *, int);
286 extern void print_combine_total_stats (void);
287 extern bool enable_rtl_dump_file (void);
289 template<unsigned int N, typename C>
290 void dump_dec (dump_flags_t, const poly_int<N, C> &);
292 /* In tree-dump.c */
293 extern void dump_node (const_tree, dump_flags_t, FILE *);
295 /* In combine.c */
296 extern void dump_combine_total_stats (FILE *);
297 /* In cfghooks.c */
298 extern void dump_bb (FILE *, basic_block, int, dump_flags_t);
300 /* Global variables used to communicate with passes. */
301 extern FILE *dump_file;
302 extern FILE *alt_dump_file;
303 extern dump_flags_t dump_flags;
304 extern const char *dump_file_name;
306 /* Return true if any of the dumps is enabled, false otherwise. */
307 static inline bool
308 dump_enabled_p (void)
310 return (dump_file || alt_dump_file);
313 namespace gcc {
315 class dump_manager
317 public:
319 dump_manager ();
320 ~dump_manager ();
322 /* Register a dumpfile.
324 TAKE_OWNERSHIP determines whether callee takes ownership of strings
325 SUFFIX, SWTCH, and GLOB. */
326 unsigned int
327 dump_register (const char *suffix, const char *swtch, const char *glob,
328 dump_kind dkind, optgroup_flags_t optgroup_flags,
329 bool take_ownership);
331 /* Allow languages and middle-end to register their dumps before the
332 optimization passes. */
333 void
334 register_dumps ();
336 /* Return the dump_file_info for the given phase. */
337 struct dump_file_info *
338 get_dump_file_info (int phase) const;
340 struct dump_file_info *
341 get_dump_file_info_by_switch (const char *swtch) const;
343 /* Return the name of the dump file for the given phase.
344 If the dump is not enabled, returns NULL. */
345 char *
346 get_dump_file_name (int phase) const;
348 char *
349 get_dump_file_name (struct dump_file_info *dfi) const;
352 dump_switch_p (const char *arg);
354 /* Start a dump for PHASE. Store user-supplied dump flags in
355 *FLAG_PTR. Return the number of streams opened. Set globals
356 DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
357 set dump_flags appropriately for both pass dump stream and
358 -fopt-info stream. */
360 dump_start (int phase, dump_flags_t *flag_ptr);
362 /* Finish a tree dump for PHASE and close associated dump streams. Also
363 reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
364 void
365 dump_finish (int phase);
367 FILE *
368 dump_begin (int phase, dump_flags_t *flag_ptr);
370 /* Returns nonzero if tree dump PHASE has been initialized. */
372 dump_initialized_p (int phase) const;
374 /* Returns the switch name of PHASE. */
375 const char *
376 dump_flag_name (int phase) const;
378 private:
381 dump_phase_enabled_p (int phase) const;
384 dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob);
387 dump_enable_all (dump_kind dkind, dump_flags_t flags, const char *filename);
390 opt_info_enable_passes (optgroup_flags_t optgroup_flags, dump_flags_t flags,
391 const char *filename);
393 private:
395 /* Dynamically registered dump files and switches. */
396 int m_next_dump;
397 struct dump_file_info *m_extra_dump_files;
398 size_t m_extra_dump_files_in_use;
399 size_t m_extra_dump_files_alloced;
401 /* Grant access to dump_enable_all. */
402 friend bool ::enable_rtl_dump_file (void);
404 /* Grant access to opt_info_enable_passes. */
405 friend int ::opt_info_switch_p (const char *arg);
407 }; // class dump_manager
409 } // namespace gcc
411 #endif /* GCC_DUMPFILE_H */