GCC Middle and Back End API Reference
dumpfile.h
Go to the documentation of this file.
1 /* Definitions for the shared dumpfile.
2  Copyright (C) 2004-2013 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 #include "line-map.h"
25 
26 /* Different tree dump places. When you add new tree dump places,
27  extend the DUMP_FILES array in dumpfile.c. */
28 enum tree_dump_index
29 {
30  TDI_none, /* No dump */
31  TDI_cgraph, /* dump function call graph. */
32  TDI_inheritance, /* dump type inheritance graph. */
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  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. */
41 
43 };
44 
45 /* Bit masks to control dumping. Not all values are applicable to all
46  dumps. Add new ones at the end. When you define new values, extend
47  the DUMP_OPTIONS array in dumpfile.c. The TDF_* flags coexist with
48  MSG_* flags (for -fopt-info) and the bit values must be chosen to
49  allow that. */
50 #define TDF_ADDRESS (1 << 0) /* dump node addresses */
51 #define TDF_SLIM (1 << 1) /* don't go wild following links */
52 #define TDF_RAW (1 << 2) /* don't unparse the function */
53 #define TDF_DETAILS (1 << 3) /* show more detailed info about
54  each pass */
55 #define TDF_STATS (1 << 4) /* dump various statistics about
56  each pass */
57 #define TDF_BLOCKS (1 << 5) /* display basic block boundaries */
58 #define TDF_VOPS (1 << 6) /* display virtual operands */
59 #define TDF_LINENO (1 << 7) /* display statement line numbers */
60 #define TDF_UID (1 << 8) /* display decl UIDs */
61 
62 #define TDF_TREE (1 << 9) /* is a tree dump */
63 #define TDF_RTL (1 << 10) /* is a RTL dump */
64 #define TDF_IPA (1 << 11) /* is an IPA dump */
65 #define TDF_STMTADDR (1 << 12) /* Address of stmt. */
66 
67 #define TDF_GRAPH (1 << 13) /* a graph dump is being emitted */
68 #define TDF_MEMSYMS (1 << 14) /* display memory symbols in expr.
69  Implies TDF_VOPS. */
70 
71 #define TDF_DIAGNOSTIC (1 << 15) /* A dump to be put in a diagnostic
72  message. */
73 #define TDF_VERBOSE (1 << 16) /* A dump that uses the full tree
74  dumper to print stmts. */
75 #define TDF_RHS_ONLY (1 << 17) /* a flag to only print the RHS of
76  a gimple stmt. */
77 #define TDF_ASMNAME (1 << 18) /* display asm names of decls */
78 #define TDF_EH (1 << 19) /* display EH region number
79  holding this gimple statement. */
80 #define TDF_NOUID (1 << 20) /* omit UIDs from dumps. */
81 #define TDF_ALIAS (1 << 21) /* display alias information */
82 #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid. */
83 #define TDF_CSELIB (1 << 23) /* Dump cselib details. */
84 #define TDF_SCEV (1 << 24) /* Dump SCEV details. */
85 #define TDF_COMMENT (1 << 25) /* Dump lines with prefix ";;" */
86 #define MSG_OPTIMIZED_LOCATIONS (1 << 26) /* -fopt-info optimized sources */
87 #define MSG_MISSED_OPTIMIZATION (1 << 27) /* missed opportunities */
88 #define MSG_NOTE (1 << 28) /* general optimization info */
89 #define MSG_ALL (MSG_OPTIMIZED_LOCATIONS | MSG_MISSED_OPTIMIZATION \
90  | MSG_NOTE)
91 
92 
93 /* Flags to control high-level -fopt-info dumps. Usually these flags
94  define a group of passes. An optimization pass can be part of
95  multiple groups. */
96 #define OPTGROUP_NONE (0)
97 #define OPTGROUP_IPA (1 << 1) /* IPA optimization passes */
98 #define OPTGROUP_LOOP (1 << 2) /* Loop optimization passes */
99 #define OPTGROUP_INLINE (1 << 3) /* Inlining passes */
100 #define OPTGROUP_VEC (1 << 4) /* Vectorization passes */
101 #define OPTGROUP_OTHER (1 << 5) /* All other passes */
102 #define OPTGROUP_ALL (OPTGROUP_IPA | OPTGROUP_LOOP | OPTGROUP_INLINE \
103  | OPTGROUP_VEC | OPTGROUP_OTHER)
104 
105 /* Define a tree dump switch. */
106 struct dump_file_info
107 {
108  const char *suffix; /* suffix to give output file. */
109  const char *swtch; /* command line dump switch */
110  const char *glob; /* command line glob */
111  const char *pfilename; /* filename for the pass-specific stream */
112  const char *alt_filename; /* filename for the -fopt-info stream */
113  FILE *pstream; /* pass-specific dump stream */
114  FILE *alt_stream; /* -fopt-info stream */
115  int pflags; /* dump flags */
116  int optgroup_flags; /* optgroup flags for -fopt-info */
117  int alt_flags; /* flags for opt-info */
118  int pstate; /* state of pass-specific stream */
119  int alt_state; /* state of the -fopt-info stream */
120  int num; /* dump file number */
121 };
123 /* In dumpfile.c */
124 extern FILE *dump_begin (int, int *);
125 extern void dump_end (int, FILE *);
126 extern int opt_info_switch_p (const char *);
127 extern const char *dump_flag_name (int);
128 extern void dump_printf (int, const char *, ...) ATTRIBUTE_PRINTF_2;
129 extern void dump_printf_loc (int, source_location,
130  const char *, ...) ATTRIBUTE_PRINTF_3;
131 extern void dump_basic_block (int, basic_block, int);
132 extern void dump_generic_expr_loc (int, source_location, int, tree);
133 extern void dump_generic_expr (int, int, tree);
134 extern void dump_gimple_stmt_loc (int, source_location, int, gimple, int);
135 extern void dump_gimple_stmt (int, int, gimple, int);
136 extern void print_combine_total_stats (void);
137 extern bool enable_rtl_dump_file (void);
138 
139 /* In tree-dump.c */
140 extern void dump_node (const_tree, int, FILE *);
141 
142 /* In combine.c */
143 extern void dump_combine_total_stats (FILE *);
144 /* In cfghooks.c */
145 extern void dump_bb (FILE *, basic_block, int, int);
146 
147 /* Global variables used to communicate with passes. */
148 extern FILE *dump_file;
149 extern FILE *alt_dump_file;
150 extern int dump_flags;
151 extern const char *dump_file_name;
152 
153 /* Return true if any of the dumps is enabled, false otherwise. */
154 static inline bool
155 dump_enabled_p (void)
156 {
157  return (dump_file || alt_dump_file);
158 }
159 
160 namespace gcc {
161 
162 class dump_manager
163 {
164 public:
165 
167 
168  unsigned int
169  dump_register (const char *suffix, const char *swtch, const char *glob,
170  int flags, int optgroup_flags);
171 
172  /* Return the dump_file_info for the given phase. */
173  struct dump_file_info *
174  get_dump_file_info (int phase) const;
175 
176  /* Return the name of the dump file for the given phase.
177  If the dump is not enabled, returns NULL. */
178  char *
179  get_dump_file_name (int phase) const;
180 
181  int
182  dump_switch_p (const char *arg);
183 
184  /* Start a dump for PHASE. Store user-supplied dump flags in
185  *FLAG_PTR. Return the number of streams opened. Set globals
186  DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
187  set dump_flags appropriately for both pass dump stream and
188  -fopt-info stream. */
189  int
190  dump_start (int phase, int *flag_ptr);
191 
192  /* Finish a tree dump for PHASE and close associated dump streams. Also
193  reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
194  void
195  dump_finish (int phase);
196 
197  FILE *
198  dump_begin (int phase, int *flag_ptr);
199 
200  /* Returns nonzero if tree dump PHASE has been initialized. */
201  int
202  dump_initialized_p (int phase) const;
203 
204  /* Returns the switch name of PHASE. */
205  const char *
206  dump_flag_name (int phase) const;
207 
208 private:
209 
210  int
211  dump_phase_enabled_p (int phase) const;
212 
213  int
214  dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob);
215 
216  int
217  dump_enable_all (int flags, const char *filename);
218 
219  int
220  opt_info_enable_passes (int optgroup_flags, int flags, const char *filename);
221 
222 private:
223 
224  /* Dynamically registered dump files and switches. */
225  int m_next_dump;
229 
230  /* Grant access to dump_enable_all. */
231  friend bool ::enable_rtl_dump_file (void);
232 
233  /* Grant access to opt_info_enable_passes. */
234  friend int ::opt_info_switch_p (const char *arg);
235 
236 }; // class dump_manager
237 
238 } // namespace gcc
239 
240 #endif /* GCC_DUMPFILE_H */