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>.
5 This file is part of GCC.
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)
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.
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/>. */
22 #ifndef GCC_DUMP_CONTEXT_H
23 #define GCC_DUMP_CONTEXT_H 1
25 /* A class for handling the various dump_* calls.
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.
31 Putting this in a class (rather than as global state) allows
32 for selftesting of this code. */
36 friend class temp_dump_context
;
38 static dump_context
&get () { return *s_current
; }
42 void dump_gimple_stmt (dump_flags_t dump_kind
, dump_flags_t extra_dump_flags
,
45 void dump_gimple_stmt_loc (dump_flags_t dump_kind
,
46 const dump_location_t
&loc
,
47 dump_flags_t extra_dump_flags
,
50 void dump_gimple_expr (dump_flags_t dump_kind
,
51 dump_flags_t extra_dump_flags
,
54 void dump_gimple_expr_loc (dump_flags_t dump_kind
,
55 const dump_location_t
&loc
,
56 dump_flags_t extra_dump_flags
,
60 void dump_generic_expr (dump_flags_t dump_kind
,
61 dump_flags_t extra_dump_flags
,
64 void dump_generic_expr_loc (dump_flags_t dump_kind
,
65 const dump_location_t
&loc
,
66 dump_flags_t extra_dump_flags
,
69 void dump_printf_va (dump_flags_t dump_kind
, const char *format
,
70 va_list ap
) ATTRIBUTE_PRINTF (3, 0);
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);
76 template<unsigned int N
, typename C
>
77 void dump_dec (dump_flags_t dump_kind
, const poly_int
<N
, C
> &value
);
79 void dump_symtab_node (dump_flags_t dump_kind
, symtab_node
*node
);
81 /* Managing nested scopes. */
82 unsigned int get_scope_depth () const;
83 void begin_scope (const char *name
, const dump_location_t
&loc
);
86 /* For use in selftests; if true then optinfo_enabled_p is true. */
87 bool forcibly_enable_optinfo_p () const
89 return m_forcibly_enable_optinfo
;
92 void end_any_optinfo ();
95 optinfo
&ensure_pending_optinfo ();
96 optinfo
&begin_next_optinfo (const dump_location_t
&loc
);
98 /* For use in selftests; if true then optinfo_enabled_p is true. */
99 bool m_forcibly_enable_optinfo
;
101 /* The current nesting depth of dump scopes, for showing nesting
103 unsigned int m_scope_depth
;
105 /* The optinfo currently being accumulated since the last dump_*_loc call,
109 /* The currently active dump_context, for use by the dump_* API calls. */
110 static dump_context
*s_current
;
112 /* The default active context. */
113 static dump_context s_default
;
118 /* An RAII-style class for use in selftests for temporarily using a different
121 class temp_dump_context
124 temp_dump_context (bool forcibly_enable_optinfo
);
125 ~temp_dump_context ();
127 /* Support for selftests. */
128 optinfo
*get_pending_optinfo () const { return m_context
.m_pending
; }
131 dump_context m_context
;
132 dump_context
*m_saved
;
133 bool m_saved_flag_remarks
;
136 #endif /* CHECKING_P */
138 #endif /* GCC_DUMP_CONTEXT_H */