Line data Source code
1 : /* SSA name expresssons routines
2 : Copyright (C) 2013-2026 Free Software Foundation, Inc.
3 :
4 : This file is part of GCC.
5 :
6 : GCC is free software; you can redistribute it and/or modify it under
7 : the terms of the GNU General Public License as published by the Free
8 : Software Foundation; either version 3, or (at your option) any later
9 : version.
10 :
11 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 : for more details.
15 :
16 : You should have received a copy of the GNU General Public License
17 : along 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 : inline irange_storage *
24 : ssa_name_irange_info (const_tree name)
25 : {
26 : vrange_storage *s = SSA_NAME_RANGE_INFO (name);
27 : return s ? s->dyn_irange () : NULL;
28 : }
29 :
30 : inline prange_storage *
31 7189680458 : ssa_name_prange_info (const_tree name)
32 : {
33 7189680458 : vrange_storage *s = SSA_NAME_RANGE_INFO (name);
34 7189680458 : return s ? s->dyn_prange () : NULL;
35 : }
36 :
37 : inline frange_storage *
38 : ssa_name_frange_info (const_tree name)
39 : {
40 : vrange_storage *s = SSA_NAME_RANGE_INFO (name);
41 : return s ? s->dyn_frange () : NULL;
42 : }
43 :
44 : /* Return NAME's points-to solution, or NULL if it has none. Returns NULL
45 : for a non pointer type. */
46 : inline const pt_solution *
47 6971021296 : ssa_name_pt_solution (const_tree name)
48 : {
49 6971021296 : prange_storage *s = ssa_name_prange_info (name);
50 6971021296 : return s ? s->pt : NULL;
51 : }
52 :
53 : /* Make PT the points-to solution for NAME, which must have pointer type. */
54 : extern void set_ssa_name_pt_solution (tree name, const pt_solution &pt);
55 :
56 : #define SSANAMES(fun) (fun)->gimple_df->ssa_names
57 : #define DEFAULT_DEFS(fun) (fun)->gimple_df->default_defs
58 :
59 : #define num_ssa_names (vec_safe_length (cfun->gimple_df->ssa_names))
60 : #define ssa_name(i) ((*cfun->gimple_df->ssa_names)[(i)])
61 :
62 : #define FOR_EACH_SSA_NAME(I, VAR, FN) \
63 : for (I = 1; SSANAMES (FN)->iterate (I, &VAR); ++I) \
64 : if (VAR)
65 :
66 : /* Sets the value range to SSA. */
67 : extern bool set_range_info (tree, const vrange &);
68 : extern void set_nonzero_bits (tree, const wide_int &);
69 : extern void set_bitmask (tree, const wide_int &value, const wide_int &mask);
70 : extern wide_int get_nonzero_bits (const_tree);
71 : extern wide_int get_known_nonzero_bits (const_tree);
72 : extern bool ssa_name_has_boolean_range (tree, gimple * = nullptr);
73 : extern void init_ssanames (struct function *, int);
74 : extern void fini_ssanames (struct function *);
75 : extern void ssanames_print_statistics (void);
76 : extern tree make_ssa_name_fn (struct function *, tree, gimple *,
77 : unsigned int version = 0);
78 : extern void init_ssa_name_imm_use (tree);
79 : extern void release_ssa_name_fn (struct function *, tree);
80 : extern bool get_ssa_name_alignment (const_tree, unsigned int *,
81 : unsigned int *);
82 : extern void mark_ssa_name_alignment_unknown (tree);
83 : extern void set_ssa_name_alignment (tree, unsigned int, unsigned int);
84 : extern void set_ptr_nonnull (tree);
85 : extern bool ptr_nonnull_p (tree);
86 :
87 : extern tree copy_ssa_name_fn (struct function *, tree, gimple *);
88 : extern tree duplicate_ssa_name_fn (struct function *, tree, gimple *);
89 : extern void duplicate_ssa_name_pt_solution (tree dest, const pt_solution *);
90 : extern void duplicate_ssa_name_pt_solution (tree dest, tree src);
91 : extern void duplicate_ssa_name_range_info (tree dest, tree src,
92 : bool remove_local_addr = false);
93 : extern void maybe_duplicate_ssa_info_at_copy (tree dest, tree src);
94 : extern void reset_flow_sensitive_info (tree);
95 : extern void reset_flow_sensitive_info_in_bb (basic_block);
96 : extern void release_defs (gimple *);
97 : extern void replace_ssa_name_symbol (tree, tree);
98 : extern void flush_ssaname_freelist (void);
99 :
100 :
101 : /* Return an SSA_NAME node for variable VAR defined in statement STMT
102 : in function cfun. */
103 :
104 : inline tree
105 115633715 : make_ssa_name (tree var, gimple *stmt = NULL)
106 : {
107 114985841 : return make_ssa_name_fn (cfun, var, stmt);
108 : }
109 :
110 : /* Return an SSA_NAME node using the template SSA name NAME defined in
111 : statement STMT in function cfun. */
112 :
113 : inline tree
114 1700853 : copy_ssa_name (tree var, gimple *stmt = NULL)
115 : {
116 1700853 : return copy_ssa_name_fn (cfun, var, stmt);
117 : }
118 :
119 : /* Creates a duplicate of a SSA name NAME tobe defined by statement STMT
120 : in function cfun. */
121 :
122 : inline tree
123 18413447 : duplicate_ssa_name (tree var, gimple *stmt)
124 : {
125 18413447 : return duplicate_ssa_name_fn (cfun, var, stmt);
126 : }
127 :
128 : /* Release the SSA name NAME used in function cfun. */
129 :
130 : inline void
131 83088631 : release_ssa_name (tree name)
132 : {
133 83088511 : release_ssa_name_fn (cfun, name);
134 : }
135 :
136 : /* Return an anonymous SSA_NAME node for type TYPE defined in statement STMT
137 : in function cfun. Arrange so that it uses NAME in dumps. */
138 :
139 : inline tree
140 8026523 : make_temp_ssa_name (tree type, gimple *stmt, const char *name)
141 : {
142 8026523 : tree ssa_name;
143 8026523 : gcc_checking_assert (TYPE_P (type));
144 8026523 : ssa_name = make_ssa_name_fn (cfun, type, stmt);
145 8026523 : SET_SSA_NAME_VAR_OR_IDENTIFIER (ssa_name, get_identifier (name));
146 8026523 : return ssa_name;
147 : }
148 :
149 : /* A class which is used to save/restore the flow sensitive information. */
150 : class flow_sensitive_info_storage
151 : {
152 : public:
153 : /* Save the flow sensitive info from NAME. */
154 7070681 : inline void save (tree name)
155 : {
156 7070681 : gcc_checking_assert (state == 0);
157 7070681 : range_info = SSA_NAME_RANGE_INFO (name);
158 7070681 : state = 1;
159 7070681 : }
160 :
161 : /* Restore the flow sensitive info from NAME. */
162 7070681 : inline void restore (tree name) const
163 : {
164 7070681 : gcc_checking_assert (state == 1);
165 7070681 : SSA_NAME_RANGE_INFO (name) = range_info;
166 7070681 : }
167 :
168 : /* Save the flow sensitive info from NAME and reset that info. */
169 7070681 : inline void save_and_clear (tree name)
170 : {
171 7070681 : save (name);
172 7070681 : reset_flow_sensitive_info (name);
173 : }
174 :
175 : /* Clear the storage. */
176 : inline void clear_storage () { state = 0; }
177 : private:
178 : /* 0 means there is nothing saved. 1 means something is saved. */
179 : int state = 0;
180 : /* The range info contains all flow sensitive information now. */
181 : vrange_storage *range_info = nullptr;
182 : };
183 :
184 : #endif /* GCC_TREE_SSANAMES_H */
|