GCC Middle and Back End API Reference
record-layout.h
Go to the documentation of this file.
1/* Declaration of class record_layout.
2 Copyright (C) 2022-2026 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_ANALYZER_RECORD_LAYOUT_H
22#define GCC_ANALYZER_RECORD_LAYOUT_H
23
24#include "analyzer/store.h"
25
26namespace ana {
27
30
31extern tree
33 concrete_bit_offset bit_offset);
34
35/* Information of the layout of a RECORD_TYPE, capturing it as a vector
36 of items, where each item is either a field or padding. */
37
39{
40public:
41 /* An item within a record; either a field, or padding after a field. */
42 struct item
43 {
44 public:
46 const_tree field,
47 bool is_padding)
48 : m_bit_range (br),
49 m_field (field),
50 m_is_padding (is_padding)
51 {
52 }
53
62
63 bool contains_p (concrete_bit_offset offset) const
64 {
65 return m_bit_range.contains_p (offset);
66 }
67
68 void dump_to_pp (pretty_printer *pp) const
69 {
70 if (m_is_padding)
71 pp_printf (pp, "padding after %qD", m_field);
72 else
73 pp_printf (pp, "%qD", m_field);
74 pp_string (pp, ", ");
76 }
77
81 };
82
84
85 void dump_to_pp (pretty_printer *pp) const;
86 DEBUG_FUNCTION void dump () const;
87
89
90 auto begin () const { return m_items.begin (); }
91 auto end () const { return m_items.end (); }
92
93private:
95
97};
98
99} // namespace ana
100
101#endif /* GCC_ANALYZER_RECORD_LAYOUT_H */
ConcreteValueType get_next_offset() const
Definition concrete-ranges.h:66
ConcreteValueType get_start_offset() const
Definition concrete-ranges.h:54
bool contains_p(ConcreteValueType offset) const
Definition concrete-ranges.h:69
void dump_to_pp(pretty_printer *pp) const
const record_layout::item * get_item_at(concrete_bit_offset offset) const
record_layout(const_tree record_type)
auto end() const
Definition record-layout.h:91
auto_vec< item > m_items
Definition record-layout.h:96
DEBUG_FUNCTION void dump() const
void maybe_pad_to(concrete_bit_offset next_offset)
auto begin() const
Definition record-layout.h:90
void dump_to_pp(pretty_printer *pp) const
Definition vec.h:1667
Definition pretty-print.h:241
const union tree_node * const_tree
Definition coretypes.h:98
union tree_node * tree
Definition coretypes.h:97
Definition access-diagram.h:30
concrete_bit_offset get_bit_position(const_tree field)
integer_with_unit< units::bit > concrete_bit_offset
Definition integer-with-unit.h:329
concrete::range< integer_with_unit< units::bit > > concrete_bit_range
Definition concrete-ranges.h:117
tree get_field_at_bit_offset(tree record_type, concrete_bit_offset bit_offset)
void pp_printf(pretty_printer *pp, const char *msg,...)
Definition pretty-print.cc:2684
void pp_string(pretty_printer *pp, const char *str)
Definition pretty-print.cc:2765
Definition record-layout.h:43
concrete_bit_range m_bit_range
Definition record-layout.h:78
item(const concrete_bit_range &br, const_tree field, bool is_padding)
Definition record-layout.h:45
bool m_is_padding
Definition record-layout.h:80
void dump_to_pp(pretty_printer *pp) const
Definition record-layout.h:68
concrete_bit_offset get_next_offset() const
Definition record-layout.h:58
bool contains_p(concrete_bit_offset offset) const
Definition record-layout.h:63
const_tree m_field
Definition record-layout.h:79
concrete_bit_offset get_start_offset() const
Definition record-layout.h:54
#define DEBUG_FUNCTION
Definition system.h:1131