Line data Source code
1 : /* A (base_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 (base_region, symbolic bit range) pair.
31 : Note that the range has a granularity of *bits*. */
32 :
33 : class memory_range
34 : {
35 : public:
36 651145 : memory_range (const region &base_reg,
37 : symbolic_bit_range bit_range)
38 651145 : : m_base_reg (base_reg),
39 651145 : 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 4679 : operator== (const memory_range &other) const
50 : {
51 4679 : return (&m_base_reg == &other.m_base_reg
52 35821 : && 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 : const region &
62 4193983 : get_base_region () const { return m_base_reg; }
63 :
64 : symbolic_bit_range
65 3991925 : get_bit_range () const { return m_bit_range; }
66 :
67 : const symbolic_bit_offset &
68 3759 : get_start_offset () const { return m_bit_range.get_start_offset (); }
69 :
70 : const symbolic_bit_offset &
71 6 : get_next_offset () const { return m_bit_range.get_next_offset (); }
72 :
73 : const symbolic_bit_size &
74 1328658 : get_size () const { return m_bit_range.get_size (); }
75 :
76 : private:
77 : const region &m_base_reg;
78 : symbolic_bit_range m_bit_range;
79 : };
80 :
81 : } // namespace ana::symbolic
82 :
83 : } // namespace ana
84 :
85 : #endif /* GCC_ANALYZER_SYMBOLIC_MEMORY_RANGES_H */
|