GCC Middle and Back End API Reference
stor-layout.h
Go to the documentation of this file.
1/* Definitions and declarations for stor-layout.cc.
2 Copyright (C) 2013-2024 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
20#ifndef GCC_STOR_LAYOUT_H
21#define GCC_STOR_LAYOUT_H
22
24extern void fixup_signed_type (tree);
26 unsigned int);
28extern tree bit_from_pos (tree, tree);
29extern tree byte_from_pos (tree, tree);
30extern void pos_from_bit (tree *, tree *, unsigned int, tree);
31extern void normalize_offset (tree *, tree *, unsigned int);
36extern void compute_record_mode (tree);
37extern void finish_bitfield_layout (tree);
39extern void finalize_size_functions (void);
40extern void fixup_unsigned_type (tree);
41extern void initialize_sizetypes (void);
42
43/* Finish up a builtin RECORD_TYPE. Give it a name and provide its
44 fields. Optionally specify an alignment, and then lay it out. */
45extern void finish_builtin_struct (tree, const char *, tree, tree);
46
47/* Given a VAR_DECL, PARM_DECL, RESULT_DECL or FIELD_DECL node,
48 calculates the DECL_SIZE, DECL_SIZE_UNIT, DECL_ALIGN and DECL_MODE
49 fields. Call this only once for any given decl node.
50
51 Second argument is the boundary that this field can be assumed to
52 be starting at (in bits). Zero means it can be assumed aligned
53 on any boundary that may be needed. */
54extern void layout_decl (tree, unsigned);
55
56/* Given a ..._TYPE node, calculate the TYPE_SIZE, TYPE_SIZE_UNIT,
57 TYPE_ALIGN and TYPE_MODE fields. If called more than once on one
58 node, does nothing except for the first time. */
59extern void layout_type (tree);
60
61/* Return the least alignment in bytes required for type TYPE. */
62extern unsigned int min_align_of_type (tree);
63
64/* Construct various nodes representing fract or accum data types. */
65extern tree make_fract_type (int, int, int);
66extern tree make_accum_type (int, int, int);
67
68#define make_signed_fract_type(P) make_fract_type (P, 0, 0)
69#define make_unsigned_fract_type(P) make_fract_type (P, 1, 0)
70#define make_sat_signed_fract_type(P) make_fract_type (P, 0, 1)
71#define make_sat_unsigned_fract_type(P) make_fract_type (P, 1, 1)
72#define make_signed_accum_type(P) make_accum_type (P, 0, 0)
73#define make_unsigned_accum_type(P) make_accum_type (P, 1, 0)
74#define make_sat_signed_accum_type(P) make_accum_type (P, 0, 1)
75#define make_sat_unsigned_accum_type(P) make_accum_type (P, 1, 1)
76
77#define make_or_reuse_signed_fract_type(P) \
78 make_or_reuse_fract_type (P, 0, 0)
79#define make_or_reuse_unsigned_fract_type(P) \
80 make_or_reuse_fract_type (P, 1, 0)
81#define make_or_reuse_sat_signed_fract_type(P) \
82 make_or_reuse_fract_type (P, 0, 1)
83#define make_or_reuse_sat_unsigned_fract_type(P) \
84 make_or_reuse_fract_type (P, 1, 1)
85#define make_or_reuse_signed_accum_type(P) \
86 make_or_reuse_accum_type (P, 0, 0)
87#define make_or_reuse_unsigned_accum_type(P) \
88 make_or_reuse_accum_type (P, 1, 0)
89#define make_or_reuse_sat_signed_accum_type(P) \
90 make_or_reuse_accum_type (P, 0, 1)
91#define make_or_reuse_sat_unsigned_accum_type(P) \
92 make_or_reuse_accum_type (P, 1, 1)
93
94extern tree make_signed_type (int);
95extern tree make_unsigned_type (int);
96
97/* Return the mode for data of a given size SIZE and mode class CLASS.
98 If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE.
99 The value is BLKmode if no other mode is found. This is like
100 mode_for_size, but is passed a tree. */
102
103extern tree bitwise_type_for_mode (machine_mode);
104
106
107/* Given a VAR_DECL, PARM_DECL or RESULT_DECL, clears the results of
108 a previous call to layout_decl and calls it again. */
109extern void relayout_decl (tree);
110
111/* variable_size (EXP) is like save_expr (EXP) except that it
112 is for the special case of something that is part of a
113 variable size for a data type. It makes special arrangements
114 to compute the value at the right time when the data type
115 belongs to a function parameter. */
116extern tree variable_size (tree);
117
118#endif // GCC_STOR_LAYOUT_H
Definition machmode.h:263
const union tree_node * const_tree
Definition coretypes.h:98
union tree_node * tree
Definition coretypes.h:97
mode_class
Definition genmodes.cc:29
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
signop
Definition signop.h:28
void finalize_size_functions(void)
Definition stor-layout.cc:275
void place_field(record_layout_info, tree)
Definition stor-layout.cc:1279
void finish_bitfield_layout(tree)
Definition stor-layout.cc:2227
tree make_fract_type(int, int, int)
Definition stor-layout.cc:2845
tree rli_size_unit_so_far(record_layout_info)
Definition stor-layout.cc:1045
void finish_builtin_struct(tree, const char *, tree, tree)
Definition stor-layout.cc:2362
void normalize_offset(tree *, tree *, unsigned int)
Definition stor-layout.cc:993
tree bitwise_type_for_mode(machine_mode)
Definition stor-layout.cc:461
void set_min_and_max_values_for_integral_type(tree, int, signop)
Definition stor-layout.cc:2970
tree make_signed_type(int)
Definition stor-layout.cc:2818
opt_machine_mode mode_for_size_tree(const_tree, enum mode_class, int)
Definition stor-layout.cc:327
void fixup_signed_type(tree)
Definition stor-layout.cc:2993
tree make_unsigned_type(int)
Definition stor-layout.cc:2831
void pos_from_bit(tree *, tree *, unsigned int, tree)
Definition stor-layout.cc:966
void finish_record_layout(record_layout_info, int)
Definition stor-layout.cc:2314
void fixup_unsigned_type(tree)
Definition stor-layout.cc:3008
tree bit_from_pos(tree, tree)
Definition stor-layout.cc:940
tree make_accum_type(int, int, int)
Definition stor-layout.cc:2867
void relayout_decl(tree)
Definition stor-layout.cc:851
unsigned int min_align_of_type(tree)
Definition stor-layout.cc:2797
record_layout_info start_record_layout(tree)
Definition stor-layout.cc:871
void layout_type(tree)
Definition stor-layout.cc:2405
tree byte_from_pos(tree, tree)
Definition stor-layout.cc:951
tree rli_size_so_far(record_layout_info)
Definition stor-layout.cc:1053
void layout_decl(tree, unsigned)
opt_machine_mode bitwise_mode_for_size(poly_uint64)
Definition stor-layout.cc:483
unsigned int update_alignment_for_field(record_layout_info, tree, unsigned int)
Definition stor-layout.cc:1064
void normalize_rli(record_layout_info)
Definition stor-layout.cc:1037
tree variable_size(tree)
Definition stor-layout.cc:67
void initialize_sizetypes(void)
Definition stor-layout.cc:2888
void compute_record_mode(tree)
Definition stor-layout.cc:1866