OSDN Git Service

2004-07-04 Matthias Klose <doko@debian.org>
[pf3gnuchains/gcc-fork.git] / gcc / tree-alias-common.h
1 /* Tree based points-to analysis
2    Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3    Contributed by Daniel Berlin <dberlin@dberlin.org>
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20 */
21
22 #ifndef TREE_ALIAS_COMMON
23 #define TREE_ALIAS_COMMON
24
25 #include "tree-alias-type.h"
26
27 /* Alias analysis function pointers.
28    Functions implemented by the actual alias analysis algorithms in
29    order for them to work with the common points-to structure.  */
30 struct tree_alias_ops
31 {
32   /* Initialization.
33      Called right before we start using the other functions.  */
34   void (*init) (struct tree_alias_ops *);
35
36   /* Cleanup. 
37      Called when we are finished with the alias analyzer.  */
38   void (*cleanup) (struct tree_alias_ops *);
39
40   /* Add variable.
41      Called when we want to inform the alias analyzer about a new
42      variable we've found.  */
43   alias_var (*add_var) (struct tree_alias_ops *, tree);
44
45   /* Add variable equivalent to existing one.
46      Called when we want to inform the alias analyzer about a new
47      variable that has the same points-to set as an existing
48      variable.  */ 
49   alias_var (*add_var_same) (struct tree_alias_ops *, tree,
50                                  alias_var);
51   
52   /* Process a simple assignment (a = b).
53      Called to process simple assignment statements of the form a = b,
54      where a and b are both variables.  */
55   void (*simple_assign) (struct tree_alias_ops *, alias_var,
56                          alias_var);
57   /* Process an address assignment (a = &b).
58      Called to process address assignment statements of the form a =
59      &b, where a and b are both variables.  */
60   void (*addr_assign) (struct tree_alias_ops *, alias_var, alias_var);
61
62   /* Process a pointer assignment (a = *b).
63      Called to process pointer assignment statements of the form a =
64      *b, where a and b are both variables.  */
65   void (*ptr_assign) (struct tree_alias_ops *, alias_var, alias_var);
66
67   /* Process an operator assignment (a = op (...))
68      Called to process operators of the form a = op(...), where a is a
69      variable.  */
70   void (*op_assign) (struct tree_alias_ops *, alias_var, varray_type, 
71                      tree, bitmap);
72   /* Process a heap assignment (a = alloc (...))
73      Called to process a heap assignment of the form a = alloc
74      (...), where a is a variable, and *alloc is a function that
75      returns new memory.  */
76   void (*heap_assign) (struct tree_alias_ops *, alias_var);
77
78   /* Process an assignment to a pointer (*a = b)
79      Called to process assignment to pointer statements of the form
80      *a = b, where a and b are both variables.  */
81   void (*assign_ptr) (struct tree_alias_ops *, alias_var, alias_var);
82
83   /* Process a function definition.
84      Called to inform the alias analyzer about a new function
85      definition.  */
86   void (*function_def) (struct tree_alias_ops *, alias_var,
87                         varray_type, alias_var);
88
89   /* Process a function call.
90      Return 1 if we need to assume conservative side-effects.  */
91   int (*function_call) (struct tree_alias_ops *, alias_var,
92                         alias_var, varray_type, bitmap);
93
94   /* Determine if two alias variables may alias.   */
95   bool (*may_alias) (struct tree_alias_ops *, alias_var, alias_var);
96
97   /* Determine if two alias variables have the same points-to set.  */
98   bool (*same_points_to_set) (struct tree_alias_ops *, alias_var, 
99                               alias_var);
100   
101   /* Determine if the alias variable has an empty points-to set.  */
102   bool (*empty_points_to_set) (struct tree_alias_ops *, alias_var);
103   
104   /* Private data.  */
105   void *data;
106
107   /* Interprocedural.  */
108   unsigned int ip:1; 
109
110   /* Can do conservative interprocedural analysis if we save the 
111    * info.  */
112   unsigned int ip_partial:1; 
113
114 };
115
116 extern struct tree_alias_ops *current_alias_ops;
117 extern void init_alias_vars (void);
118 extern bool ptr_may_alias_var (tree, tree);
119 extern bool same_points_to_set (tree, tree);
120 extern bool empty_points_to_set (tree);
121 extern const char *alias_get_name (tree);
122
123 #endif /* TREE_ALIAS_COMMON */