]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/dumpfile.h
* dumpfile.h (TDI_lang_all): New.
[thirdparty/gcc.git] / gcc / dumpfile.h
1 /* Definitions for the shared dumpfile.
2 Copyright (C) 2004-2017 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
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.
10
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.
15
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/>. */
19
20
21 #ifndef GCC_DUMPFILE_H
22 #define GCC_DUMPFILE_H 1
23
24
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
28 {
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_tu, /* dump the whole translation unit. */
34 TDI_class, /* dump class hierarchy. */
35 TDI_original, /* dump each function before optimizing it */
36 TDI_generic, /* dump each function after genericizing it */
37 TDI_nested, /* dump each function after unnesting it */
38
39 TDI_lang_all, /* enable all the language dumps. */
40 TDI_tree_all, /* enable all the GENERIC/GIMPLE dumps. */
41 TDI_rtl_all, /* enable all the RTL dumps. */
42 TDI_ipa_all, /* enable all the IPA dumps. */
43
44 TDI_end
45 };
46
47 /* Bit masks to control dumping. Not all values are applicable to all
48 dumps. Add new ones at the end. When you define new values, extend
49 the DUMP_OPTIONS array in dumpfile.c. The TDF_* flags coexist with
50 MSG_* flags (for -fopt-info) and the bit values must be chosen to
51 allow that. */
52 #define TDF_LANG 0 /* is a lang-specific dump. */
53 #define TDF_TREE 1 /* is a tree dump */
54 #define TDF_RTL 2 /* is a RTL dump */
55 #define TDF_IPA 3 /* is an IPA dump */
56 #define TDF_KIND_MASK 3
57 #define TDF_KIND(X) ((X) & TDF_KIND_MASK)
58
59 /* Bit 2 unused, available for hire. */
60 #define TDF_ADDRESS (1 << 3) /* dump node addresses */
61 #define TDF_SLIM (1 << 4) /* don't go wild following links */
62 #define TDF_RAW (1 << 5) /* don't unparse the function */
63 #define TDF_DETAILS (1 << 6) /* show more detailed info about
64 each pass */
65 #define TDF_STATS (1 << 7) /* dump various statistics about
66 each pass */
67 #define TDF_BLOCKS (1 << 8) /* display basic block boundaries */
68 #define TDF_VOPS (1 << 9) /* display virtual operands */
69 #define TDF_LINENO (1 << 10) /* display statement line numbers */
70 #define TDF_UID (1 << 11) /* display decl UIDs */
71
72 #define TDF_STMTADDR (1 << 12) /* Address of stmt. */
73
74 #define TDF_GRAPH (1 << 13) /* a graph dump is being emitted */
75 #define TDF_MEMSYMS (1 << 14) /* display memory symbols in expr.
76 Implies TDF_VOPS. */
77
78 #define TDF_DIAGNOSTIC (1 << 15) /* A dump to be put in a diagnostic
79 message. */
80 #define TDF_VERBOSE (1 << 16) /* A dump that uses the full tree
81 dumper to print stmts. */
82 #define TDF_RHS_ONLY (1 << 17) /* a flag to only print the RHS of
83 a gimple stmt. */
84 #define TDF_ASMNAME (1 << 18) /* display asm names of decls */
85 #define TDF_EH (1 << 19) /* display EH region number
86 holding this gimple statement. */
87 #define TDF_NOUID (1 << 20) /* omit UIDs from dumps. */
88 #define TDF_ALIAS (1 << 21) /* display alias information */
89 #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid. */
90 #define TDF_CSELIB (1 << 23) /* Dump cselib details. */
91 #define TDF_SCEV (1 << 24) /* Dump SCEV details. */
92 #define TDF_COMMENT (1 << 25) /* Dump lines with prefix ";;" */
93 #define TDF_GIMPLE (1 << 26) /* Dump in GIMPLE FE syntax */
94 #define MSG_OPTIMIZED_LOCATIONS (1 << 27) /* -fopt-info optimized sources */
95 #define MSG_MISSED_OPTIMIZATION (1 << 28) /* missed opportunities */
96 #define MSG_NOTE (1 << 29) /* general optimization info */
97 #define MSG_ALL (MSG_OPTIMIZED_LOCATIONS | MSG_MISSED_OPTIMIZATION \
98 | MSG_NOTE)
99
100
101 /* Flags to control high-level -fopt-info dumps. Usually these flags
102 define a group of passes. An optimization pass can be part of
103 multiple groups. */
104 #define OPTGROUP_NONE (0)
105 #define OPTGROUP_IPA (1 << 1) /* IPA optimization passes */
106 #define OPTGROUP_LOOP (1 << 2) /* Loop optimization passes */
107 #define OPTGROUP_INLINE (1 << 3) /* Inlining passes */
108 #define OPTGROUP_OMP (1 << 4) /* OMP (Offloading and Multi
109 Processing) transformations */
110 #define OPTGROUP_VEC (1 << 5) /* Vectorization passes */
111 #define OPTGROUP_OTHER (1 << 6) /* All other passes */
112 #define OPTGROUP_ALL (OPTGROUP_IPA | OPTGROUP_LOOP | OPTGROUP_INLINE \
113 | OPTGROUP_OMP | OPTGROUP_VEC | OPTGROUP_OTHER)
114
115 /* Define a tree dump switch. */
116 struct dump_file_info
117 {
118 const char *suffix; /* suffix to give output file. */
119 const char *swtch; /* command line dump switch */
120 const char *glob; /* command line glob */
121 const char *pfilename; /* filename for the pass-specific stream */
122 const char *alt_filename; /* filename for the -fopt-info stream */
123 FILE *pstream; /* pass-specific dump stream */
124 FILE *alt_stream; /* -fopt-info stream */
125 int pflags; /* dump flags */
126 int optgroup_flags; /* optgroup flags for -fopt-info */
127 int alt_flags; /* flags for opt-info */
128 int pstate; /* state of pass-specific stream */
129 int alt_state; /* state of the -fopt-info stream */
130 int num; /* dump file number */
131 bool owns_strings; /* fields "suffix", "swtch", "glob" can be
132 const strings, or can be dynamically
133 allocated, needing free. */
134 bool graph_dump_initialized; /* When a given dump file is being
135 initialized, this flag is set to
136 true if the corresponding TDF_graph
137 dump file has also been
138 initialized. */
139 };
140
141 /* In dumpfile.c */
142 extern FILE *dump_begin (int, int *);
143 extern void dump_end (int, FILE *);
144 extern int opt_info_switch_p (const char *);
145 extern const char *dump_flag_name (int);
146 extern void dump_printf (int, const char *, ...) ATTRIBUTE_PRINTF_2;
147 extern void dump_printf_loc (int, source_location,
148 const char *, ...) ATTRIBUTE_PRINTF_3;
149 extern void dump_basic_block (int, basic_block, int);
150 extern void dump_generic_expr_loc (int, source_location, int, tree);
151 extern void dump_generic_expr (int, int, tree);
152 extern void dump_gimple_stmt_loc (int, source_location, int, gimple *, int);
153 extern void dump_gimple_stmt (int, int, gimple *, int);
154 extern void print_combine_total_stats (void);
155 extern bool enable_rtl_dump_file (void);
156
157 /* In tree-dump.c */
158 extern void dump_node (const_tree, int, FILE *);
159
160 /* In combine.c */
161 extern void dump_combine_total_stats (FILE *);
162 /* In cfghooks.c */
163 extern void dump_bb (FILE *, basic_block, int, int);
164
165 /* Global variables used to communicate with passes. */
166 extern FILE *dump_file;
167 extern FILE *alt_dump_file;
168 extern int dump_flags;
169 extern const char *dump_file_name;
170
171 /* Return true if any of the dumps is enabled, false otherwise. */
172 static inline bool
173 dump_enabled_p (void)
174 {
175 return (dump_file || alt_dump_file);
176 }
177
178 namespace gcc {
179
180 class dump_manager
181 {
182 public:
183
184 dump_manager ();
185 ~dump_manager ();
186
187 /* Register a dumpfile.
188
189 TAKE_OWNERSHIP determines whether callee takes ownership of strings
190 SUFFIX, SWTCH, and GLOB. */
191 unsigned int
192 dump_register (const char *suffix, const char *swtch, const char *glob,
193 int flags, int optgroup_flags,
194 bool take_ownership);
195
196 /* Return the dump_file_info for the given phase. */
197 struct dump_file_info *
198 get_dump_file_info (int phase) const;
199
200 struct dump_file_info *
201 get_dump_file_info_by_switch (const char *swtch) const;
202
203 /* Return the name of the dump file for the given phase.
204 If the dump is not enabled, returns NULL. */
205 char *
206 get_dump_file_name (int phase) const;
207
208 char *
209 get_dump_file_name (struct dump_file_info *dfi) const;
210
211 int
212 dump_switch_p (const char *arg);
213
214 /* Start a dump for PHASE. Store user-supplied dump flags in
215 *FLAG_PTR. Return the number of streams opened. Set globals
216 DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
217 set dump_flags appropriately for both pass dump stream and
218 -fopt-info stream. */
219 int
220 dump_start (int phase, int *flag_ptr);
221
222 /* Finish a tree dump for PHASE and close associated dump streams. Also
223 reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
224 void
225 dump_finish (int phase);
226
227 FILE *
228 dump_begin (int phase, int *flag_ptr);
229
230 /* Returns nonzero if tree dump PHASE has been initialized. */
231 int
232 dump_initialized_p (int phase) const;
233
234 /* Returns the switch name of PHASE. */
235 const char *
236 dump_flag_name (int phase) const;
237
238 private:
239
240 int
241 dump_phase_enabled_p (int phase) const;
242
243 int
244 dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob);
245
246 int
247 dump_enable_all (int flags, const char *filename);
248
249 int
250 opt_info_enable_passes (int optgroup_flags, int flags, const char *filename);
251
252 private:
253
254 /* Dynamically registered dump files and switches. */
255 int m_next_dump;
256 struct dump_file_info *m_extra_dump_files;
257 size_t m_extra_dump_files_in_use;
258 size_t m_extra_dump_files_alloced;
259
260 /* Grant access to dump_enable_all. */
261 friend bool ::enable_rtl_dump_file (void);
262
263 /* Grant access to opt_info_enable_passes. */
264 friend int ::opt_info_switch_p (const char *arg);
265
266 }; // class dump_manager
267
268 } // namespace gcc
269
270 #endif /* GCC_DUMPFILE_H */