dumpfile.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. /* Definitions for the shared dumpfile.
  2. Copyright (C) 2004-2019 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3, or (at your option)
  7. any later version.
  8. GCC is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef GCC_DUMPFILE_H
  16. #define GCC_DUMPFILE_H 1
  17. #include "profile-count.h"
  18. /* An attribute for annotating formatting printing functions that use
  19. the dumpfile/optinfo formatting codes. These are the pretty_printer
  20. format codes (see pretty-print.c), with additional codes for middle-end
  21. specific entities (see dumpfile.c). */
  22. #if GCC_VERSION >= 9000
  23. #define ATTRIBUTE_GCC_DUMP_PRINTF(m, n) \
  24. __attribute__ ((__format__ (__gcc_dump_printf__, m ,n))) \
  25. ATTRIBUTE_NONNULL(m)
  26. #else
  27. #define ATTRIBUTE_GCC_DUMP_PRINTF(m, n) ATTRIBUTE_NONNULL(m)
  28. #endif
  29. /* Different tree dump places. When you add new tree dump places,
  30. extend the DUMP_FILES array in dumpfile.c. */
  31. enum tree_dump_index
  32. {
  33. TDI_none, /* No dump */
  34. TDI_cgraph, /* dump function call graph. */
  35. TDI_inheritance, /* dump type inheritance graph. */
  36. TDI_clones, /* dump IPA cloning decisions. */
  37. TDI_original, /* dump each function before optimizing it */
  38. TDI_gimple, /* dump each function after gimplifying it */
  39. TDI_nested, /* dump each function after unnesting it */
  40. TDI_lto_stream_out, /* dump information about lto streaming */
  41. TDI_lang_all, /* enable all the language dumps. */
  42. TDI_tree_all, /* enable all the GENERIC/GIMPLE dumps. */
  43. TDI_rtl_all, /* enable all the RTL dumps. */
  44. TDI_ipa_all, /* enable all the IPA dumps. */
  45. TDI_end
  46. };
  47. /* Enum used to distinguish dump files to types. */
  48. enum dump_kind
  49. {
  50. DK_none,
  51. DK_lang,
  52. DK_tree,
  53. DK_rtl,
  54. DK_ipa
  55. };
  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
  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. */
  61. enum dump_flag
  62. {
  63. /* Value of TDF_NONE is used just for bits filtered by TDF_KIND_MASK. */
  64. TDF_NONE = 0,
  65. /* Dump node addresses. */
  66. TDF_ADDRESS = (1 << 0),
  67. /* Don't go wild following links. */
  68. TDF_SLIM = (1 << 1),
  69. /* Don't unparse the function. */
  70. TDF_RAW = (1 << 2),
  71. /* Show more detailed info about each pass. */
  72. TDF_DETAILS = (1 << 3),
  73. /* Dump various statistics about each pass. */
  74. TDF_STATS = (1 << 4),
  75. /* Display basic block boundaries. */
  76. TDF_BLOCKS = (1 << 5),
  77. /* Display virtual operands. */
  78. TDF_VOPS = (1 << 6),
  79. /* Display statement line numbers. */
  80. TDF_LINENO = (1 << 7),
  81. /* Display decl UIDs. */
  82. TDF_UID = (1 << 8),
  83. /* Address of stmt. */
  84. TDF_STMTADDR = (1 << 9),
  85. /* A graph dump is being emitted. */
  86. TDF_GRAPH = (1 << 10),
  87. /* Display memory symbols in expr.
  88. Implies TDF_VOPS. */
  89. TDF_MEMSYMS = (1 << 11),
  90. /* A flag to only print the RHS of a gimple stmt. */
  91. TDF_RHS_ONLY = (1 << 12),
  92. /* Display asm names of decls. */
  93. TDF_ASMNAME = (1 << 13),
  94. /* Display EH region number holding this gimple statement. */
  95. TDF_EH = (1 << 14),
  96. /* Omit UIDs from dumps. */
  97. TDF_NOUID = (1 << 15),
  98. /* Display alias information. */
  99. TDF_ALIAS = (1 << 16),
  100. /* Enumerate locals by uid. */
  101. TDF_ENUMERATE_LOCALS = (1 << 17),
  102. /* Dump cselib details. */
  103. TDF_CSELIB = (1 << 18),
  104. /* Dump SCEV details. */
  105. TDF_SCEV = (1 << 19),
  106. /* Dump in GIMPLE FE syntax */
  107. TDF_GIMPLE = (1 << 20),
  108. /* Dump folding details. */
  109. TDF_FOLDING = (1 << 21),
  110. /* MSG_* flags for expressing the kinds of message to
  111. be emitted by -fopt-info. */
  112. /* -fopt-info optimized sources. */
  113. MSG_OPTIMIZED_LOCATIONS = (1 << 22),
  114. /* Missed opportunities. */
  115. MSG_MISSED_OPTIMIZATION = (1 << 23),
  116. /* General optimization info. */
  117. MSG_NOTE = (1 << 24),
  118. /* Mask for selecting MSG_-kind flags. */
  119. MSG_ALL_KINDS = (MSG_OPTIMIZED_LOCATIONS
  120. | MSG_MISSED_OPTIMIZATION
  121. | MSG_NOTE),
  122. /* MSG_PRIORITY_* flags for expressing the priority levels of message
  123. to be emitted by -fopt-info, and filtering on them.
  124. By default, messages at the top-level dump scope are "user-facing",
  125. whereas those that are in nested scopes are implicitly "internals".
  126. This behavior can be overridden for a given dump message by explicitly
  127. specifying one of the MSG_PRIORITY_* flags.
  128. By default, dump files show both kinds of message, whereas -fopt-info
  129. only shows "user-facing" messages, and requires the "-internals"
  130. sub-option of -fopt-info to show the internal messages. */
  131. /* Implicitly supplied for messages at the top-level dump scope. */
  132. MSG_PRIORITY_USER_FACING = (1 << 25),
  133. /* Implicitly supplied for messages within nested dump scopes. */
  134. MSG_PRIORITY_INTERNALS = (1 << 26),
  135. /* Supplied when an opt_problem generated in a nested scope is re-emitted
  136. at the top-level. We want to default to showing these in -fopt-info
  137. output, but to *not* show them in dump files, as the message would be
  138. shown twice, messing up "scan-tree-dump-times" in DejaGnu tests. */
  139. MSG_PRIORITY_REEMITTED = (1 << 27),
  140. /* Mask for selecting MSG_PRIORITY_* flags. */
  141. MSG_ALL_PRIORITIES = (MSG_PRIORITY_USER_FACING
  142. | MSG_PRIORITY_INTERNALS
  143. | MSG_PRIORITY_REEMITTED),
  144. /* Dumping for -fcompare-debug. */
  145. TDF_COMPARE_DEBUG = (1 << 28),
  146. /* All values. */
  147. TDF_ALL_VALUES = (1 << 29) - 1
  148. };
  149. /* Dump flags type. */
  150. typedef enum dump_flag dump_flags_t;
  151. static inline dump_flags_t
  152. operator| (dump_flags_t lhs, dump_flags_t rhs)
  153. {
  154. return (dump_flags_t)((int)lhs | (int)rhs);
  155. }
  156. static inline dump_flags_t
  157. operator& (dump_flags_t lhs, dump_flags_t rhs)
  158. {
  159. return (dump_flags_t)((int)lhs & (int)rhs);
  160. }
  161. static inline dump_flags_t
  162. operator~ (dump_flags_t flags)
  163. {
  164. return (dump_flags_t)~((int)flags);
  165. }
  166. static inline dump_flags_t &
  167. operator|= (dump_flags_t &lhs, dump_flags_t rhs)
  168. {
  169. lhs = (dump_flags_t)((int)lhs | (int)rhs);
  170. return lhs;
  171. }
  172. static inline dump_flags_t &
  173. operator&= (dump_flags_t &lhs, dump_flags_t rhs)
  174. {
  175. lhs = (dump_flags_t)((int)lhs & (int)rhs);
  176. return lhs;
  177. }
  178. /* Flags to control high-level -fopt-info dumps. Usually these flags
  179. define a group of passes. An optimization pass can be part of
  180. multiple groups. */
  181. enum optgroup_flag
  182. {
  183. OPTGROUP_NONE = 0,
  184. /* IPA optimization passes */
  185. OPTGROUP_IPA = (1 << 1),
  186. /* Loop optimization passes */
  187. OPTGROUP_LOOP = (1 << 2),
  188. /* Inlining passes */
  189. OPTGROUP_INLINE = (1 << 3),
  190. /* OMP (Offloading and Multi Processing) transformations */
  191. OPTGROUP_OMP = (1 << 4),
  192. /* Vectorization passes */
  193. OPTGROUP_VEC = (1 << 5),
  194. /* All other passes */
  195. OPTGROUP_OTHER = (1 << 6),
  196. OPTGROUP_ALL = (OPTGROUP_IPA | OPTGROUP_LOOP | OPTGROUP_INLINE
  197. | OPTGROUP_OMP | OPTGROUP_VEC | OPTGROUP_OTHER)
  198. };
  199. typedef enum optgroup_flag optgroup_flags_t;
  200. static inline optgroup_flags_t
  201. operator| (optgroup_flags_t lhs, optgroup_flags_t rhs)
  202. {
  203. return (optgroup_flags_t)((int)lhs | (int)rhs);
  204. }
  205. static inline optgroup_flags_t &
  206. operator|= (optgroup_flags_t &lhs, optgroup_flags_t rhs)
  207. {
  208. lhs = (optgroup_flags_t)((int)lhs | (int)rhs);
  209. return lhs;
  210. }
  211. /* Define a tree dump switch. */
  212. struct dump_file_info
  213. {
  214. /* Suffix to give output file. */
  215. const char *suffix;
  216. /* Command line dump switch. */
  217. const char *swtch;
  218. /* Command line glob. */
  219. const char *glob;
  220. /* Filename for the pass-specific stream. */
  221. const char *pfilename;
  222. /* Filename for the -fopt-info stream. */
  223. const char *alt_filename;
  224. /* Pass-specific dump stream. */
  225. FILE *pstream;
  226. /* -fopt-info stream. */
  227. FILE *alt_stream;
  228. /* Dump kind. */
  229. dump_kind dkind;
  230. /* Dump flags. */
  231. dump_flags_t pflags;
  232. /* A pass flags for -fopt-info. */
  233. dump_flags_t alt_flags;
  234. /* Flags for -fopt-info given by a user. */
  235. optgroup_flags_t optgroup_flags;
  236. /* State of pass-specific stream. */
  237. int pstate;
  238. /* State of the -fopt-info stream. */
  239. int alt_state;
  240. /* Dump file number. */
  241. int num;
  242. /* Fields "suffix", "swtch", "glob" can be const strings,
  243. or can be dynamically allocated, needing free. */
  244. bool owns_strings;
  245. /* When a given dump file is being initialized, this flag is set to true
  246. if the corresponding TDF_graph dump file has also been initialized. */
  247. bool graph_dump_initialized;
  248. };
  249. /* A class for describing where in the user's source that a dump message
  250. relates to, with various constructors for convenience.
  251. In particular, this lets us associate dump messages
  252. with hotness information (e.g. from PGO), allowing them to
  253. be prioritized by code hotness. */
  254. class dump_user_location_t
  255. {
  256. public:
  257. /* Default constructor, analogous to UNKNOWN_LOCATION. */
  258. dump_user_location_t () : m_count (), m_loc (UNKNOWN_LOCATION) {}
  259. /* Construct from a gimple statement (using its location and hotness). */
  260. dump_user_location_t (const gimple *stmt);
  261. /* Construct from an RTL instruction (using its location and hotness). */
  262. dump_user_location_t (const rtx_insn *insn);
  263. /* Construct from a location_t. This one is deprecated (since it doesn't
  264. capture hotness information); it thus needs to be spelled out. */
  265. static dump_user_location_t
  266. from_location_t (location_t loc)
  267. {
  268. return dump_user_location_t (profile_count (), loc);
  269. }
  270. /* Construct from a function declaration. This one requires spelling out
  271. to avoid accidentally constructing from other kinds of tree. */
  272. static dump_user_location_t
  273. from_function_decl (tree fndecl);
  274. profile_count get_count () const { return m_count; }
  275. location_t get_location_t () const { return m_loc; }
  276. private:
  277. /* Private ctor from count and location, for use by from_location_t. */
  278. dump_user_location_t (profile_count count, location_t loc)
  279. : m_count (count), m_loc (loc)
  280. {}
  281. profile_count m_count;
  282. location_t m_loc;
  283. };
  284. /* A class for identifying where in the compiler's own source
  285. (or a plugin) that a dump message is being emitted from. */
  286. struct dump_impl_location_t
  287. {
  288. dump_impl_location_t (
  289. #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
  290. const char *file = __builtin_FILE (),
  291. int line = __builtin_LINE (),
  292. const char *function = __builtin_FUNCTION ()
  293. #else
  294. const char *file = __FILE__,
  295. int line = __LINE__,
  296. const char *function = NULL
  297. #endif
  298. )
  299. : m_file (file), m_line (line), m_function (function)
  300. {}
  301. const char *m_file;
  302. int m_line;
  303. const char *m_function;
  304. };
  305. /* A bundle of metadata for describing a dump message:
  306. (a) the dump_flags
  307. (b) the source location within the compiler/plugin.
  308. The constructors use default parameters so that (b) gets sets up
  309. automatically.
  310. Hence you can pass in e.g. MSG_NOTE, and the dump call
  311. will automatically record where in GCC's source code the
  312. dump was emitted from. */
  313. class dump_metadata_t
  314. {
  315. public:
  316. dump_metadata_t (dump_flags_t dump_flags,
  317. const dump_impl_location_t &impl_location
  318. = dump_impl_location_t ())
  319. : m_dump_flags (dump_flags),
  320. m_impl_location (impl_location)
  321. {
  322. }
  323. dump_flags_t get_dump_flags () const { return m_dump_flags; }
  324. const dump_impl_location_t &
  325. get_impl_location () const { return m_impl_location; }
  326. private:
  327. dump_flags_t m_dump_flags;
  328. dump_impl_location_t m_impl_location;
  329. };
  330. /* A bundle of information for describing the location of a dump message:
  331. (a) the source location and hotness within the user's code, together with
  332. (b) the source location within the compiler/plugin.
  333. The constructors use default parameters so that (b) gets sets up
  334. automatically.
  335. The upshot is that you can pass in e.g. a gimple * to dump_printf_loc,
  336. and the dump call will automatically record where in GCC's source
  337. code the dump was emitted from. */
  338. class dump_location_t
  339. {
  340. public:
  341. /* Default constructor, analogous to UNKNOWN_LOCATION. */
  342. dump_location_t (const dump_impl_location_t &impl_location
  343. = dump_impl_location_t ())
  344. : m_user_location (dump_user_location_t ()),
  345. m_impl_location (impl_location)
  346. {
  347. }
  348. /* Construct from a gimple statement (using its location and hotness). */
  349. dump_location_t (const gimple *stmt,
  350. const dump_impl_location_t &impl_location
  351. = dump_impl_location_t ())
  352. : m_user_location (dump_user_location_t (stmt)),
  353. m_impl_location (impl_location)
  354. {
  355. }
  356. /* Construct from an RTL instruction (using its location and hotness). */
  357. dump_location_t (const rtx_insn *insn,
  358. const dump_impl_location_t &impl_location
  359. = dump_impl_location_t ())
  360. : m_user_location (dump_user_location_t (insn)),
  361. m_impl_location (impl_location)
  362. {
  363. }
  364. /* Construct from a dump_user_location_t. */
  365. dump_location_t (const dump_user_location_t &user_location,
  366. const dump_impl_location_t &impl_location
  367. = dump_impl_location_t ())
  368. : m_user_location (user_location),
  369. m_impl_location (impl_location)
  370. {
  371. }
  372. /* Construct from a location_t. This one is deprecated (since it doesn't
  373. capture hotness information), and thus requires spelling out. */
  374. static dump_location_t
  375. from_location_t (location_t loc,
  376. const dump_impl_location_t &impl_location
  377. = dump_impl_location_t ())
  378. {
  379. return dump_location_t (dump_user_location_t::from_location_t (loc),
  380. impl_location);
  381. }
  382. const dump_user_location_t &
  383. get_user_location () const { return m_user_location; }
  384. const dump_impl_location_t &
  385. get_impl_location () const { return m_impl_location; }
  386. location_t get_location_t () const
  387. {
  388. return m_user_location.get_location_t ();
  389. }
  390. profile_count get_count () const { return m_user_location.get_count (); }
  391. private:
  392. dump_user_location_t m_user_location;
  393. dump_impl_location_t m_impl_location;
  394. };
  395. /* In dumpfile.c */
  396. extern FILE *dump_begin (int, dump_flags_t *, int part=-1);
  397. extern void dump_end (int, FILE *);
  398. extern int opt_info_switch_p (const char *);
  399. extern const char *dump_flag_name (int);
  400. extern const kv_pair<optgroup_flags_t> optgroup_options[];
  401. /* Global variables used to communicate with passes. */
  402. extern FILE *dump_file;
  403. extern dump_flags_t dump_flags;
  404. extern const char *dump_file_name;
  405. extern bool dumps_are_enabled;
  406. extern void set_dump_file (FILE *new_dump_file);
  407. /* Return true if any of the dumps is enabled, false otherwise. */
  408. static inline bool
  409. dump_enabled_p (void)
  410. {
  411. return dumps_are_enabled;
  412. }
  413. /* The following API calls (which *don't* take a "FILE *")
  414. write the output to zero or more locations.
  415. Some destinations are written to immediately as dump_* calls
  416. are made; for others, the output is consolidated into an "optinfo"
  417. instance (with its own metadata), and only emitted once the optinfo
  418. is complete.
  419. The destinations are:
  420. (a) the "immediate" destinations:
  421. (a.1) the active dump_file, if any
  422. (a.2) the -fopt-info destination, if any
  423. (b) the "optinfo" destinations, if any:
  424. (b.1) as optimization records
  425. dump_* (MSG_*) --> dumpfile.c --> items --> (a.1) dump_file
  426. | `-> (a.2) alt_dump_file
  427. |
  428. `--> (b) optinfo
  429. `---> optinfo destinations
  430. (b.1) optimization records
  431. For optinfos, the dump_*_loc mark the beginning of an optinfo
  432. instance: all subsequent dump_* calls are consolidated into
  433. that optinfo, until the next dump_*_loc call (or a change in
  434. dump scope, or a call to dumpfile_ensure_any_optinfo_are_flushed).
  435. A group of dump_* calls should be guarded by:
  436. if (dump_enabled_p ())
  437. to minimize the work done for the common case where dumps
  438. are disabled. */
  439. extern void dump_printf (const dump_metadata_t &, const char *, ...)
  440. ATTRIBUTE_GCC_DUMP_PRINTF (2, 3);
  441. extern void dump_printf_loc (const dump_metadata_t &, const dump_user_location_t &,
  442. const char *, ...)
  443. ATTRIBUTE_GCC_DUMP_PRINTF (3, 0);
  444. extern void dump_function (int phase, tree fn);
  445. extern void dump_basic_block (dump_flags_t, basic_block, int);
  446. extern void dump_generic_expr_loc (const dump_metadata_t &,
  447. const dump_user_location_t &,
  448. dump_flags_t, tree);
  449. extern void dump_generic_expr (const dump_metadata_t &, dump_flags_t, tree);
  450. extern void dump_gimple_stmt_loc (const dump_metadata_t &,
  451. const dump_user_location_t &,
  452. dump_flags_t, gimple *, int);
  453. extern void dump_gimple_stmt (const dump_metadata_t &, dump_flags_t, gimple *, int);
  454. extern void dump_gimple_expr_loc (const dump_metadata_t &,
  455. const dump_user_location_t &,
  456. dump_flags_t, gimple *, int);
  457. extern void dump_gimple_expr (const dump_metadata_t &, dump_flags_t, gimple *, int);
  458. extern void dump_symtab_node (const dump_metadata_t &, symtab_node *);
  459. template<unsigned int N, typename C>
  460. void dump_dec (const dump_metadata_t &, const poly_int<N, C> &);
  461. extern void dump_dec (dump_flags_t, const poly_wide_int &, signop);
  462. extern void dump_hex (dump_flags_t, const poly_wide_int &);
  463. extern void dumpfile_ensure_any_optinfo_are_flushed ();
  464. /* Managing nested scopes, so that dumps can express the call chain
  465. leading to a dump message. */
  466. extern unsigned int get_dump_scope_depth ();
  467. extern void dump_begin_scope (const char *name,
  468. const dump_user_location_t &user_location,
  469. const dump_impl_location_t &impl_location);
  470. extern void dump_end_scope ();
  471. /* Implementation detail of the AUTO_DUMP_SCOPE macro below.
  472. A RAII-style class intended to make it easy to emit dump
  473. information about entering and exiting a collection of nested
  474. function calls. */
  475. class auto_dump_scope
  476. {
  477. public:
  478. auto_dump_scope (const char *name,
  479. const dump_user_location_t &user_location,
  480. const dump_impl_location_t &impl_location
  481. = dump_impl_location_t ())
  482. {
  483. if (dump_enabled_p ())
  484. dump_begin_scope (name, user_location, impl_location);
  485. }
  486. ~auto_dump_scope ()
  487. {
  488. if (dump_enabled_p ())
  489. dump_end_scope ();
  490. }
  491. };
  492. /* A macro for calling:
  493. dump_begin_scope (NAME, USER_LOC);
  494. via an RAII object, thus printing "=== MSG ===\n" to the dumpfile etc,
  495. and then calling
  496. dump_end_scope ();
  497. once the object goes out of scope, thus capturing the nesting of
  498. the scopes.
  499. These scopes affect dump messages within them: dump messages at the
  500. top level implicitly default to MSG_PRIORITY_USER_FACING, whereas those
  501. in a nested scope implicitly default to MSG_PRIORITY_INTERNALS. */
  502. #define AUTO_DUMP_SCOPE(NAME, USER_LOC) \
  503. auto_dump_scope scope (NAME, USER_LOC)
  504. extern void dump_function (int phase, tree fn);
  505. extern void print_combine_total_stats (void);
  506. extern bool enable_rtl_dump_file (void);
  507. /* In tree-dump.c */
  508. extern void dump_node (const_tree, dump_flags_t, FILE *);
  509. /* In combine.c */
  510. extern void dump_combine_total_stats (FILE *);
  511. /* In cfghooks.c */
  512. extern void dump_bb (FILE *, basic_block, int, dump_flags_t);
  513. struct opt_pass;
  514. namespace gcc {
  515. /* A class for managing all of the various dump files used by the
  516. optimization passes. */
  517. class dump_manager
  518. {
  519. public:
  520. dump_manager ();
  521. ~dump_manager ();
  522. /* Register a dumpfile.
  523. TAKE_OWNERSHIP determines whether callee takes ownership of strings
  524. SUFFIX, SWTCH, and GLOB. */
  525. unsigned int
  526. dump_register (const char *suffix, const char *swtch, const char *glob,
  527. dump_kind dkind, optgroup_flags_t optgroup_flags,
  528. bool take_ownership);
  529. /* Allow languages and middle-end to register their dumps before the
  530. optimization passes. */
  531. void
  532. register_dumps ();
  533. /* Return the dump_file_info for the given phase. */
  534. struct dump_file_info *
  535. get_dump_file_info (int phase) const;
  536. struct dump_file_info *
  537. get_dump_file_info_by_switch (const char *swtch) const;
  538. /* Return the name of the dump file for the given phase.
  539. If the dump is not enabled, returns NULL. */
  540. char *
  541. get_dump_file_name (int phase, int part = -1) const;
  542. char *
  543. get_dump_file_name (struct dump_file_info *dfi, int part = -1) const;
  544. int
  545. dump_switch_p (const char *arg);
  546. /* Start a dump for PHASE. Store user-supplied dump flags in
  547. *FLAG_PTR. Return the number of streams opened. Set globals
  548. DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
  549. set dump_flags appropriately for both pass dump stream and
  550. -fopt-info stream. */
  551. int
  552. dump_start (int phase, dump_flags_t *flag_ptr);
  553. /* Finish a tree dump for PHASE and close associated dump streams. Also
  554. reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS. */
  555. void
  556. dump_finish (int phase);
  557. FILE *
  558. dump_begin (int phase, dump_flags_t *flag_ptr, int part);
  559. /* Returns nonzero if tree dump PHASE has been initialized. */
  560. int
  561. dump_initialized_p (int phase) const;
  562. /* Returns the switch name of PHASE. */
  563. const char *
  564. dump_flag_name (int phase) const;
  565. void register_pass (opt_pass *pass);
  566. private:
  567. int
  568. dump_phase_enabled_p (int phase) const;
  569. int
  570. dump_switch_p_1 (const char *arg, struct dump_file_info *dfi, bool doglob);
  571. int
  572. dump_enable_all (dump_kind dkind, dump_flags_t flags, const char *filename);
  573. int
  574. opt_info_enable_passes (optgroup_flags_t optgroup_flags, dump_flags_t flags,
  575. const char *filename);
  576. bool update_dfi_for_opt_info (dump_file_info *dfi) const;
  577. private:
  578. /* Dynamically registered dump files and switches. */
  579. int m_next_dump;
  580. struct dump_file_info *m_extra_dump_files;
  581. size_t m_extra_dump_files_in_use;
  582. size_t m_extra_dump_files_alloced;
  583. /* Stored values from -fopt-info, for handling passes created after
  584. option-parsing (by backends and by plugins). */
  585. optgroup_flags_t m_optgroup_flags;
  586. dump_flags_t m_optinfo_flags;
  587. char *m_optinfo_filename;
  588. /* Grant access to dump_enable_all. */
  589. friend bool ::enable_rtl_dump_file (void);
  590. /* Grant access to opt_info_enable_passes. */
  591. friend int ::opt_info_switch_p (const char *arg);
  592. }; // class dump_manager
  593. } // namespace gcc
  594. #endif /* GCC_DUMPFILE_H */