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