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 */
37 TDI_lang_all
, /* enable all the language dumps. */
38 TDI_tree_all
, /* enable all the GENERIC/GIMPLE dumps. */
39 TDI_rtl_all
, /* enable all the RTL dumps. */
40 TDI_ipa_all
, /* enable all the IPA dumps. */
45 /* Enum used to distinguish dump files to types. */
56 /* Bit masks to control dumping. Not all values are applicable to all
57 dumps. Add new ones at the end. When you define new values, extend
58 the DUMP_OPTIONS array in dumpfile.c. The TDF_* flags coexist with
59 MSG_* flags (for -fopt-info) and the bit values must be chosen to
63 /* Value of TDF_NONE is used just for bits filtered by TDF_KIND_MASK. */
66 /* Dump node addresses. */
67 TDF_ADDRESS
= (1 << 0),
69 /* Don't go wild following links. */
72 /* Don't unparse the function. */
75 /* Show more detailed info about each pass. */
76 TDF_DETAILS
= (1 << 3),
78 /* Dump various statistics about each pass. */
81 /* Display basic block boundaries. */
82 TDF_BLOCKS
= (1 << 5),
84 /* Display virtual operands. */
87 /* Display statement line numbers. */
88 TDF_LINENO
= (1 << 7),
90 /* Display decl UIDs. */
93 /* Address of stmt. */
94 TDF_STMTADDR
= (1 << 9),
96 /* A graph dump is being emitted. */
97 TDF_GRAPH
= (1 << 10),
99 /* Display memory symbols in expr.
101 TDF_MEMSYMS
= (1 << 11),
103 /* A flag to only print the RHS of a gimple stmt. */
104 TDF_RHS_ONLY
= (1 << 12),
106 /* Display asm names of decls. */
107 TDF_ASMNAME
= (1 << 13),
109 /* Display EH region number holding this gimple statement. */
112 /* Omit UIDs from dumps. */
113 TDF_NOUID
= (1 << 15),
115 /* Display alias information. */
116 TDF_ALIAS
= (1 << 16),
118 /* Enumerate locals by uid. */
119 TDF_ENUMERATE_LOCALS
= (1 << 17),
121 /* Dump cselib details. */
122 TDF_CSELIB
= (1 << 18),
124 /* Dump SCEV details. */
125 TDF_SCEV
= (1 << 19),
127 /* Dump in GIMPLE FE syntax */
128 TDF_GIMPLE
= (1 << 20),
130 /* Dump folding details. */
131 TDF_FOLDING
= (1 << 21),
133 /* -fopt-info optimized sources. */
134 MSG_OPTIMIZED_LOCATIONS
= (1 << 22),
136 /* Missed opportunities. */
137 MSG_MISSED_OPTIMIZATION
= (1 << 23),
139 /* General optimization info. */
140 MSG_NOTE
= (1 << 24),
142 MSG_ALL
= (MSG_OPTIMIZED_LOCATIONS
143 | MSG_MISSED_OPTIMIZATION
146 /* Dumping for -fcompare-debug. */
147 TDF_COMPARE_DEBUG
= (1 << 25)
150 /* Dump flags type. */
152 typedef enum dump_flag dump_flags_t
;
154 static inline dump_flags_t
155 operator| (dump_flags_t lhs
, dump_flags_t rhs
)
157 return (dump_flags_t
)((int)lhs
| (int)rhs
);
160 static inline dump_flags_t
161 operator& (dump_flags_t lhs
, dump_flags_t rhs
)
163 return (dump_flags_t
)((int)lhs
& (int)rhs
);
166 static inline dump_flags_t
167 operator~ (dump_flags_t flags
)
169 return (dump_flags_t
)~((int)flags
);
172 static inline dump_flags_t
&
173 operator|= (dump_flags_t
&lhs
, dump_flags_t rhs
)
175 lhs
= (dump_flags_t
)((int)lhs
| (int)rhs
);
179 static inline dump_flags_t
&
180 operator&= (dump_flags_t
&lhs
, dump_flags_t rhs
)
182 lhs
= (dump_flags_t
)((int)lhs
& (int)rhs
);
186 /* Flags to control high-level -fopt-info dumps. Usually these flags
187 define a group of passes. An optimization pass can be part of
194 /* IPA optimization passes */
195 OPTGROUP_IPA
= (1 << 1),
197 /* Loop optimization passes */
198 OPTGROUP_LOOP
= (1 << 2),
200 /* Inlining passes */
201 OPTGROUP_INLINE
= (1 << 3),
203 /* OMP (Offloading and Multi Processing) transformations */
204 OPTGROUP_OMP
= (1 << 4),
206 /* Vectorization passes */
207 OPTGROUP_VEC
= (1 << 5),
209 /* All other passes */
210 OPTGROUP_OTHER
= (1 << 6),
212 OPTGROUP_ALL
= (OPTGROUP_IPA
| OPTGROUP_LOOP
| OPTGROUP_INLINE
213 | OPTGROUP_OMP
| OPTGROUP_VEC
| OPTGROUP_OTHER
)
216 typedef enum optgroup_flag optgroup_flags_t
;
218 static inline optgroup_flags_t
219 operator| (optgroup_flags_t lhs
, optgroup_flags_t rhs
)
221 return (optgroup_flags_t
)((int)lhs
| (int)rhs
);
224 static inline optgroup_flags_t
&
225 operator|= (optgroup_flags_t
&lhs
, optgroup_flags_t rhs
)
227 lhs
= (optgroup_flags_t
)((int)lhs
| (int)rhs
);
231 /* Define a tree dump switch. */
232 struct dump_file_info
234 /* Suffix to give output file. */
236 /* Command line dump switch. */
238 /* Command line glob. */
240 /* Filename for the pass-specific stream. */
241 const char *pfilename
;
242 /* Filename for the -fopt-info stream. */
243 const char *alt_filename
;
244 /* Pass-specific dump stream. */
246 /* -fopt-info stream. */
252 /* A pass flags for -fopt-info. */
253 dump_flags_t alt_flags
;
254 /* Flags for -fopt-info given by a user. */
255 optgroup_flags_t optgroup_flags
;
256 /* State of pass-specific stream. */
258 /* State of the -fopt-info stream. */
260 /* Dump file number. */
262 /* Fields "suffix", "swtch", "glob" can be const strings,
263 or can be dynamically allocated, needing free. */
265 /* When a given dump file is being initialized, this flag is set to true
266 if the corresponding TDF_graph dump file has also been initialized. */
267 bool graph_dump_initialized
;
271 extern FILE *dump_begin (int, dump_flags_t
*);
272 extern void dump_end (int, FILE *);
273 extern int opt_info_switch_p (const char *);
274 extern const char *dump_flag_name (int);
275 extern void dump_printf (dump_flags_t
, const char *, ...) ATTRIBUTE_PRINTF_2
;
276 extern void dump_printf_loc (dump_flags_t
, source_location
,
277 const char *, ...) ATTRIBUTE_PRINTF_3
;
278 extern void dump_function (int phase
, tree fn
);
279 extern void dump_basic_block (dump_flags_t
, basic_block
, int);
280 extern void dump_generic_expr_loc (dump_flags_t
, source_location
, dump_flags_t
, tree
);
281 extern void dump_generic_expr (dump_flags_t
, dump_flags_t
, tree
);
282 extern void dump_gimple_stmt_loc (dump_flags_t
, source_location
, dump_flags_t
,
284 extern void dump_gimple_stmt (dump_flags_t
, dump_flags_t
, gimple
*, int);
285 extern void print_combine_total_stats (void);
286 extern bool enable_rtl_dump_file (void);
288 template<unsigned int N
, typename C
>
289 void dump_dec (dump_flags_t
, const poly_int
<N
, C
> &);
292 extern void dump_node (const_tree
, dump_flags_t
, FILE *);
295 extern void dump_combine_total_stats (FILE *);
297 extern void dump_bb (FILE *, basic_block
, int, dump_flags_t
);
299 /* Global variables used to communicate with passes. */
300 extern FILE *dump_file
;
301 extern FILE *alt_dump_file
;
302 extern dump_flags_t dump_flags
;
303 extern const char *dump_file_name
;
305 /* Return true if any of the dumps is enabled, false otherwise. */
307 dump_enabled_p (void)
309 return (dump_file
|| alt_dump_file
);
321 /* Register a dumpfile.
323 TAKE_OWNERSHIP determines whether callee takes ownership of strings
324 SUFFIX, SWTCH, and GLOB. */
326 dump_register (const char *suffix
, const char *swtch
, const char *glob
,
327 dump_kind dkind
, optgroup_flags_t optgroup_flags
,
328 bool take_ownership
);
330 /* Allow languages and middle-end to register their dumps before the
331 optimization passes. */
335 /* Return the dump_file_info for the given phase. */
336 struct dump_file_info
*
337 get_dump_file_info (int phase
) const;
339 struct dump_file_info
*
340 get_dump_file_info_by_switch (const char *swtch
) const;
342 /* Return the name of the dump file for the given phase.
343 If the dump is not enabled, returns NULL. */
345 get_dump_file_name (int phase
) const;
348 get_dump_file_name (struct dump_file_info
*dfi
) const;
351 dump_switch_p (const char *arg
);
353 /* Start a dump for PHASE. Store user-supplied dump flags in
354 *FLAG_PTR. Return the number of streams opened. Set globals
355 DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
356 set dump_flags appropriately for both pass dump stream and
357 -fopt-info stream. */
359 dump_start (int phase
, dump_flags_t
*flag_ptr
);
361 /* Finish a tree dump for PHASE and close associated dump streams. Also
362 reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
364 dump_finish (int phase
);
367 dump_begin (int phase
, dump_flags_t
*flag_ptr
);
369 /* Returns nonzero if tree dump PHASE has been initialized. */
371 dump_initialized_p (int phase
) const;
373 /* Returns the switch name of PHASE. */
375 dump_flag_name (int phase
) const;
380 dump_phase_enabled_p (int phase
) const;
383 dump_switch_p_1 (const char *arg
, struct dump_file_info
*dfi
, bool doglob
);
386 dump_enable_all (dump_kind dkind
, dump_flags_t flags
, const char *filename
);
389 opt_info_enable_passes (optgroup_flags_t optgroup_flags
, dump_flags_t flags
,
390 const char *filename
);
394 /* Dynamically registered dump files and switches. */
396 struct dump_file_info
*m_extra_dump_files
;
397 size_t m_extra_dump_files_in_use
;
398 size_t m_extra_dump_files_alloced
;
400 /* Grant access to dump_enable_all. */
401 friend bool ::enable_rtl_dump_file (void);
403 /* Grant access to opt_info_enable_passes. */
404 friend int ::opt_info_switch_p (const char *arg
);
406 }; // class dump_manager
410 #endif /* GCC_DUMPFILE_H */