Avoid is_constant calls in vectorizable_bswap
[official-gcc.git] / gcc / dump-context.h
blob5ac9dd60e8dd719c3eea842cc355533a774732dd
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)
10 any later version.
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 #include "dumpfile.h"
26 #include "pretty-print.h"
28 /* A class for handling the various dump_* calls.
30 In particular, this class has responsibility for consolidating
31 the "dump_*" calls into optinfo instances (delimited by "dump_*_loc"
32 calls), and emitting them.
34 Putting this in a class (rather than as global state) allows
35 for selftesting of this code. */
37 class dump_context
39 friend class temp_dump_context;
40 public:
41 static dump_context &get () { return *s_current; }
43 ~dump_context ();
45 void refresh_dumps_are_enabled ();
47 void dump_loc (dump_flags_t dump_kind, const dump_location_t &loc);
49 void dump_gimple_stmt (dump_flags_t dump_kind, dump_flags_t extra_dump_flags,
50 gimple *gs, int spc);
52 void dump_gimple_stmt_loc (dump_flags_t dump_kind,
53 const dump_location_t &loc,
54 dump_flags_t extra_dump_flags,
55 gimple *gs, int spc);
57 void dump_gimple_expr (dump_flags_t dump_kind,
58 dump_flags_t extra_dump_flags,
59 gimple *gs, int spc);
61 void dump_gimple_expr_loc (dump_flags_t dump_kind,
62 const dump_location_t &loc,
63 dump_flags_t extra_dump_flags,
64 gimple *gs,
65 int spc);
67 void dump_generic_expr (dump_flags_t dump_kind,
68 dump_flags_t extra_dump_flags,
69 tree t);
71 void dump_generic_expr_loc (dump_flags_t dump_kind,
72 const dump_location_t &loc,
73 dump_flags_t extra_dump_flags,
74 tree t);
76 void dump_printf_va (dump_flags_t dump_kind, const char *format,
77 va_list *ap) ATTRIBUTE_GCC_DUMP_PRINTF (3, 0);
79 void dump_printf_loc_va (dump_flags_t dump_kind, const dump_location_t &loc,
80 const char *format, va_list *ap)
81 ATTRIBUTE_GCC_DUMP_PRINTF (4, 0);
83 template<unsigned int N, typename C>
84 void dump_dec (dump_flags_t dump_kind, const poly_int<N, C> &value);
86 void dump_symtab_node (dump_flags_t dump_kind, symtab_node *node);
88 /* Managing nested scopes. */
89 unsigned int get_scope_depth () const;
90 void begin_scope (const char *name, const dump_location_t &loc);
91 void end_scope ();
93 /* For use in selftests; if true then optinfo_enabled_p is true. */
94 bool forcibly_enable_optinfo_p () const
96 return m_forcibly_enable_optinfo;
99 void end_any_optinfo ();
101 void emit_item (optinfo_item *item, dump_flags_t dump_kind);
103 private:
104 optinfo &ensure_pending_optinfo ();
105 optinfo &begin_next_optinfo (const dump_location_t &loc);
107 /* For use in selftests; if true then optinfo_enabled_p is true. */
108 bool m_forcibly_enable_optinfo;
110 /* The current nesting depth of dump scopes, for showing nesting
111 via indentation). */
112 unsigned int m_scope_depth;
114 /* The optinfo currently being accumulated since the last dump_*_loc call,
115 if any. */
116 optinfo *m_pending;
118 /* For use in selftests: if non-NULL, then items are to be printed
119 to this, using the given flags. */
120 pretty_printer *m_test_pp;
121 dump_flags_t m_test_pp_flags;
123 /* The currently active dump_context, for use by the dump_* API calls. */
124 static dump_context *s_current;
126 /* The default active context. */
127 static dump_context s_default;
130 #if CHECKING_P
132 /* An RAII-style class for use in selftests for temporarily using a different
133 dump_context. */
135 class temp_dump_context
137 public:
138 temp_dump_context (bool forcibly_enable_optinfo,
139 dump_flags_t test_pp_flags);
140 ~temp_dump_context ();
142 /* Support for selftests. */
143 optinfo *get_pending_optinfo () const { return m_context.m_pending; }
144 const char *get_dumped_text ();
146 private:
147 pretty_printer m_pp;
148 dump_context m_context;
149 dump_context *m_saved;
150 bool m_saved_flag_remarks;
153 #endif /* CHECKING_P */
155 #endif /* GCC_DUMP_CONTEXT_H */