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)
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_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. */
46 /* Enum used to distinguish dump files to types. */
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
64 /* Value of TDF_NONE is used just for bits filtered by TDF_KIND_MASK. */
67 /* Dump node addresses. */
68 TDF_ADDRESS
= (1 << 0),
70 /* Don't go wild following links. */
73 /* Don't unparse the function. */
76 /* Show more detailed info about each pass. */
77 TDF_DETAILS
= (1 << 3),
79 /* Dump various statistics about each pass. */
82 /* Display basic block boundaries. */
83 TDF_BLOCKS
= (1 << 5),
85 /* Display virtual operands. */
88 /* Display statement line numbers. */
89 TDF_LINENO
= (1 << 7),
91 /* Display decl UIDs. */
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.
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. */
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
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
);
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
);
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
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
);
232 /* Define a tree dump switch. */
233 struct dump_file_info
235 /* Suffix to give output file. */
237 /* Command line dump switch. */
239 /* Command line 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. */
247 /* -fopt-info stream. */
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. */
259 /* State of the -fopt-info stream. */
261 /* Dump file number. */
263 /* Fields "suffix", "swtch", "glob" can be const strings,
264 or can be dynamically allocated, needing free. */
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
;
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
,
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
> &);
293 extern void dump_node (const_tree
, dump_flags_t
, FILE *);
296 extern void dump_combine_total_stats (FILE *);
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. */
308 dump_enabled_p (void)
310 return (dump_file
|| alt_dump_file
);
322 /* Register a dumpfile.
324 TAKE_OWNERSHIP determines whether callee takes ownership of strings
325 SUFFIX, SWTCH, and GLOB. */
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. */
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. */
346 get_dump_file_name (int phase
) const;
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. */
365 dump_finish (int phase
);
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. */
376 dump_flag_name (int phase
) const;
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
);
395 /* Dynamically registered dump files and switches. */
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
411 #endif /* GCC_DUMPFILE_H */