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