GCC Middle and Back End API Reference
gimple-ssa.h
Go to the documentation of this file.
1/* Header file for routines that straddle the border between GIMPLE and
2 SSA in gimple.
3 Copyright (C) 2009-2024 Free Software Foundation, Inc.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under 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,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General 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_GIMPLE_SSA_H
22#define GCC_GIMPLE_SSA_H
23
24#include "tree-ssa-operands.h"
25
26/* This structure is used to map a gimple statement to a label,
27 or list of labels to represent transaction restart. */
28
33
34/* Hasher for tm_restart_node. */
35
36struct tm_restart_hasher : ggc_ptr_hash<tm_restart_node>
37{
38 static hashval_t hash (tm_restart_node *n) { return htab_hash_pointer (n); }
39
40 static bool
42 {
43 return a == b;
44 }
45};
46
47extern void gt_ggc_mx (gimple *&);
48extern void gt_pch_nx (gimple *&);
49
50struct ssa_name_hasher : ggc_ptr_hash<tree_node>
51{
52 /* Hash a tree in a uid_decl_map. */
53
54 static hashval_t
55 hash (tree item)
56 {
57 return item->ssa_name.var->decl_minimal.uid;
58 }
59
60 /* Return true if the DECL_UID in both trees are equal. */
61
62 static bool
64{
65 return (a->ssa_name.var->decl_minimal.uid == b->ssa_name.var->decl_minimal.uid);
66}
67};
68
69/* Gimple dataflow datastructure. All publicly available fields shall have
70 gimple_ accessor defined, all publicly modifiable fields should have
71 gimple_set accessor. */
72struct GTY(()) gimple_df {
73 /* Array of all SSA_NAMEs used in the function. */
75
76 /* Artificial variable used for the virtual operand FUD chain. */
78
79 /* The PTA solution for the ESCAPED and ESCAPED_RETURN artificial
80 variables. */
81 struct pt_solution escaped;
82 struct pt_solution escaped_return;
83
84 /* A map of decls to artificial ssa-names that point to the partition
85 of the decl. */
86 hash_map<tree, tree> * GTY((skip(""))) decls_to_pointers;
87
88 /* Free list of SSA_NAMEs. */
89 vec<tree, va_gc> *free_ssanames;
90
91 /* Queue of SSA_NAMEs to be freed at the next opportunity. */
92 vec<tree, va_gc> *free_ssanames_queue;
93
94 /* Hashtable holding definition for symbol. If this field is not NULL, it
95 means that the first reference to this variable in the function is a
96 USE or a VUSE. In those cases, the SSA renamer creates an SSA name
97 for this variable with an empty defining statement. */
99
100 /* True if there are any symbols that need to be renamed. */
101 unsigned int ssa_renaming_needed : 1;
102
103 /* True if all virtual operands need to be renamed. */
104 unsigned int rename_vops : 1;
105
106 /* True if the code is in ssa form. */
107 unsigned int in_ssa_p : 1;
108
109 /* True if IPA points-to information was computed for this function. */
110 unsigned int ipa_pta : 1;
111
113
114 /* Map gimple stmt to tree label (or list of labels) for transaction
115 restart and abort. */
117};
118
119
120/* Return true when gimple SSA form was built.
121 gimple_in_ssa_p is queried by gimplifier in various early stages before SSA
122 infrastructure is initialized. Check for presence of the datastructures
123 at first place. */
124inline bool
126{
127 return fun && fun->gimple_df && fun->gimple_df->in_ssa_p;
128}
129
130/* Artificial variable used for the virtual operand FUD chain. */
131inline tree
132gimple_vop (const struct function *fun)
133{
134 gcc_checking_assert (fun && fun->gimple_df);
135 return fun->gimple_df->vop;
136}
137
138/* Return the set of VUSE operand for statement G. */
139
140inline use_operand_p
142{
143 struct use_optype_d *ops;
146 if (!mem_ops_stmt)
147 return NULL_USE_OPERAND_P;
148 ops = mem_ops_stmt->use_ops;
149 if (ops
150 && USE_OP_PTR (ops)->use == &mem_ops_stmt->vuse)
151 return USE_OP_PTR (ops);
152 return NULL_USE_OPERAND_P;
153}
154
155/* Return the set of VDEF operand for statement G. */
156
157inline def_operand_p
168
169/* Mark statement S as modified, and update it. */
170
171inline void
173{
174 if (gimple_has_ops (s))
175 {
176 gimple_set_modified (s, true);
178 }
179}
180
181/* Update statement S if it has been optimized. */
182
183inline void
189
190/* Mark statement S as modified, and update it. */
191
192inline void
194{
195 if (gimple_has_ops (s))
196 {
197 gimple_set_modified (s, true);
198 update_stmt_operands (fn, s);
199 }
200}
201
202
203#endif /* GCC_GIMPLE_SSA_H */
Definition hash-map.h:40
Definition hash-table.h:375
gcc::context * g
Definition context.cc:29
#define GTY(x)
Definition coretypes.h:41
union tree_node * tree
Definition coretypes.h:97
#define cfun
Definition function.h:475
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
def_operand_p gimple_vdef_op(gimple *g)
Definition gimple-ssa.h:158
void gt_pch_nx(gimple *&)
void gt_ggc_mx(gimple *&)
bool gimple_in_ssa_p(const struct function *fun)
Definition gimple-ssa.h:125
use_operand_p gimple_vuse_op(const gimple *g)
Definition gimple-ssa.h:141
void update_stmt_fn(struct function *fn, gimple *s)
Definition gimple-ssa.h:193
void update_stmt(gimple *s)
Definition gimple-ssa.h:172
void update_stmt_if_modified(gimple *s)
Definition gimple-ssa.h:184
tree gimple_vop(const struct function *fun)
Definition gimple-ssa.h:132
bool gimple_has_ops(const gimple *g)
Definition gimple.h:2102
bool gimple_modified_p(const gimple *g)
Definition gimple.h:2244
void gimple_set_modified(gimple *s, bool modifiedp)
Definition gimple.h:2254
Ca const poly_int< N, Cb > & b
Definition poly-int.h:767
Ca & a
Definition poly-int.h:766
Definition function.h:249
struct gimple_df * gimple_df
Definition function.h:259
Definition hash-traits.h:321
Definition gimple-ssa.h:72
vec< tree, va_gc > * free_ssanames_queue
Definition gimple-ssa.h:92
vec< tree, va_gc > * ssa_names
Definition gimple-ssa.h:74
struct pt_solution escaped
Definition gimple-ssa.h:81
unsigned int ipa_pta
Definition gimple-ssa.h:110
unsigned int rename_vops
Definition gimple-ssa.h:104
vec< tree, va_gc > * free_ssanames
Definition gimple-ssa.h:89
hash_table< ssa_name_hasher > * default_defs
Definition gimple-ssa.h:98
tree vop
Definition gimple-ssa.h:77
unsigned int in_ssa_p
Definition gimple-ssa.h:107
hash_map< tree, tree > * decls_to_pointers
Definition gimple-ssa.h:86
struct pt_solution escaped_return
Definition gimple-ssa.h:82
hash_table< tm_restart_hasher > * tm_restart
Definition gimple-ssa.h:116
unsigned int ssa_renaming_needed
Definition gimple-ssa.h:101
Definition gimple.h:338
Definition gimple.h:225
Definition tree-ssa-alias.h:29
Definition gimple-ssa.h:51
static hashval_t hash(tree item)
Definition gimple-ssa.h:55
static bool equal(tree a, tree b)
Definition gimple-ssa.h:63
Definition tree-ssa-operands.h:54
Definition tree-core.h:1612
Definition gimple-ssa.h:37
static hashval_t hash(tm_restart_node *n)
Definition gimple-ssa.h:38
static bool equal(tm_restart_node *a, tm_restart_node *b)
Definition gimple-ssa.h:41
Definition gimple-ssa.h:29
tree label_or_list
Definition gimple-ssa.h:31
gimple * stmt
Definition gimple-ssa.h:30
Definition tree-ssa-operands.h:38
Definition loop-invariant.cc:78
Definition vec.h:359
Definition vec.h:450
#define gcc_checking_assert(EXPR)
Definition system.h:828
void update_stmt_operands(struct function *fn, gimple *stmt)
Definition tree-ssa-operands.cc:1136
tree * def_operand_p
Definition tree-ssa-operands.h:27
#define USE_OP_PTR(OP)
Definition tree-ssa-operands.h:72
#define NULL_USE_OPERAND_P
Definition tree-ssa-operands.h:33
#define NULL_DEF_OPERAND_P
Definition tree-ssa-operands.h:34