1/* SSA name expresssons routines
2 Copyright (C) 2013-2017 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/* Value range information for SSA_NAMEs representing non-pointer variables. */
49
50struct GTY ((variable_size)) range_info_def {
51 /* Minimum, maximum and nonzero bits. */
52 TRAILING_WIDE_INT_ACCESSOR (min, ints, 0)
53 TRAILING_WIDE_INT_ACCESSOR (max, ints, 1)
54 TRAILING_WIDE_INT_ACCESSOR (nonzero_bits, ints, 2)
55 trailing_wide_ints <3> ints;
56};
57
58
59#define SSANAMES(fun) (fun)->gimple_df->ssa_names
60#define DEFAULT_DEFS(fun) (fun)->gimple_df->default_defs
61
62#define num_ssa_names (vec_safe_length (cfun->gimple_df->ssa_names))
63#define ssa_name(i) ((*cfun->gimple_df->ssa_names)[(i)])
64
65#define FOR_EACH_SSA_NAME(I, VAR, FN) \
66 for (I = 1; SSANAMES (FN)->iterate (I, &VAR); ++I) \
67 if (VAR)
68
69/* Sets the value range to SSA. */
70extern void set_range_info (tree, enum value_range_type, const wide_int_ref &,
71 const wide_int_ref &);
72extern void set_range_info_raw (tree, enum value_range_type,
73 const wide_int_ref &,
74 const wide_int_ref &);
75/* Gets the value range from SSA. */
76extern enum value_range_type get_range_info (const_tree, wide_int *,
77 wide_int *);
78extern void set_nonzero_bits (tree, const wide_int_ref &);
79extern wide_int get_nonzero_bits (const_tree);
80extern bool ssa_name_has_boolean_range (tree);
81extern void init_ssanames (struct function *, int);
82extern void fini_ssanames (struct function *);
83extern void ssanames_print_statistics (void);
84extern tree make_ssa_name_fn (struct function *, tree, gimple *,
85 unsigned int version = 0);
86extern void release_ssa_name_fn (struct function *, tree);
87extern bool get_ptr_info_alignment (struct ptr_info_def *, unsigned int *,
88 unsigned int *);
89extern void mark_ptr_info_alignment_unknown (struct ptr_info_def *);
90extern void set_ptr_info_alignment (struct ptr_info_def *, unsigned int,
91 unsigned int);
92extern void adjust_ptr_info_misalignment (struct ptr_info_def *,
93 unsigned int);
94extern struct ptr_info_def *get_ptr_info (tree);
95extern void set_ptr_nonnull (tree);
96extern bool get_ptr_nonnull (const_tree);
97
98extern tree copy_ssa_name_fn (struct function *, tree, gimple *);
99extern void duplicate_ssa_name_ptr_info (tree, struct ptr_info_def *);
100extern tree duplicate_ssa_name_fn (struct function *, tree, gimple *);
101extern void duplicate_ssa_name_range_info (tree, enum value_range_type,
102 struct range_info_def *);
103extern void reset_flow_sensitive_info (tree);
104extern void reset_flow_sensitive_info_in_bb (basic_block);
105extern void release_defs (gimple *);
106extern void replace_ssa_name_symbol (tree, tree);
107extern void flush_ssaname_freelist (void);
108
109
110/* Return an SSA_NAME node for variable VAR defined in statement STMT
111 in function cfun. */
112
113static inline tree
114make_ssa_name (tree var, gimple *stmt = NULL)
115{
116 return make_ssa_name_fn (cfun, var, stmt);
117}
118
119/* Return an SSA_NAME node using the template SSA name NAME defined in
120 statement STMT in function cfun. */
121
122static inline tree
123copy_ssa_name (tree var, gimple *stmt = NULL)
124{
125 return copy_ssa_name_fn (cfun, var, stmt);
126}
127
128/* Creates a duplicate of a SSA name NAME tobe defined by statement STMT
129 in function cfun. */
130
131static inline tree
132duplicate_ssa_name (tree var, gimple *stmt)
133{
134 return duplicate_ssa_name_fn (cfun, var, stmt);
135}
136
137/* Release the SSA name NAME used in function cfun. */
138
139static inline void
140release_ssa_name (tree name)
141{
142 release_ssa_name_fn (cfun, name);
143}
144
145/* Return an anonymous SSA_NAME node for type TYPE defined in statement STMT
146 in function cfun. Arrange so that it uses NAME in dumps. */
147
148static inline tree
149make_temp_ssa_name (tree type, gimple *stmt, const char *name)
150{
151 tree ssa_name;
152 gcc_checking_assert (TYPE_P (type));
153 ssa_name = make_ssa_name_fn (cfun, type, stmt);
154 SET_SSA_NAME_VAR_OR_IDENTIFIER (ssa_name, get_identifier (name));
155 return ssa_name;
156}
157
158
159#endif /* GCC_TREE_SSANAMES_H */
160