1*e4b17023SJohn Marino /* Tree based alias analysis and alias oracle.
2*e4b17023SJohn Marino    Copyright (C) 2008, 2010 Free Software Foundation, Inc.
3*e4b17023SJohn Marino    Contributed by Richard Guenther  <rguenther@suse.de>
4*e4b17023SJohn Marino 
5*e4b17023SJohn Marino    This file is part of GCC.
6*e4b17023SJohn Marino 
7*e4b17023SJohn Marino    GCC is free software; you can redistribute it and/or modify
8*e4b17023SJohn Marino    under the terms of the GNU General Public License as published by
9*e4b17023SJohn Marino    the Free Software Foundation; either version 3 of the License, or
10*e4b17023SJohn Marino    (at your option) any later version.
11*e4b17023SJohn Marino 
12*e4b17023SJohn Marino    GCC is distributed in the hope that it will be useful,
13*e4b17023SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*e4b17023SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*e4b17023SJohn Marino    GNU General Public License for more details.
16*e4b17023SJohn Marino 
17*e4b17023SJohn Marino    You should have received a copy of the GNU General Public License
18*e4b17023SJohn Marino    along with GCC; see the file COPYING3.  If not see
19*e4b17023SJohn Marino    <http://www.gnu.org/licenses/>.  */
20*e4b17023SJohn Marino 
21*e4b17023SJohn Marino #ifndef TREE_SSA_ALIAS_H
22*e4b17023SJohn Marino #define TREE_SSA_ALIAS_H
23*e4b17023SJohn Marino 
24*e4b17023SJohn Marino #include "coretypes.h"
25*e4b17023SJohn Marino 
26*e4b17023SJohn Marino 
27*e4b17023SJohn Marino /* The points-to solution.
28*e4b17023SJohn Marino 
29*e4b17023SJohn Marino    The points-to solution is a union of pt_vars and the abstract
30*e4b17023SJohn Marino    sets specified by the flags.  */
31*e4b17023SJohn Marino struct GTY(()) pt_solution
32*e4b17023SJohn Marino {
33*e4b17023SJohn Marino   /* Nonzero if points-to analysis couldn't determine where this pointer
34*e4b17023SJohn Marino      is pointing to.  */
35*e4b17023SJohn Marino   unsigned int anything : 1;
36*e4b17023SJohn Marino 
37*e4b17023SJohn Marino   /* Nonzero if the points-to set includes any global memory.  Note that
38*e4b17023SJohn Marino      even if this is zero pt_vars can still include global variables.  */
39*e4b17023SJohn Marino   unsigned int nonlocal : 1;
40*e4b17023SJohn Marino 
41*e4b17023SJohn Marino   /* Nonzero if the points-to set includes the local escaped solution by
42*e4b17023SJohn Marino      reference.  */
43*e4b17023SJohn Marino   unsigned int escaped : 1;
44*e4b17023SJohn Marino 
45*e4b17023SJohn Marino   /* Nonzero if the points-to set includes the IPA escaped solution by
46*e4b17023SJohn Marino      reference.  */
47*e4b17023SJohn Marino   unsigned int ipa_escaped : 1;
48*e4b17023SJohn Marino 
49*e4b17023SJohn Marino   /* Nonzero if the points-to set includes 'nothing', the points-to set
50*e4b17023SJohn Marino      includes memory at address NULL.  */
51*e4b17023SJohn Marino   unsigned int null : 1;
52*e4b17023SJohn Marino 
53*e4b17023SJohn Marino 
54*e4b17023SJohn Marino   /* Nonzero if the pt_vars bitmap includes a global variable.  */
55*e4b17023SJohn Marino   unsigned int vars_contains_global : 1;
56*e4b17023SJohn Marino 
57*e4b17023SJohn Marino 
58*e4b17023SJohn Marino   /* Set of variables that this pointer may point to.  */
59*e4b17023SJohn Marino   bitmap vars;
60*e4b17023SJohn Marino };
61*e4b17023SJohn Marino 
62*e4b17023SJohn Marino 
63*e4b17023SJohn Marino /* Simplified and cached information about a memory reference tree.
64*e4b17023SJohn Marino    Used by the alias-oracle internally and externally in alternate
65*e4b17023SJohn Marino    interfaces.  */
66*e4b17023SJohn Marino typedef struct ao_ref_s
67*e4b17023SJohn Marino {
68*e4b17023SJohn Marino   /* The original full memory reference tree or NULL_TREE if that is
69*e4b17023SJohn Marino      not available.  */
70*e4b17023SJohn Marino   tree ref;
71*e4b17023SJohn Marino 
72*e4b17023SJohn Marino   /* The following fields are the decomposed reference as returned
73*e4b17023SJohn Marino      by get_ref_base_and_extent.  */
74*e4b17023SJohn Marino   /* The base object of the memory reference or NULL_TREE if all of
75*e4b17023SJohn Marino      the following fields are not yet computed.  */
76*e4b17023SJohn Marino   tree base;
77*e4b17023SJohn Marino   /* The offset relative to the base.  */
78*e4b17023SJohn Marino   HOST_WIDE_INT offset;
79*e4b17023SJohn Marino   /* The size of the access.  */
80*e4b17023SJohn Marino   HOST_WIDE_INT size;
81*e4b17023SJohn Marino   /* The maximum possible extent of the access or -1 if unconstrained.  */
82*e4b17023SJohn Marino   HOST_WIDE_INT max_size;
83*e4b17023SJohn Marino 
84*e4b17023SJohn Marino   /* The alias set of the access or -1 if not yet computed.  */
85*e4b17023SJohn Marino   alias_set_type ref_alias_set;
86*e4b17023SJohn Marino 
87*e4b17023SJohn Marino   /* The alias set of the base object or -1 if not yet computed.  */
88*e4b17023SJohn Marino   alias_set_type base_alias_set;
89*e4b17023SJohn Marino 
90*e4b17023SJohn Marino   /* Whether the memory is considered a volatile access.  */
91*e4b17023SJohn Marino   bool volatile_p;
92*e4b17023SJohn Marino } ao_ref;
93*e4b17023SJohn Marino 
94*e4b17023SJohn Marino 
95*e4b17023SJohn Marino /* In tree-ssa-alias.c  */
96*e4b17023SJohn Marino extern void ao_ref_init (ao_ref *, tree);
97*e4b17023SJohn Marino extern void ao_ref_init_from_ptr_and_size (ao_ref *, tree, tree);
98*e4b17023SJohn Marino extern tree ao_ref_base (ao_ref *);
99*e4b17023SJohn Marino extern alias_set_type ao_ref_alias_set (ao_ref *);
100*e4b17023SJohn Marino extern bool ptr_deref_may_alias_global_p (tree);
101*e4b17023SJohn Marino extern bool ptr_derefs_may_alias_p (tree, tree);
102*e4b17023SJohn Marino extern bool refs_may_alias_p (tree, tree);
103*e4b17023SJohn Marino extern bool refs_may_alias_p_1 (ao_ref *, ao_ref *, bool);
104*e4b17023SJohn Marino extern bool refs_anti_dependent_p (tree, tree);
105*e4b17023SJohn Marino extern bool refs_output_dependent_p (tree, tree);
106*e4b17023SJohn Marino extern bool ref_maybe_used_by_stmt_p (gimple, tree);
107*e4b17023SJohn Marino extern bool stmt_may_clobber_ref_p (gimple, tree);
108*e4b17023SJohn Marino extern bool stmt_may_clobber_ref_p_1 (gimple, ao_ref *);
109*e4b17023SJohn Marino extern bool call_may_clobber_ref_p (gimple, tree);
110*e4b17023SJohn Marino extern bool stmt_kills_ref_p (gimple, tree);
111*e4b17023SJohn Marino extern tree get_continuation_for_phi (gimple, ao_ref *, bitmap *, bool);
112*e4b17023SJohn Marino extern void *walk_non_aliased_vuses (ao_ref *, tree,
113*e4b17023SJohn Marino 				     void *(*)(ao_ref *, tree, void *),
114*e4b17023SJohn Marino 				     void *(*)(ao_ref *, tree, void *), void *);
115*e4b17023SJohn Marino extern unsigned int walk_aliased_vdefs (ao_ref *, tree,
116*e4b17023SJohn Marino 					bool (*)(ao_ref *, tree, void *),
117*e4b17023SJohn Marino 					void *, bitmap *);
118*e4b17023SJohn Marino extern struct ptr_info_def *get_ptr_info (tree);
119*e4b17023SJohn Marino extern void dump_alias_info (FILE *);
120*e4b17023SJohn Marino extern void debug_alias_info (void);
121*e4b17023SJohn Marino extern void dump_points_to_solution (FILE *, struct pt_solution *);
122*e4b17023SJohn Marino extern void dump_points_to_info_for (FILE *, tree);
123*e4b17023SJohn Marino extern void debug_points_to_info_for (tree);
124*e4b17023SJohn Marino extern void dump_alias_stats (FILE *);
125*e4b17023SJohn Marino 
126*e4b17023SJohn Marino 
127*e4b17023SJohn Marino /* In tree-ssa-structalias.c  */
128*e4b17023SJohn Marino extern unsigned int compute_may_aliases (void);
129*e4b17023SJohn Marino extern bool pt_solution_empty_p (struct pt_solution *);
130*e4b17023SJohn Marino extern bool pt_solution_singleton_p (struct pt_solution *, unsigned *);
131*e4b17023SJohn Marino extern bool pt_solution_includes_global (struct pt_solution *);
132*e4b17023SJohn Marino extern bool pt_solution_includes (struct pt_solution *, const_tree);
133*e4b17023SJohn Marino extern bool pt_solutions_intersect (struct pt_solution *, struct pt_solution *);
134*e4b17023SJohn Marino extern void pt_solution_reset (struct pt_solution *);
135*e4b17023SJohn Marino extern void pt_solution_set (struct pt_solution *, bitmap, bool);
136*e4b17023SJohn Marino extern void pt_solution_set_var (struct pt_solution *, tree);
137*e4b17023SJohn Marino 
138*e4b17023SJohn Marino extern void dump_pta_stats (FILE *);
139*e4b17023SJohn Marino 
140*e4b17023SJohn Marino extern GTY(()) struct pt_solution ipa_escaped_pt;
141*e4b17023SJohn Marino 
142*e4b17023SJohn Marino 
143*e4b17023SJohn Marino #endif /* TREE_SSA_ALIAS_H  */
144