1169689Skan/* Tree based points-to analysis
2169689Skan   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3169689Skan   Contributed by Daniel Berlin <dberlin@dberlin.org>
4169689Skan
5169689SkanThis file is part of GCC.
6169689Skan
7169689SkanGCC is free software; you can redistribute it and/or modify
8169689Skanunder the terms of the GNU General Public License as published by
9169689Skanthe Free Software Foundation; either version 2 of the License, or
10169689Skan(at your option) any later version.
11169689Skan
12169689SkanGCC is distributed in the hope that it will be useful,
13169689Skanbut WITHOUT ANY WARRANTY; without even the implied warranty of
14169689SkanMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15169689SkanGNU General Public License for more details.
16169689Skan
17169689SkanYou should have received a copy of the GNU General Public License
18169689Skanalong with GCC; if not, write to the Free Software
19169689SkanFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20169689Skan*/
21169689Skan
22169689Skan#ifndef TREE_SSA_STRUCTALIAS_H
23169689Skan#define TREE_SSA_STRUCTALIAS_H
24169689Skan
25169689Skan/* True if the data pointed to by PTR can alias anything.  */
26169689Skan#define PTR_IS_REF_ALL(PTR) TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (PTR))
27169689Skan
28169689Skanstruct constraint;
29169689Skantypedef struct constraint *constraint_t;
30169689Skan
31169689Skan/* Alias information used by compute_may_aliases and its helpers.  */
32169689Skanstruct alias_info
33169689Skan{
34169689Skan  /* SSA names visited while collecting points-to information.  If bit I
35169689Skan     is set, it means that SSA variable with version I has already been
36169689Skan     visited.  */
37169689Skan  sbitmap ssa_names_visited;
38169689Skan
39169689Skan  /* Array of SSA_NAME pointers processed by the points-to collector.  */
40169689Skan  VEC(tree,heap) *processed_ptrs;
41169689Skan
42169689Skan  /* ADDRESSABLE_VARS contains all the global variables and locals that
43169689Skan     have had their address taken.  */
44169689Skan  struct alias_map_d **addressable_vars;
45169689Skan  size_t num_addressable_vars;
46169689Skan
47169689Skan  /* POINTERS contains all the _DECL pointers with unique memory tags
48169689Skan     that have been referenced in the program.  */
49169689Skan  struct alias_map_d **pointers;
50169689Skan  size_t num_pointers;
51169689Skan
52169689Skan  /* Number of function calls found in the program.  */
53169689Skan  size_t num_calls_found;
54169689Skan
55169689Skan  /* Number of const/pure function calls found in the program.  */
56169689Skan  size_t num_pure_const_calls_found;
57169689Skan
58169689Skan  /* Total number of virtual operands that will be needed to represent
59169689Skan     all the aliases of all the pointers found in the program.  */
60169689Skan  long total_alias_vops;
61169689Skan
62169689Skan  /* Variables that have been written to.  */
63169689Skan  bitmap written_vars;
64169689Skan
65169689Skan  /* Pointers that have been used in an indirect store operation.  */
66169689Skan  bitmap dereferenced_ptrs_store;
67169689Skan
68169689Skan  /* Pointers that have been used in an indirect load operation.  */
69169689Skan  bitmap dereferenced_ptrs_load;
70169689Skan
71169689Skan  /* Memory tag for all the PTR_IS_REF_ALL pointers.  */
72169689Skan  tree ref_all_symbol_mem_tag;
73169689Skan};
74169689Skan
75169689Skan/* Keep track of how many times each pointer has been dereferenced in
76169689Skan   the program using the aux variable.  This is used by the alias
77169689Skan   grouping heuristic in compute_flow_insensitive_aliasing.  */
78169689Skan#define NUM_REFERENCES(ANN) ((size_t)((ANN)->common.aux))
79169689Skan#define NUM_REFERENCES_CLEAR(ANN) ((ANN)->common.aux) = 0
80169689Skan#define NUM_REFERENCES_INC(ANN) (ANN)->common.aux = (void*) (((size_t)((ANN)->common.aux)) + 1)
81169689Skan#define NUM_REFERENCES_SET(ANN, VAL) (ANN)->common.aux = (void*) ((void *)(VAL))
82169689Skan
83169689Skan/* In tree-ssa-alias.c.  */
84169689Skanenum escape_type is_escape_site (tree);
85169689Skan
86169689Skan/* In tree-ssa-structalias.c.  */
87169689Skanextern void compute_points_to_sets (struct alias_info *);
88169689Skanextern void delete_points_to_sets (void);
89169689Skanextern void dump_constraint (FILE *, constraint_t);
90169689Skanextern void dump_constraints (FILE *);
91169689Skanextern void debug_constraint (constraint_t);
92169689Skanextern void debug_constraints (void);
93169689Skanextern void dump_solution_for_var (FILE *, unsigned int);
94169689Skanextern void debug_solution_for_var (unsigned int);
95169689Skanextern void dump_sa_points_to_info (FILE *);
96169689Skanextern void debug_sa_points_to_info (void);
97169689Skan
98169689Skan#endif /* TREE_SSA_STRUCTALIAS_H  */
99