]>
Commit | Line | Data |
---|---|---|
38cf91e5 | 1 | /* Support code for handling the various dump_* calls in dumpfile.h |
2 | Copyright (C) 2018 Free Software Foundation, Inc. | |
3 | Contributed by David Malcolm <dmalcolm@redhat.com>. | |
4 | ||
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GCC is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GCC; see the file COPYING3. If not see | |
19 | <http://www.gnu.org/licenses/>. */ | |
20 | ||
21 | ||
22 | #ifndef GCC_DUMP_CONTEXT_H | |
23 | #define GCC_DUMP_CONTEXT_H 1 | |
24 | ||
25 | /* A class for handling the various dump_* calls. | |
26 | ||
27 | In particular, this class has responsibility for consolidating | |
28 | the "dump_*" calls into optinfo instances (delimited by "dump_*_loc" | |
29 | calls), and emitting them. | |
30 | ||
31 | Putting this in a class (rather than as global state) allows | |
32 | for selftesting of this code. */ | |
33 | ||
34 | class dump_context | |
35 | { | |
36 | friend class temp_dump_context; | |
37 | public: | |
38 | static dump_context &get () { return *s_current; } | |
39 | ||
40 | ~dump_context (); | |
41 | ||
42 | void dump_gimple_stmt (dump_flags_t dump_kind, dump_flags_t extra_dump_flags, | |
43 | gimple *gs, int spc); | |
44 | ||
45 | void dump_gimple_stmt_loc (dump_flags_t dump_kind, | |
46 | const dump_location_t &loc, | |
47 | dump_flags_t extra_dump_flags, | |
48 | gimple *gs, int spc); | |
49 | ||
50 | void dump_gimple_expr (dump_flags_t dump_kind, | |
51 | dump_flags_t extra_dump_flags, | |
52 | gimple *gs, int spc); | |
53 | ||
54 | void dump_gimple_expr_loc (dump_flags_t dump_kind, | |
55 | const dump_location_t &loc, | |
56 | dump_flags_t extra_dump_flags, | |
57 | gimple *gs, | |
58 | int spc); | |
59 | ||
60 | void dump_generic_expr (dump_flags_t dump_kind, | |
61 | dump_flags_t extra_dump_flags, | |
62 | tree t); | |
63 | ||
64 | void dump_generic_expr_loc (dump_flags_t dump_kind, | |
65 | const dump_location_t &loc, | |
66 | dump_flags_t extra_dump_flags, | |
67 | tree t); | |
68 | ||
69 | void dump_printf_va (dump_flags_t dump_kind, const char *format, | |
70 | va_list ap) ATTRIBUTE_PRINTF (3, 0); | |
71 | ||
72 | void dump_printf_loc_va (dump_flags_t dump_kind, const dump_location_t &loc, | |
73 | const char *format, va_list ap) | |
74 | ATTRIBUTE_PRINTF (4, 0); | |
75 | ||
76 | template<unsigned int N, typename C> | |
77 | void dump_dec (dump_flags_t dump_kind, const poly_int<N, C> &value); | |
78 | ||
79 | void dump_symtab_node (dump_flags_t dump_kind, symtab_node *node); | |
80 | ||
81 | /* Managing nested scopes. */ | |
82 | unsigned int get_scope_depth () const; | |
83 | void begin_scope (const char *name, const dump_location_t &loc); | |
84 | void end_scope (); | |
85 | ||
86 | /* For use in selftests; if true then optinfo_enabled_p is true. */ | |
87 | bool forcibly_enable_optinfo_p () const | |
88 | { | |
89 | return m_forcibly_enable_optinfo; | |
90 | } | |
91 | ||
92 | void end_any_optinfo (); | |
93 | ||
94 | private: | |
95 | optinfo &ensure_pending_optinfo (); | |
96 | optinfo &begin_next_optinfo (const dump_location_t &loc); | |
97 | ||
98 | /* For use in selftests; if true then optinfo_enabled_p is true. */ | |
99 | bool m_forcibly_enable_optinfo; | |
100 | ||
101 | /* The current nesting depth of dump scopes, for showing nesting | |
102 | via indentation). */ | |
103 | unsigned int m_scope_depth; | |
104 | ||
105 | /* The optinfo currently being accumulated since the last dump_*_loc call, | |
106 | if any. */ | |
107 | optinfo *m_pending; | |
108 | ||
109 | /* The currently active dump_context, for use by the dump_* API calls. */ | |
110 | static dump_context *s_current; | |
111 | ||
112 | /* The default active context. */ | |
113 | static dump_context s_default; | |
114 | }; | |
115 | ||
116 | #if CHECKING_P | |
117 | ||
118 | /* An RAII-style class for use in selftests for temporarily using a different | |
119 | dump_context. */ | |
120 | ||
121 | class temp_dump_context | |
122 | { | |
123 | public: | |
124 | temp_dump_context (bool forcibly_enable_optinfo); | |
125 | ~temp_dump_context (); | |
126 | ||
127 | /* Support for selftests. */ | |
128 | optinfo *get_pending_optinfo () const { return m_context.m_pending; } | |
129 | ||
130 | private: | |
131 | dump_context m_context; | |
132 | dump_context *m_saved; | |
133 | bool m_saved_flag_remarks; | |
134 | }; | |
135 | ||
136 | #endif /* CHECKING_P */ | |
137 | ||
138 | #endif /* GCC_DUMP_CONTEXT_H */ |