]>
Commit | Line | Data |
---|---|---|
b12ebd96 | 1 | /* SSA name expresssons routines |
aeee4812 | 2 | Copyright (C) 2013-2023 Free Software Foundation, Inc. |
b12ebd96 AM |
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 | /* Aliasing information for SSA_NAMEs representing pointer variables. */ | |
24 | ||
25 | struct 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 | |
b12ebd96 AM |
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 | ||
46aa019a KV |
55 | #define FOR_EACH_SSA_NAME(I, VAR, FN) \ |
56 | for (I = 1; SSANAMES (FN)->iterate (I, &VAR); ++I) \ | |
57 | if (VAR) | |
58 | ||
a895a2b8 | 59 | /* Sets the value range to SSA. */ |
0a7e721a | 60 | extern bool set_range_info (tree, const vrange &); |
c92b8be9 | 61 | extern void set_nonzero_bits (tree, const wide_int &); |
53cf0c58 | 62 | extern void set_bitmask (tree, const wide_int &value, const wide_int &mask); |
807e902e | 63 | extern wide_int get_nonzero_bits (const_tree); |
40c43aca | 64 | extern bool ssa_name_has_boolean_range (tree); |
b12ebd96 | 65 | extern void init_ssanames (struct function *, int); |
61183076 | 66 | extern void fini_ssanames (struct function *); |
b12ebd96 | 67 | extern void ssanames_print_statistics (void); |
1ee62b92 PG |
68 | extern tree make_ssa_name_fn (struct function *, tree, gimple *, |
69 | unsigned int version = 0); | |
5f487a34 | 70 | extern void init_ssa_name_imm_use (tree); |
6a58ccca | 71 | extern void release_ssa_name_fn (struct function *, tree); |
b12ebd96 AM |
72 | extern bool get_ptr_info_alignment (struct ptr_info_def *, unsigned int *, |
73 | unsigned int *); | |
74 | extern void mark_ptr_info_alignment_unknown (struct ptr_info_def *); | |
75 | extern void set_ptr_info_alignment (struct ptr_info_def *, unsigned int, | |
76 | unsigned int); | |
bc83d568 | 77 | extern void adjust_ptr_info_misalignment (struct ptr_info_def *, poly_uint64); |
b12ebd96 | 78 | extern struct ptr_info_def *get_ptr_info (tree); |
735b8f9f | 79 | extern void set_ptr_nonnull (tree); |
b12ebd96 | 80 | |
355fe088 | 81 | extern tree copy_ssa_name_fn (struct function *, tree, gimple *); |
b12ebd96 | 82 | extern void duplicate_ssa_name_ptr_info (tree, struct ptr_info_def *); |
355fe088 | 83 | extern tree duplicate_ssa_name_fn (struct function *, tree, gimple *); |
6ccc4356 | 84 | extern void duplicate_ssa_name_range_info (tree dest, tree src); |
8bb8e838 | 85 | extern void reset_flow_sensitive_info (tree); |
6ea2f74c | 86 | extern void reset_flow_sensitive_info_in_bb (basic_block); |
355fe088 | 87 | extern void release_defs (gimple *); |
b12ebd96 | 88 | extern void replace_ssa_name_symbol (tree, tree); |
dc0ccbb3 | 89 | extern void flush_ssaname_freelist (void); |
b12ebd96 AM |
90 | |
91 | ||
92 | /* Return an SSA_NAME node for variable VAR defined in statement STMT | |
93 | in function cfun. */ | |
94 | ||
cb3e0eac | 95 | inline tree |
355fe088 | 96 | make_ssa_name (tree var, gimple *stmt = NULL) |
b12ebd96 AM |
97 | { |
98 | return make_ssa_name_fn (cfun, var, stmt); | |
99 | } | |
100 | ||
101 | /* Return an SSA_NAME node using the template SSA name NAME defined in | |
102 | statement STMT in function cfun. */ | |
103 | ||
cb3e0eac | 104 | inline tree |
355fe088 | 105 | copy_ssa_name (tree var, gimple *stmt = NULL) |
b12ebd96 AM |
106 | { |
107 | return copy_ssa_name_fn (cfun, var, stmt); | |
108 | } | |
109 | ||
110 | /* Creates a duplicate of a SSA name NAME tobe defined by statement STMT | |
111 | in function cfun. */ | |
112 | ||
cb3e0eac | 113 | inline tree |
355fe088 | 114 | duplicate_ssa_name (tree var, gimple *stmt) |
b12ebd96 AM |
115 | { |
116 | return duplicate_ssa_name_fn (cfun, var, stmt); | |
117 | } | |
118 | ||
6a58ccca RB |
119 | /* Release the SSA name NAME used in function cfun. */ |
120 | ||
cb3e0eac | 121 | inline void |
6a58ccca RB |
122 | release_ssa_name (tree name) |
123 | { | |
124 | release_ssa_name_fn (cfun, name); | |
125 | } | |
126 | ||
b12ebd96 AM |
127 | /* Return an anonymous SSA_NAME node for type TYPE defined in statement STMT |
128 | in function cfun. Arrange so that it uses NAME in dumps. */ | |
129 | ||
cb3e0eac | 130 | inline tree |
355fe088 | 131 | make_temp_ssa_name (tree type, gimple *stmt, const char *name) |
b12ebd96 AM |
132 | { |
133 | tree ssa_name; | |
134 | gcc_checking_assert (TYPE_P (type)); | |
135 | ssa_name = make_ssa_name_fn (cfun, type, stmt); | |
136 | SET_SSA_NAME_VAR_OR_IDENTIFIER (ssa_name, get_identifier (name)); | |
137 | return ssa_name; | |
138 | } | |
139 | ||
a86d5eca AP |
140 | /* A class which is used to save/restore the flow sensitive information. */ |
141 | class flow_sensitive_info_storage | |
142 | { | |
143 | public: | |
144 | void save (tree); | |
145 | void save_and_clear (tree); | |
146 | void restore (tree); | |
147 | void clear_storage (); | |
148 | private: | |
149 | /* 0 means there is nothing saved. | |
150 | 1 means non pointer is saved. | |
151 | -1 means a pointer type is saved. | |
152 | -2 means a pointer type is saved but no information was saved. */ | |
153 | int state = 0; | |
154 | /* The range info for non pointers */ | |
155 | vrange_storage *range_info = nullptr; | |
156 | /* Flow sensitive pointer information. */ | |
157 | unsigned int align = 0; | |
158 | unsigned int misalign = 0; | |
159 | bool null = true; | |
160 | }; | |
b12ebd96 AM |
161 | |
162 | #endif /* GCC_TREE_SSANAMES_H */ |