dumpfile.h 9.2 KB

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