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