Update baseline symbols for hppa-linux.
[official-gcc.git] / gcc / analyzer / access-diagram.h
blobc124e80ac2ead1c510fffa11e600fd38c4e1de08
1 /* Text art visualizations within -fanalyzer.
2 Copyright (C) 2023 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 it
8 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, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 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/>. */
21 #ifndef GCC_ANALYZER_ACCESS_DIAGRAM_H
22 #define GCC_ANALYZER_ACCESS_DIAGRAM_H
24 #include "text-art/canvas.h"
25 #include "text-art/theme.h"
26 #include "text-art/widget.h"
27 #include "analyzer/analyzer.h"
28 #include "analyzer/store.h"
30 namespace ana {
32 class bit_size_expr
34 public:
35 bit_size_expr () : m_num_bits (NULL) {}
36 bit_size_expr (tree num_bits) : m_num_bits (num_bits) {}
38 text_art::styled_string
39 get_formatted_str (text_art::style_manager &sm,
40 const char *concrete_single_bit_fmt,
41 const char *concrete_plural_bits_fmt,
42 const char *concrete_single_byte_fmt,
43 const char *concrete_plural_bytes_fmt,
44 const char *symbolic_bits_fmt,
45 const char *symbolic_bytes_fmt) const;
46 void print (pretty_printer *pp) const;
48 tree maybe_get_as_bytes () const;
50 private:
51 tree m_num_bits;
54 /* A range of bits within a base region, where each endpoint
55 could be concrete or symbolic (not necessarily the same). */
57 struct access_range
59 access_range ()
60 : m_start (), m_next ()
63 access_range (region_offset start, region_offset next)
64 : m_start (start), m_next (next)
66 access_range (const region *base_region, const bit_range &bits);
67 access_range (const region *base_region, const byte_range &bytes);
68 access_range (const region &reg, region_model_manager *);
70 bool concrete_p () const
72 return m_start.concrete_p () && m_next.concrete_p ();
75 bool empty_p () const;
77 bool get_size (const region_model &model, bit_size_expr *out) const;
79 bool get_size_in_bits (bit_size_t *out) const
81 if (concrete_p ())
83 *out = m_next.get_bit_offset () - m_start.get_bit_offset ();
84 return true;
86 return false;
89 bool as_concrete_bit_range (bit_range *out) const
91 if (!concrete_p ())
92 return false;
93 bit_size_t size = m_next.get_bit_offset () - m_start.get_bit_offset ();
94 *out = bit_range (m_start.get_bit_offset (), size);
95 return true;
97 bool as_concrete_byte_range (byte_range *out) const
99 bit_range bits (0, 0);
100 if (!as_concrete_bit_range (&bits))
101 return false;
102 return bits.as_byte_range (out);
105 bool contains_p (const access_range &other) const;
107 void dump_to_pp (pretty_printer *pp, bool) const;
108 void dump (bool) const;
109 void log (const char *title, logger &) const;
111 region_offset m_start;
112 region_offset m_next;
115 struct access_operation
117 access_operation (const region_model &model,
118 enum access_direction dir,
119 const region &reg,
120 const svalue *sval_hint)
121 : m_model (model),
122 m_dir (dir),
123 m_reg (reg),
124 m_sval_hint (sval_hint),
125 m_base_region (reg.get_base_region ())
128 region_model_manager *get_manager () const
130 return m_model.get_manager ();
133 /* Get the valid bits to access within the base region. */
134 access_range get_valid_bits () const;
136 /* Get the actual bits accessed within the base region. */
137 access_range get_actual_bits () const;
139 bool maybe_get_invalid_before_bits (access_range *out) const;
140 bool maybe_get_invalid_after_bits (access_range *out) const;
142 const region_model &m_model;
143 enum access_direction m_dir;
144 const region &m_reg;
145 const svalue *m_sval_hint;
146 const region *m_base_region;
149 class access_diagram : public text_art::wrapper_widget
151 public:
152 access_diagram (const access_operation &op,
153 diagnostic_event_id_t region_creation_event_id,
154 text_art::style_manager &sm,
155 const text_art::theme &theme,
156 logger *logger);
157 const char *get_desc () const override
159 return "access_diagram";
163 } // namespace ana
165 #endif /* GCC_ANALYZER_ACCESS_DIAGRAM_H */