Line data Source code
1 : /* A (cluster_region, symbolic bit range) pair.
2 : Copyright (C) 2026 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 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.
11 :
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.
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 : #ifndef GCC_ANALYZER_SYMBOLIC_MEMORY_RANGES_H
22 : #define GCC_ANALYZER_SYMBOLIC_MEMORY_RANGES_H
23 :
24 : #include "analyzer/symbolic-ranges.h"
25 : #include "analyzer/symbolic-pointers.h"
26 :
27 : namespace ana {
28 : namespace symbolic {
29 :
30 : /* A (cluster_region, symbolic bit range) pair.
31 : Note that the range has a granularity of *bits*. */
32 :
33 : class memory_range
34 : {
35 : public:
36 667124 : memory_range (const cluster_region &cluster_reg,
37 : symbolic_bit_range bit_range)
38 667124 : : m_cluster_reg (cluster_reg),
39 667124 : m_bit_range (bit_range)
40 : {
41 : }
42 :
43 : memory_range (pointer sym_ptr,
44 : const symbolic_byte_size &num_bytes);
45 :
46 : void dump () const;
47 :
48 : bool
49 4740 : operator== (const memory_range &other) const
50 : {
51 4740 : return (&m_cluster_reg == &other.m_cluster_reg
52 35991 : && m_bit_range == other.m_bit_range);
53 : }
54 :
55 : std::unique_ptr<text_art::tree_widget>
56 : make_dump_widget (node_dump_state &nds) const;
57 :
58 : std::unique_ptr<json::object>
59 : to_json () const;
60 :
61 : /* Deprecated (poor terminology); use get_cluster_region instead. */
62 : const cluster_region &
63 1853969 : get_base_region () const { return m_cluster_reg; }
64 :
65 : const cluster_region &
66 2368348 : get_cluster_region () const { return m_cluster_reg; }
67 :
68 : symbolic_bit_range
69 4019522 : get_bit_range () const { return m_bit_range; }
70 :
71 : const symbolic_bit_offset &
72 3782 : get_start_offset () const { return m_bit_range.get_start_offset (); }
73 :
74 : const symbolic_bit_offset &
75 6 : get_next_offset () const { return m_bit_range.get_next_offset (); }
76 :
77 : const symbolic_bit_size &
78 668736 : get_size () const { return m_bit_range.get_size (); }
79 :
80 : private:
81 : const cluster_region &m_cluster_reg;
82 : symbolic_bit_range m_bit_range;
83 : };
84 :
85 : } // namespace ana::symbolic
86 :
87 : } // namespace ana
88 :
89 : #endif /* GCC_ANALYZER_SYMBOLIC_MEMORY_RANGES_H */
|