]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/dumpfile.h
Update copyright years.
[thirdparty/gcc.git] / gcc / dumpfile.h
CommitLineData
7ee2468b 1/* Definitions for the shared dumpfile.
85ec4feb 2 Copyright (C) 2004-2018 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
78c60e3d 24
7ee2468b 25/* Different tree dump places. When you add new tree dump places,
2b4e6bf1 26 extend the DUMP_FILES array in dumpfile.c. */
7ee2468b
SB
27enum tree_dump_index
28{
29 TDI_none, /* No dump */
0e0a19c5
NS
30 TDI_cgraph, /* dump function call graph. */
31 TDI_inheritance, /* dump type inheritance graph. */
0bdad123 32 TDI_clones, /* dump IPA cloning decisions. */
7ee2468b 33 TDI_original, /* dump each function before optimizing it */
363dc72c 34 TDI_gimple, /* dump each function after gimplifying it */
7ee2468b 35 TDI_nested, /* dump each function after unnesting it */
a529e0a6
NS
36
37 TDI_lang_all, /* enable all the language dumps. */
0e0a19c5
NS
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. */
7ee2468b
SB
41
42 TDI_end
43};
44
8264c84d
ML
45/* Enum used to distinguish dump files to types. */
46
47enum dump_kind
48{
49 DK_none,
50 DK_lang,
51 DK_tree,
52 DK_rtl,
286c97f3 53 DK_ipa
8264c84d
ML
54};
55
78c60e3d
SS
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
2b4e6bf1
SS
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
60 allow that. */
262149f5
ML
61#define TDF_ADDRESS (1 << 0) /* dump node addresses */
62#define TDF_SLIM (1 << 1) /* don't go wild following links */
63#define TDF_RAW (1 << 2) /* don't unparse the function */
64#define TDF_DETAILS (1 << 3) /* show more detailed info about
7ee2468b 65 each pass */
262149f5 66#define TDF_STATS (1 << 4) /* dump various statistics about
7ee2468b 67 each pass */
262149f5
ML
68#define TDF_BLOCKS (1 << 5) /* display basic block boundaries */
69#define TDF_VOPS (1 << 6) /* display virtual operands */
70#define TDF_LINENO (1 << 7) /* display statement line numbers */
71#define TDF_UID (1 << 8) /* display decl UIDs */
7ee2468b 72
262149f5 73#define TDF_STMTADDR (1 << 9) /* Address of stmt. */
7ee2468b 74
262149f5
ML
75#define TDF_GRAPH (1 << 10) /* a graph dump is being emitted */
76#define TDF_MEMSYMS (1 << 11) /* display memory symbols in expr.
0e0a19c5 77 Implies TDF_VOPS. */
7ee2468b 78
262149f5 79#define TDF_RHS_ONLY (1 << 12) /* a flag to only print the RHS of
7ee2468b 80 a gimple stmt. */
262149f5
ML
81#define TDF_ASMNAME (1 << 13) /* display asm names of decls */
82#define TDF_EH (1 << 14) /* display EH region number
7ee2468b 83 holding this gimple statement. */
262149f5
ML
84#define TDF_NOUID (1 << 15) /* omit UIDs from dumps. */
85#define TDF_ALIAS (1 << 16) /* display alias information */
86#define TDF_ENUMERATE_LOCALS (1 << 17) /* Enumerate locals by uid. */
87#define TDF_CSELIB (1 << 18) /* Dump cselib details. */
88#define TDF_SCEV (1 << 19) /* Dump SCEV details. */
89#define TDF_GIMPLE (1 << 20) /* Dump in GIMPLE FE syntax */
90#define TDF_FOLDING (1 << 21) /* Dump folding details. */
91#define MSG_OPTIMIZED_LOCATIONS (1 << 22) /* -fopt-info optimized sources */
92#define MSG_MISSED_OPTIMIZATION (1 << 23) /* missed opportunities */
93#define MSG_NOTE (1 << 24) /* general optimization info */
0e0a19c5
NS
94#define MSG_ALL (MSG_OPTIMIZED_LOCATIONS | MSG_MISSED_OPTIMIZATION \
95 | MSG_NOTE)
171a55e7 96#define TDF_COMPARE_DEBUG (1 << 25) /* Dumping for -fcompare-debug. */
7ee2468b 97
2b4e6bf1 98
1a817418
ML
99/* Value of TDF_NONE is used just for bits filtered by TDF_KIND_MASK. */
100
101#define TDF_NONE 0
102
2b4e6bf1
SS
103/* Flags to control high-level -fopt-info dumps. Usually these flags
104 define a group of passes. An optimization pass can be part of
105 multiple groups. */
0e0a19c5
NS
106#define OPTGROUP_NONE (0)
107#define OPTGROUP_IPA (1 << 1) /* IPA optimization passes */
108#define OPTGROUP_LOOP (1 << 2) /* Loop optimization passes */
109#define OPTGROUP_INLINE (1 << 3) /* Inlining passes */
110#define OPTGROUP_OMP (1 << 4) /* OMP (Offloading and Multi
fd2b8c8b 111 Processing) transformations */
0e0a19c5
NS
112#define OPTGROUP_VEC (1 << 5) /* Vectorization passes */
113#define OPTGROUP_OTHER (1 << 6) /* All other passes */
2b4e6bf1 114#define OPTGROUP_ALL (OPTGROUP_IPA | OPTGROUP_LOOP | OPTGROUP_INLINE \
0e0a19c5 115 | OPTGROUP_OMP | OPTGROUP_VEC | OPTGROUP_OTHER)
2b4e6bf1 116
1a817418
ML
117/* Dump flags type. */
118
119typedef uint64_t dump_flags_t;
120
78c60e3d
SS
121/* Define a tree dump switch. */
122struct dump_file_info
123{
8264c84d
ML
124 /* Suffix to give output file. */
125 const char *suffix;
126 /* Command line dump switch. */
127 const char *swtch;
128 /* Command line glob. */
129 const char *glob;
130 /* Filename for the pass-specific stream. */
131 const char *pfilename;
132 /* Filename for the -fopt-info stream. */
133 const char *alt_filename;
134 /* Pass-specific dump stream. */
135 FILE *pstream;
136 /* -fopt-info stream. */
137 FILE *alt_stream;
138 /* Dump kind. */
139 dump_kind dkind;
140 /* Dump flags. */
141 dump_flags_t pflags;
142 /* A pass flags for -fopt-info. */
143 int alt_flags;
144 /* Flags for -fopt-info given by a user. */
145 int optgroup_flags;
146 /* State of pass-specific stream. */
147 int pstate;
148 /* State of the -fopt-info stream. */
149 int alt_state;
150 /* Dump file number. */
151 int num;
152 /* Fields "suffix", "swtch", "glob" can be const strings,
153 or can be dynamically allocated, needing free. */
154 bool owns_strings;
155 /* When a given dump file is being initialized, this flag is set to true
156 if the corresponding TDF_graph dump file has also been initialized. */
157 bool graph_dump_initialized;
78c60e3d 158};
7ee2468b 159
78c60e3d 160/* In dumpfile.c */
1a817418 161extern FILE *dump_begin (int, dump_flags_t *);
7ee2468b 162extern void dump_end (int, FILE *);
78c60e3d 163extern int opt_info_switch_p (const char *);
7ee2468b 164extern const char *dump_flag_name (int);
1a817418
ML
165extern void dump_printf (dump_flags_t, const char *, ...) ATTRIBUTE_PRINTF_2;
166extern void dump_printf_loc (dump_flags_t, source_location,
167 const char *, ...) ATTRIBUTE_PRINTF_3;
c24e924f 168extern void dump_function (int phase, tree fn);
78c60e3d
SS
169extern void dump_basic_block (int, basic_block, int);
170extern void dump_generic_expr_loc (int, source_location, int, tree);
1a817418
ML
171extern void dump_generic_expr (dump_flags_t, dump_flags_t, tree);
172extern void dump_gimple_stmt_loc (dump_flags_t, source_location, dump_flags_t,
173 gimple *, int);
174extern void dump_gimple_stmt (dump_flags_t, dump_flags_t, gimple *, int);
78c60e3d 175extern void print_combine_total_stats (void);
78c60e3d
SS
176extern bool enable_rtl_dump_file (void);
177
dc3f3805
RS
178template<unsigned int N, typename C>
179void dump_dec (int, const poly_int<N, C> &);
180
7b3b6ae4 181/* In tree-dump.c */
1a817418 182extern void dump_node (const_tree, dump_flags_t, FILE *);
7b3b6ae4 183
78c60e3d
SS
184/* In combine.c */
185extern void dump_combine_total_stats (FILE *);
186/* In cfghooks.c */
1a817418 187extern void dump_bb (FILE *, basic_block, int, dump_flags_t);
7ee2468b
SB
188
189/* Global variables used to communicate with passes. */
190extern FILE *dump_file;
73fbfcad 191extern FILE *alt_dump_file;
1a817418 192extern dump_flags_t dump_flags;
7ee2468b
SB
193extern const char *dump_file_name;
194
2b4e6bf1 195/* Return true if any of the dumps is enabled, false otherwise. */
73fbfcad
SS
196static inline bool
197dump_enabled_p (void)
198{
199 return (dump_file || alt_dump_file);
200}
201
47e0da37
DM
202namespace gcc {
203
204class dump_manager
205{
206public:
207
208 dump_manager ();
10fdd6e9 209 ~dump_manager ();
47e0da37 210
10fdd6e9
DM
211 /* Register a dumpfile.
212
213 TAKE_OWNERSHIP determines whether callee takes ownership of strings
214 SUFFIX, SWTCH, and GLOB. */
47e0da37
DM
215 unsigned int
216 dump_register (const char *suffix, const char *swtch, const char *glob,
8264c84d 217 dump_kind dkind, int optgroup_flags, bool take_ownership);
47e0da37 218
363dc72c
JJ
219 /* Allow languages and middle-end to register their dumps before the
220 optimization passes. */
221 void
222 register_dumps ();
223
47e0da37
DM
224 /* Return the dump_file_info for the given phase. */
225 struct dump_file_info *
226 get_dump_file_info (int phase) const;
227
799505ae
DM
228 struct dump_file_info *
229 get_dump_file_info_by_switch (const char *swtch) const;
230
47e0da37
DM
231 /* Return the name of the dump file for the given phase.
232 If the dump is not enabled, returns NULL. */
233 char *
234 get_dump_file_name (int phase) const;
235
799505ae
DM
236 char *
237 get_dump_file_name (struct dump_file_info *dfi) const;
238
47e0da37
DM
239 int
240 dump_switch_p (const char *arg);
241
242 /* Start a dump for PHASE. Store user-supplied dump flags in
243 *FLAG_PTR. Return the number of streams opened. Set globals
244 DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
245 set dump_flags appropriately for both pass dump stream and
246 -fopt-info stream. */
247 int
1a817418 248 dump_start (int phase, dump_flags_t *flag_ptr);
47e0da37
DM
249
250 /* Finish a tree dump for PHASE and close associated dump streams. Also
251 reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
252 void
253 dump_finish (int phase);
254
255 FILE *
1a817418 256 dump_begin (int phase, dump_flags_t *flag_ptr);
47e0da37
DM
257
258 /* Returns nonzero if tree dump PHASE has been initialized. */
259 int
260 dump_initialized_p (int phase) const;
261
262 /* Returns the switch name of PHASE. */
263 const char *
264 dump_flag_name (int phase) const;
265
266private:
267
268 int
269 dump_phase_enabled_p (int phase) const;
270
271 int
272 dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob);
273
274 int
8264c84d 275 dump_enable_all (dump_kind dkind, dump_flags_t flags, const char *filename);
47e0da37
DM
276
277 int
1a817418
ML
278 opt_info_enable_passes (int optgroup_flags, dump_flags_t flags,
279 const char *filename);
47e0da37
DM
280
281private:
282
283 /* Dynamically registered dump files and switches. */
284 int m_next_dump;
285 struct dump_file_info *m_extra_dump_files;
286 size_t m_extra_dump_files_in_use;
287 size_t m_extra_dump_files_alloced;
288
289 /* Grant access to dump_enable_all. */
290 friend bool ::enable_rtl_dump_file (void);
291
292 /* Grant access to opt_info_enable_passes. */
293 friend int ::opt_info_switch_p (const char *arg);
294
295}; // class dump_manager
296
297} // namespace gcc
298
7ee2468b 299#endif /* GCC_DUMPFILE_H */