1/* SSA name expresssons routines
2 Copyright (C) 2013-2026 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
14 for 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_TREE_SSANAMES_H
21#define GCC_TREE_SSANAMES_H
22
23/* Aliasing information for SSA_NAMEs representing pointer variables. */
24
25struct GTY(()) ptr_info_def
26{
27 /* The points-to solution. */
28 struct pt_solution pt;
29
30 /* Alignment and misalignment of the pointer in bytes. Together
31 align and misalign specify low known bits of the pointer.
32 ptr & (align - 1) == misalign. */
33
34 /* When known, this is the power-of-two byte alignment of the object this
35 pointer points into. This is usually DECL_ALIGN_UNIT for decls and
36 MALLOC_ABI_ALIGNMENT for allocated storage. When the alignment is not
37 known, it is zero. Do not access directly but use functions
38 get_ptr_info_alignment, set_ptr_info_alignment,
39 mark_ptr_info_alignment_unknown and similar. */
40 unsigned int align;
41
42 /* When alignment is known, the byte offset this pointer differs from the
43 above alignment. Access only through the same helper functions as align
44 above. */
45 unsigned int misalign;
46};
47
48
49#define SSANAMES(fun) (fun)->gimple_df->ssa_names
50#define DEFAULT_DEFS(fun) (fun)->gimple_df->default_defs
51
52#define num_ssa_names (vec_safe_length (cfun->gimple_df->ssa_names))
53#define ssa_name(i) ((*cfun->gimple_df->ssa_names)[(i)])
54
55#define FOR_EACH_SSA_NAME(I, VAR, FN) \
56 for (I = 1; SSANAMES (FN)->iterate (I, &VAR); ++I) \
57 if (VAR)
58
59/* Sets the value range to SSA. */
60extern bool set_range_info (tree, const vrange &);
61extern void set_nonzero_bits (tree, const wide_int &);
62extern void set_bitmask (tree, const wide_int &value, const wide_int &mask);
63extern wide_int get_nonzero_bits (const_tree);
64extern wide_int get_known_nonzero_bits (const_tree);
65extern bool ssa_name_has_boolean_range (tree, gimple * = nullptr);
66extern void init_ssanames (struct function *, int);
67extern void fini_ssanames (struct function *);
68extern void ssanames_print_statistics (void);
69extern tree make_ssa_name_fn (struct function *, tree, gimple *,
70 unsigned int version = 0);
71extern void init_ssa_name_imm_use (tree);
72extern void release_ssa_name_fn (struct function *, tree);
73extern bool get_ptr_info_alignment (struct ptr_info_def *, unsigned int *,
74 unsigned int *);
75extern void mark_ptr_info_alignment_unknown (struct ptr_info_def *);
76extern void set_ptr_info_alignment (struct ptr_info_def *, unsigned int,
77 unsigned int);
78extern void adjust_ptr_info_misalignment (struct ptr_info_def *, poly_uint64);
79extern struct ptr_info_def *get_ptr_info (tree);
80extern void set_ptr_nonnull (tree);
81
82extern tree copy_ssa_name_fn (struct function *, tree, gimple *);
83extern tree duplicate_ssa_name_fn (struct function *, tree, gimple *);
84extern void duplicate_ssa_name_ptr_info (tree, struct ptr_info_def *);
85extern void duplicate_ssa_name_range_info (tree dest, tree src);
86extern void maybe_duplicate_ssa_info_at_copy (tree dest, tree src);
87extern void reset_flow_sensitive_info (tree);
88extern void reset_flow_sensitive_info_in_bb (basic_block);
89extern void release_defs (gimple *);
90extern void replace_ssa_name_symbol (tree, tree);
91extern void flush_ssaname_freelist (void);
92
93
94/* Return an SSA_NAME node for variable VAR defined in statement STMT
95 in function cfun. */
96
97inline tree
98make_ssa_name (tree var, gimple *stmt = NULL)
99{
100 return make_ssa_name_fn (cfun, var, stmt);
101}
102
103/* Return an SSA_NAME node using the template SSA name NAME defined in
104 statement STMT in function cfun. */
105
106inline tree
107copy_ssa_name (tree var, gimple *stmt = NULL)
108{
109 return copy_ssa_name_fn (cfun, var, stmt);
110}
111
112/* Creates a duplicate of a SSA name NAME tobe defined by statement STMT
113 in function cfun. */
114
115inline tree
116duplicate_ssa_name (tree var, gimple *stmt)
117{
118 return duplicate_ssa_name_fn (cfun, var, stmt);
119}
120
121/* Release the SSA name NAME used in function cfun. */
122
123inline void
124release_ssa_name (tree name)
125{
126 release_ssa_name_fn (cfun, name);
127}
128
129/* Return an anonymous SSA_NAME node for type TYPE defined in statement STMT
130 in function cfun. Arrange so that it uses NAME in dumps. */
131
132inline tree
133make_temp_ssa_name (tree type, gimple *stmt, const char *name)
134{
135 tree ssa_name;
136 gcc_checking_assert (TYPE_P (type));
137 ssa_name = make_ssa_name_fn (cfun, type, stmt);
138 SET_SSA_NAME_VAR_OR_IDENTIFIER (ssa_name, get_identifier (name));
139 return ssa_name;
140}
141
142/* A class which is used to save/restore the flow sensitive information. */
143class flow_sensitive_info_storage
144{
145public:
146 void save (tree);
147 void save_and_clear (tree);
148 void restore (tree);
149 void clear_storage ();
150private:
151 /* 0 means there is nothing saved.
152 1 means non pointer is saved.
153 -1 means a pointer type is saved.
154 -2 means a pointer type is saved but no information was saved. */
155 int state = 0;
156 /* The range info for non pointers */
157 vrange_storage *range_info = nullptr;
158 /* Flow sensitive pointer information. */
159 unsigned int align = 0;
160 unsigned int misalign = 0;
161 bool null = true;
162};
163
164#endif /* GCC_TREE_SSANAMES_H */
165

source code of gcc/tree-ssanames.h